aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am48
-rw-r--r--src/Makefile.in82
-rw-r--r--src/app-menu-item.c11
-rw-r--r--src/dbus-data.h13
-rw-r--r--src/gen-messages-service.xml.c27
-rw-r--r--src/gen-messages-service.xml.h1
-rw-r--r--src/im-menu-item.c16
-rw-r--r--src/indicator-messages.c410
-rw-r--r--src/launcher-menu-item.c4
-rw-r--r--src/messages-service-client.h139
-rw-r--r--src/messages-service-dbus.c144
-rw-r--r--src/messages-service-server.h126
-rw-r--r--src/messages-service.c2
-rw-r--r--src/messages-service.xml2
14 files changed, 588 insertions, 437 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c9842a..8597d77 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,9 +9,17 @@ 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_CFLAGS = \
+ $(APPLET_CFLAGS) \
+ -Wall \
+ -Wl,-Bsymbolic-functions \
+ -Wl,-z,defs \
+ -Wl,--as-needed \
+ -Werror \
+ -DG_LOG_DOMAIN=\"Indicator-Messages\"
libmessaging_la_LIBADD = $(APPLET_LIBS)
libmessaging_la_LDFLAGS = -module -avoid-version
@@ -23,9 +31,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 \
@@ -36,26 +45,29 @@ indicator_messages_service_SOURCES = \
seen-db.h \
dirs.h \
dbus-data.h
-indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror
+indicator_messages_service_CFLAGS = \
+ $(APPLET_CFLAGS) \
+ -Wall \
+ -Wl,-Bsymbolic-functions \
+ -Wl,-z,defs \
+ -Wl,--as-needed \
+ -Werror \
+ -DG_LOG_DOMAIN=\"Indicator-Messages\"
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)
diff --git a/src/Makefile.in b/src/Makefile.in
index 756fbc9..c1ca548 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -72,7 +72,8 @@ am__installdirs = "$(DESTDIR)$(messaginglibdir)" \
LTLIBRARIES = $(messaginglib_LTLIBRARIES)
am__DEPENDENCIES_1 =
libmessaging_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
-am_libmessaging_la_OBJECTS = libmessaging_la-indicator-messages.lo
+am_libmessaging_la_OBJECTS = libmessaging_la-indicator-messages.lo \
+ libmessaging_la-gen-messages-service.xml.lo
libmessaging_la_OBJECTS = $(am_libmessaging_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
@@ -86,6 +87,7 @@ am_indicator_messages_service_OBJECTS = \
indicator_messages_service-default-applications.$(OBJEXT) \
indicator_messages_service-messages-service.$(OBJEXT) \
indicator_messages_service-messages-service-dbus.$(OBJEXT) \
+ indicator_messages_service-gen-messages-service.xml.$(OBJEXT) \
indicator_messages_service-im-menu-item.$(OBJEXT) \
indicator_messages_service-app-menu-item.$(OBJEXT) \
indicator_messages_service-launcher-menu-item.$(OBJEXT) \
@@ -209,6 +211,8 @@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POFILES = @POFILES@
POSUB = @POSUB@
PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@
@@ -281,10 +285,19 @@ 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_CFLAGS = \
+ $(APPLET_CFLAGS) \
+ -Wall \
+ -Wl,-Bsymbolic-functions \
+ -Wl,-z,defs \
+ -Wl,--as-needed \
+ -Werror \
+ -DG_LOG_DOMAIN=\"Indicator-Messages\"
+
libmessaging_la_LIBADD = $(APPLET_LIBS)
libmessaging_la_LDFLAGS = -module -avoid-version
@@ -295,9 +308,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 \
@@ -309,11 +323,19 @@ indicator_messages_service_SOURCES = \
dirs.h \
dbus-data.h
-indicator_messages_service_CFLAGS = $(APPLET_CFLAGS) -Wall -Wl,-Bsymbolic-functions -Wl,-z,defs -Wl,--as-needed -Werror
+indicator_messages_service_CFLAGS = \
+ $(APPLET_CFLAGS) \
+ -Wall \
+ -Wl,-Bsymbolic-functions \
+ -Wl,-z,defs \
+ -Wl,--as-needed \
+ -Werror \
+ -DG_LOG_DOMAIN=\"Indicator-Messages\"
+
indicator_messages_service_LDADD = $(APPLET_LIBS)
BUILT_SOURCES = \
- messages-service-client.h \
- messages-service-server.h
+ gen-messages-service.xml.h \
+ gen-messages-service.xml.c
CLEANFILES = \
$(BUILT_SOURCES)
@@ -444,11 +466,13 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-app-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-default-applications.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-im-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-launcher-menu-item.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-messages-service-dbus.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-messages-service.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/indicator_messages_service-seen-db.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmessaging_la-gen-messages-service.xml.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmessaging_la-indicator-messages.Plo@am__quote@
.c.o:
@@ -483,6 +507,14 @@ libmessaging_la-indicator-messages.lo: indicator-messages.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -c -o libmessaging_la-indicator-messages.lo `test -f 'indicator-messages.c' || echo '$(srcdir)/'`indicator-messages.c
+libmessaging_la-gen-messages-service.xml.lo: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -MT libmessaging_la-gen-messages-service.xml.lo -MD -MP -MF $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Tpo -c -o libmessaging_la-gen-messages-service.xml.lo `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Tpo $(DEPDIR)/libmessaging_la-gen-messages-service.xml.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='libmessaging_la-gen-messages-service.xml.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libmessaging_la_CFLAGS) $(CFLAGS) -c -o libmessaging_la-gen-messages-service.xml.lo `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+
indicator_messages_service-default-applications.o: default-applications.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-default-applications.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-default-applications.Tpo -c -o indicator_messages_service-default-applications.o `test -f 'default-applications.c' || echo '$(srcdir)/'`default-applications.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-default-applications.Tpo $(DEPDIR)/indicator_messages_service-default-applications.Po
@@ -531,6 +563,22 @@ indicator_messages_service-messages-service-dbus.obj: messages-service-dbus.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-messages-service-dbus.obj `if test -f 'messages-service-dbus.c'; then $(CYGPATH_W) 'messages-service-dbus.c'; else $(CYGPATH_W) '$(srcdir)/messages-service-dbus.c'; fi`
+indicator_messages_service-gen-messages-service.xml.o: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-gen-messages-service.xml.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo -c -o indicator_messages_service-gen-messages-service.xml.o `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='indicator_messages_service-gen-messages-service.xml.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-gen-messages-service.xml.o `test -f 'gen-messages-service.xml.c' || echo '$(srcdir)/'`gen-messages-service.xml.c
+
+indicator_messages_service-gen-messages-service.xml.obj: gen-messages-service.xml.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-gen-messages-service.xml.obj -MD -MP -MF $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo -c -o indicator_messages_service-gen-messages-service.xml.obj `if test -f 'gen-messages-service.xml.c'; then $(CYGPATH_W) 'gen-messages-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-messages-service.xml.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Tpo $(DEPDIR)/indicator_messages_service-gen-messages-service.xml.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gen-messages-service.xml.c' object='indicator_messages_service-gen-messages-service.xml.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -c -o indicator_messages_service-gen-messages-service.xml.obj `if test -f 'gen-messages-service.xml.c'; then $(CYGPATH_W) 'gen-messages-service.xml.c'; else $(CYGPATH_W) '$(srcdir)/gen-messages-service.xml.c'; fi`
+
indicator_messages_service-im-menu-item.o: im-menu-item.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(indicator_messages_service_CFLAGS) $(CFLAGS) -MT indicator_messages_service-im-menu-item.o -MD -MP -MF $(DEPDIR)/indicator_messages_service-im-menu-item.Tpo -c -o indicator_messages_service-im-menu-item.o `test -f 'im-menu-item.c' || echo '$(srcdir)/'`im-menu-item.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/indicator_messages_service-im-menu-item.Tpo $(DEPDIR)/indicator_messages_service-im-menu-item.Po
@@ -811,19 +859,15 @@ uninstall-am: uninstall-libexecPROGRAMS \
uninstall-messaginglibLTLIBRARIES
-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 ";" >> $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/src/app-menu-item.c b/src/app-menu-item.c
index c276a90..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);
@@ -328,6 +328,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar
priv->desktop = g_strdup(value);
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
+ dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), APPLICATION_MENUITEM_PROP_RUNNING, TRUE);
update_label(self);
@@ -355,7 +356,6 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio
AppMenuItem * self = APP_MENU_ITEM(data);
AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self);
DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child);
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
priv->shortcuts = g_list_insert(priv->shortcuts, mip, position);
@@ -456,7 +456,6 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data
g_debug("\tProcessing %d children", g_list_length(children));
while (children != NULL) {
DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data));
- dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
priv->shortcuts = g_list_append(priv->shortcuts, mip);
g_signal_emit(G_OBJECT(self), signals[SHORTCUT_ADDED], 0, mip, TRUE);
children = g_list_next(children);
@@ -470,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/dbus-data.h b/src/dbus-data.h
index c16b2b5..abff3aa 100644
--- a/src/dbus-data.h
+++ b/src/dbus-data.h
@@ -2,15 +2,16 @@
#ifndef __DBUS_DATA_H__
#define __DBUS_DATA_H__ 1
-#define INDICATOR_MESSAGES_DBUS_NAME "org.ayatana.indicator.messages"
-#define INDICATOR_MESSAGES_DBUS_OBJECT "/org/ayatana/indicator/messages/menu"
+#define INDICATOR_MESSAGES_DBUS_NAME "com.canonical.indicator.messages"
+#define INDICATOR_MESSAGES_DBUS_OBJECT "/com/canonical/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"
+#define INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT "/com/canonical/indicator/messages/service"
+#define INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "com.canonical.indicator.messages.service"
#define APPLICATION_MENUITEM_TYPE "application-item"
-#define APPLICATION_MENUITEM_PROP_NAME "app-name"
-#define APPLICATION_MENUITEM_PROP_ICON "app-icon"
+#define APPLICATION_MENUITEM_PROP_NAME "label"
+#define APPLICATION_MENUITEM_PROP_ICON "icon-name"
+#define APPLICATION_MENUITEM_PROP_RUNNING "app-running"
#define INDICATOR_MENUITEM_TYPE "indicator-item"
#define INDICATOR_MENUITEM_PROP_LABEL "indicator-label"
diff --git a/src/gen-messages-service.xml.c b/src/gen-messages-service.xml.c
new file mode 100644
index 0000000..0a1c0d1
--- /dev/null
+++ b/src/gen-messages-service.xml.c
@@ -0,0 +1,27 @@
+const char * _messages_service =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<node name=\"/\">\n"
+" <interface name=\"com.canonical.indicator.messages.service\">\n"
+"\n"
+"<!-- Methods -->\n"
+" <method name=\"Watch\">\n"
+" <annotation name=\"org.freedesktop.DBus.GLib.Async\" value=\"true\" />\n"
+" </method>\n"
+" <method name=\"AttentionRequested\">\n"
+" <arg type=\"b\" name=\"dot\" direction=\"out\" />\n"
+" </method>\n"
+" <method name=\"IconShown\">\n"
+" <arg type=\"b\" name=\"hidden\" direction=\"out\" />\n"
+" </method>\n"
+"\n"
+"<!-- Signals -->\n"
+" <signal name=\"AttentionChanged\">\n"
+" <arg type=\"b\" name=\"dot\" direction=\"out\" />\n"
+" </signal>\n"
+" <signal name=\"IconChanged\">\n"
+" <arg type=\"b\" name=\"hidden\" direction=\"out\" />\n"
+" </signal>\n"
+"\n"
+" </interface>\n"
+"</node>\n"
+;
diff --git a/src/gen-messages-service.xml.h b/src/gen-messages-service.xml.h
new file mode 100644
index 0000000..7884498
--- /dev/null
+++ b/src/gen-messages-service.xml.h
@@ -0,0 +1 @@
+extern const char * _messages_service;
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index 5841d81..25fea52 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -348,7 +348,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, Indicate
g_free(priv->count);
}
- priv->count = g_strdup_printf("(%s)", propertydata);
+ priv->count = g_strdup_printf("%s", propertydata);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), INDICATOR_MENUITEM_PROP_RIGHT, priv->count);
return;
@@ -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);
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index f47eccd..ed6caa6 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -23,11 +23,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <string.h>
#include <glib.h>
#include <glib-object.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libdbusmenu-gtk/menu.h>
#include <libdbusmenu-gtk/menuitem.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
#include <libindicator/indicator.h>
#include <libindicator/indicator-object.h>
@@ -35,7 +34,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-service-manager.h>
#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))
@@ -44,11 +43,17 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_INDICATOR_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_MESSAGES_TYPE))
#define INDICATOR_MESSAGES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessagesClass))
+#define M_PI 3.1415926535897932384626433832795028841971693993751
+
+#define RIGHT_LABEL_FONT_SIZE 12
+#define RIGHT_LABEL_RADIUS 20
+
typedef struct _IndicatorMessages IndicatorMessages;
typedef struct _IndicatorMessagesClass IndicatorMessagesClass;
struct _IndicatorMessagesClass {
IndicatorObjectClass parent_class;
+ void (*update_a11y_desc) (IndicatorServiceManager * service, gpointer * user_data);
};
struct _IndicatorMessages {
@@ -64,8 +69,12 @@ 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;
+static const gchar * accessible_desc = NULL;
+static IndicatorObject * indicator = NULL;
/* Prototypes */
static void indicator_messages_class_init (IndicatorMessagesClass *klass);
@@ -74,12 +83,34 @@ static void indicator_messages_dispose (GObject *object);
static void indicator_messages_finalize (GObject *object);
static GtkImage * get_icon (IndicatorObject * io);
static GtkMenu * get_menu (IndicatorObject * io);
+static const gchar * get_accessible_desc (IndicatorObject * io);
static void connection_change (IndicatorServiceManager * sm,
gboolean connected,
gpointer user_data);
G_DEFINE_TYPE (IndicatorMessages, indicator_messages, INDICATOR_OBJECT_TYPE);
+static void
+update_a11y_desc (void)
+{
+ g_return_if_fail(IS_INDICATOR_MESSAGES(indicator));
+
+ GList *entries = indicator_object_get_entries(indicator);
+ IndicatorObjectEntry * entry = (IndicatorObjectEntry *)entries->data;
+
+ entry->accessible_desc = get_accessible_desc(indicator);
+
+ g_signal_emit(G_OBJECT(indicator),
+ INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID,
+ 0,
+ entry,
+ TRUE);
+
+ g_list_free(entries);
+
+ return;
+}
+
/* Initialize the one-timers */
static void
indicator_messages_class_init (IndicatorMessagesClass *klass)
@@ -93,6 +124,25 @@ indicator_messages_class_init (IndicatorMessagesClass *klass)
io_class->get_image = get_icon;
io_class->get_menu = get_menu;
+ io_class->get_accessible_desc = get_accessible_desc;
+
+ 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;
}
@@ -108,6 +158,8 @@ indicator_messages_init (IndicatorMessages *self)
self->service = indicator_service_manager_new_version(INDICATOR_MESSAGES_DBUS_NAME, 1);
g_signal_connect(self->service, INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_change), self);
+ indicator = INDICATOR_OBJECT(self);
+
return;
}
@@ -140,54 +192,85 @@ 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");
+ accessible_desc = _("New Messages");
+ } else {
+ indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages");
+ accessible_desc = _("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);
}
+
+ update_a11y_desc();
+
return;
}
/* 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");
+ accessible_desc = _("New Messages");
+ } else {
+ indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages");
+ accessible_desc = _("Messages");
+ }
+
+ update_a11y_desc();
+
+ 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;
@@ -204,6 +287,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,
+ user_data);
+ g_dbus_proxy_call(icon_proxy,
+ "IconShown",
+ NULL, /* params */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ icon_cb,
+ user_data);
+
+ return;
+}
+
/* Sets up all the icon information in the proxy. */
static void
connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
@@ -220,51 +340,46 @@ 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_TYPE_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;
}
/* 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);
}
}
@@ -273,24 +388,150 @@ 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));
}
}
+ if (!g_strcmp0(prop, APPLICATION_MENUITEM_PROP_RUNNING)) {
+ /* TODO: should hide/show the triangle live if the menu was open.
+ In practice, this is rarely needed. */
+ }
+
return;
}
+/* Draws a triangle on the left, using fg[STATE_TYPE] color. */
+static gboolean
+application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ GtkAllocation allocation;
+ GtkStyle *style;
+ cairo_t *cr;
+ int x, y, arrow_width, arrow_height;
+
+ if (!GTK_IS_WIDGET (widget)) return FALSE;
+ if (!DBUSMENU_IS_MENUITEM (data)) return FALSE;
+
+ /* render the triangle indicator only if the application is running */
+ if (! dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM(data), APPLICATION_MENUITEM_PROP_RUNNING))
+ return FALSE;;
+
+ /* get style */
+ style = gtk_widget_get_style (widget);
+
+ /* set arrow position / dimensions */
+ arrow_width = 5; /* the pixel-based reference triangle is 5x9 */
+ arrow_height = 9;
+ gtk_widget_get_allocation (widget, &allocation);
+ x = allocation.x;
+ y = allocation.y + allocation.height/2.0 - (double)arrow_height/2.0;
+
+ /* initialize cairo drawing area */
+ cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget));
+
+ /* set line width */
+ cairo_set_line_width (cr, 1.0);
+
+ /* cairo drawing code */
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x, y + arrow_height);
+ cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0);
+ cairo_close_path (cr);
+ cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0,
+ style->fg[gtk_widget_get_state(widget)].green/65535.0,
+ style->fg[gtk_widget_get_state(widget)].blue/65535.0);
+ cairo_fill (cr);
+
+ /* remember to destroy cairo context to avoid leaks */
+ cairo_destroy (cr);
+
+ return FALSE;
+}
+
+/* Custom function to draw rounded rectangle with max radius */
+static void
+custom_cairo_rounded_rectangle (cairo_t *cr,
+ double x, double y, double w, double h)
+{
+ double radius = MIN (w/2.0, h/2.0);
+
+ cairo_move_to (cr, x+radius, y);
+ cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2);
+ cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI*0.5);
+ cairo_arc (cr, x+radius, y+h-radius, radius, M_PI*0.5, M_PI);
+ cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5);
+}
+
+/* Draws a rounded rectangle with text inside. */
+static gboolean
+numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ GtkAllocation allocation;
+ GtkStyle *style;
+ cairo_t *cr;
+ double x, y, w, h;
+ PangoLayout * layout;
+ gint font_size = RIGHT_LABEL_FONT_SIZE;
+
+ if (!GTK_IS_WIDGET (widget)) return FALSE;
+
+ /* get style */
+ style = gtk_widget_get_style (widget);
+
+ /* set arrow position / dimensions */
+ gtk_widget_get_allocation (widget, &allocation);
+ w = allocation.width;
+ h = allocation.height;
+ x = allocation.x;
+ y = allocation.y;
+
+ layout = gtk_label_get_layout (GTK_LABEL(widget));
+
+ /* This does not work, don't ask me why but font_size is 0.
+ * I wanted to use a dynamic font size to adjust the padding on left/right edges
+ * of the rounded rectangle. Andrea Cimitan */
+ /* const PangoFontDescription * font_description = pango_layout_get_font_description (layout);
+ font_size = pango_font_description_get_size (font_description); */
+
+ /* initialize cairo drawing area */
+ cr = (cairo_t*) gdk_cairo_create (gtk_widget_get_window (widget));
+
+ /* set line width */
+ cairo_set_line_width (cr, 1.0);
+
+ cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
+
+ /* cairo drawing code */
+ custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h);
+
+ cairo_set_source_rgba (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0,
+ style->fg[gtk_widget_get_state(widget)].green/65535.0,
+ style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5);
+
+ cairo_move_to (cr, x, y);
+ pango_cairo_layout_path (cr, layout);
+ cairo_fill (cr);
+
+ /* remember to destroy cairo context to avoid leaks */
+ cairo_destroy (cr);
+
+ return TRUE;
+}
+
/* Builds a menu item representing a running application in the
messaging menu */
static gboolean
-new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
+new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data)
{
+ g_debug ("%s (\"%s\")", __func__, dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
+
GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new());
+ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE);
gint padding = 4;
gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL);
@@ -302,9 +543,12 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu
gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);
GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU);
- gtk_widget_set_size_request(icon, width, height);
- gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding);
+ gtk_widget_set_size_request(icon, width
+ + 5 /* ref triangle is 5x9 pixels */
+ + 2 /* padding */,
+ height);
+ gtk_misc_set_alignment(GTK_MISC(icon), 1.0 /* right aligned */, 0.5);
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon);
gtk_widget_show(icon);
/* Application name in a label */
@@ -317,25 +561,17 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu
gtk_container_add(GTK_CONTAINER(gmi), hbox);
gtk_widget_show(hbox);
- /* Build up the running icon */
- GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon);
- gtk_widget_show(running_icon);
-
- /* Make sure it always appears */
- gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE);
-
/* Attach some of the standard GTK stuff */
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent);
/* Make sure we can handle the label changing */
g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label);
g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon);
+ g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), newitem);
return TRUE;
}
-
typedef struct _indicator_item_t indicator_item_t;
struct _indicator_item_t {
GtkWidget * icon;
@@ -346,14 +582,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
@@ -383,6 +619,10 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, i
if (resized_pixbuf != pixbuf) {
g_object_unref(resized_pixbuf);
}
+
+ gtk_widget_show(mi_data->icon);
+ } else {
+ gtk_widget_hide(mi_data->icon);
}
}
@@ -394,7 +634,7 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, i
shifting over and putting the icon in with some right
side text that'll be determined by the service. */
static gboolean
-new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
+new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data)
{
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE);
g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE);
@@ -405,6 +645,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new());
gint padding = 4;
+ gint font_size = RIGHT_LABEL_FONT_SIZE;
gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL);
GtkWidget * hbox = gtk_hbox_new(FALSE, 0);
@@ -443,7 +684,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
}
gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding);
- gtk_widget_show(mi_data->icon);
+
+ if (pixbuf != NULL) {
+ gtk_widget_show(mi_data->icon);
+ }
/* Label, probably a username, chat room or mailbox name */
mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL));
@@ -455,8 +699,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm
item. */
mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT));
gtk_size_group_add_widget(indicator_right_group, mi_data->right);
+ /* install extra decoration overlay */
+ g_signal_connect (G_OBJECT (mi_data->right), "expose_event",
+ G_CALLBACK (numbers_draw_cb), NULL);
+
gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5);
- gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding);
+ gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0);
gtk_widget_show(mi_data->right);
gtk_container_add(GTK_CONTAINER(gmi), hbox);
@@ -495,3 +743,9 @@ get_menu (IndicatorObject * io)
return GTK_MENU(menu);
}
+/* Returns the accessible description of the indicator */
+static const gchar *
+get_accessible_desc (IndicatorObject * io)
+{
+ return accessible_desc;
+}
diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c
index 63e5594..60880ad 100644
--- a/src/launcher-menu-item.c
+++ b/src/launcher-menu-item.c
@@ -97,6 +97,8 @@ launcher_menu_item_init (LauncherMenuItem *self)
priv->ids = NULL;
priv->shortcuts = NULL;
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
+
return;
}
@@ -197,9 +199,9 @@ launcher_menu_item_new (const gchar * desktop_file)
gint i;
for (i = 0; nicks[i] != NULL; i++) {
DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
g_object_set_data(G_OBJECT(mi), NICK_DATA, (gpointer)nicks[i]);
- dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK);
dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, indicator_desktop_shortcuts_nick_get_name(priv->ids, nicks[i]));
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(nick_activate_cb), self);
diff --git a/src/messages-service-client.h b/src/messages-service-client.h
deleted file mode 100644
index 2a858e8..0000000
--- a/src/messages-service-client.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Generated by dbus-binding-tool; do not edit! */
-
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-
-G_BEGIN_DECLS
-
-#ifndef _DBUS_GLIB_ASYNC_DATA_FREE
-#define _DBUS_GLIB_ASYNC_DATA_FREE
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-void
-_dbus_glib_async_data_free (gpointer stuff)
-{
- g_slice_free (DBusGAsyncData, stuff);
-}
-#endif
-
-#ifndef DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service
-#define DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_watch (DBusGProxy *proxy, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "Watch", error, G_TYPE_INVALID, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_watch_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_watch_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_watch_reply)data->cb) (proxy, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_watch_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_watch_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "Watch", org_ayatana_indicator_messages_service_watch_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_attention_requested (DBusGProxy *proxy, gboolean* OUT_dot, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "AttentionRequested", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_dot, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_attention_requested_reply) (DBusGProxy *proxy, gboolean OUT_dot, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_attention_requested_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- gboolean OUT_dot;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_dot, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_attention_requested_reply)data->cb) (proxy, OUT_dot, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_attention_requested_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_attention_requested_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "AttentionRequested", org_ayatana_indicator_messages_service_attention_requested_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-gboolean
-org_ayatana_indicator_messages_service_icon_shown (DBusGProxy *proxy, gboolean* OUT_hidden, GError **error)
-
-{
- return dbus_g_proxy_call (proxy, "IconShown", error, G_TYPE_INVALID, G_TYPE_BOOLEAN, OUT_hidden, G_TYPE_INVALID);
-}
-
-typedef void (*org_ayatana_indicator_messages_service_icon_shown_reply) (DBusGProxy *proxy, gboolean OUT_hidden, GError *error, gpointer userdata);
-
-static void
-org_ayatana_indicator_messages_service_icon_shown_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
-{
- DBusGAsyncData *data = (DBusGAsyncData*) user_data;
- GError *error = NULL;
- gboolean OUT_hidden;
- dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_BOOLEAN, &OUT_hidden, G_TYPE_INVALID);
- (*(org_ayatana_indicator_messages_service_icon_shown_reply)data->cb) (proxy, OUT_hidden, error, data->userdata);
- return;
-}
-
-static
-#ifdef G_HAVE_INLINE
-inline
-#endif
-DBusGProxyCall*
-org_ayatana_indicator_messages_service_icon_shown_async (DBusGProxy *proxy, org_ayatana_indicator_messages_service_icon_shown_reply callback, gpointer userdata)
-
-{
- DBusGAsyncData *stuff;
- stuff = g_slice_new (DBusGAsyncData);
- stuff->cb = G_CALLBACK (callback);
- stuff->userdata = userdata;
- return dbus_g_proxy_begin_call (proxy, "IconShown", org_ayatana_indicator_messages_service_icon_shown_async_callback, stuff, _dbus_glib_async_data_free, G_TYPE_INVALID);
-}
-#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_ayatana_indicator_messages_service */
-
-G_END_DECLS
diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c
index d9c0e8d..6cc33e0 100644
--- a/src/messages-service-dbus.c
+++ b/src/messages-service-dbus.c
@@ -24,9 +24,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#endif
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
#include "messages-service-dbus.h"
#include "dbus-data.h"
+#include "gen-messages-service.xml.h"
enum {
ATTENTION_CHANGED,
@@ -40,6 +41,7 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate;
struct _MessageServiceDbusPrivate
{
+ GDBusConnection * connection;
gboolean dot;
gboolean hidden;
};
@@ -51,15 +53,26 @@ 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 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 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 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);
+
static void
message_service_dbus_class_init (MessageServiceDbusClass *klass)
{
@@ -86,8 +99,57 @@ 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);
+ }
+ }
+
+ 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;
+}
+
+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;
+ }
+
+ 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,
+ &bus_interface_table,
+ user_data,
+ NULL, /* destroy */
+ &error);
+
+ if (error != NULL) {
+ g_error("Unable to register on session bus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
- dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info);
+ g_debug("Service on session bus");
return;
}
@@ -95,10 +157,7 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass)
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);
@@ -111,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;
@@ -132,31 +196,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)
-{
-
-}
-
-/* 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)
+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(self);
- *dot = priv->dot;
- return TRUE;
-}
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ 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
@@ -167,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;
}
@@ -179,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;
}
diff --git a/src/messages-service-server.h b/src/messages-service-server.h
deleted file mode 100644
index 61921f9..0000000
--- a/src/messages-service-server.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Generated by dbus-binding-tool; do not edit! */
-
-
-#ifndef __dbus_glib_marshal__messages_service_server_MARSHAL_H__
-#define __dbus_glib_marshal__messages_service_server_MARSHAL_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v) g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v) g_value_get_int (v)
-#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
-#define g_marshal_value_peek_long(v) g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
-#define g_marshal_value_peek_float(v) g_value_get_float (v)
-#define g_marshal_value_peek_double(v) g_value_get_double (v)
-#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v) g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v) g_value_get_object (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- * Do not access GValues directly in your code. Instead, use the
- * g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
-#define g_marshal_value_peek_char(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v) (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v) (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
-#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
-#define g_marshal_value_peek_float(v) (v)->data[0].v_float
-#define g_marshal_value_peek_double(v) (v)->data[0].v_double
-#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* NONE:POINTER */
-#define dbus_glib_marshal__messages_service_server_VOID__POINTER g_cclosure_marshal_VOID__POINTER
-#define dbus_glib_marshal__messages_service_server_NONE__POINTER dbus_glib_marshal__messages_service_server_VOID__POINTER
-
-/* BOOLEAN:POINTER,POINTER */
-extern void dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure,
- GValue *return_value,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint,
- gpointer marshal_data);
-void
-dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER (GClosure *closure,
- GValue *return_value G_GNUC_UNUSED,
- guint n_param_values,
- const GValue *param_values,
- gpointer invocation_hint G_GNUC_UNUSED,
- gpointer marshal_data)
-{
- typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
- gpointer arg_1,
- gpointer arg_2,
- gpointer data2);
- register GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
- register GCClosure *cc = (GCClosure*) closure;
- register gpointer data1, data2;
- gboolean v_return;
-
- g_return_if_fail (return_value != NULL);
- g_return_if_fail (n_param_values == 3);
-
- if (G_CCLOSURE_SWAP_DATA (closure))
- {
- data1 = closure->data;
- data2 = g_value_peek_pointer (param_values + 0);
- }
- else
- {
- data1 = g_value_peek_pointer (param_values + 0);
- data2 = closure->data;
- }
- callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
-
- v_return = callback (data1,
- g_marshal_value_peek_pointer (param_values + 1),
- g_marshal_value_peek_pointer (param_values + 2),
- data2);
-
- g_value_set_boolean (return_value, v_return);
-}
-
-G_END_DECLS
-
-#endif /* __dbus_glib_marshal__messages_service_server_MARSHAL_H__ */
-
-#include <dbus/dbus-glib.h>
-static const DBusGMethodInfo dbus_glib__messages_service_server_methods[] = {
- { (GCallback) _messages_service_server_watch, dbus_glib_marshal__messages_service_server_NONE__POINTER, 0 },
- { (GCallback) _messages_service_server_attention_requested, dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER, 48 },
- { (GCallback) _messages_service_server_icon_shown, dbus_glib_marshal__messages_service_server_BOOLEAN__POINTER_POINTER, 121 },
-};
-
-const DBusGObjectInfo dbus_glib__messages_service_server_object_info = {
- 0,
- dbus_glib__messages_service_server_methods,
- 3,
-"org.ayatana.indicator.messages.service\0Watch\0A\0\0org.ayatana.indicator.messages.service\0AttentionRequested\0S\0dot\0O\0F\0N\0b\0\0org.ayatana.indicator.messages.service\0IconShown\0S\0hidden\0O\0F\0N\0b\0\0\0",
-"org.ayatana.indicator.messages.service\0AttentionChanged\0org.ayatana.indicator.messages.service\0IconChanged\0\0",
-"\0"
-};
-
diff --git a/src/messages-service.c b/src/messages-service.c
index 0783d91..e3352e8 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -25,7 +25,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libintl.h>
#include <config.h>
#include <pango/pango-utils.h>
-#include <dbus/dbus-glib-bindings.h>
#include <libindicate/listener.h>
#include <libindicator/indicator-service.h>
#include <gio/gio.h>
@@ -1346,6 +1345,7 @@ build_launcher_core (const gchar * desktop)
launcherList = g_list_insert_sorted(launcherList, ll, launcherList_sort);
/* Add it to the menu */
+ dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(ll->menuitem), DBUSMENU_MENUITEM_PROP_TYPE, APPLICATION_MENUITEM_TYPE);
dbusmenu_menuitem_child_append(root_menuitem, DBUSMENU_MENUITEM(ll->menuitem));
GList * shortcuts = launcher_menu_item_get_items(ll->menuitem);
while (shortcuts != NULL) {
diff --git a/src/messages-service.xml b/src/messages-service.xml
index f991179..8a592db 100644
--- a/src/messages-service.xml
+++ b/src/messages-service.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/">
- <interface name="org.ayatana.indicator.messages.service">
+ <interface name="com.canonical.indicator.messages.service">
<!-- Methods -->
<method name="Watch">