[gnome-panel/wip-geiger-popup-menu: 2/2] modules: use gp_applet_popup_menu_for_widget



commit 279d930ec5c0bef6f9323d44983db0286dcfca24
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sun Apr 5 21:07:45 2020 +0200

    modules: use gp_applet_popup_menu_for_widget

 modules/menu/gp-menu-button-applet.c | 37 +++----------------------
 modules/status-notifier/sn-applet.c  | 52 +++++++-----------------------------
 2 files changed, 13 insertions(+), 76 deletions(-)
---
diff --git a/modules/menu/gp-menu-button-applet.c b/modules/menu/gp-menu-button-applet.c
index c7e141446..a7d6ab2ad 100644
--- a/modules/menu/gp-menu-button-applet.c
+++ b/modules/menu/gp-menu-button-applet.c
@@ -716,45 +716,16 @@ gp_menu_button_applet_popup_menu (GpMenuButtonApplet *menu_button,
                                   GdkEvent           *event)
 {
   GpMenuButtonAppletPrivate *priv;
-  GdkGravity widget_anchor;
-  GdkGravity menu_anchor;
 
   priv = gp_menu_button_applet_get_instance_private (menu_button);
 
   if (priv->menu == NULL)
     return FALSE;
 
-  switch (gp_applet_get_position (GP_APPLET (menu_button)))
-    {
-      case GTK_POS_TOP:
-        widget_anchor = GDK_GRAVITY_SOUTH_WEST;
-        menu_anchor = GDK_GRAVITY_NORTH_WEST;
-        break;
-
-      case GTK_POS_LEFT:
-        widget_anchor = GDK_GRAVITY_NORTH_EAST;
-        menu_anchor = GDK_GRAVITY_NORTH_WEST;
-        break;
-
-      case GTK_POS_RIGHT:
-        widget_anchor = GDK_GRAVITY_NORTH_WEST;
-        menu_anchor = GDK_GRAVITY_NORTH_EAST;
-        break;
-
-      case GTK_POS_BOTTOM:
-        widget_anchor = GDK_GRAVITY_NORTH_WEST;
-        menu_anchor = GDK_GRAVITY_SOUTH_WEST;
-        break;
-
-      default:
-        g_assert_not_reached ();
-        break;
-    }
-
-  gtk_menu_popup_at_widget (GTK_MENU (priv->menu),
-                            priv->button,
-                            widget_anchor, menu_anchor,
-                            event);
+  gp_applet_popup_menu_at_widget (GP_APPLET (menu_button),
+                                  GTK_MENU (priv->menu),
+                                  priv->button,
+                                  event);
 
   return TRUE;
 }
diff --git a/modules/status-notifier/sn-applet.c b/modules/status-notifier/sn-applet.c
index b93d40b26..2e90e20b5 100644
--- a/modules/status-notifier/sn-applet.c
+++ b/modules/status-notifier/sn-applet.c
@@ -109,47 +109,6 @@ get_popup_position (SnApplet *sn,
     }
 }
 
-static void
-popup_menu_at_item (SnApplet *sn,
-                    GtkMenu  *menu,
-                    SnItem   *item,
-                    GdkEvent *event)
-{
-  GdkGravity widget_anchor;
-  GdkGravity menu_anchor;
-
-  switch (gp_applet_get_position (GP_APPLET (sn)))
-    {
-      case GTK_POS_TOP:
-        widget_anchor = GDK_GRAVITY_SOUTH_WEST;
-        menu_anchor = GDK_GRAVITY_NORTH_WEST;
-        break;
-
-      case GTK_POS_LEFT:
-        widget_anchor = GDK_GRAVITY_NORTH_EAST;
-        menu_anchor = GDK_GRAVITY_NORTH_WEST;
-        break;
-
-      case GTK_POS_RIGHT:
-        widget_anchor = GDK_GRAVITY_NORTH_WEST;
-        menu_anchor = GDK_GRAVITY_NORTH_EAST;
-        break;
-
-      case GTK_POS_BOTTOM:
-        widget_anchor = GDK_GRAVITY_NORTH_WEST;
-        menu_anchor = GDK_GRAVITY_SOUTH_WEST;
-        break;
-
-      default:
-        g_assert_not_reached ();
-        break;
-    }
-
-  gtk_menu_popup_at_widget (menu, GTK_WIDGET (item),
-                            widget_anchor, menu_anchor,
-                            event);
-}
-
 static gboolean
 button_press_event_cb (GtkWidget      *widget,
                        GdkEventButton *event,
@@ -173,7 +132,11 @@ button_press_event_cb (GtkWidget      *widget,
 
       if (menu != NULL)
         {
-          popup_menu_at_item (sn, menu, item, (GdkEvent *) event);
+          gp_applet_popup_menu_at_widget (GP_APPLET (sn),
+                                           menu,
+                                           GTK_WIDGET (item),
+                                           (GdkEvent *) event);
+
           return GDK_EVENT_STOP;
         }
       else
@@ -198,7 +161,10 @@ popup_menu_cb (GtkWidget *widget,
 
   if (menu != NULL)
     {
-      popup_menu_at_item (sn, menu, item, NULL);
+      gp_applet_popup_menu_at_widget (GP_APPLET (sn),
+                                      menu,
+                                      GTK_WIDGET (item),
+                                      NULL);
     }
   else
     {


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