places sidebar: Handle menu key
authorMatthias Clasen <mclasen@redhat.com>
Wed, 15 Jul 2015 05:44:31 +0000 (01:44 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 15 Jul 2015 16:46:06 +0000 (12:46 -0400)
It is good practice to handle the menu key and Shift-F10 to
allow keyboard-driven use of context menus.

gtk/gtkplacessidebar.c

index 322b7f154269514d32e2519d2cd8490289120baf..3b20ff610636321c0537663d2f72ea05f869dc9f 100644 (file)
@@ -249,6 +249,7 @@ static gboolean on_button_press_event (GtkWidget      *widget,
 static gboolean on_button_release_event (GtkWidget      *widget,
                                          GdkEventButton *event,
                                          GtkSidebarRow  *sidebar);
+static void popup_menu_cb (GtkSidebarRow *row);
 static void stop_drop_feedback (GtkPlacesSidebar *sidebar);
 
 
@@ -3215,6 +3216,15 @@ on_key_press_event (GtkWidget        *widget,
               rename_bookmark (GTK_SIDEBAR_ROW (row));
               return TRUE;
             }
+
+          if ((event->keyval == GDK_KEY_Menu) ||
+              ((event->keyval == GDK_KEY_F10) &&
+               (event->state & modifiers) == GDK_SHIFT_MASK))
+
+            {
+              popup_menu_cb (GTK_SIDEBAR_ROW (row));
+              return TRUE;
+            }
         }
     }
 
@@ -3495,6 +3505,17 @@ on_button_release_event (GtkWidget      *widget,
   return ret;
 }
 
+static void
+popup_menu_cb (GtkSidebarRow *row)
+{
+  GtkPlacesSidebarPlaceType row_type;
+
+  g_object_get (row, "place-type", &row_type, NULL);
+
+  if (row_type != PLACES_CONNECT_TO_SERVER)
+    bookmarks_popup_menu (row, NULL);
+}
+
 static gint
 list_box_sort_func (GtkListBoxRow *row1,
                     GtkListBoxRow *row2,