From b94b15e1048dffe16bca53a3cb0f607a539bd9c6 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sat, 9 Jul 2016 21:46:25 +0200 Subject: Reorganize the tray icon code to make it easier for AppIndicator support to be patched in taken from: https://git.gnome.org/browse/gnome-power-manager/commit/?id=9786241 --- src/gpm-tray-icon.c | 55 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c index 18c2c8b..0f9b911 100644 --- a/src/gpm-tray-icon.c +++ b/src/gpm-tray-icon.c @@ -198,21 +198,6 @@ gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data) NULL); } -/** - * gpm_tray_icon_popup_cleared_cd: - * @widget: The popup Gtkwidget - * - * We have to re-enable the tooltip when the popup is removed - **/ -static void -gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon) -{ - g_return_if_fail (GPM_IS_TRAY_ICON (icon)); - egg_debug ("clear tray"); - g_object_ref_sink (widget); - g_object_unref (widget); -} - /** * gpm_tray_icon_class_init: **/ @@ -292,10 +277,10 @@ gpm_tray_icon_add_device (GpmTrayIcon *icon, GtkMenu *menu, const GPtrArray *arr /** * gpm_tray_icon_create_menu: * - * Display the popup menu. + * Create the popup menu. **/ -static void -gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp) +static GtkMenu * +gpm_tray_icon_create_menu (GpmTrayIcon *icon) { GtkMenu *menu = (GtkMenu*) gtk_menu_new (); GtkWidget *item; @@ -355,6 +340,36 @@ gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); skip_prefs: + return menu; +} + +/** + * gpm_tray_icon_popup_cleared_cd: + * @widget: The popup Gtkwidget + * + * We have to re-enable the tooltip when the popup is removed + **/ +static void +gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon) +{ + g_return_if_fail (GPM_IS_TRAY_ICON (icon)); + egg_debug ("clear tray"); + g_object_ref_sink (widget); + g_object_unref (widget); +} + +/** + * gpm_tray_icon_popup_menu: + * + * Display the popup menu. + **/ +static void +gpm_tray_icon_popup_menu (GpmTrayIcon *icon, guint32 timestamp) +{ + GtkMenu *menu; + + menu = gpm_tray_icon_create_menu (icon); + /* show the menu */ gtk_widget_show_all (GTK_WIDGET (menu)); gtk_menu_popup (GTK_MENU (menu), NULL, NULL, @@ -374,7 +389,7 @@ static void gpm_tray_icon_popup_menu_cb (GtkStatusIcon *status_icon, guint button, guint32 timestamp, GpmTrayIcon *icon) { egg_debug ("icon right clicked"); - gpm_tray_icon_create_menu (icon, timestamp); + gpm_tray_icon_popup_menu (icon, timestamp); } @@ -388,7 +403,7 @@ static void gpm_tray_icon_activate_cb (GtkStatusIcon *status_icon, GpmTrayIcon *icon) { egg_debug ("icon left clicked"); - gpm_tray_icon_create_menu (icon, gtk_get_current_event_time()); + gpm_tray_icon_popup_menu (icon, gtk_get_current_event_time()); } /** -- cgit v1.2.1