[Xfce4-commits] <postler:master> Move button_menu_position function into App

Christian Dywan noreply at xfce.org
Fri Jan 14 23:32:02 CET 2011


Updating branch refs/heads/master
         to df6167d8c5b1c8103861922c510d5f688439be89 (commit)
       from d13d60da7ec49da88c71f9b9dc42d880ab35eab5 (commit)

commit df6167d8c5b1c8103861922c510d5f688439be89
Author: Christian Dywan <christian at twotoasts.de>
Date:   Fri Jan 14 23:32:18 2011 +0100

    Move button_menu_position function into App

 postler/postler-app.vala      |   15 +++++++++++++++
 postler/postler-bureau.vala   |   16 +---------------
 postler/postler-composer.vala |   17 +----------------
 3 files changed, 17 insertions(+), 31 deletions(-)

diff --git a/postler/postler-app.vala b/postler/postler-app.vala
index 5503b0b..f64c821 100644
--- a/postler/postler-app.vala
+++ b/postler/postler-app.vala
@@ -237,5 +237,20 @@ public class Postler.App : Unique.App {
             Canberra.Context.create (out sound_context);
         sound_context.play (0, Canberra.PROP_EVENT_ID, sound);
     }
+
+    public static void button_menu_position (Gtk.Menu menu, ref int x, ref int y,
+        ref bool push_in) {
+        /* Position the menu right below the widget */
+        var widget = menu.get_attach_widget ();
+        Gtk.Allocation allocation = widget.allocation;
+        int widget_x, widget_y;
+        widget.window.get_position (out widget_x, out widget_y);
+        Gtk.Requisition requisition;
+        widget.size_request (out requisition);
+        int widget_height = requisition.height;
+        x = widget_x + allocation.x;
+        y = widget_y + allocation.y + widget_height;
+        push_in = true;
+    }
 }
 
diff --git a/postler/postler-bureau.vala b/postler/postler-bureau.vala
index 0a11b7e..7144c40 100644
--- a/postler/postler-bureau.vala
+++ b/postler/postler-bureau.vala
@@ -269,27 +269,13 @@ public class Postler.Bureau : Gtk.Window {
         folders.populate ();
     }
 
-    void button_menu_position (Gtk.Menu menu, ref int x, ref int y, ref bool push_in) {
-        /* Position the menu right below the widget */
-        var widget = menu.get_attach_widget ();
-        Gtk.Allocation allocation = widget.allocation;
-        int widget_x, widget_y;
-        widget.window.get_position (out widget_x, out widget_y);
-        Gtk.Requisition requisition;
-        widget.size_request (out requisition);
-        int widget_height = requisition.height;
-        x = widget_x + allocation.x;
-        y = widget_y + allocation.y + widget_height;
-        push_in = true;
-    }
-
     void action_view (Gtk.Action action) {
         var menu = ui.get_widget ("/view") as Gtk.Menu;
         if (menu.get_attach_widget () == null) {
             var proxy = action.get_proxies ().nth_data (0);
             menu.attach_to_widget (proxy, (widget, menu) => { });
         }
-        menu.popup (null, null, button_menu_position, 1,
+        menu.popup (null, null, Postler.App.button_menu_position, 1,
                     Gtk.get_current_event_time ());
         menu.select_first (true);
         menu.deactivate.connect ((menu_shell) => {
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index c029d6f..6dcb716 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -337,7 +337,7 @@ public class Postler.Composer : Gtk.Window {
             var proxy = action.get_proxies ().nth_data (0);
             menu.attach_to_widget (proxy, (widget, menu) => { });
         }
-        menu.popup (null, null, button_menu_position, 1,
+        menu.popup (null, null, Postler.App.button_menu_position, 1,
                     Gtk.get_current_event_time ());
         menu.select_first (true);
         menu.deactivate.connect (( menu_shell ) => {
@@ -345,21 +345,6 @@ public class Postler.Composer : Gtk.Window {
         });
     }
 
-    /* FIXME: Share this function */
-    void button_menu_position (Gtk.Menu menu, ref int x, ref int y, ref bool push_in) {
-        /* Position the menu right below the widget */
-        var widget = menu.get_attach_widget ();
-        Gtk.Allocation allocation = widget.allocation;
-        int widget_x, widget_y;
-        widget.window.get_position (out widget_x, out widget_y);
-        Gtk.Requisition requisition;
-        widget.size_request (out requisition);
-        int widget_height = requisition.height;
-        x = widget_x + allocation.x;
-        y = widget_y + allocation.y + widget_height;
-        push_in = true;
-    }
-
     void action_insert_emoticon (Gtk.Action action) {
         unowned string name = action.name;
         string emoticon;



More information about the Xfce4-commits mailing list