aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-01-15 23:01:16 -0600
committerTed Gould <ted@canonical.com>2009-01-15 23:01:16 -0600
commit0d1e01e34d94b47b8785cac9138f529c1fcc55b9 (patch)
treead05f61a87b514a6b5bf626a81544aeca79d0b4d
parent2722037935bb34848b71128776b997c6c158ff8e (diff)
downloadlibayatana-indicator-0d1e01e34d94b47b8785cac9138f529c1fcc55b9.tar.gz
libayatana-indicator-0d1e01e34d94b47b8785cac9138f529c1fcc55b9.tar.bz2
libayatana-indicator-0d1e01e34d94b47b8785cac9138f529c1fcc55b9.zip
Getting the signals in shape
-rw-r--r--libindicate/listener-marshal.list4
-rw-r--r--libindicate/listener.c44
-rw-r--r--libindicate/listener.h14
3 files changed, 40 insertions, 22 deletions
diff --git a/libindicate/listener-marshal.list b/libindicate/listener-marshal.list
index c02c70f..562d06f 100644
--- a/libindicate/listener-marshal.list
+++ b/libindicate/listener-marshal.list
@@ -1,2 +1,6 @@
# IndicatorAdded, IndicatorRemoved, IndicatorModified
VOID:UINT,STRING
+# Local indicator_added, indicator_removed
+VOID:POINTER,POINTER,STRING
+# Local indicator_modified
+VOID:POINTER,POINTER,STRING,STRING
diff --git a/libindicate/listener.c b/libindicate/listener.c
index 70ba8f4..75c7649 100644
--- a/libindicate/listener.c
+++ b/libindicate/listener.c
@@ -59,29 +59,41 @@ indicate_listener_class_init (IndicateListenerClass * class)
gobj->finalize = indicate_listener_finalize;
-/* TODO, I need new marshallers here, bah humbug
signals[INDICATOR_ADDED] = g_signal_new("indicator-added",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicateListenerClass, indicator_added),
NULL, NULL,
- g_cclosure_marshal_VOID__POINTER_POINTER_POINTER,
- G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_OBJECT, G_TYPE_STRING);
+ indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
+ G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
signals[INDICATOR_REMOVED] = g_signal_new("indicator-removed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, indicator_removed),
+ G_STRUCT_OFFSET (IndicateListenerClass, indicator_removed),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT_POINTER,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ indicate_listener_marshal_VOID__POINTER_POINTER_STRING,
+ G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING);
signals[INDICATOR_MODIFIED] = g_signal_new("indicator-modified",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IndicateServerClass, indicator_modified),
+ G_STRUCT_OFFSET (IndicateListenerClass, indicator_modified),
NULL, NULL,
- g_cclosure_marshal_VOID__UINT_POINTER,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
-*/
+ indicate_listener_marshal_VOID__POINTER_POINTER_STRING_STRING,
+ G_TYPE_NONE, 4, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_STRING);
+ signals[SERVER_ADDED] = g_signal_new("server-added",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateListenerClass, server_added),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[SERVER_REMOVED] = g_signal_new("server-removed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IndicateListenerClass, server_removed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
dbus_g_object_register_marshaller(indicate_listener_marshal_VOID__UINT_STRING,
G_TYPE_NONE,
@@ -376,7 +388,7 @@ proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t
dbus_g_proxy_connect_signal(proxyt->proxy, "IndicatorModified",
G_CALLBACK(proxy_indicator_modified), proxyt, NULL);
- /* TODO: Send signal */
+ g_signal_emit(proxyt->listener, signals[SERVER_ADDED], 0, proxyt->name, TRUE);
}
GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
@@ -387,8 +399,8 @@ proxy_indicator_added (DBusGProxy * proxy, guint id, const gchar * type, proxy_t
}
if (g_hash_table_lookup(indicators, (gpointer)id)) {
- g_hash_table_insert(indicators, (gpointer)id, TRUE);
- /* TODO: Send signal */
+ g_hash_table_insert(indicators, (gpointer)id, (gpointer)TRUE);
+ g_signal_emit(proxyt->listener, signals[INDICATOR_ADDED], 0, proxyt->name, id, type, TRUE);
}
return;
@@ -414,8 +426,7 @@ proxy_indicator_removed (DBusGProxy * proxy, guint id, const gchar * type, proxy
}
g_hash_table_remove(indicators, (gpointer)id);
-
- /* TODO: Signal here */
+ g_signal_emit(proxyt->listener, signals[INDICATOR_REMOVED], 0, proxyt->name, id, type, TRUE);
return;
}
@@ -428,6 +439,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * type, prox
return;
}
+ // TODO: Search for the ID to discover the type
GHashTable * indicators = g_hash_table_lookup(proxyt->indicators, type);
if (indicators == NULL) {
g_warning("Can not modify indicator %d of type '%s' as there are no indicators of that type on %s.", id, type, proxyt->name);
@@ -439,7 +451,7 @@ proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * type, prox
return;
}
- /* TODO: Signal here */
+ g_signal_emit(proxyt->listener, signals[INDICATOR_MODIFIED], 0, proxyt->name, id, type, type, TRUE);
return;
}
diff --git a/libindicate/listener.h b/libindicate/listener.h
index 5c482ba..c40bc07 100644
--- a/libindicate/listener.h
+++ b/libindicate/listener.h
@@ -20,6 +20,9 @@ G_BEGIN_DECLS
#define INDICATE_IS_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), INDICATE_TYPE_LISTENER))
#define INDICATE_LISTENER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), INDICATE_TYPE_LISTENER, IndicateListenerClass))
+typedef gchar IndicateListenerServer;
+typedef guint IndicateListenerIndicator;
+
typedef struct _IndicateListener IndicateListener;
struct _IndicateListener {
GObject parent;
@@ -42,13 +45,12 @@ struct _IndicateListenerClass {
GObjectClass parent;
/* Signals */
- void (* indicator_added) (IndicateServer * server, IndicateIndicator * indicator, gchar * type);
- void (* indicator_removed) (IndicateServer * server, IndicateIndicator * indicator, gchar * type);
- void (* indicator_modified) (IndicateServer * server, IndicateIndicator * indicator, gchar * property);
-
- void (* server_added) (IndicateServer * server);
- void (* server_removed) (IndicateServer * server);
+ void (* indicator_added) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);
+ void (* indicator_removed) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type);
+ void (* indicator_modified) (IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gchar * property);
+ void (* server_added) (IndicateListenerServer * server);
+ void (* server_removed) (IndicateListenerServer * server);
};
GType indicate_listener_get_type (void) G_GNUC_CONST;