From 09c4a9167b0bd484367ff98e8e58dd68fb5b51c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Mon, 27 Jun 2011 04:00:08 +0100 Subject: Implement skeleton of power-service --- src/power-service.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/power-service.c b/src/power-service.c index 7e1ca1e..7d8e514 100644 --- a/src/power-service.c +++ b/src/power-service.c @@ -35,6 +35,33 @@ with this program. If not, see . #include +#include "dbus-shared-names.h" + +static IndicatorService *service = NULL; +static GMainLoop *mainloop = NULL; +static DbusmenuServer *server = NULL; +static DbusmenuMenuitem *root_menuitem = NULL; +/*TODO Do we need this?*/ +/*static PowerServiceDbus *dbus_interface = NULL;*/ + + +/* Repsonds to the service object saying it's time to shutdown. + It stops the mainloop. */ +static void +service_shutdown (IndicatorService *service, + gpointer user_data) +{ + g_warning("Shutting down service!"); + + g_main_loop_quit(mainloop); +} + +static void +build_menus (gpointer data) +{ + /*TODO*/ +} + gint main (gint argc, gchar **argv) @@ -46,5 +73,31 @@ main (gint argc, textdomain (GETTEXT_PACKAGE); setlocale (LC_ALL, ""); + /* Acknowledging the service init and setting up the interface */ + service = indicator_service_new_version (INDICATOR_POWER_DBUS_NAME, + INDICATOR_POWER_DBUS_VERSION); + g_signal_connect (service, + INDICATOR_SERVICE_SIGNAL_SHUTDOWN, + G_CALLBACK (service_shutdown), + NULL); + + /* Building the base menu */ + server = dbusmenu_server_new (INDICATOR_POWER_DBUS_OBJECT); + root_menuitem = dbusmenu_menuitem_new (); + dbusmenu_server_set_root (server, root_menuitem); + + build_menus (root_menuitem); + + /* Setup dbus interface */ + /*TODO*/ + /*dbus_interface = g_object_new (POWER_SERVICE_DBUS_TYPE, NULL);*/ + + mainloop = g_main_loop_new (NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref (G_OBJECT (service)); + g_object_unref (G_OBJECT (server)); + g_object_unref (G_OBJECT (root_menuitem)); + return 0; } -- cgit v1.2.3