[gnome-panel/wip-geiger-popup-menu] modules: use gp_applet_popup_menu_for_widget
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip-geiger-popup-menu] modules: use gp_applet_popup_menu_for_widget
- Date: Sun, 5 Apr 2020 19:03:45 +0000 (UTC)
commit 2072a3535e809378a8ff640f10cb097e09c44874
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 | 34 +++----------------------
modules/status-notifier/sn-applet.c | 48 ++++--------------------------------
2 files changed, 8 insertions(+), 74 deletions(-)
---
diff --git a/modules/menu/gp-menu-button-applet.c b/modules/menu/gp-menu-button-applet.c
index c7e141446..3c5efb3f6 100644
--- a/modules/menu/gp-menu-button-applet.c
+++ b/modules/menu/gp-menu-button-applet.c
@@ -724,37 +724,9 @@ gp_menu_button_applet_popup_menu (GpMenuButtonApplet *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_for_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..222e9621c 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,9 @@ button_press_event_cb (GtkWidget *widget,
if (menu != NULL)
{
- popup_menu_at_item (sn, menu, item, (GdkEvent *) event);
+ gp_applet_popup_menu_for_widget (GP_APPLET (sn), menu,
+ GTK_WIDGET (item), event);
+
return GDK_EVENT_STOP;
}
else
@@ -198,7 +159,8 @@ popup_menu_cb (GtkWidget *widget,
if (menu != NULL)
{
- popup_menu_at_item (sn, menu, item, NULL);
+ gp_applet_popup_menu_for_widget (GP_APPLET (sn), menu,
+ GTK_WIDGET (item), NULL);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]