From 34a33b2a7a30351d44fcbcca51ceff9010f5220d Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Fri, 11 Dec 1998 03:18:41 +0000 Subject: [PATCH] 1998-12-10 Federico Mena Quintero * gcmd.c: #include "../vfs/vfs.h" * gdesktop.c (setup_icon_dnd_actions): Moved the code that calls gtk_drag_source_set() for an icon here. (editing_started): Temporarily disable drags while the icon's text is being edited. (editing_stopped): Re-enable DnD from the icon once editing has stopped. --- gnome/ChangeLog | 1 - gnome/gcmd.c | 1 + gnome/gdesktop.c | 38 +++++++++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index 88758c27b..9e9239009 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -66,7 +66,6 @@ Thu Dec 10 21:38:55 1998 Owen Taylor * gscreen.c (panel_icon_list_select_icon): Middle button opens a new panel on a directory. ->>>>>>> 1.184 1998-12-08 Federico Mena Quintero * gdesktop.c: Moved the old DnD cruft to olddnd.c to keep it there diff --git a/gnome/gcmd.c b/gnome/gcmd.c index a8c22d1a2..011e03527 100644 --- a/gnome/gcmd.c +++ b/gnome/gcmd.c @@ -20,6 +20,7 @@ #include "gcmd.h" #include "dialog.h" #include "layout.h" +#include "../vfs/vfs.h" void gnome_listing_cmd (GtkWidget *widget, WPanel *panel) diff --git a/gnome/gdesktop.c b/gnome/gdesktop.c index c2d09df77..86613d6fa 100644 --- a/gnome/gdesktop.c +++ b/gnome/gdesktop.c @@ -581,6 +581,10 @@ editing_started (GnomeIconTextItem *iti, gpointer data) dii = data; + /* Disable drags from this icon until editing is finished */ + + gtk_drag_source_unset (DESKTOP_ICON (dii->dicon)->canvas); + /* Unselect all icons but this one */ unselect_all (dii); @@ -600,6 +604,17 @@ editing_started (GnomeIconTextItem *iti, gpointer data) gdk_keyboard_grab (GTK_LAYOUT (DESKTOP_ICON (dii->dicon)->canvas)->bin_window, FALSE, GDK_CURRENT_TIME); } +/* Sets up the specified icon as a drag source, but does not connect the signals */ +static void +setup_icon_dnd_actions (struct desktop_icon_info *dii) +{ + gtk_drag_source_set (DESKTOP_ICON (dii->dicon)->canvas, + GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, + dnd_icon_sources, + dnd_icon_nsources, + GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK); +} + /* Callback used when the user finishes editing the icon text item in a desktop icon. It removes * the mouse and keyboard grabs. */ @@ -612,6 +627,10 @@ editing_stopped (GnomeIconTextItem *iti, gpointer data) gdk_pointer_ungrab (GDK_CURRENT_TIME); gdk_keyboard_ungrab (GDK_CURRENT_TIME); + + /* Re-enable drags from this icon */ + + setup_icon_dnd_actions (dii); } /* Used to open a desktop icon when the user double-clicks on it */ @@ -656,6 +675,11 @@ icon_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) dii = data; + /* If the text is being edited, do not handle clicks by ourselves */ + + if (GNOME_ICON_TEXT_ITEM (DESKTOP_ICON (dii->dicon)->text)->editing) + return FALSE; + /* Save the mouse position for DnD */ dnd_press_x = event->x; @@ -865,11 +889,7 @@ drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *sel static void setup_icon_dnd_source (struct desktop_icon_info *dii) { - gtk_drag_source_set (DESKTOP_ICON (dii->dicon)->canvas, - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, - dnd_icon_sources, - dnd_icon_nsources, - GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK); + setup_icon_dnd_actions (dii); gtk_signal_connect (GTK_OBJECT (DESKTOP_ICON (dii->dicon)->canvas), "drag_begin", (GtkSignalFunc) drag_begin, @@ -927,6 +947,8 @@ setup_icon_dnd_dest (struct desktop_icon_info *dii) if (!fe) return; /* eek */ + /* See what actions are appropriate for this icon */ + if (fe->f.link_to_dir) actions = GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK; else if (is_exe (fe->buf.st_mode) && if_link_is_exe (fe)) @@ -939,6 +961,8 @@ setup_icon_dnd_dest (struct desktop_icon_info *dii) if (!actions) return; + /* Connect the drop signals */ + gtk_drag_dest_set (DESKTOP_ICON (dii->dicon)->canvas, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, dnd_icon_targets, @@ -1383,6 +1407,10 @@ setup_desktop_clicks (void) gtk_widget_show (click_proxy_invisible); gdk_window_set_user_data (click_proxy_gdk_window, click_proxy_invisible); /* make it send events to us */ + /* The proxy window for clicks sends us events as SubstructureNotify things */ + + XSelectInput (GDK_DISPLAY (), GDK_WINDOW_XWINDOW (click_proxy_gdk_window), SubstructureNotifyMask); + gtk_signal_connect (GTK_OBJECT (click_proxy_invisible), "event", (GtkSignalFunc) click_proxy_event, NULL);