summaryrefslogtreecommitdiff
path: root/examples/selection
diff options
context:
space:
mode:
authorBST 2002 Tony Gale <gale@gtk.org>2002-08-25 11:28:42 +0000
committerTony Gale <gale@src.gnome.org>2002-08-25 11:28:42 +0000
commit992ea8e1d7a4673831b146e803578dda3a36d44c (patch)
tree869788fa12a1dc9bb945ef3611c94f2b4f3f4a84 /examples/selection
parent2f31e7ed12099c8a6c54255867e9fc9dbb88dd89 (diff)
downloadgtk+-992ea8e1d7a4673831b146e803578dda3a36d44c.tar.gz
update packaging script for current tutorial
Sun Aug 25 11:58:27 BST 2002 Tony Gale <gale@gtk.org> * docs/tutorial/package-db-tutorial.sh: update packaging script for current tutorial * docs/tutorial/images/*.eps: New Files EPS versions of the tutorial images
Diffstat (limited to 'examples/selection')
-rw-r--r--examples/selection/gettargets.c9
-rw-r--r--examples/selection/setselection.c22
2 files changed, 18 insertions, 13 deletions
diff --git a/examples/selection/gettargets.c b/examples/selection/gettargets.c
index 7c0cc276fd..bfc44a0ee6 100644
--- a/examples/selection/gettargets.c
+++ b/examples/selection/gettargets.c
@@ -11,13 +11,14 @@ void get_targets( GtkWidget *widget,
gpointer data )
{
static GdkAtom targets_atom = GDK_NONE;
+ GtkWidget *window = (GtkWidget *)data;
/* Get the atom corresponding to the string "TARGETS" */
if (targets_atom == GDK_NONE)
targets_atom = gdk_atom_intern ("TARGETS", FALSE);
/* And request the "TARGETS" target for the primary selection */
- gtk_selection_convert (widget, GDK_SELECTION_PRIMARY, targets_atom,
+ gtk_selection_convert (window, GDK_SELECTION_PRIMARY, targets_atom,
GDK_CURRENT_TIME);
}
@@ -82,9 +83,9 @@ int main( int argc,
button = gtk_button_new_with_label ("Get Targets");
gtk_container_add (GTK_CONTAINER (window), button);
- g_signal_connect (G_OBJECT(button), "clicked",
- G_CALLBACK (get_targets), NULL);
- g_signal_connect (G_OBJECT(button), "selection_received",
+ g_signal_connect (G_OBJECT (button), "clicked",
+ G_CALLBACK (get_targets), (gpointer) window);
+ g_signal_connect (G_OBJECT (window), "selection_received",
G_CALLBACK (selection_received), NULL);
gtk_widget_show (button);
diff --git a/examples/selection/setselection.c b/examples/selection/setselection.c
index e79a09131b..3dcb3a53b5 100644
--- a/examples/selection/setselection.c
+++ b/examples/selection/setselection.c
@@ -2,6 +2,10 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <time.h>
+#include <string.h>
+
+GtkWidget *selection_button;
+GtkWidget *selection_widget;
/* Callback when the user toggles the selection */
void selection_toggled( GtkWidget *widget,
@@ -9,7 +13,7 @@ void selection_toggled( GtkWidget *widget,
{
if (GTK_TOGGLE_BUTTON (widget)->active)
{
- *have_selection = gtk_selection_owner_set (widget,
+ *have_selection = gtk_selection_owner_set (selection_widget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME);
/* if claiming the selection failed, we return the button to
@@ -37,7 +41,7 @@ gint selection_clear( GtkWidget *widget,
gint *have_selection )
{
*have_selection = FALSE;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (selection_button), FALSE);
return TRUE;
}
@@ -65,7 +69,6 @@ int main( int argc,
char *argv[] )
{
GtkWidget *window;
- GtkWidget *selection_button;
static int have_selection = FALSE;
@@ -82,21 +85,22 @@ int main( int argc,
/* Create a toggle button to act as the selection */
+ selection_widget = gtk_invisible_new ();
selection_button = gtk_toggle_button_new_with_label ("Claim Selection");
gtk_container_add (GTK_CONTAINER (window), selection_button);
gtk_widget_show (selection_button);
g_signal_connect (G_OBJECT (selection_button), "toggled",
- G_CALLBACK (selection_toggled), &have_selection);
- g_signal_connect (G_OBJECT (selection_button), "selection_clear_event",
- G_CALLBACK (selection_clear), &have_selection);
+ G_CALLBACK (selection_toggled), (gpointer) &have_selection);
+ g_signal_connect (G_OBJECT (selection_widget), "selection_clear_event",
+ G_CALLBACK (selection_clear), (gpointer) &have_selection);
- gtk_selection_add_target (selection_button,
+ gtk_selection_add_target (selection_widget,
GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING,
1);
- g_signal_connect (G_OBJECT (selection_button), "selection_get",
- G_CALLBACK (selection_handle), &have_selection);
+ g_signal_connect (G_OBJECT (selection_widget), "selection_get",
+ G_CALLBACK (selection_handle), (gpointer) &have_selection);
gtk_widget_show (selection_button);
gtk_widget_show (window);