Re: [Nautilus-list] some eel patching
- From: Havoc Pennington <hp redhat com>
- To: nautilus-list eazel com
- Subject: Re: [Nautilus-list] some eel patching
- Date: 01 Nov 2001 09:00:45 -0500
Hi,
Revision of the eel-dnd.c patch fixes a couple glitches.
Havoc
Index: eel-dnd.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-dnd.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 eel-dnd.c
--- eel-dnd.c 2001/10/01 22:23:12 1.9
+++ eel-dnd.c 2001/11/01 14:01:26
@@ -33,6 +33,8 @@
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkseparatormenuitem.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomevfs/gnome-vfs-find-directory.h>
@@ -487,59 +489,120 @@ eel_drag_modifier_based_action (int defa
return default_action;
}
-#ifdef GNOME2_CONVERSION_COMPLETE
+typedef struct
+{
+ GMainLoop *loop;
+ GdkDragAction chosen;
+} DropActionMenuData;
-/* The menu of DnD actions */
-static GnomeUIInfo menu_items[] = {
- GNOMEUIINFO_ITEM_NONE (N_("_Move here"), NULL, NULL),
- GNOMEUIINFO_ITEM_NONE (N_("_Copy here"), NULL, NULL),
- GNOMEUIINFO_ITEM_NONE (N_("_Link here"), NULL, NULL),
- GNOMEUIINFO_SEPARATOR,
- GNOMEUIINFO_ITEM_NONE (N_("Cancel"), NULL, NULL),
- GNOMEUIINFO_END
-};
+static void
+menu_deactivate_callback (GtkWidget *menu,
+ gpointer data)
+{
+ DropActionMenuData *damd;
+
+ damd = data;
-#endif
+ if (g_main_loop_is_running (damd->loop))
+ g_main_loop_quit (damd->loop);
+}
+
+static void
+drop_action_activated_callback (GtkWidget *menu_item,
+ gpointer data)
+{
+ DropActionMenuData *damd;
+
+ damd = data;
+
+ damd->chosen = GPOINTER_TO_INT (g_object_get_data (G_OBJECT
(menu_item),
+ "action"));
+
+ if (g_main_loop_is_running (damd->loop))
+ g_main_loop_quit (damd->loop);
+}
+
+static void
+append_drop_action_menu_item (GtkWidget *menu,
+ const char *text,
+ GdkDragAction action,
+ gboolean sensitive,
+ DropActionMenuData *damd)
+{
+ GtkWidget *menu_item;
+
+ menu_item = gtk_menu_item_new_with_mnemonic (text);
+ gtk_widget_set_sensitive (menu_item, sensitive);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+
+ g_object_set_data (G_OBJECT (menu_item),
+ "action",
+ GINT_TO_POINTER (action));
+
+ g_signal_connect (G_OBJECT (menu_item), "activate",
+ G_CALLBACK (drop_action_activated_callback),
+ damd);
+
+ gtk_widget_show (menu_item);
+}
/* Pops up a menu of actions to perform on dropped files */
GdkDragAction
eel_drag_drop_action_ask (GdkDragAction actions)
{
-#ifndef GNOME2_CONVERSION_COMPLETE
- return 0;
-#else
GtkWidget *menu;
- int action;
-
+ GtkWidget *menu_item;
+ DropActionMenuData damd;
+
/* Create the menu and set the sensitivity of the items based
on the
* allowed actions.
*/
- textdomain
- menu = gnome_popup_menu_new (menu_items);
- textdomain
-
- gtk_widget_set_sensitive (menu_items[0].widget, (actions &
GDK_ACTION_MOVE) != 0);
- gtk_widget_set_sensitive (menu_items[1].widget, (actions &
GDK_ACTION_COPY) != 0);
- gtk_widget_set_sensitive (menu_items[2].widget, (actions &
GDK_ACTION_LINK) != 0);
-
- switch (gnome_popup_menu_do_popup_modal (menu, NULL, NULL,
NULL, NULL)) {
- case 0:
- action = GDK_ACTION_MOVE;
- break;
- case 1:
- action = GDK_ACTION_COPY;
- break;
- case 2:
- action = GDK_ACTION_LINK;
- break;
- default:
- action = 0;
- }
+ menu = gtk_menu_new ();
+
+ append_drop_action_menu_item (menu, _("_Move here"),
+ GDK_ACTION_MOVE,
+ (actions & GDK_ACTION_MOVE) !=
0,
+ &damd);
+
+ append_drop_action_menu_item (menu, _("_Copy here"),
+ GDK_ACTION_COPY,
+ (actions & GDK_ACTION_COPY) !=
0,
+ &damd);
+
+ append_drop_action_menu_item (menu, _("_Link here"),
+ GDK_ACTION_LINK,
+ (actions & GDK_ACTION_LINK) !=
0,
+ &damd);
+
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ menu_item = gtk_menu_item_new_with_mnemonic (_("Cancel"));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ damd.chosen = 0;
+ damd.loop = g_main_loop_new (NULL, FALSE);
- gtk_widget_destroy (menu);
+ g_signal_connect (G_OBJECT (menu), "deactivate",
+ G_CALLBACK (menu_deactivate_callback),
+ &damd);
+
+ gtk_grab_add (menu);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ NULL, NULL, 0, GDK_CURRENT_TIME);
+
+ g_main_loop_run (damd.loop);
- return action;
-#endif
+ gtk_grab_remove (menu);
+
+ g_main_loop_unref (damd.loop);
+
+ gtk_object_sink (GTK_OBJECT (menu));
+
+ return damd.chosen;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]