[epiphany] CookiesDialog: Define keybindings in UI file.



commit 0078d00a10fe44ef4bc2db284001fbdbe69bdd99
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat Oct 31 06:36:04 2015 +0100

    CookiesDialog: Define keybindings in UI file.
    
    This commit also adds a keybinding for the forget-all action.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757401

 src/cookies-dialog.c            |   28 +++-------------------------
 src/resources/cookies-dialog.ui |    4 +++-
 2 files changed, 6 insertions(+), 26 deletions(-)
---
diff --git a/src/cookies-dialog.c b/src/cookies-dialog.c
index 3b0fa61..049d8d4 100644
--- a/src/cookies-dialog.c
+++ b/src/cookies-dialog.c
@@ -111,7 +111,9 @@ cookie_remove (CookiesDialog *dialog,
 }
 
 static void
-delete_selection (CookiesDialog *dialog)
+forget (GSimpleAction *action,
+        GVariant      *parameter,
+        CookiesDialog *dialog)
 {
        GList *llist, *rlist = NULL, *l, *r;
        GtkTreeModel *model;
@@ -202,29 +204,6 @@ delete_selection (CookiesDialog *dialog)
        }
 }
 
-static gboolean
-on_cookies_treeview_key_press_event (GtkWidget     *widget,
-                                    GdkEventKey   *event,
-                                    CookiesDialog *dialog)
-{
-       if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete)
-       {
-               delete_selection (dialog);
-
-               return TRUE;
-       }
-
-       return FALSE;
-}
-
-static void
-forget (GSimpleAction *action,
-        GVariant      *parameter,
-        CookiesDialog *dialog)
-{
-       delete_selection (dialog);
-}
-
 static void
 update_selection_actions (GActionMap *action_map,
                           gboolean    has_selection)
@@ -282,7 +261,6 @@ cookies_dialog_class_init (CookiesDialogClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, CookiesDialog, cookies_treeview);
        gtk_widget_class_bind_template_child_private (widget_class, CookiesDialog, tree_selection);
 
-       gtk_widget_class_bind_template_callback (widget_class, on_cookies_treeview_key_press_event);
        gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
        gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
 }
diff --git a/src/resources/cookies-dialog.ui b/src/resources/cookies-dialog.ui
index 8a4f81e..3fcb6fa 100644
--- a/src/resources/cookies-dialog.ui
+++ b/src/resources/cookies-dialog.ui
@@ -36,6 +36,7 @@
             <property name="use_underline">True</property>
             <property name="valign">center</property>
             <property name="action-name">cookies.forget-all</property>
+            <accelerator key="Delete" modifiers="GDK_SHIFT_MASK" signal="clicked"/>
             <style>
               <class name="destructive-action"/>
               <class name="text-button"/>
@@ -79,7 +80,6 @@
                     <property name="model">treemodelsort</property>
                     <property name="enable_search">False</property>
                     <property name="search_column">0</property>
-                    <signal name="key-press-event" handler="on_cookies_treeview_key_press_event"/>
                     <child internal-child="selection">
                       <object class="GtkTreeSelection" id="tree_selection">
                         <property name="mode">multiple</property>
@@ -121,6 +121,8 @@
                             <property name="tooltip_text" translatable="yes">Delete the selected 
cookies</property>
                             <property name="label" translatable="yes">Remove</property> <!-- TODO conflicts 
with the image -->
                             <property name="action-name">cookies.forget</property>
+                            <accelerator key="Delete" signal="clicked"/>
+                            <accelerator key="KP_Delete" signal="clicked"/>
                             <child>
                               <object class="GtkImage">
                                 <property name="visible">True</property>


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