summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-07-09 21:46:25 +0200
committerraveit65 <[email protected]>2016-07-25 16:13:41 +0200
commitb94b15e1048dffe16bca53a3cb0f607a539bd9c6 (patch)
treeba79c5fa505399cca15df597a95653482ee27b06 /src
parent01c2420b51731687b7dae1481101ec04fa0fc2d2 (diff)
downloadmate-power-manager-b94b15e1048dffe16bca53a3cb0f607a539bd9c6.tar.bz2
mate-power-manager-b94b15e1048dffe16bca53a3cb0f607a539bd9c6.tar.xz
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
Diffstat (limited to 'src')
-rw-r--r--src/gpm-tray-icon.c55
1 files 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
@@ -199,21 +199,6 @@ gpm_tray_icon_show_about_cb (GtkMenuItem *item, gpointer data)
}
/**
- * 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:
**/
static void
@@ -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());
}
/**