aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-11-23 12:02:40 -0600
committerTed Gould <ted@canonical.com>2009-11-23 12:02:40 -0600
commitf22ff6a153ca3b6ebc6cab0177913823f0251be7 (patch)
tree3ebd5674c64c6fc4ab958c33a20ff1d1ab84965c
parentf7cfd25bc2cf4696a579d8b7374666ee5e6bb3b3 (diff)
downloadayatana-indicator-application-f22ff6a153ca3b6ebc6cab0177913823f0251be7.tar.gz
ayatana-indicator-application-f22ff6a153ca3b6ebc6cab0177913823f0251be7.tar.bz2
ayatana-indicator-application-f22ff6a153ca3b6ebc6cab0177913823f0251be7.zip
Cleaning up main a little bit and handling the 'disconnected' case that doesn't yet quite exist.
-rw-r--r--src/custom-service.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/custom-service.c b/src/custom-service.c
index 3205bc2..5bd9b96 100644
--- a/src/custom-service.c
+++ b/src/custom-service.c
@@ -5,22 +5,52 @@
#include "custom-service-watcher.h"
#include "dbus-shared.h"
+/* The base main loop */
static GMainLoop * mainloop = NULL;
+/* Where the application registry lives */
static CustomServiceAppstore * appstore = NULL;
+/* Interface for applications */
static CustomServiceWatcher * watcher = NULL;
+/* The service management interface */
static IndicatorService * service = NULL;
+
+/* Recieves the disonnection signal from the service
+ object and closes the mainloop. */
+static void
+service_disconnected (IndicatorService * service, gpointer data)
+{
+ g_debug("Service disconnected");
+ if (mainloop != NULL) {
+ g_main_loop_quit(mainloop);
+ }
+ return;
+}
+/* Builds up the core objects and puts us spinning into
+ a main loop. */
int
main (int argc, char ** argv)
{
g_type_init();
+ /* Bring us up as a basic indicator service */
service = indicator_service_new(INDICATOR_CUSTOM_DBUS_ADDR);
+ g_signal_connect(G_OBJECT(service), "disconnected", G_CALLBACK(service_disconnected), NULL);
+
+ /* Building our app store */
appstore = CUSTOM_SERVICE_APPSTORE(g_object_new(CUSTOM_SERVICE_APPSTORE_TYPE, NULL));
+
+ /* Adding a watcher for the Apps coming up */
watcher = custom_service_watcher_new(appstore);
+ /* Building and executing our main loop */
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);
+ /* Unref'ing all the objects */
+ g_object_unref(G_OBJECT(watcher));
+ g_object_unref(G_OBJECT(appstore));
+ g_object_unref(G_OBJECT(service));
+
return 0;
}