[PATCH] Little fix for #136452



A proposal to fix #136452 (Edit Bookmarks dialog ignores Delete). I had
to refactor a bit of code. Ok to commit?
-- 
"The missionaries go forth to Christianize the savages -- as if
the savages weren't dangerous enough already" [Edward Abbey]

xan, xan gnome org
Index: src/nautilus-bookmarks-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-bookmarks-window.c,v
retrieving revision 1.79
diff -u -3 -p -u -r1.79 nautilus-bookmarks-window.c
--- src/nautilus-bookmarks-window.c	11 Feb 2004 16:03:44 -0000	1.79
+++ src/nautilus-bookmarks-window.c	1 Apr 2004 15:27:36 -0000
@@ -61,6 +61,7 @@ static int		     uri_field_changed_signa
 static int		     row_changed_signal_id;
 static int		     row_deleted_signal_id;
 static int                   row_activated_signal_id;
+static int                   key_pressed_signal_id;
 
 /* forward declarations */
 static guint    get_selected_row                            (void);
@@ -86,6 +87,9 @@ static void	on_row_activated			    (GtkT
 							     GtkTreePath	  *path,
                                                              GtkTreeViewColumn    *column,
 							     gpointer		   user_data);
+static gboolean	on_key_pressed                              (GtkTreeView	  *view,
+                                                             GdkEventKey          *event,
+							     gpointer		   user_data);
 static void     on_selection_changed                        (GtkTreeSelection     *treeselection,
 							     gpointer              user_data);
 
@@ -306,6 +310,9 @@ create_bookmarks_window (NautilusBookmar
         row_activated_signal_id =
                 g_signal_connect (bookmark_list_widget, "row_activated",
                                   G_CALLBACK (on_row_activated), undo_manager_source);
+        key_pressed_signal_id =
+                g_signal_connect (bookmark_list_widget, "key_press_event",
+                                  G_CALLBACK (on_key_pressed), NULL);
 	selection_changed_id =
 		g_signal_connect (bookmark_selection, "changed",
 				  G_CALLBACK (on_selection_changed), NULL);	
@@ -503,8 +510,7 @@ on_jump_button_clicked (GtkButton *butto
 }
 
 static void
-on_remove_button_clicked (GtkButton *button,
-                          gpointer   user_data)
+bookmarks_delete_bookmark ()
 {
 	GtkTreeIter iter;
 	GtkTreePath *path;
@@ -539,6 +545,14 @@ on_remove_button_clicked (GtkButton *but
 	}
 }
 
+static void
+on_remove_button_clicked (GtkButton *button,
+                          gpointer   user_data)
+{
+        bookmarks_delete_bookmark ();
+}
+
+
 /* This is a bit of a kludge to get DnD to work. We check if the row in the
    GtkListStore matches the one in the bookmark list. If it doesn't, we assume
    the bookmark has just been dragged here and we insert it into the bookmark
@@ -588,6 +602,19 @@ on_row_changed (GtkListStore *store,
 	}
 }
 
+static gboolean
+on_key_pressed (GtkTreeView *view,
+                GdkEventKey *event,
+                gpointer user_data)
+{
+        if (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete) {
+                bookmarks_delete_bookmark ();
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
 static void
 on_row_activated (GtkTreeView       *view,
                   GtkTreePath       *path,
@@ -785,11 +812,15 @@ repopulate (void)
 				row_deleted_signal_id);
         g_signal_handler_block (bookmark_list_widget,
                                 row_activated_signal_id);
+        g_signal_handler_block (bookmark_list_widget,
+                                key_pressed_signal_id);
 
 	gtk_list_store_clear (store);
 	
 	g_signal_handler_unblock (bookmark_list_widget,
 				  row_activated_signal_id);
+        g_signal_handler_unblock (bookmark_list_widget,
+                                  key_pressed_signal_id);
 	g_signal_handler_unblock (bookmark_list_store,
 				  row_deleted_signal_id);
 	g_signal_handler_unblock (bookmark_selection,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]