aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/power-service.c53
1 files changed, 53 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-service.h>
+#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;
}