[gnome-flashback] desktop: handle Menu key



commit 316e590203075044df1af674a14871802fb278fe
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Nov 17 14:20:32 2019 +0200

    desktop: handle Menu key

 gnome-flashback/libdesktop/gf-icon-view.c | 28 ++++++++++++++++++++++++++++
 gnome-flashback/libdesktop/gf-icon.c      | 20 +++++++++++++-------
 gnome-flashback/libdesktop/gf-icon.h      |  2 ++
 3 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/gnome-flashback/libdesktop/gf-icon-view.c b/gnome-flashback/libdesktop/gf-icon-view.c
index a574408..dcf8655 100644
--- a/gnome-flashback/libdesktop/gf-icon-view.c
+++ b/gnome-flashback/libdesktop/gf-icon-view.c
@@ -2061,6 +2061,33 @@ gf_icon_view_draw (GtkWidget *widget,
   return TRUE;
 }
 
+static gboolean
+gf_icon_view_popup_menu (GtkWidget *widget)
+{
+  GfIconView *self;
+
+  self = GF_ICON_VIEW (widget);
+
+  if (self->selected_icons == NULL)
+    {
+      GtkWidget *popup_menu;
+
+      popup_menu = create_popup_menu (self);
+      g_object_ref_sink (popup_menu);
+
+      gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), NULL);
+      g_object_unref (popup_menu);
+
+      return TRUE;
+    }
+  else
+    {
+      gf_icon_popup_menu (GF_ICON (self->selected_icons->data));
+    }
+
+  return FALSE;
+}
+
 static void
 install_signals (void)
 {
@@ -2120,6 +2147,7 @@ gf_icon_view_class_init (GfIconViewClass *self_class)
   object_class->finalize = gf_icon_view_finalize;
 
   widget_class->draw = gf_icon_view_draw;
+  widget_class->popup_menu = gf_icon_view_popup_menu;
 
   install_signals ();
 
diff --git a/gnome-flashback/libdesktop/gf-icon.c b/gnome-flashback/libdesktop/gf-icon.c
index b38bce8..bead321 100644
--- a/gnome-flashback/libdesktop/gf-icon.c
+++ b/gnome-flashback/libdesktop/gf-icon.c
@@ -383,19 +383,13 @@ multi_press_pressed_cb (GtkGestureMultiPress *gesture,
     }
   else if (button == GDK_BUTTON_SECONDARY)
     {
-      GtkWidget *popup_menu;
-
       if (!priv->selected && !control_pressed)
         gf_icon_view_clear_selection (priv->icon_view);
 
       gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
       gf_icon_set_selected (self, TRUE);
 
-      popup_menu = create_popup_menu (self);
-      g_object_ref_sink (popup_menu);
-
-      gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), event);
-      g_object_unref (popup_menu);
+      gf_icon_popup_menu (self);
     }
   else if (button == GDK_BUTTON_MIDDLE)
     {
@@ -976,6 +970,18 @@ gf_icon_open (GfIcon *self)
   g_free (uri);
 }
 
+void
+gf_icon_popup_menu (GfIcon *self)
+{
+  GtkWidget *popup_menu;
+
+  popup_menu = create_popup_menu (self);
+  g_object_ref_sink (popup_menu);
+
+  gtk_menu_popup_at_pointer (GTK_MENU (popup_menu), NULL);
+  g_object_unref (popup_menu);
+}
+
 void
 gf_icon_update (GfIcon *self)
 {
diff --git a/gnome-flashback/libdesktop/gf-icon.h b/gnome-flashback/libdesktop/gf-icon.h
index 677a09a..fe6d6cf 100644
--- a/gnome-flashback/libdesktop/gf-icon.h
+++ b/gnome-flashback/libdesktop/gf-icon.h
@@ -60,6 +60,8 @@ gboolean    gf_icon_get_selected      (GfIcon     *self);
 
 void        gf_icon_open              (GfIcon     *self);
 
+void        gf_icon_popup_menu        (GfIcon     *self);
+
 void        gf_icon_update            (GfIcon     *self);
 
 G_END_DECLS


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