aboutsummaryrefslogtreecommitdiff
path: root/libmessaging-menu
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2012-08-27 18:38:53 +0200
committerSebastien Bacher <seb128@ubuntu.com>2012-08-27 18:38:53 +0200
commitd28296b69565793050e51717a89c84eeadd88dbc (patch)
treee3d5330da86f1e626a3b649a429f56a102b5dd6a /libmessaging-menu
parent9d8a4eeaf93b5f5537558e925a1c4f9b16e772b7 (diff)
parentabda3b07fce605d8de1c182e1dfc7569ed681f3e (diff)
downloadayatana-indicator-messages-d28296b69565793050e51717a89c84eeadd88dbc.tar.gz
ayatana-indicator-messages-d28296b69565793050e51717a89c84eeadd88dbc.tar.bz2
ayatana-indicator-messages-d28296b69565793050e51717a89c84eeadd88dbc.zip
Import upstream version 12.10.1
Diffstat (limited to 'libmessaging-menu')
-rw-r--r--libmessaging-menu/Makefile.am6
-rw-r--r--libmessaging-menu/Makefile.in9
-rw-r--r--libmessaging-menu/indicator-messages-service.c2
-rw-r--r--libmessaging-menu/indicator-messages-service.h2
-rw-r--r--libmessaging-menu/messaging-menu.c105
5 files changed, 87 insertions, 37 deletions
diff --git a/libmessaging-menu/Makefile.am b/libmessaging-menu/Makefile.am
index 187e6dc..ef37700 100644
--- a/libmessaging-menu/Makefile.am
+++ b/libmessaging-menu/Makefile.am
@@ -18,7 +18,7 @@ libmessaging_menu_la_CFLAGS = \
$(GIO_CFLAGS) \
-Wall
-libmessaging_menu_la_LDFLAGS = -export-symbols-regex="^messaging_menu_.*"
+libmessaging_menu_la_LDFLAGS = -export-symbols-regex "^messaging_menu_.*"
BUILT_SOURCES = \
indicator-messages-service.c \
@@ -41,7 +41,7 @@ pkgconfig_DATA = messaging-menu.pc
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
-INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
if HAVE_INTROSPECTION
@@ -51,7 +51,7 @@ MessagingMenu_1_0_gir_NAMESPACE = MessagingMenu
MessagingMenu_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0
MessagingMenu_1_0_gir_CFLAGS = $(INCLUDES) $(GIO_CFLAGS)
MessagingMenu_1_0_gir_LIBS = libmessaging-menu.la
-MessagingMenu_1_0_gir_FILES = $(libmessaging_menu_la_SOURCES) $(libmessaging_menu_la_HEADERS)
+MessagingMenu_1_0_gir_FILES = messaging-menu.c messaging-menu.h
INTROSPECTION_GIRS += MessagingMenu-1.0.gir
girdir = $(datadir)/gir-1.0
diff --git a/libmessaging-menu/Makefile.in b/libmessaging-menu/Makefile.in
index 11cf221..29215c2 100644
--- a/libmessaging-menu/Makefile.in
+++ b/libmessaging-menu/Makefile.in
@@ -63,7 +63,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/gcov.m4 \
$(top_srcdir)/m4/gtest.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = messaging-menu.pc
CONFIG_CLEAN_VPATH_FILES =
@@ -209,7 +209,6 @@ GTKDOC_MKPDF = @GTKDOC_MKPDF@
GTKDOC_REBASE = @GTKDOC_REBASE@
HTML_DIR = @HTML_DIR@
INDICATORDIR = @INDICATORDIR@
-INDICATORICONSDIR = @INDICATORICONSDIR@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -352,7 +351,7 @@ libmessaging_menu_la_CFLAGS = \
$(GIO_CFLAGS) \
-Wall
-libmessaging_menu_la_LDFLAGS = -export-symbols-regex="^messaging_menu_.*"
+libmessaging_menu_la_LDFLAGS = -export-symbols-regex "^messaging_menu_.*"
BUILT_SOURCES = \
indicator-messages-service.c \
indicator-messages-service.h
@@ -361,13 +360,13 @@ CLEANFILES = $(BUILT_SOURCES) $(am__append_2)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = messaging-menu.pc
INTROSPECTION_GIRS = $(am__append_1)
-INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_NAMESPACE = MessagingMenu
@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0
@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_CFLAGS = $(INCLUDES) $(GIO_CFLAGS)
@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_LIBS = libmessaging-menu.la
-@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_FILES = $(libmessaging_menu_la_SOURCES) $(libmessaging_menu_la_HEADERS)
+@HAVE_INTROSPECTION_TRUE@MessagingMenu_1_0_gir_FILES = messaging-menu.c messaging-menu.h
@HAVE_INTROSPECTION_TRUE@girdir = $(datadir)/gir-1.0
@HAVE_INTROSPECTION_TRUE@gir_DATA = $(INTROSPECTION_GIRS)
@HAVE_INTROSPECTION_TRUE@typelibdir = $(libdir)/girepository-1.0
diff --git a/libmessaging-menu/indicator-messages-service.c b/libmessaging-menu/indicator-messages-service.c
index 24772c1..a42a534 100644
--- a/libmessaging-menu/indicator-messages-service.c
+++ b/libmessaging-menu/indicator-messages-service.c
@@ -1,5 +1,5 @@
/*
- * Generated by gdbus-codegen 2.33.8. DO NOT EDIT.
+ * Generated by gdbus-codegen 2.33.10. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
diff --git a/libmessaging-menu/indicator-messages-service.h b/libmessaging-menu/indicator-messages-service.h
index cb399f5..2adaaf3 100644
--- a/libmessaging-menu/indicator-messages-service.h
+++ b/libmessaging-menu/indicator-messages-service.h
@@ -1,5 +1,5 @@
/*
- * Generated by gdbus-codegen 2.33.8. DO NOT EDIT.
+ * Generated by gdbus-codegen 2.33.10. DO NOT EDIT.
*
* The license of this code is the same as for the source it was derived from.
*/
diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c
index 336e89c..b090352 100644
--- a/libmessaging-menu/messaging-menu.c
+++ b/libmessaging-menu/messaging-menu.c
@@ -39,6 +39,7 @@ struct _MessagingMenuApp
GMenu *menu;
IndicatorMessagesService *messages_service;
+ guint watch_id;
GCancellable *cancellable;
};
@@ -75,6 +76,21 @@ static void global_status_changed (IndicatorMessagesService *service,
gpointer user_data);
static void
+messaging_menu_app_set_desktop_id (MessagingMenuApp *app,
+ const gchar *desktop_id)
+{
+ g_return_if_fail (desktop_id != NULL);
+
+ /* no need to clean up, it's construct only */
+ app->appinfo = g_desktop_app_info_new (desktop_id);
+ if (app->appinfo == NULL)
+ {
+ g_warning ("could not find the desktop file for '%s'",
+ desktop_id);
+ }
+}
+
+static void
messaging_menu_app_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -85,12 +101,7 @@ messaging_menu_app_set_property (GObject *object,
switch (prop_id)
{
case PROP_DESKTOP_ID:
- app->appinfo = g_desktop_app_info_new (g_value_get_string (value));
- if (app->appinfo == NULL)
- {
- g_warning ("could not find the desktop file for '%s'",
- g_value_get_string (value));
- }
+ messaging_menu_app_set_desktop_id (app, g_value_get_string (value));
break;
default:
@@ -109,6 +120,12 @@ messaging_menu_app_dispose (GObject *object)
{
MessagingMenuApp *app = MESSAGING_MENU_APP (object);
+ if (app->watch_id > 0)
+ {
+ g_bus_unwatch_name (app->watch_id);
+ app->watch_id = 0;
+ }
+
if (app->cancellable)
{
g_cancellable_cancel (app->cancellable);
@@ -233,6 +250,17 @@ got_session_bus (GObject *source,
g_error_free (error);
}
+ g_object_unref (bus);
+}
+
+static void
+indicator_messages_appeared (GDBusConnection *bus,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ MessagingMenuApp *app = user_data;
+
indicator_messages_service_proxy_new (bus,
G_DBUS_PROXY_FLAGS_NONE,
"com.canonical.indicator.messages",
@@ -240,8 +268,22 @@ got_session_bus (GObject *source,
app->cancellable,
created_messages_service,
app);
+}
- g_object_unref (bus);
+static void
+indicator_messages_vanished (GDBusConnection *bus,
+ const gchar *name,
+ gpointer user_data)
+{
+ MessagingMenuApp *app = user_data;
+
+ if (app->messages_service)
+ {
+ g_signal_handlers_disconnect_by_func (app->messages_service,
+ global_status_changed,
+ app);
+ g_clear_object (&app->messages_service);
+ }
}
static void
@@ -262,6 +304,14 @@ messaging_menu_app_init (MessagingMenuApp *app)
app->cancellable,
got_session_bus,
app);
+
+ app->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ "com.canonical.indicator.messages",
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ indicator_messages_appeared,
+ indicator_messages_vanished,
+ app,
+ NULL);
}
/**
@@ -277,7 +327,7 @@ messaging_menu_app_init (MessagingMenuApp *app)
* The messaging menu will return to marking the application as not running as
* soon as the returned #MessagingMenuApp is destroyed.
*
- * Returns: (transfer-full): a new #MessagingMenuApp
+ * Returns: (transfer full): a new #MessagingMenuApp
*/
MessagingMenuApp *
messaging_menu_app_new (const gchar *desktop_id)
@@ -409,6 +459,8 @@ source_action_activated (GTupleAction *action,
const gchar *name = g_action_get_name (G_ACTION (action));
GQuark q = g_quark_from_string (name);
+ messaging_menu_app_remove_source (app, name);
+
g_signal_emit (app, signals[ACTIVATE_SOURCE], q, name);
}
@@ -501,7 +553,7 @@ messaging_menu_app_insert_source (MessagingMenuApp *app,
* messaging_menu_app_append_source:
* @app: a #MessagingMenuApp
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
*
* Appends a new message source to the end of the section representing @app.
@@ -525,7 +577,7 @@ messaging_menu_app_append_source (MessagingMenuApp *app,
* @app: a #MessagingMenuApp
* @position: the position at which to insert the source
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @count: the count for the source
*
@@ -553,7 +605,7 @@ messaging_menu_app_insert_source_with_count (MessagingMenuApp *app,
* messaging_menu_app_append_source_with_count:
* @app: a #MessagingMenuApp
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @count: the count for the source
*
@@ -579,7 +631,7 @@ void messaging_menu_app_append_source_with_count (MessagingMenuApp *app,
* @app: a #MessagingMenuApp
* @position: the position at which to insert the source
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @time: the time when the source was created
*
@@ -606,9 +658,8 @@ messaging_menu_app_insert_source_with_time (MessagingMenuApp *app,
/**
* messaging_menu_app_append_source_with_time:
* @app: a #MessagingMenuApp
- * @position: the position at which to insert the source
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @time: the time when the source was created
*
@@ -635,7 +686,7 @@ messaging_menu_app_append_source_with_time (MessagingMenuApp *app,
* @app: a #MessagingMenuApp
* @position: the position at which to insert the source
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @str: a string associated with the source
*
@@ -662,9 +713,8 @@ messaging_menu_app_insert_source_with_string (MessagingMenuApp *app,
/**
* messaging_menu_app_append_source_with_string:
* @app: a #MessagingMenuApp
- * @position: the position at which to insert the source
* @id: a unique identifier for the source to be added
- * @icon: the icon associated with the source
+ * @icon: (allow-none): the icon associated with the source
* @label: a user-visible string best describing the source
* @str: a string associated with the source
*
@@ -704,22 +754,23 @@ messaging_menu_app_remove_source (MessagingMenuApp *app,
g_return_if_fail (source_id != NULL);
if (g_simple_action_group_lookup (app->source_actions, source_id) == NULL)
- {
- g_warning ("%s: a source with id '%s' doesn't exist", G_STRFUNC, source_id);
return;
- }
n_items = g_menu_model_get_n_items (G_MENU_MODEL (app->menu));
for (i = 0; i < n_items; i++)
{
- const gchar *action = NULL;
+ gchar *action;
- g_menu_model_get_item_attribute (G_MENU_MODEL (app->menu), i,
- "action", "&s", &action);
- if (!g_strcmp0 (action, source_id))
+ if (g_menu_model_get_item_attribute (G_MENU_MODEL (app->menu), i,
+ "action", "s", &action))
{
- g_menu_remove (app->menu, i);
- break;
+ if (!g_strcmp0 (action, source_id))
+ {
+ g_menu_remove (app->menu, i);
+ break;
+ }
+
+ g_free (action);
}
}
@@ -783,7 +834,7 @@ messaging_menu_app_set_source_time (MessagingMenuApp *app,
* messaging_menu_app_set_source_string:
* @app: a #MessagingMenuApp
* @source_id: a source id
- * @string: the new string for the source
+ * @str: the new string for the source
*
* Updates the string displayed next to @source_id to @str.
*