aboutsummaryrefslogtreecommitdiff
path: root/libindicate
diff options
context:
space:
mode:
Diffstat (limited to 'libindicate')
-rw-r--r--libindicate/listener.c18
-rw-r--r--libindicate/listener.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/libindicate/listener.c b/libindicate/listener.c
index efd69fc..5ac03b9 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -243,11 +243,29 @@ indicate_listener_finalize (GObject * obj)
IndicateListener *
indicate_listener_new (void)
{
+ g_warning("Creating a new listener is general discouraged, please use indicate_listener_ref_default");
+
IndicateListener * listener;
listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
return listener;
}
+static IndicateListener * default_indicate_listener = NULL;
+
+IndicateListener *
+indicate_listener_ref_default (void)
+{
+ if (default_indicate_listener != NULL) {
+ g_object_ref(default_indicate_listener);
+ } else {
+ default_indicate_listener = g_object_new(INDICATE_TYPE_LISTENER, NULL);
+ g_object_add_weak_pointer(G_OBJECT(default_indicate_listener),
+ (gpointer *)&default_indicate_listener);
+ }
+
+ return default_indicate_listener;
+}
+
static void
dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, IndicateListener * listener)
{
diff --git a/libindicate/listener.h b/libindicate/listener.h
index 9ecdfc6..3d8c7ef 100644
--- a/libindicate/listener.h
+++ b/libindicate/listener.h
@@ -83,6 +83,7 @@ typedef void (*indicate_listener_get_server_property_cb) (IndicateListener * lis
/* Create a new listener */
IndicateListener * indicate_listener_new (void);
+IndicateListener * indicate_listener_ref_default (void);
void indicate_listener_get_property (IndicateListener * listener,
IndicateListenerServer * server,
IndicateListenerIndicator * indicator,