From 7258fe52ed30b06de812773f123fedabb90efe89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 21:39:54 -0500 Subject: Switching to ayatana.org and adding a new name for the service as a whole. --- src/dbus-data.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dbus-data.h b/src/dbus-data.h index 4aeedf0..e7d4d26 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -2,7 +2,10 @@ #ifndef __DBUS_DATA_H__ #define __DBUS_DATA_H__ 1 -#define INDICATOR_MESSAGES_DBUS_NAME "com.ubuntu.indicator.messages" -#define INDICATOR_MESSAGES_DBUS_OBJECT "/com/ubuntu/indicator/messages" +#define INDICATOR_MESSAGES_DBUS_NAME "org.ayatana.indicator.messages" +#define INDICATOR_MESSAGES_DBUS_OBJECT "/org/ayatana/indicator/messages/menu" + +#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service" +#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" #endif /* __DBUS_DATA_H__ */ -- cgit v1.2.3 From 8601a2b19bdb2352b1830888f982978a447dbeec Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 21:40:35 -0500 Subject: Adding in a new dbus interface. --- .bzrignore | 2 ++ src/Makefile.am | 29 ++++++++++++++++++++++++++++- src/messages-service.xml | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/messages-service.xml diff --git a/.bzrignore b/.bzrignore index 42bdaa3..1d6767c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -19,3 +19,5 @@ src/libmessaging_la-app-menu-item.lo data/indicator-messages.service indicator-messages-service indicator-messages-service-activate +src/messages-service-client.h +src/messages-service-server.h diff --git a/src/Makefile.am b/src/Makefile.am index 0678537..243247e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,8 @@ bin_PROGRAMS = indicator-messages-service messaginglibdir = $(INDICATORDIR) messaginglib_LTLIBRARIES = libmessaging.la libmessaging_la_SOURCES = \ - indicator-messages.c\ + indicator-messages.c \ + messages-service-client.h \ dbus-data.h libmessaging_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror libmessaging_la_LIBADD = $(APPLET_LIBS) @@ -20,6 +21,7 @@ libmessaging_la_LDFLAGS = -module -avoid-version indicator_messages_service_SOURCES = \ messages-service.c \ + messages-service-server.h \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ @@ -30,3 +32,28 @@ indicator_messages_service_SOURCES = \ dbus-data.h 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 + +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 + +BUILT_SOURCES = \ + messages-service-client.h \ + messages-service-server.h + +CLEANFILES = \ + $(BUILT_SOURCES) + +EXTRA_DIST = \ + messages-service.xml + diff --git a/src/messages-service.xml b/src/messages-service.xml new file mode 100644 index 0000000..f991179 --- /dev/null +++ b/src/messages-service.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From e7695d9f9da90e12aaefe490e46e18d3b32f33dd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:08:41 -0500 Subject: Building an object to represent the service over DBus. --- src/Makefile.am | 2 ++ src/messages-service-dbus.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ src/messages-service-dbus.h | 37 ++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 src/messages-service-dbus.c create mode 100644 src/messages-service-dbus.h diff --git a/src/Makefile.am b/src/Makefile.am index 243247e..38787a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,6 +22,8 @@ libmessaging_la_LDFLAGS = -module -avoid-version indicator_messages_service_SOURCES = \ messages-service.c \ messages-service-server.h \ + messages-service-dbus.c \ + messages-service-dbus.h \ im-menu-item.c \ im-menu-item.h \ app-menu-item.c \ diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c new file mode 100644 index 0000000..6fa2125 --- /dev/null +++ b/src/messages-service-dbus.c @@ -0,0 +1,84 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "messages-service-dbus.h" + +typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; + +struct _MessageServiceDbusPrivate +{ + guint temp; +}; + +#define MESSAGE_SERVICE_DBUS_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusPrivate)) + +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 _messages_service_server_watch (void); +static void _messages_service_server_attention_requested (void); +static void _messages_service_server_icon_shown (void); + +#include "messages-service-server.h" + +G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT); + +static void +message_service_dbus_class_init (MessageServiceDbusClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (MessageServiceDbusPrivate)); + + object_class->dispose = message_service_dbus_dispose; + object_class->finalize = message_service_dbus_finalize; + + return; +} + +static void +message_service_dbus_init (MessageServiceDbus *self) +{ + return; +} + +static void +message_service_dbus_dispose (GObject *object) +{ + + + G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object); + return; +} + +static void +message_service_dbus_finalize (GObject *object) +{ + + + G_OBJECT_CLASS (message_service_dbus_parent_class)->finalize (object); + return; +} + +static void +_messages_service_server_watch (void) +{ + +} + +static void +_messages_service_server_attention_requested (void) +{ + +} + +static void +_messages_service_server_icon_shown (void) +{ + +} + diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h new file mode 100644 index 0000000..cde14b1 --- /dev/null +++ b/src/messages-service-dbus.h @@ -0,0 +1,37 @@ +#ifndef __MESSAGE_SERVICE_DBUS_H__ +#define __MESSAGE_SERVICE_DBUS_H__ + +#include +#include + +G_BEGIN_DECLS + +#define MESSAGE_SERVICE_DBUS_TYPE (message_service_dbus_get_type ()) +#define MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbus)) +#define MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass)) +#define IS_MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MESSAGE_SERVICE_DBUS_TYPE)) +#define IS_MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MESSAGE_SERVICE_DBUS_TYPE)) +#define MESSAGE_SERVICE_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass)) + +#define MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED "attention-changed" +#define MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED "icon-changed" + +typedef struct _MessageServiceDbus MessageServiceDbus; +typedef struct _MessageServiceDbusClass MessageServiceDbusClass; + +struct _MessageServiceDbusClass { + GObjectClass parent_class; + + void (*attention_changed) (gboolean dot); + void (*icon_changed) (gboolean hidden); +}; + +struct _MessageServiceDbus { + GObject parent; +}; + +GType message_service_dbus_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From 2b7746e2e74ffbafb7f1eb663a6a525dec9d28cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:23:15 -0500 Subject: Creating a real object and initing it. --- src/messages-service-dbus.c | 6 ++++++ src/messages-service-dbus.h | 3 +++ src/messages-service.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 6fa2125..ecc74e2 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -64,6 +64,12 @@ message_service_dbus_finalize (GObject *object) return; } +MessageServiceDbus * +message_service_dbus_new (void) +{ + return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL)); +} + static void _messages_service_server_watch (void) { diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index cde14b1..26035b7 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -31,6 +31,9 @@ struct _MessageServiceDbus { }; GType message_service_dbus_get_type (void); +MessageServiceDbus * message_service_dbus_new (void); +void message_service_dbus_set_attention (gboolean attention); +void message_service_dbus_set_icon (gboolean hidden); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index e4982a2..d23e9ee 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -33,6 +33,7 @@ with this program. If not, see . #include "launcher-menu-item.h" #include "dbus-data.h" #include "dirs.h" +#include "messages-service-dbus.h" static IndicateListener * listener; static GList * serverList = NULL; @@ -41,6 +42,8 @@ static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; +static MessageServiceDbus * dbus_interface = NULL; + static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); @@ -986,6 +989,8 @@ main (int argc, char ** argv) return 1; } + dbus_interface = message_service_dbus_new(); + listener = indicate_listener_ref_default(); serverList = NULL; -- cgit v1.2.3 From 96b2dc1cc2be79cdda2fb109eebe2f4bab6551d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 22:48:52 -0500 Subject: Bringing up the object and having some variables to access. --- src/messages-service-dbus.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index ecc74e2..5ce7695 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -2,13 +2,16 @@ #include "config.h" #endif +#include #include "messages-service-dbus.h" +#include "dbus-data.h" typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate { - guint temp; + gboolean dot; + gboolean hidden; }; #define MESSAGE_SERVICE_DBUS_GET_PRIVATE(o) \ @@ -20,8 +23,8 @@ static void message_service_dbus_dispose (GObject *object); static void message_service_dbus_finalize (GObject *object); static void _messages_service_server_watch (void); -static void _messages_service_server_attention_requested (void); -static void _messages_service_server_icon_shown (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" @@ -37,12 +40,24 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) object_class->dispose = message_service_dbus_dispose; object_class->finalize = message_service_dbus_finalize; + dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); + 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)); + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + + priv->dot = FALSE; + priv->hidden = FALSE; + return; } @@ -76,15 +91,19 @@ _messages_service_server_watch (void) } -static void -_messages_service_server_attention_requested (void) +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; } -static void -_messages_service_server_icon_shown (void) +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; } -- cgit v1.2.3 From 9efbade0a88f7ebce9ceb8d06293b1d636d02672 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:17:50 -0500 Subject: Some comments. --- src/messages-service-dbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 5ce7695..da91af5 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -85,12 +85,15 @@ 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 */ static void _messages_service_server_watch (void) { } +/* 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) { @@ -99,6 +102,8 @@ _messages_service_server_attention_requested (MessageServiceDbus * self, gboolea return TRUE; } +/* 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) { -- cgit v1.2.3 From 4b1b97c765557715451b16aa9c409e1539050b9f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:20:34 -0500 Subject: Adding the basic set functions into the C files. --- src/messages-service-dbus.c | 17 +++++++++++++++++ src/messages-service-dbus.h | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index da91af5..8d0d5e7 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -112,3 +112,20 @@ _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidde return TRUE; } +void +message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + /* Do signal */ + priv->dot = attention; + return; +} + +void +message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) +{ + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); + /* Do signal */ + priv->hidden = hidden; + return; +} diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index 26035b7..1075eb4 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -32,8 +32,8 @@ struct _MessageServiceDbus { GType message_service_dbus_get_type (void); MessageServiceDbus * message_service_dbus_new (void); -void message_service_dbus_set_attention (gboolean attention); -void message_service_dbus_set_icon (gboolean hidden); +void message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention); +void message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); G_END_DECLS -- cgit v1.2.3 From 964062bdeb9d3e9ca8db4bb0466440523c323f39 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:30:16 -0500 Subject: Making some signal lovin' --- src/messages-service-dbus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 8d0d5e7..38f2894 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -6,6 +6,14 @@ #include "messages-service-dbus.h" #include "dbus-data.h" +enum { + ATTENTION_CHANGED, + ICON_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; + typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate; struct _MessageServiceDbusPrivate @@ -40,6 +48,23 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass) object_class->dispose = message_service_dbus_dispose; object_class->finalize = message_service_dbus_finalize; + signals[ATTENTION_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MessageServiceDbusClass, attention_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + signals[ICON_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MessageServiceDbusClass, icon_changed), + NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); + + dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info); return; -- cgit v1.2.3 From 3e09c01a33e88d9789678adbdb57f1bfcbe44edd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:37:53 -0500 Subject: Okay, now we're signaling change. --- src/messages-service-dbus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 38f2894..108360b 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -142,7 +142,10 @@ message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ - priv->dot = attention; + if (attention != priv->dot) { + priv->dot = attention; + g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE); + } return; } @@ -151,6 +154,9 @@ message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ - priv->hidden = hidden; + if (hidden != priv->hidden) { + priv->hidden = hidden; + g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE); + } return; } -- cgit v1.2.3 From 03ca8ad97b53334826abc317472932289b17f69f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 09:48:45 -0500 Subject: Building a proxy... --- src/indicator-messages.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index efb52b2..a7628b0 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -32,11 +32,34 @@ INDICATOR_SET_NAME("messages") #include "dbus-data.h" -static GtkWidget * main_image; +static GtkWidget * main_image = NULL; #define DESIGN_TEAM_SIZE design_team_size static GtkIconSize design_team_size; +static DBusGProxy * icon_proxy = NULL; + +gboolean +setup_icon_proxy (gpointer userdata) +{ + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); + if (connection == NULL) { + g_warning("Unable to get session bus"); + return FALSE; /* TRUE? */ + } + + 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 FALSE; + } + + return FALSE; +} + GtkLabel * get_label (void) { @@ -51,8 +74,6 @@ get_icon (void) main_image = gtk_image_new_from_icon_name("indicator-messages", DESIGN_TEAM_SIZE); gtk_widget_show(main_image); - /* Need a proxy here to figure out when the icon changes */ - return GTK_IMAGE(main_image); } @@ -76,6 +97,8 @@ get_menu (void) return NULL; } + g_idle_add(setup_icon_proxy, NULL); + return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT)); } -- cgit v1.2.3 From 91fa6c67e8720123c2d81ac8aac0ef5aa4ac97e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:03:34 -0500 Subject: Setting up signals and callbacks, oh my! Watch for lions. --- src/indicator-messages.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a7628b0..87fd77e 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -31,6 +31,7 @@ INDICATOR_SET_VERSION INDICATOR_SET_NAME("messages") #include "dbus-data.h" +#include "messages-service-client.h" static GtkWidget * main_image = NULL; @@ -39,7 +40,43 @@ static GtkIconSize design_team_size; static DBusGProxy * icon_proxy = NULL; -gboolean +static void +attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) +{ + +} + +static void +icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) +{ + +} + +static void +watch_cb (DBusGProxy * proxy, GError * error, gpointer userdata) +{ + if (error != NULL) { + g_warning("Watch failed! %s", error->message); + g_error_free(error); + } + return; +} + +static void +attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) +{ + + return; +} + +static void +icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) +{ + + return; +} + +static gboolean setup_icon_proxy (gpointer userdata) { DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); @@ -56,6 +93,23 @@ setup_icon_proxy (gpointer userdata) g_warning("Unable to get messages service interface."); return FALSE; } + + org_ayatana_indicator_messages_service_watch_async(icon_proxy, watch_cb, NULL); + + dbus_g_proxy_connect_signal(icon_proxy, + "AttentionChanged", + G_CALLBACK(attention_changed_cb), + NULL, + NULL); + + dbus_g_proxy_connect_signal(icon_proxy, + "IconChanged", + G_CALLBACK(icon_changed_cb), + NULL, + NULL); + + 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 FALSE; } -- cgit v1.2.3 From 7c407863390dbe97bccad51a52baf3ffc65d213b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:13:08 -0500 Subject: Oh, wow, now there's some flesh on these. Let's hide and show icons. --- src/indicator-messages.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 87fd77e..ef77c28 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -43,13 +43,23 @@ static DBusGProxy * icon_proxy = NULL; static void attention_changed_cb (DBusGProxy * proxy, gboolean dot, gpointer userdata) { - + if (dot) { + gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); + } else { + gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); + } + return; } static void icon_changed_cb (DBusGProxy * proxy, gboolean hidden, gpointer userdata) { - + if (hidden) { + gtk_widget_hide(main_image); + } else { + gtk_widget_show(main_image); + } + return; } static void @@ -65,15 +75,25 @@ watch_cb (DBusGProxy * proxy, GError * error, gpointer userdata) static void attention_cb (DBusGProxy * proxy, gboolean dot, GError * error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get attention status: %s", error->message); + g_error_free(error); + return; + } - return; + return attention_changed_cb(proxy, dot, userdata); } static void icon_cb (DBusGProxy * proxy, gboolean hidden, GError * error, gpointer userdata) { + if (error != NULL) { + g_warning("Unable to get icon visibility: %s", error->message); + g_error_free(error); + return; + } - return; + return icon_changed_cb(proxy, hidden, userdata); } static gboolean -- cgit v1.2.3 From cffb400b0c368f4314f734596c144278dbb2ce53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:15:57 -0500 Subject: Legal crap. --- src/messages-service-dbus.c | 22 ++++++++++++++++++++++ src/messages-service-dbus.h | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 108360b..7b0a0ff 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -1,3 +1,25 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index 1075eb4..caf50db 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -1,3 +1,25 @@ +/* +An indicator to show information that is in messaging applications +that the user is using. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + #ifndef __MESSAGE_SERVICE_DBUS_H__ #define __MESSAGE_SERVICE_DBUS_H__ -- cgit v1.2.3 From bd24e02220d5158b1b502771bbba3012848fcef5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:32:07 -0500 Subject: Setting the attention parameter in the dbus interface. --- src/messages-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index d23e9ee..6b11e8c 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -441,7 +441,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (count != 0) { g_debug("Setting image to 'new'"); showing_new_icon = TRUE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, TRUE); return; } @@ -462,7 +462,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (!we_have_indicators) { g_debug("Setting image to boring"); showing_new_icon = FALSE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, FALSE); } return; -- cgit v1.2.3 From fe8917650da7a04c0a7ed4a6549597f2f6437101 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:35:56 -0500 Subject: Bad name, fixed. --- src/messages-service-dbus.c | 4 ++-- src/messages-service-dbus.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 7b0a0ff..d9c0e8d 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -160,7 +160,7 @@ _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidde } void -message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention) +message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ @@ -172,7 +172,7 @@ message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention } void -message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) +message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden) { MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self); /* Do signal */ diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h index caf50db..7a8574e 100644 --- a/src/messages-service-dbus.h +++ b/src/messages-service-dbus.h @@ -54,8 +54,8 @@ struct _MessageServiceDbus { GType message_service_dbus_get_type (void); MessageServiceDbus * message_service_dbus_new (void); -void message_server_dbus_set_attention (MessageServiceDbus * self, gboolean attention); -void message_server_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); +void message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention); +void message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden); G_END_DECLS -- cgit v1.2.3 From f551d2604b0afbcb682b5836e98e40db074c447c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:40:35 -0500 Subject: Forgot to change to Ayatana --- data/indicator-messages.service.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/indicator-messages.service.in b/data/indicator-messages.service.in index 908079a..9ae3960 100644 --- a/data/indicator-messages.service.in +++ b/data/indicator-messages.service.in @@ -1,3 +1,3 @@ [D-BUS Service] -Name=com.ubuntu.indicator.messages +Name=org.ayatana.indicator.messages Exec=@prefix@/bin/indicator-messages-service -- cgit v1.2.3 From 0f990e5a823361e8e428aea77d2db1b7a1cbe8b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 10:50:02 -0500 Subject: The documentation clearly states that you don't need these if the client supports introspection. I thought I was being old school by still putting them in. But, THE DOCUMENTATION LIES, you need to add the signals no matter what. --- src/indicator-messages.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index ef77c28..0d2854b 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -116,12 +116,14 @@ setup_icon_proxy (gpointer userdata) org_ayatana_indicator_messages_service_watch_async(icon_proxy, watch_cb, NULL); + 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), -- cgit v1.2.3 From 81ad298ac031b8a1d3727f00f19b7d82bef981f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:14:39 -0500 Subject: Adding in teh ability to count the number of launchers that are visable --- src/launcher-menu-item.c | 13 +++++++++++++ src/launcher-menu-item.h | 1 + src/messages-service.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6c79adb..d9c35a8 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -194,3 +194,16 @@ launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); return; } + +gboolean +launcher_menu_item_get_eclipsed (LauncherMenuItem * li) +{ + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show"); + if (show == NULL) { + return FALSE; + } + if (!g_strcmp0(show, "true")) { + return TRUE; + } + return FALSE; +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 2b39073..920194e 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -57,6 +57,7 @@ LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); +gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index 6b11e8c..5632c22 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -60,6 +60,7 @@ static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static gboolean destroy_launcher (gpointer data); +static void check_hidden (void); /* @@ -167,6 +168,29 @@ launcherList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +static void +launcherList_count_helper (gpointer data, gpointer user_data) +{ + guint * count = (guint *)user_data; + launcherList_t * li = (launcherList_t *)data; + + if (!launcher_menu_item_get_eclipsed(li->menuitem)) { + *count = *count + 1; + } + + return; +} + +static guint +launcherList_count (void) +{ + guint count = 0; + + g_list_foreach(launcherList, launcherList_count_helper, &count); + + return count; +} + /* * Black List */ @@ -263,6 +287,8 @@ blacklist_add (gpointer udata) } } + check_hidden(); + return FALSE; } @@ -312,6 +338,8 @@ blacklist_remove (gpointer data) g_warning("Unable to remove '%s' with value '%s'", definition_file, (gchar *)key); } + check_hidden(); + return FALSE; } @@ -542,6 +570,13 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { return; } +static void +check_hidden (void) +{ + launcherList_count(); + return; +} + static void resort_menu (DbusmenuMenuitem * menushell) { -- cgit v1.2.3 From d9debb0b236b8e1e3e404224d128443c9fb50819 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:18:12 -0500 Subject: Putting in the hiding logic --- src/messages-service.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/messages-service.c b/src/messages-service.c index 5632c22..d2f0785 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -573,7 +573,15 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { static void check_hidden (void) { - launcherList_count(); + gboolean hide = FALSE; + if (launcherList_count() == 0) { + /* If we don't have visible launchers we need to look more */ + if (serverList != NULL) { /* Basically if there are zero entries it'll be NULL */ + hide = TRUE; + } + } + + message_service_dbus_set_icon(dbus_interface, hide); return; } -- cgit v1.2.3 From a13c1cb4fad904f91df3b32bad5d49918cab01da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 11:19:34 -0500 Subject: Checking hidden when servers are added and removed as well. --- src/messages-service.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index d2f0785..23721be 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -437,6 +437,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Should be prepend ^ */ resort_menu(menushell); + check_hidden(); return; } @@ -539,6 +540,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* Simulate a server saying zero to recalculate icon */ server_count_changed(NULL, 0, NULL); + check_hidden(); return; } -- cgit v1.2.3 From 7f0a072a9c1f1efc914c132b1e208b05176f7de9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 12:44:48 -0500 Subject: Some debug messages and checking the list length, but most importantly, got the show/eclipsed logic backwards. --- src/launcher-menu-item.c | 3 ++- src/messages-service.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index d9c35a8..802575f 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -202,7 +202,8 @@ launcher_menu_item_get_eclipsed (LauncherMenuItem * li) if (show == NULL) { return FALSE; } - if (!g_strcmp0(show, "true")) { + g_debug("Launcher check eclipse: %s", show); + if (!g_strcmp0(show, "false")) { return TRUE; } return FALSE; diff --git a/src/messages-service.c b/src/messages-service.c index 23721be..a5af895 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -575,10 +575,13 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { static void check_hidden (void) { + g_debug("Checking Hidden..."); gboolean hide = FALSE; if (launcherList_count() == 0) { + g_debug("\tZero Launchers"); /* If we don't have visible launchers we need to look more */ - if (serverList != NULL) { /* Basically if there are zero entries it'll be NULL */ + if (g_list_length(serverList) == 0) { + g_debug("\tZero Applications"); hide = TRUE; } } -- cgit v1.2.3 -- cgit v1.2.3