[cheese] Refactor thumb view popup menu handling



commit 2ecb01c2d5f00cea15184e02ba8abd1897d05304
Author: David King <amigadave amigadave com>
Date:   Thu Aug 7 15:08:15 2014 +0100

    Refactor thumb view popup menu handling
    
    Popup the thumb view context menu in response to the popup-menu signal
    on GtkWidget.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724905

 src/cheese-window.vala |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 90ad255..9e0b733 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -162,6 +162,20 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
         return false;
     }
 
+    private void do_thumb_view_popup_menu (Gtk.Widget widget,
+                                           uint button,
+                                           uint time)
+    {
+        thumbnail_popup.popup (null, widget, null, button, time);
+    }
+
+    private bool on_thumb_view_popup_menu (Gtk.Widget thumbview)
+    {
+        do_thumb_view_popup_menu (thumbview, 0, 0);
+
+        return true;
+    }
+
     /**
     * Popup a context menu when right-clicking on a thumbnail.
     *
@@ -190,18 +204,18 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
 
         if (event.type == Gdk.EventType.BUTTON_PRESS)
         {
-            Gdk.Event* button_press = (Gdk.Event*)(&event);
+            Gdk.Event* button_press = (Gdk.Event*)(event);
 
             if (button_press->triggers_context_menu ())
             {
-                thumbnail_popup.popup (null, thumb_view, null, event.button,
-                                       event.time);
-            }
-            else if (event.type == Gdk.EventType.2BUTTON_PRESS)
-            {
-                on_file_open ();
+                do_thumb_view_popup_menu (thumb_view, event.button,
+                                          event.time);
+                return true;
             }
-
+        }
+        else if (event.type == Gdk.EventType.2BUTTON_PRESS)
+        {
+            on_file_open ();
             return true;
         }
 
@@ -1272,6 +1286,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
     thumb_view = new Cheese.ThumbView ();
     thumb_nav  = new Eog.ThumbNav (thumb_view, false);
         thumbnail_popup.attach_to_widget (thumb_view, null);
+        thumb_view.popup_menu.connect (on_thumb_view_popup_menu);
 
         Gtk.CssProvider css;
         try


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