aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJavier Jardón <javier.jardon@codethink.co.uk>2011-06-29 16:43:38 +0100
committerJavier Jardón <javier.jardon@codethink.co.uk>2011-06-29 16:43:38 +0100
commitb1d0f0e0a01b958f179845bac8b43ba742961ab6 (patch)
tree772312cf2326403bdf099affec234705a463bbc8 /src
parent377412200227fc9fb895df8c30d2f6cf70dc5597 (diff)
downloadayatana-indicator-power-b1d0f0e0a01b958f179845bac8b43ba742961ab6.tar.gz
ayatana-indicator-power-b1d0f0e0a01b958f179845bac8b43ba742961ab6.tar.bz2
ayatana-indicator-power-b1d0f0e0a01b958f179845bac8b43ba742961ab6.zip
Populate menu: Add preferences menu item
Diffstat (limited to 'src')
-rw-r--r--src/indicator-power.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/indicator-power.c b/src/indicator-power.c
index 1eb0797..697f7c6 100644
--- a/src/indicator-power.c
+++ b/src/indicator-power.c
@@ -329,6 +329,49 @@ service_proxy_cb (GObject *object,
}
static void
+show_preferences_cb (GtkMenuItem *item,
+ gpointer data)
+{
+ const gchar *command = "gnome-power-preferences";
+
+ if (g_spawn_command_line_async (command, NULL) == FALSE)
+ g_warning ("Couldn't execute command: %s", command);
+}
+
+static void
+build_menu (IndicatorPower *self)
+{
+ IndicatorPowerPrivate *priv = self->priv;
+ GtkWidget *item;
+ GtkWidget *image;
+ guint n_devices = 1; /*TODO*/
+
+ priv->menu = GTK_MENU (gtk_menu_new ());
+
+ item = gtk_image_menu_item_new_from_stock ("battery", NULL);
+ gtk_menu_item_set_label (GTK_MENU_ITEM (item), "Battery Remaining: 0:45s"); /*TODO*/
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
+
+ /* only do the seporator if we have at least one device */
+ if (n_devices != 0)
+ {
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
+ }
+
+ /* preferences */
+ item = gtk_image_menu_item_new_with_mnemonic (_("Power Settings ..."));
+ image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ g_signal_connect (G_OBJECT (item), "activate",
+ G_CALLBACK (show_preferences_cb), NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
+
+ /* show the menu */
+ gtk_widget_show_all (GTK_WIDGET (priv->menu));
+}
+
+static void
indicator_power_init (IndicatorPower *self)
{
IndicatorPowerPrivate *priv;
@@ -341,10 +384,7 @@ indicator_power_init (IndicatorPower *self)
/* Init variables */
priv->menu = NULL;
- priv->menu = GTK_MENU (gtk_menu_new ());
- gtk_menu_set_title (priv->menu, _("Power"));
-
- gtk_menu_popup (priv->menu, NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time ());
+ build_menu (self);
priv->proxy_cancel = g_cancellable_new();