diff options
author | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-06-27 12:19:09 +0100 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-06-27 12:19:09 +0100 |
commit | e9f91cffa10b6d00743674faf516dff8e3e13311 (patch) | |
tree | 5f8e6f0b8e849b03119bf3f25253b83af3be7cdf | |
parent | 998509ea7c9b3a984bad2383f7487241f4820eb0 (diff) | |
download | ayatana-indicator-power-e9f91cffa10b6d00743674faf516dff8e3e13311.tar.gz ayatana-indicator-power-e9f91cffa10b6d00743674faf516dff8e3e13311.tar.bz2 ayatana-indicator-power-e9f91cffa10b6d00743674faf516dff8e3e13311.zip |
power-service: Add more items to the menu
-rw-r--r-- | src/power-service.c | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/src/power-service.c b/src/power-service.c index f63c995..bca079b 100644 --- a/src/power-service.c +++ b/src/power-service.c @@ -43,9 +43,6 @@ static DbusmenuServer *server = NULL; /*TODO Do we need this?*/ /*static PowerServiceDbus *dbus_interface = NULL;*/ -/* Global Items */ -static DbusmenuMenuitem *settings = NULL; - /* Repsonds to the service object saying it's time to shutdown. It stops the mainloop. */ static void @@ -58,23 +55,53 @@ service_shutdown (IndicatorService *service, } static void +spawn_on_activate_cb (DbusmenuMenuitem *mi, + guint timestamp, + gpointer user_data) +{ + GError * error = NULL; + + if (!g_spawn_command_line_async (user_data, &error)) + { + g_warning ("Unable to start %s: %s", (char *)user_data, error->message); + g_error_free (error); + } +} + +static void build_menus (DbusmenuMenuitem *root_menuitem) { - /*TODO*/ + DbusmenuMenuitem *power_mi = NULL; + DbusmenuMenuitem *separator_mi = NULL; + DbusmenuMenuitem *settings_mi = NULL; - settings = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (settings, + power_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (power_mi, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Laptop Battery 0:25")); /*TODO*/ + g_signal_connect (G_OBJECT (power_mi), + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (spawn_on_activate_cb), + "gnome-power-statistic"); + + settings_mi = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (settings_mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Power Settings...")); - /* insensitive until we check for available apps */ -/* - dbusmenu_menuitem_property_set_bool (settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); - g_signal_connect (G_OBJECT (settings), + g_signal_connect (G_OBJECT (power_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (activate_cb), - "indicator-power-preferences"); -*/ - dbusmenu_menuitem_child_append (root_menuitem, settings); + G_CALLBACK (spawn_on_activate_cb), + "gnome-power-preferences"); + + separator_mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (separator_mi, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_SEPARATOR); + + + dbusmenu_menuitem_child_append (root_menuitem, power_mi); + dbusmenu_menuitem_child_append (root_menuitem, separator_mi); + dbusmenu_menuitem_child_append (root_menuitem, settings_mi); } gint |