]> Pileus Git - ~andy/gtk/commitdiff
Fixes #140412.
authorFederico Mena Quintero <federico@ximian.com>
Thu, 29 Apr 2004 23:13:50 +0000 (23:13 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Thu, 29 Apr 2004 23:13:50 +0000 (23:13 +0000)
2004-04-29  Federico Mena Quintero  <federico@ximian.com>

Fixes #140412.

* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c

index 54efeb14e982f54fb59f701ee2d293f1c12c3c7a..b5c2a04c4270794b99089d0f5bbd8d954ead4ba8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-04-29  Federico Mena Quintero  <federico@ximian.com>
+
+       Fixes #140412.
+
+       * gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
+       function; moved the code over from
+       remove_bookmark_button_clicked_cb().
+       (remove_selected_bookmarks): Now, getting a non-removable bookmark
+       is not an error, as we may be called as a result of hitting the
+       Delete key.
+       (shortcuts_key_press_event_cb): New handler; delete the bookmark
+       if the user presses Backspace, Delete, or KP_Delete.
+
 2004-04-29  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Use
index 54efeb14e982f54fb59f701ee2d293f1c12c3c7a..b5c2a04c4270794b99089d0f5bbd8d954ead4ba8 100644 (file)
@@ -1,3 +1,16 @@
+2004-04-29  Federico Mena Quintero  <federico@ximian.com>
+
+       Fixes #140412.
+
+       * gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
+       function; moved the code over from
+       remove_bookmark_button_clicked_cb().
+       (remove_selected_bookmarks): Now, getting a non-removable bookmark
+       is not an error, as we may be called as a result of hitting the
+       Delete key.
+       (shortcuts_key_press_event_cb): New handler; delete the bookmark
+       if the user presses Backspace, Delete, or KP_Delete.
+
 2004-04-29  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Use
index 54efeb14e982f54fb59f701ee2d293f1c12c3c7a..b5c2a04c4270794b99089d0f5bbd8d954ead4ba8 100644 (file)
@@ -1,3 +1,16 @@
+2004-04-29  Federico Mena Quintero  <federico@ximian.com>
+
+       Fixes #140412.
+
+       * gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
+       function; moved the code over from
+       remove_bookmark_button_clicked_cb().
+       (remove_selected_bookmarks): Now, getting a non-removable bookmark
+       is not an error, as we may be called as a result of hitting the
+       Delete key.
+       (shortcuts_key_press_event_cb): New handler; delete the bookmark
+       if the user presses Backspace, Delete, or KP_Delete.
+
 2004-04-29  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Use
index 54efeb14e982f54fb59f701ee2d293f1c12c3c7a..b5c2a04c4270794b99089d0f5bbd8d954ead4ba8 100644 (file)
@@ -1,3 +1,16 @@
+2004-04-29  Federico Mena Quintero  <federico@ximian.com>
+
+       Fixes #140412.
+
+       * gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
+       function; moved the code over from
+       remove_bookmark_button_clicked_cb().
+       (remove_selected_bookmarks): Now, getting a non-removable bookmark
+       is not an error, as we may be called as a result of hitting the
+       Delete key.
+       (shortcuts_key_press_event_cb): New handler; delete the bookmark
+       if the user presses Backspace, Delete, or KP_Delete.
+
 2004-04-29  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Use
index 54efeb14e982f54fb59f701ee2d293f1c12c3c7a..b5c2a04c4270794b99089d0f5bbd8d954ead4ba8 100644 (file)
@@ -1,3 +1,16 @@
+2004-04-29  Federico Mena Quintero  <federico@ximian.com>
+
+       Fixes #140412.
+
+       * gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
+       function; moved the code over from
+       remove_bookmark_button_clicked_cb().
+       (remove_selected_bookmarks): Now, getting a non-removable bookmark
+       is not an error, as we may be called as a result of hitting the
+       Delete key.
+       (shortcuts_key_press_event_cb): New handler; delete the bookmark
+       if the user presses Backspace, Delete, or KP_Delete.
+
 2004-04-29  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkaction.c (closure_accel_activate): Use
index 60143eec9ac86ac9c2e54f88f2a9c75e30bb32c4..b3cc47280e3fc9c32f64297af2851f648c536815 100644 (file)
@@ -329,6 +329,11 @@ static void     shortcuts_row_activated_cb (GtkTreeView           *tree_view,
                                            GtkTreePath           *path,
                                            GtkTreeViewColumn     *column,
                                            GtkFileChooserDefault *impl);
+
+static gboolean shortcuts_key_press_event_cb (GtkWidget             *widget,
+                                             GdkEventKey           *event,
+                                             GtkFileChooserDefault *impl);
+
 static gboolean shortcuts_select_func   (GtkTreeSelection      *selection,
                                         GtkTreeModel          *model,
                                         GtkTreePath           *path,
@@ -1701,10 +1706,9 @@ add_bookmark_button_clicked_cb (GtkButton *button,
                                         impl);
 }
 
-/* Callback used when the "Remove bookmark" button is clicked */
+/* Removes the selected bookmarks */
 static void
-remove_bookmark_button_clicked_cb (GtkButton *button,
-                                  GtkFileChooserDefault *impl)
+remove_selected_bookmarks (GtkFileChooserDefault *impl)
 {
   GtkTreeSelection *selection;
   GtkTreeIter iter;
@@ -1714,28 +1718,33 @@ remove_bookmark_button_clicked_cb (GtkButton *button,
 
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
-  if (gtk_tree_selection_get_selected (selection, NULL, &iter))
-    {
-      gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
-                         SHORTCUTS_COL_PATH, &path,
-                         SHORTCUTS_COL_REMOVABLE, &removable, -1);
-      if (!removable)
-       {
-         g_assert_not_reached ();
-         return;
-       }
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+    return;
 
-      error = NULL;
-      if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
-       {
-         error_dialog (impl,
-                       _("Could not remove bookmark for %s:\n%s"),
-                       path,
-                       error);
-       }
+  gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
+                     SHORTCUTS_COL_PATH, &path,
+                     SHORTCUTS_COL_REMOVABLE, &removable, -1);
+  if (!removable)
+    return;
+
+  error = NULL;
+  if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
+    {
+      error_dialog (impl,
+                   _("Could not remove bookmark for %s:\n%s"),
+                   path,
+                   error);
     }
 }
 
+/* Callback used when the "Remove bookmark" button is clicked */
+static void
+remove_bookmark_button_clicked_cb (GtkButton *button,
+                                  GtkFileChooserDefault *impl)
+{
+  remove_selected_bookmarks (impl);
+}
+
 struct selection_check_closure {
   GtkFileChooserDefault *impl;
   gboolean empty;
@@ -2482,6 +2491,9 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
   g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
                    G_CALLBACK (shortcuts_row_activated_cb), impl);
 
+  g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
+                   G_CALLBACK (shortcuts_key_press_event_cb), impl);
+
   g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin",
                    G_CALLBACK (shortcuts_drag_begin_cb), impl);
   g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end",
@@ -4819,6 +4831,28 @@ shortcuts_row_activated_cb (GtkTreeView           *tree_view,
   shortcuts_activate_item (impl, selected);
 }
 
+/* Handler for GtkWidget::key-press-event on the shortcuts list */
+static gboolean
+shortcuts_key_press_event_cb (GtkWidget             *widget,
+                             GdkEventKey           *event,
+                             GtkFileChooserDefault *impl)
+{
+  guint modifiers;
+
+  modifiers = gtk_accelerator_get_default_mod_mask ();
+
+  if ((event->keyval == GDK_BackSpace
+      || event->keyval == GDK_Delete
+      || event->keyval == GDK_KP_Delete)
+      && (event->state & modifiers) == 0)
+    {
+      remove_selected_bookmarks (impl);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static gboolean
 shortcuts_select_func  (GtkTreeSelection  *selection,
                        GtkTreeModel      *model,