aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-07-02 09:11:23 -0500
committerTed Gould <ted@gould.cx>2011-07-02 09:11:23 -0500
commit8ae2a2a48815b9fe84e779dad8c581b222ee70e7 (patch)
treec8b39244c87e4c0374ccaa3e541ab8642d63219a
parent22abed03db8cb4d3e8b860075cc832bd964ca543 (diff)
downloadayatana-indicator-messages-8ae2a2a48815b9fe84e779dad8c581b222ee70e7.tar.gz
ayatana-indicator-messages-8ae2a2a48815b9fe84e779dad8c581b222ee70e7.tar.bz2
ayatana-indicator-messages-8ae2a2a48815b9fe84e779dad8c581b222ee70e7.zip
Connecting a callback and cleaning up
-rw-r--r--src/messages-service.c9
-rw-r--r--src/status-items.c16
-rw-r--r--src/status-items.h5
3 files changed, 27 insertions, 3 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index 0db4a7e..4ccd0f1 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -1433,6 +1433,12 @@ service_shutdown (IndicatorService * service, gpointer user_data)
return;
}
+static void
+status_update_callback (void)
+{
+ return;
+}
+
/* Oh, if you don't know what main() is for
we really shouldn't be talking. */
int
@@ -1462,7 +1468,7 @@ main (int argc, char ** argv)
DbusmenuServer * server = dbusmenu_server_new(INDICATOR_MESSAGES_DBUS_OBJECT);
dbusmenu_server_set_root(server, root_menuitem);
- status_items_build();
+ status_items_build(&status_update_callback);
/* Start up the libindicate listener */
listener = indicate_listener_ref_default();
@@ -1486,6 +1492,7 @@ main (int argc, char ** argv)
g_main_loop_run(mainloop);
/* Clean up */
+ status_items_cleanup();
g_free(userdir);
return 0;
diff --git a/src/status-items.c b/src/status-items.c
index e210c01..4f83c23 100644
--- a/src/status-items.c
+++ b/src/status-items.c
@@ -55,7 +55,7 @@ GList * status_providers = NULL;
/* Build the inital status items and start kicking off the async code
for handling all the statuses */
GList *
-status_items_build (void)
+status_items_build (StatusUpdateFunc status_update_func)
{
int i;
for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_DISCONNECTED; i++) {
@@ -78,6 +78,20 @@ status_items_build (void)
return menuitems;
}
+/* Clean up our globals and stop with all this allocation
+ of memory */
+void
+status_items_cleanup (void)
+{
+ while (status_providers != NULL) {
+ StatusProvider * sprovider = STATUS_PROVIDER(status_providers->data);
+ g_object_unref(sprovider);
+ status_providers = g_list_remove(status_providers, sprovider);
+ }
+
+ return;
+}
+
/* Get the icon that should be shown on the panel */
const gchar *
status_current_panel_icon (gboolean alert)
diff --git a/src/status-items.h b/src/status-items.h
index 686d03c..f685a0e 100644
--- a/src/status-items.h
+++ b/src/status-items.h
@@ -6,8 +6,11 @@
G_BEGIN_DECLS
-GList * status_items_build (void);
+typedef void (*StatusUpdateFunc) (void);
+
+GList * status_items_build (StatusUpdateFunc update_func);
const gchar * status_current_panel_icon (gboolean alert);
+void status_items_cleanup (void);
G_END_DECLS