From 22481b092787e357f3c70b086e36c9028359d3ad Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:27:40 -0600 Subject: Switching the pkgconfig files that are used. --- configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 8f533db..6b757be 100644 --- a/configure.ac +++ b/configure.ac @@ -38,15 +38,15 @@ AS_IF([test "x$enable_deprecations" = xno], GTK_REQUIRED_VERSION=2.12 GIO_UNIX_REQUIRED_VERSION=2.18 PANEL_REQUIRED_VERSION=2.0.0 -INDICATE_REQUIRED_VERSION=0.3.0 +INDICATE_REQUIRED_VERSION=0.4.90 INDICATOR_REQUIRED_VERSION=0.3.5 -DBUSMENUGTK_REQUIRED_VERSION=0.2.8 +DBUSMENUGTK_REQUIRED_VERSION=0.3.90 PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION indicator >= $INDICATOR_REQUIRED_VERSION - indicate >= $INDICATE_REQUIRED_VERSION - dbusmenu-gtk >= $DBUSMENUGTK_REQUIRED_VERSION) + indicate-0.5 >= $INDICATE_REQUIRED_VERSION + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) -- cgit v1.2.3 From 05083ac8dd47fdf45fc0823b9410ac5a58724578 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:33:06 -0600 Subject: Switching over from using dbus-binding-tool to sed --- src/Makefile.am | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7c9842a..dd09b8a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,8 @@ messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la libmessaging_la_SOURCES = \ indicator-messages.c \ - messages-service-client.h \ + gen-messages-service.xml.h \ + gen-messages-service.xml.c \ dbus-data.h libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) @@ -23,9 +24,10 @@ indicator_messages_service_SOURCES = \ default-applications.h \ default-applications.c \ messages-service.c \ - messages-service-server.h \ messages-service-dbus.c \ messages-service-dbus.h \ + gen-messages-service.xml.h \ + gen-messages-service.xml.c \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ @@ -39,23 +41,19 @@ indicator_messages_service_SOURCES = \ indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror indicator_messages_service_LDADD = $(APPLET_LIBS) -messages-service-client.h: $(srcdir)/messages-service.xml - dbus-binding-tool \ - --prefix=_messages_service_client \ - --mode=glib-client \ - --output=messages-service-client.h \ - $(srcdir)/messages-service.xml +gen-%.xml.h: %.xml + @echo "Building $@ from $<" + @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@ -messages-service-server.h: $(srcdir)/messages-service.xml - dbus-binding-tool \ - --prefix=_messages_service_server \ - --mode=glib-server \ - --output=messages-service-server.h \ - $(srcdir)/messages-service.xml +gen-%.xml.c: %.xml + @echo "Building $@ from $<" + echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@ + @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@ + @echo ";" >> $@ BUILT_SOURCES = \ - messages-service-client.h \ - messages-service-server.h + gen-messages-service.xml.h \ + gen-messages-service.xml.c CLEANFILES = \ $(BUILT_SOURCES) -- cgit v1.2.3 From 4729b567a36fd08308e06b10dfd1c0285f95522b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:44:57 -0600 Subject: Changing to get the interface from the included XML file --- src/indicator-messages.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index b57244c..7608678 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -26,8 +26,6 @@ with this program. If not, see . #include #include #include -#include -#include #include #include @@ -35,7 +33,7 @@ with this program. If not, see . #include #include "dbus-data.h" -#include "messages-service-client.h" +#include "gen-messages-service.xml.h" #define INDICATOR_MESSAGES_TYPE (indicator_messages_get_type ()) #define INDICATOR_MESSAGES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessages)) @@ -69,8 +67,10 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; -static DBusGProxy * icon_proxy = NULL; +static GDBusProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; +static GDBusNodeInfo * bus_node_info = NULL; +static GDBusInterfaceInfo * bus_interface_info = NULL; /* Prototypes */ static void indicator_messages_class_init (IndicatorMessagesClass *klass); @@ -99,6 +99,24 @@ indicator_messages_class_init (IndicatorMessagesClass *klass) io_class->get_image = get_icon; io_class->get_menu = get_menu; + if (bus_node_info == NULL) { + GError * error = NULL; + + bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error); + if (error != NULL) { + g_error("Unable to parse Messaging Menu Interface description: %s", error->message); + g_error_free(error); + } + } + + if (bus_interface_info == NULL) { + bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); + + if (bus_interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'"); + } + } + return; } -- cgit v1.2.3 From 4792855a9b4d615993df48f7e4595f9ca2baf582 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:54:55 -0600 Subject: Changing the creation of the proxy --- src/indicator-messages.c | 94 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 7608678..638b484 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -227,6 +227,43 @@ connection_drop_cb (gpointer user_data) return FALSE; } +/* Proxy is setup now.. whoo! */ +static void +proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (error != NULL) { + g_warning("Unable to get proxy of service: %s", error->message); + g_error_free(error); + return; + } + + icon_proxy = proxy; + + g_signal_connect(G_OBJECT(proxy), "g-signal", G_CALLBACK(proxy_signal), user_data); + + g_dbus_proxy_call(icon_proxy, + "AttentionRequested", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + attention_cb, + sm); + g_dbus_proxy_call(icon_proxy, + "IconShown", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + icon_cb, + sm); + + return; +} + /* Sets up all the icon information in the proxy. */ static void connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data) @@ -243,40 +280,35 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us return; } - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - if (connection == NULL) { - g_warning("Unable to get session bus"); - return; - } - if (icon_proxy == NULL) { - icon_proxy = dbus_g_proxy_new_for_name(connection, - INDICATOR_MESSAGES_DBUS_NAME, - INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, - INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); - if (icon_proxy == NULL) { - g_warning("Unable to get messages service interface."); - return; - } - - dbus_g_proxy_add_signal(icon_proxy, "AttentionChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(icon_proxy, - "AttentionChanged", - G_CALLBACK(attention_changed_cb), - NULL, - NULL); - - dbus_g_proxy_add_signal(icon_proxy, "IconChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(icon_proxy, - "IconChanged", - G_CALLBACK(icon_changed_cb), - NULL, - NULL); + g_dbus_proxy_new_for_bus(G_BUS_SESSION, + G_DBUS_PROXY_FLAGS_NONE, + bus_interface_info, + INDICATOR_MESSAGES_DBUS_NAME, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + NULL, /* cancel */ + proxy_ready_cb, + sm); + } else { + g_dbus_proxy_call(icon_proxy, + "AttentionRequested", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + attention_cb, + sm); + g_dbus_proxy_call(icon_proxy, + "IconShown", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + icon_cb, + sm); } - org_ayatana_indicator_messages_service_attention_requested_async(icon_proxy, attention_cb, NULL); - org_ayatana_indicator_messages_service_icon_shown_async(icon_proxy, icon_cb, NULL); - return; } -- cgit v1.2.3 From e8ae85455165c6ab3040c53fa66652f78cb86bbb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 12:59:30 -0600 Subject: Changing the signal callbacks --- src/indicator-messages.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 638b484..6604100 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -163,27 +163,28 @@ indicator_messages_finalize (GObject *object) /* Functions */ -/* Called everytime the attention changes in the service. */ +/* Signal off of the proxy */ static void -attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) +proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GVariant * params, gpointer user_data) { - if (dot) { - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); - } else { - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - } - return; -} + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(params, 0)); -/* Change the icon to whether it should be visible or not */ -static void -icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) -{ - if (hidden) { - gtk_widget_hide(main_image); + if (g_strcmp0("AttentionChanged", signal) == 0) { + if (prop) { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + } else { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + } + } else if (g_strcmp0("IconChanged", signal) == 0) { + if (prop) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } } else { - gtk_widget_show(main_image); + g_warning("Unknown signal %s", signal); } + return; } -- cgit v1.2.3 From b141e4fe3dc5c1c86180a7f1a9b18d39ec44bc22 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:05:27 -0600 Subject: Switching the function callbacks --- src/indicator-messages.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 6604100..cb435c4 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -190,28 +190,50 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV /* Callback from getting the attention status from the service. */ static void -attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) +attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) { + GError * error = NULL; + GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error); + if (error != NULL) { g_warning("Unable to get attention status: %s", error->message); g_error_free(error); return; } - return attention_changed_cb(proxy, dot, userdata); + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0)); + + if (prop) { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); + } else { + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + } + + return; } /* Change from getting the icon visibility from the service */ static void -icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) +icon_cb (GObject * object, GAsyncResult * ares, gpointer user_data) { + GError * error = NULL; + GVariant * res = g_dbus_proxy_call_finish(G_DBUS_PROXY(object), ares, &error); + if (error != NULL) { g_warning("Unable to get icon visibility: %s", error->message); g_error_free(error); return; } - return icon_changed_cb(proxy, hidden, userdata); + gboolean prop = g_variant_get_boolean(g_variant_get_child_value(res, 0)); + + if (prop) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } + + return; } static guint connection_drop_timeout = 0; @@ -252,7 +274,7 @@ proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) -1, /* timeout */ NULL, /* cancel */ attention_cb, - sm); + user_data); g_dbus_proxy_call(icon_proxy, "IconShown", NULL, /* params */ @@ -260,7 +282,7 @@ proxy_ready_cb (GObject * obj, GAsyncResult * res, gpointer user_data) -1, /* timeout */ NULL, /* cancel */ icon_cb, - sm); + user_data); return; } -- cgit v1.2.3 From 5f18bbc4b0789b75868e07627da88dcafb478bab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:07:27 -0600 Subject: Type to session --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index cb435c4..1c2cfeb 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -304,7 +304,7 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us } if (icon_proxy == NULL) { - g_dbus_proxy_new_for_bus(G_BUS_SESSION, + g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, bus_interface_info, INDICATOR_MESSAGES_DBUS_NAME, -- cgit v1.2.3 From c53751d07949b38ad75e794a43a6272634507ee1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:10:10 -0600 Subject: Switch to new dbusmenu signal prototype --- src/indicator-messages.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 1c2cfeb..6fd6c5c 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -337,12 +337,12 @@ connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer us /* Sets the icon when it changes. */ static void -application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, gpointer user_data) { if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_ICON)) { /* Set the main icon */ if (GTK_IS_IMAGE(user_data)) { - gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_value_get_string(value), GTK_ICON_SIZE_MENU); + gtk_image_set_from_icon_name(GTK_IMAGE(user_data), g_variant_get_string(value, NULL), GTK_ICON_SIZE_MENU); } } @@ -351,12 +351,12 @@ application_icon_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, /* Sets the label when it changes. */ static void -application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, gpointer user_data) +application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, gpointer user_data) { if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_NAME)) { /* Set the main label */ if (GTK_IS_LABEL(user_data)) { - gtk_label_set_text(GTK_LABEL(user_data), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(user_data), g_variant_get_string(value, NULL)); } } @@ -545,14 +545,14 @@ struct _indicator_item_t { /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void -indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, indicator_item_t * mi_data) +indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant * value, indicator_item_t * mi_data) { if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_LABEL)) { /* Set the main label */ - gtk_label_set_text(GTK_LABEL(mi_data->label), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(mi_data->label), g_variant_get_string(value, NULL)); } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_RIGHT)) { /* Set the right label */ - gtk_label_set_text(GTK_LABEL(mi_data->right), g_value_get_string(value)); + gtk_label_set_text(GTK_LABEL(mi_data->right), g_variant_get_string(value, NULL)); } else if (!g_strcmp0(prop, INDICATOR_MENUITEM_PROP_ICON)) { /* We don't use the value here, which is probably less efficient, but it's easier to use the easy function. And since th value -- cgit v1.2.3 From 26ceab5a8b4e80711f5cd7ed0bda4a28f3113429 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:13:43 -0600 Subject: Switching how we get our interface info --- src/messages-service-dbus.c | 24 +++++++++++++++++++++--- src/messages-service.c | 1 - 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index d9c0e8d..6ed6678 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -24,9 +24,10 @@ with this program. If not, see . #include "config.h" #endif -#include +#include #include "messages-service-dbus.h" #include "dbus-data.h" +#include "gen-messages-service.xml.h" enum { ATTENTION_CHANGED, @@ -56,10 +57,12 @@ static void _messages_service_server_watch (void); static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error); static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error); -#include "messages-service-server.h" +static GDBusNodeInfo * bus_node_info = NULL; +static GDBusInterfaceInfo * bus_interface_info = NULL; G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); + static void message_service_dbus_class_init (MessageServiceDbusClass *klass) { @@ -86,8 +89,23 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + if (bus_node_info == NULL) { + GError * error = NULL; + + bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error); + if (error != NULL) { + g_error("Unable to parse Messaging Menu Interface description: %s", error->message); + g_error_free(error); + } + } - dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); + if (bus_interface_info == NULL) { + bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE); + + if (bus_interface_info == NULL) { + g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'"); + } + } return; } diff --git a/src/messages-service.c b/src/messages-service.c index b87c2ff..e3352e8 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -25,7 +25,6 @@ with this program. If not, see . #include #include #include -#include #include #include #include -- cgit v1.2.3 From 490cde29b6d70c7abad6b6ff90609e64fd2af409 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:20:33 -0600 Subject: Get the connection in the cool new style --- src/messages-service-dbus.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 6ed6678..aeda625 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -110,13 +110,41 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) return; } +static void +connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) +{ + GError * error = NULL; + GDBusConnection * connection = g_bus_get_finish(res, &error); + + if (error != NULL) { + g_error("Unable to connect to the session bus: %s", error->message); + g_error_free(error); + return; + } + + g_dbus_connection_register_object(connection, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + bus_interface_info, + bus_vtable, + user_data, + NULL, /* destroy */ + &error); + + if (error != NULL) { + g_error("Unable to register on session bus: %s", error->message); + g_error_free(error); + return; + } + + g_debug("Service on session bus"); + + return; +} + static void message_service_dbus_init (MessageServiceDbus *self) { - DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); - dbus_g_connection_register_g_object(connection, - INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, - G_OBJECT(self)); + g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self); MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); -- cgit v1.2.3 From 39268f3a9830cb76aaf644d540dfe771fde4eebf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:23:07 -0600 Subject: Setting up the vtable and making it connect in --- src/messages-service-dbus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index aeda625..e333772 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -52,6 +52,14 @@ static void message_service_dbus_class_init (MessageServiceDbusClass *klass); static void message_service_dbus_init (MessageServiceDbus *self); static void message_service_dbus_dispose (GObject *object); static void message_service_dbus_finalize (GObject *object); +static void bus_method_call (GDBusConnection * connection, + const gchar * sender, + const gchar * path, + const gchar * interface, + const gchar * method, + GVariant * params, + GDBusMethodInvocation * invocation, + gpointer user_data); static void _messages_service_server_watch (void); static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error); @@ -59,6 +67,11 @@ static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; +static const GDBusInterfaceVTable bus_interface_table = { + method_call: bus_method_call, + get_property: NULL, /* No properties */ + set_property: NULL /* No properties */ +}; G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); @@ -125,7 +138,7 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_dbus_connection_register_object(connection, INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, bus_interface_info, - bus_vtable, + &bus_interface_table, user_data, NULL, /* destroy */ &error); -- cgit v1.2.3 From 05e767ce2daf9cca389f482b4c8ad72c375944f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:26:40 -0600 Subject: Swiching to our method function.. woot! --- src/messages-service-dbus.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index e333772..1a9564b 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -61,10 +61,6 @@ static void bus_method_call (GDBusConnection * connection, GDBusMethodInvocation * invocation, gpointer user_data); -static void _messages_service_server_watch (void); -static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error); -static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error); - static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; static const GDBusInterfaceVTable bus_interface_table = { @@ -191,31 +187,23 @@ message_service_dbus_new (void) return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL)); } -/* DBus function to say that someone is watching */ +/* Method request off of DBus */ static void -_messages_service_server_watch (void) +bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); -} - -/* DBus interface to request the private variable to know - whether there is a green dot. */ -static gboolean -_messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error) -{ - MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); - *dot = priv->dot; - return TRUE; -} + if (g_strcmp0("AttentionRequested", method) == 0) { + g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->dot)); + return; + } else if (g_strcmp0("IconShown", method) == 0) { + g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->hidden)); + return; + } else { + g_warning("Unknown function call '%s'", method); + } -/* DBus interface to request the private variable to know - whether the icon is hidden. */ -static gboolean -_messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error) -{ - MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); - *hidden = priv->hidden; - return TRUE; + return; } void -- cgit v1.2.3 From 4ef2895a07690c2c4ffaa07ac426f85ef702584d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:29:07 -0600 Subject: Saving the connection --- src/messages-service-dbus.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 1a9564b..44b35aa 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -41,6 +41,7 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate { + GDBusConnection * connection; gboolean dot; gboolean hidden; }; @@ -131,6 +132,9 @@ connection_cb (GObject * object, GAsyncResult * res, gpointer user_data) return; } + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + priv->connection = connection; + g_dbus_connection_register_object(connection, INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, bus_interface_info, @@ -166,7 +170,12 @@ message_service_dbus_init (MessageServiceDbus *self) static void message_service_dbus_dispose (GObject *object) { + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(object); + if (priv->connection != NULL) { + g_object_unref(priv->connection); + priv->connection = NULL; + } G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object); return; -- cgit v1.2.3 From e7dd62a02e53fb7b36758c67b060f42a28c4efc6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:32:24 -0600 Subject: Emitting signals for the connections --- src/messages-service-dbus.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 44b35aa..6cc33e0 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -223,6 +223,16 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio if (attention != priv->dot) { priv->dot = attention; g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE); + + if (priv->connection != NULL) { + g_dbus_connection_emit_signal(priv->connection, + NULL, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + "AttentionChanged", + g_variant_new("(b)", priv->dot), + NULL); + } } return; } @@ -235,6 +245,16 @@ message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) if (hidden != priv->hidden) { priv->hidden = hidden; g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE); + + if (priv->connection != NULL) { + g_dbus_connection_emit_signal(priv->connection, + NULL, + INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT, + INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE, + "IconChanged", + g_variant_new("(b)", priv->hidden), + NULL); + } } return; } -- cgit v1.2.3 From e7586d7f8bc699076912a67b194adca8a76b8066 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 14 Jan 2011 13:35:21 -0600 Subject: Prototype changes --- src/app-menu-item.c | 8 ++++---- src/im-menu-item.c | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 0b0588e..e846914 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -70,8 +70,8 @@ static void app_menu_item_finalize (GObject *object); static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data); static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data); static void count_cb (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data); -static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data); -static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); +static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data); +static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data); static void update_label (AppMenuItem * self); /* GObject Boilerplate */ @@ -300,7 +300,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, guint va app structure and start sucking data out of it. Mostly the name. */ static void -desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) +desktop_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * value, gpointer data) { g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); @@ -469,7 +469,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data /* Gets the path to menuitems if there are some. Now we need to make them special. */ static void -menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) +menu_cb (IndicateListener * listener, IndicateListenerServer * server, const gchar * menupath, gpointer data) { g_debug("Got Menu: %s", menupath); g_return_if_fail(IS_APP_MENU_ITEM(data)); diff --git a/src/im-menu-item.c b/src/im-menu-item.c index b8b3709..25fea52 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -358,7 +358,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate this indicator should be calling for attention or not. If we are, we need to signal that. */ static void -attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, const GValue * propertydata, gpointer data) +attention_cb (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * property, GVariant * propertydata, gpointer data) { g_debug("Got Attention Information"); ImMenuItem * self = IM_MENU_ITEM(data); @@ -373,10 +373,10 @@ attention_cb (IndicateListener * listener, IndicateListenerServer * server, Indi ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(self); gboolean wantit; - if (G_VALUE_HOLDS_BOOLEAN(propertydata)) { - wantit = g_value_get_boolean(propertydata); - } else if (G_VALUE_HOLDS_STRING(propertydata)) { - const gchar * propstring = g_value_get_string(propertydata); + if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_BOOLEAN)) { + wantit = g_variant_get_boolean(propertydata); + } else if (g_variant_is_of_type(propertydata, G_VARIANT_TYPE_STRING)) { + const gchar * propstring = g_variant_get_string(propertydata, NULL); if (propstring == NULL || propstring[0] == '\0' || !g_strcmp0(propstring, "false")) { wantit = FALSE; @@ -427,7 +427,7 @@ indicator_modified_cb (IndicateListener * listener, IndicateListenerServer * ser } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_COUNT)) { indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self); } else if (!g_strcmp0(property, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION)) { - indicate_listener_get_property_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); + indicate_listener_get_property_variant(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); } else if (!g_strcmp0(property, "sender")) { /* This is a compatibility string with v1 and should be removed */ g_debug("Indicator is using 'sender' property which is a v1 string."); @@ -460,7 +460,7 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, indicate_listener_get_property_time(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_TIME, time_cb, self); indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ICON, icon_cb, self); indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_COUNT, count_cb, self); - indicate_listener_get_property_value(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); + indicate_listener_get_property_variant(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION, attention_cb, self); indicate_listener_get_property(listener, server, indicator, "sender", sender_cb, self); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3