diff options
author | Owen Taylor <otaylor@gtk.org> | 1998-10-18 22:51:24 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-10-18 22:51:24 +0000 |
commit | f7bcb456072dac59b1ce5bd5329282ba95a3b495 (patch) | |
tree | a9085af76de35b5c883776673b7a59521e52c043 /gtk/testselection.c | |
parent | 7dbb5755a4cafc45108ec66ac89dfc1f11639494 (diff) | |
download | gtk+-f7bcb456072dac59b1ce5bd5329282ba95a3b495.tar.gz |
Added a modular client-message-filter mechanism, that is used for the DND
Sun Oct 18 18:16:39 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdk.c gdkprivate.h: Added a modular client-message-filter
mechanism, that is used for the DND messages.
Removed all the old DND code.
* gdk/gdkcolormap.c gdk/gdkcolormap.h: Add a function to
get the visual of a given colormap.
* gtk/gtkcolorsel.c: Conversion to new DND, drag
a color-swatch.
* gdk/gdk.h gdk/gdkdnd.c: The low-level
X oriented portions of drag and drop protocols.
Sending and receiving client messages, and navigating
window trees.
* gdk/gdkimage.c: added a gdk_flush() when destroying
SHM images to hopefully make it more likely that
X will gracefully handle the segment being destroyed.
* gdk/gdkprivate.h gtk/gtkdebug.h: Add new
DND debugging flags.
* gtk/gtkeditable.[ch]: Updates for the selection handling
changes.
* gtk/gtkselection.[ch]: Added GtkTargetList, a
refcounted data structure for keeping track of lists
of GdkAtom + information. Removed selection_handler_add
in favor of a "drag_data_get" signal.
* gtk/gtkdnd.[ch] gtk/gtk.h: New files - highlevel (event loop
dependent) parts of the DND protocols, display of drag icons,
drag-under highlighting, and the "default handlers".
* gtk/gtkinvisible.[ch]: New widget - InputOnly offscreen
windows that are used for reliable pointer grabs and
selection handling in the DND code.
* gtk/testdnd.c: New test program for new DND. (Old
DND tests in testgtk still need to be converted.)
* gtk/testselection.c: Use the new selection API.
* docs/dnd_internals: Start at describing how
all the new code works inside.
* docs/Changes-1.2.txt: New file describing source-incompatible
changes in GTK+-1.2.
Sat Oct 17 22:50:34 1998 Owen Taylor <otaylor@gtk.org>
* gdk/gdkwindow.c (gdk_window_remove_filter): Free
the right list node.
* gdk/gdkwindow.c (gdk_window_init): Add gdk_root_parent
to the XID table so we can receive events on it.
Wed Oct 14 12:57:40 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c gdk/gdk.h (gdk_event_get_time): New function
to get the timestamp from a generic event.
Fri Oct 9 13:16:04 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_add_events): Added function
that safely adds additional events to a widget's event
mask, even if the widget has previously been realized.
(We can do this, but not remove events from the event
mask).
Fri Oct 2 17:35:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkproperty.c (gdk_property_get): Allow type == 0,
for AnyPropertyType.
Fri Oct 2 10:32:21 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdkproperty.c (gdk_atom_intern): Add client-local
hashing.
Thu Sep 24 20:33:54 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c (gdk_event_send_clientmessage_toall): serial
isn't a timestamp.
Thu Sep 17 14:23:03 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.c (gdk_event_translate): Removed printing
of unknown window lookup warnings. (Made it
a GDK_NOTE) - they happen in many circumstances.
Diffstat (limited to 'gtk/testselection.c')
-rw-r--r-- | gtk/testselection.c | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/gtk/testselection.c b/gtk/testselection.c index 2c12b8dec4..bcb6c57bb4 100644 --- a/gtk/testselection.c +++ b/gtk/testselection.c @@ -48,50 +48,49 @@ typedef struct _Target { SelType type; GdkAtom target; gint format; - GtkSelectionFunction *handler; } Target; /* The following is a list of all the selection targets defined in the ICCCM */ static Target targets[] = { - { "ADOBE_PORTABLE_DOCUMENT_FORMAT", STRING, 0, 8, NULL }, - { "APPLE_PICT", APPLE_PICT, 0, 8, NULL }, - { "BACKGROUND", PIXEL, 0, 32, NULL }, - { "BITMAP", BITMAP, 0, 32, NULL }, - { "CHARACTER_POSITION", SPAN, 0, 32, NULL }, - { "CLASS", TEXT, 0, 8, NULL }, - { "CLIENT_WINDOW", WINDOW, 0, 32, NULL }, - { "COLORMAP", COLORMAP, 0, 32, NULL }, - { "COLUMN_NUMBER", SPAN, 0, 32, NULL }, - { "COMPOUND_TEXT", COMPOUND_TEXT, 0, 8, NULL }, - /* { "DELETE", "NULL", 0, ?, NULL }, */ - { "DRAWABLE", DRAWABLE, 0, 32, NULL }, - { "ENCAPSULATED_POSTSCRIPT", STRING, 0, 8, NULL }, - { "ENCAPSULATED_POSTSCRIPT_INTERCHANGE", STRING, 0, 8, NULL }, - { "FILE_NAME", TEXT, 0, 8, NULL }, - { "FOREGROUND", PIXEL, 0, 32, NULL }, - { "HOST_NAME", TEXT, 0, 8, NULL }, + { "ADOBE_PORTABLE_DOCUMENT_FORMAT", STRING, 0, 8 }, + { "APPLE_PICT", APPLE_PICT, 0, 8 }, + { "BACKGROUND", PIXEL, 0, 32 }, + { "BITMAP", BITMAP, 0, 32 }, + { "CHARACTER_POSITION", SPAN, 0, 32 }, + { "CLASS", TEXT, 0, 8 }, + { "CLIENT_WINDOW", WINDOW, 0, 32 }, + { "COLORMAP", COLORMAP, 0, 32 }, + { "COLUMN_NUMBER", SPAN, 0, 32 }, + { "COMPOUND_TEXT", COMPOUND_TEXT, 0, 8 }, + /* { "DELETE", "NULL", 0, ? }, */ + { "DRAWABLE", DRAWABLE, 0, 32 }, + { "ENCAPSULATED_POSTSCRIPT", STRING, 0, 8 }, + { "ENCAPSULATED_POSTSCRIPT_INTERCHANGE", STRING, 0, 8 }, + { "FILE_NAME", TEXT, 0, 8 }, + { "FOREGROUND", PIXEL, 0, 32 }, + { "HOST_NAME", TEXT, 0, 8 }, /* { "INSERT_PROPERTY", "NULL", 0, ? NULL }, */ /* { "INSERT_SELECTION", "NULL", 0, ? NULL }, */ - { "LENGTH", INTEGER, 0, 32, NULL }, - { "LINE_NUMBER", SPAN, 0, 32, NULL }, - { "LIST_LENGTH", INTEGER, 0, 32, NULL }, - { "MODULE", TEXT, 0, 8, NULL }, - /* { "MULTIPLE", "ATOM_PAIR", 0, 32, NULL }, */ - { "NAME", TEXT, 0, 8, NULL }, - { "ODIF", TEXT, 0, 8, NULL }, - { "OWNER_OS", TEXT, 0, 8, NULL }, - { "PIXMAP", PIXMAP, 0, 32, NULL }, - { "POSTSCRIPT", STRING, 0, 8, NULL }, - { "PROCEDURE", TEXT, 0, 8, NULL }, - { "PROCESS", INTEGER, 0, 32, NULL }, - { "STRING", STRING, 0, 8, NULL }, - { "TARGETS", ATOM, 0, 32, NULL }, - { "TASK", INTEGER, 0, 32, NULL }, - { "TEXT", TEXT, 0, 8 , NULL }, - { "TIMESTAMP", INTEGER, 0, 32, NULL }, - { "USER", TEXT, 0, 8, NULL }, + { "LENGTH", INTEGER, 0, 32 }, + { "LINE_NUMBER", SPAN, 0, 32 }, + { "LIST_LENGTH", INTEGER, 0, 32 }, + { "MODULE", TEXT, 0, 8 }, + /* { "MULTIPLE", "ATOM_PAIR", 0, 32 }, */ + { "NAME", TEXT, 0, 8 }, + { "ODIF", TEXT, 0, 8 }, + { "OWNER_OS", TEXT, 0, 8 }, + { "PIXMAP", PIXMAP, 0, 32 }, + { "POSTSCRIPT", STRING, 0, 8 }, + { "PROCEDURE", TEXT, 0, 8 }, + { "PROCESS", INTEGER, 0, 32 }, + { "STRING", STRING, 0, 8 }, + { "TARGETS", ATOM, 0, 32 }, + { "TASK", INTEGER, 0, 32 }, + { "TEXT", TEXT, 0, 8 }, + { "TIMESTAMP", INTEGER, 0, 32 }, + { "USER", TEXT, 0, 8 }, }; static int num_targets = sizeof(targets)/sizeof(Target); @@ -152,11 +151,15 @@ selection_toggled (GtkWidget *widget) } void -selection_handle (GtkWidget *widget, - GtkSelectionData *selection_data, gpointer data) +selection_get (GtkWidget *widget, + GtkSelectionData *selection_data, + guint info, + guint time, + gpointer data) { guchar *buffer; gint len; + GdkAtom type = GDK_NONE; if (!selection_string) { @@ -168,11 +171,17 @@ selection_handle (GtkWidget *widget, buffer = (guchar *)selection_string->str; len = selection_string->len; } + + switch (info) + { + case COMPOUND_TEXT: + case TEXT: + type = seltypes[COMPOUND_TEXT]; + case STRING: + type = seltypes[STRING]; + } - gtk_selection_data_set (selection_data, - selection_data->target == seltypes[COMPOUND_TEXT] ? - seltypes[COMPOUND_TEXT] : seltypes[STRING], - 8, buffer, len); + gtk_selection_data_set (selection_data, type, 8, buffer, len); } gint @@ -373,6 +382,13 @@ main (int argc, char *argv[]) GtkWidget *hscrollbar; GtkWidget *vscrollbar; GtkWidget *hbox; + + static GtkTargetEntry targetlist[] = { + { "STRING", STRING }, + { "TEXT", TEXT }, + { "COMPOUND_TEXT", COMPOUND_TEXT } + }; + static gint ntargets = sizeof(targetlist) / sizeof(targetlist[0]); gtk_init (&argc, &argv); @@ -408,15 +424,11 @@ main (int argc, char *argv[]) gtk_signal_connect (GTK_OBJECT(selection_button), "selection_received", GTK_SIGNAL_FUNC (selection_received), NULL); - gtk_selection_add_handler (selection_button, GDK_SELECTION_PRIMARY, - seltypes[STRING], selection_handle, NULL); - - gtk_selection_add_handler (selection_button, GDK_SELECTION_PRIMARY, - seltypes[TEXT], selection_handle, NULL); + gtk_selection_add_targets (selection_button, GDK_SELECTION_PRIMARY, + targetlist, ntargets); - gtk_selection_add_handler (selection_button, GDK_SELECTION_PRIMARY, - seltypes[COMPOUND_TEXT], - selection_handle, NULL); + gtk_signal_connect (GTK_OBJECT(selection_button), "selection_get", + GTK_SIGNAL_FUNC (selection_get), NULL); selection_text = gtk_text_new (NULL, NULL); gtk_table_attach_defaults (GTK_TABLE (table), selection_text, 0, 1, 1, 2); |