[gnome-power-manager] Reorganize the tray icon code to make it easier for AppIndicator support to be patched in



commit 978624189a9f9011976f19d2f695875b8f955096
Author: Jan Arne Petersen <jpetersen openismus com>
Date:   Wed Mar 31 16:21:33 2010 +0100

    Reorganize the tray icon code to make it easier for AppIndicator support to be patched in
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gpm-tray-icon.c |   55 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/src/gpm-tray-icon.c b/src/gpm-tray-icon.c
index c473c3e..64fc257 100644
--- a/src/gpm-tray-icon.c
+++ b/src/gpm-tray-icon.c
@@ -167,21 +167,6 @@ gpm_tray_icon_show_preferences_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
@@ -280,10 +265,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;
@@ -320,6 +305,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,
@@ -339,7 +354,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);
 }
 
 
@@ -353,7 +368,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());
 }
 
 /**



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