aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-messages.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2012-08-27 13:24:37 +0200
committerSebastien Bacher <seb128@ubuntu.com>2012-08-27 13:24:37 +0200
commit5f974f7290cb505a341c579a3fdd8efc601477fe (patch)
treeb40e469d8d8bfaa6c95364e668f3a96c54cc41e9 /src/indicator-messages.c
parentae735e195693b4179fca9e878c1518109a6fc6cd (diff)
parentacc4b2a7088a47ef3d7b8570f88833399dbfe783 (diff)
downloadayatana-indicator-messages-5f974f7290cb505a341c579a3fdd8efc601477fe.tar.gz
ayatana-indicator-messages-5f974f7290cb505a341c579a3fdd8efc601477fe.tar.bz2
ayatana-indicator-messages-5f974f7290cb505a341c579a3fdd8efc601477fe.zip
Backported fixes from trunk up to r295
Diffstat (limited to 'src/indicator-messages.c')
-rw-r--r--src/indicator-messages.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index b3166f5..4f5a012 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -90,6 +90,10 @@ static void menu_items_changed (GMenuModel *menu,
gint removed,
gint added,
gpointer user_data);
+static void messages_state_changed (GActionGroup *action_group,
+ gchar *action_name,
+ GVariant *value,
+ gpointer user_data);
G_DEFINE_TYPE (IndicatorMessages, indicator_messages, INDICATOR_OBJECT_TYPE);
@@ -118,8 +122,9 @@ indicator_messages_init (IndicatorMessages *self)
g_signal_connect (self->service, "connection-change",
G_CALLBACK (service_connection_changed), self);
- self->menu_wrapper = g_object_ref_sink (g_menu_new ());
+ self->menu_wrapper = g_menu_new ();
self->gtkmenu = gtk_menu_new_from_model (G_MENU_MODEL (self->menu_wrapper));
+ g_object_ref_sink (self->gtkmenu);
self->image = g_object_ref_sink (gtk_image_new ());
@@ -171,7 +176,10 @@ static void service_connection_changed (IndicatorServiceManager *sm,
GDBusConnection *bus;
GError *error = NULL;
- g_clear_object (&self->actions);
+ if (self->actions != NULL) {
+ g_signal_handlers_disconnect_by_func (self->actions, messages_state_changed, self);
+ g_clear_object (&self->actions);
+ }
if (self->menu != NULL) {
g_signal_handlers_disconnect_by_func (self->menu, menu_items_changed, self);
g_clear_object (&self->menu);
@@ -195,6 +203,8 @@ static void service_connection_changed (IndicatorServiceManager *sm,
gtk_widget_insert_action_group (self->gtkmenu,
get_name_hint (INDICATOR_OBJECT (self)),
self->actions);
+ g_signal_connect (self->actions, "action-state-changed::messages",
+ G_CALLBACK (messages_state_changed), self);
self->menu = G_MENU_MODEL (g_dbus_menu_model_get (bus,
INDICATOR_MESSAGES_DBUS_NAME,
@@ -322,3 +332,19 @@ menu_items_changed (GMenuModel *menu,
update_menu (self);
}
}
+
+static void
+messages_state_changed (GActionGroup *action_group,
+ gchar *action_name,
+ GVariant *value,
+ gpointer user_data)
+{
+ IndicatorMessages *self = user_data;
+
+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN));
+
+ if (g_variant_get_boolean (value))
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->image), "indicator-messages-new", GTK_ICON_SIZE_MENU);
+ else
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->image), "indicator-messages", GTK_ICON_SIZE_MENU);
+}