From 19f312f6319d5c3fcb4b21d1e655b08bc4a609de Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 25 Aug 2009 16:01:45 -0500 Subject: Checking to see if error is null before looking inside it. --- src/messages-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/messages-service.c b/src/messages-service.c index 384198a..e4982a2 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -195,7 +195,7 @@ blacklist_init (gpointer data) GError * error = NULL; GDir * dir = g_dir_open(blacklistdir, 0, &error); if (dir == NULL) { - g_warning("Unable to open blacklist directory (%s): %s", blacklistdir, error->message); + g_warning("Unable to open blacklist directory (%s): %s", blacklistdir, error == NULL ? "No Message" : error->message); g_error_free(error); g_free(blacklistdir); return FALSE; -- cgit v1.2.3 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(-) (limited to 'src') 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. --- src/Makefile.am | 29 ++++++++++++++++++++++++++++- src/messages-service.xml | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/messages-service.xml (limited to 'src') 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 (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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 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(+) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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 From 8078204a3c807df06e10be50376536ac102b3dd9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:06:20 -0500 Subject: show -> visible --- src/launcher-menu-item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 802575f..100dd67 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -191,14 +191,14 @@ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "visible", eclipsed ? "false" : "true"); return; } gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { - const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show"); + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "visible"); if (show == NULL) { return FALSE; } -- cgit v1.2.3 From 9449d49b38b2dfe2f9a0d90378877a801b6def03 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 16:47:55 -0500 Subject: Replacing the prop strings with defines --- src/app-menu-item.c | 4 ++-- src/im-menu-item.c | 2 +- src/launcher-menu-item.c | 6 +++--- src/messages-service.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 3a2c795..feb780d 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -218,10 +218,10 @@ update_label (AppMenuItem * self) /* TRANSLATORS: This is the name of the program and the number of indicators. So it would read something like "Mail Client (5)" */ gchar * label = g_strdup_printf(_("%s (%d)"), app_menu_item_get_name(self), priv->unreadcount); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", label); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, label); g_free(label); } else { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", app_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, app_menu_item_get_name(self)); } return; diff --git a/src/im-menu-item.c b/src/im-menu-item.c index d35684e..008e33f 100644 --- a/src/im-menu-item.c +++ b/src/im-menu-item.c @@ -253,7 +253,7 @@ sender_cb (IndicateListener * listener, IndicateListenerServer * server, Indicat return; } - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", propertydata); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, propertydata); return; } diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 100dd67..eb32e59 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -130,7 +130,7 @@ launcher_menu_item_new (const gchar * desktop_file) priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "label", launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -191,14 +191,14 @@ void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) { g_debug("Laucher '%s' is %s", launcher_menu_item_get_name(li), eclipsed ? "now eclipsed" : "shown again"); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "visible", eclipsed ? "false" : "true"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE, eclipsed ? "false" : "true"); return; } gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li) { - const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "visible"); + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), DBUSMENU_MENUITEM_PROP_VISIBLE); if (show == NULL) { return FALSE; } diff --git a/src/messages-service.c b/src/messages-service.c index a5af895..093ebfd 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -908,7 +908,7 @@ destroy_launcher (gpointer data) g_list_free(li->appdiritems); if (li->menuitem != NULL) { - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), "visible", "false"); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, "false"); dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem)); g_object_unref(G_OBJECT(li->menuitem)); li->menuitem = NULL; -- cgit v1.2.3 From 983f83536606972bd90e9f95377a8d1ced282720 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:27:39 -0500 Subject: Making ourselves a variable in the middle of everything. --- src/indicator-messages.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 0d2854b..80ab535 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -175,6 +175,8 @@ get_menu (void) g_idle_add(setup_icon_proxy, NULL); - return GTK_MENU(dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT)); + DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); + + return GTK_MENU(menu); } -- cgit v1.2.3 From bb8dfce7d1a137eeff3792862b3f9a27416f3836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 17:29:53 -0500 Subject: Injecting in a type for the launchers. --- src/indicator-messages.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 80ab535..2aec8e9 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -136,6 +136,13 @@ setup_icon_proxy (gpointer userdata) return FALSE; } +static gboolean +new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) +{ + + return TRUE; +} + GtkLabel * get_label (void) { @@ -176,6 +183,9 @@ get_menu (void) g_idle_add(setup_icon_proxy, NULL); DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); + DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); + + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), "launcher-item", new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From 96d5cadae1492a0d4db6e38f606be309e76ab0aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:06:09 -0500 Subject: Pulling the type and the properties into the shared DBus header. --- src/dbus-data.h | 4 ++++ src/indicator-messages.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dbus-data.h b/src/dbus-data.h index e7d4d26..db59003 100644 --- a/src/dbus-data.h +++ b/src/dbus-data.h @@ -8,4 +8,8 @@ #define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/org/ayatana/indicator/messages/service" #define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "org.ayatana.indicator.messages.service" +#define LAUNCHER_MENUITEM_TYPE "launcher-item" +#define LAUNCHER_MENUITEM_PROP_APP_NAME "application-name" +#define LAUNCHER_MENUITEM_PROP_APP_DESC "application-description" + #endif /* __DBUS_DATA_H__ */ diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 2aec8e9..8762593 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -185,7 +185,7 @@ get_menu (void) DbusmenuGtkMenu * menu = dbusmenu_gtkmenu_new(INDICATOR_MESSAGES_DBUS_NAME, INDICATOR_MESSAGES_DBUS_OBJECT); DbusmenuGtkClient * client = dbusmenu_gtkmenu_get_client(menu); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), "launcher-item", new_launcher_item); + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), LAUNCHER_MENUITEM_TYPE, new_launcher_item); return GTK_MENU(menu); } -- cgit v1.2.3 From bab6bd250e02bb8a139ea4ad36fdee2b7b250544 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:20:02 -0500 Subject: Filling in the new launcher menu item --- src/indicator-messages.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8762593..8838313 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -139,6 +139,22 @@ setup_icon_proxy (gpointer userdata) static gboolean new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + + GtkWidget * vbox = gtk_vbox_new(TRUE, 2); + + GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); + GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + + gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0); + gtk_widget_show(app_label); + gtk_box_pack_start(GTK_BOX(vbox), dsc_label, FALSE, FALSE, 0); + gtk_widget_show(dsc_label); + + gtk_container_add(GTK_CONTAINER(gmi), GTK_WIDGET(vbox)); + gtk_widget_show(GTK_WIDGET(vbox)); + + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); return TRUE; } -- cgit v1.2.3 From 2273a4d1f95cf44edb1aad21849eda6fca358deb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:24:07 -0500 Subject: Setting the type of the item and app name --- src/launcher-menu-item.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index eb32e59..9c2dbeb 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include "launcher-menu-item.h" +#include "dbus-data.h" enum { NAME_CHANGED, @@ -130,7 +131,9 @@ launcher_menu_item_new (const gchar * desktop_file) priv->desktop = g_strdup(desktop_file); g_debug("\tName: %s", launcher_menu_item_get_name(self)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_LABEL, launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", LAUNCHER_MENUITEM_TYPE); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); + // dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_name(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From d08632f2c21df15c8edf292910d63f144bb4a7a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:26:13 -0500 Subject: Use that handy get_description function that we just merged in. Heh, wonder why we did that... --- src/launcher-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 07598d7..6678cc5 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -133,7 +133,7 @@ launcher_menu_item_new (const gchar * desktop_file) g_debug("\tName: %s", launcher_menu_item_get_name(self)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", LAUNCHER_MENUITEM_TYPE); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_NAME, launcher_menu_item_get_name(self)); - // dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_name(self)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), LAUNCHER_MENUITEM_PROP_APP_DESC, launcher_menu_item_get_description(self)); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); -- cgit v1.2.3 From 1077ceea42e73c4c9ef0f368913f18a9a3b092f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:46:43 -0500 Subject: Adding a little style to our labels. Hopefully making them look a little nicer. --- src/indicator-messages.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8838313..0a1002d 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -21,6 +21,7 @@ with this program. If not, see . */ #include +#include #include #include #include @@ -144,7 +145,13 @@ new_launcher_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusme GtkWidget * vbox = gtk_vbox_new(TRUE, 2); GtkWidget * app_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_NAME)); - GtkWidget * dsc_label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + gtk_misc_set_alignment(GTK_MISC(app_label), 0.0, 0.5); + GtkWidget * dsc_label = gtk_label_new(""); + gtk_misc_set_alignment(GTK_MISC(dsc_label), 0.05, 0.5); + gtk_label_set_ellipsize(GTK_LABEL(dsc_label), PANGO_ELLIPSIZE_END); + gchar * markup = g_markup_printf_escaped("%s", dbusmenu_menuitem_property_get(newitem, LAUNCHER_MENUITEM_PROP_APP_DESC)); + gtk_label_set_markup(GTK_LABEL(dsc_label), markup); + g_free(markup); gtk_box_pack_start(GTK_BOX(vbox), app_label, FALSE, FALSE, 0); gtk_widget_show(app_label); -- cgit v1.2.3 From 6af9df41572d52b6115980ac2a1a98a74a71f9f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 26 Aug 2009 20:53:29 -0500 Subject: This stuff is crashing big time now. Not sure why it worked before, but not going to look into it now. --- src/launcher-menu-item.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src') diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6678cc5..822196b 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -160,23 +160,12 @@ activate_cb (LauncherMenuItem * self, gpointer data) LauncherMenuItemPrivate * priv = LAUNCHER_MENU_ITEM_GET_PRIVATE(self); g_return_if_fail(priv->appinfo != NULL); - /* This should manage the X stuff for us */ - GdkAppLaunchContext * context = gdk_app_launch_context_new(); - - /* Using the current time as we don't have the event - time as that's not sent across the bus */ - GTimeVal time; - g_get_current_time(&time); - gdk_app_launch_context_set_timestamp(context, time.tv_usec / 1000); - GError * error = NULL; - if (!g_app_info_launch(priv->appinfo, NULL, G_APP_LAUNCH_CONTEXT(context), &error)) { + if (!g_app_info_launch(priv->appinfo, NULL, NULL, &error)) { g_warning("Application failed to launch '%s' because: %s", launcher_menu_item_get_name(self), error->message); g_error_free(error); } - g_object_unref(G_OBJECT(context)); - return; } -- cgit v1.2.3