aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app-section.c39
-rw-r--r--src/app-section.h1
-rw-r--r--src/messages-service.c14
3 files changed, 51 insertions, 3 deletions
diff --git a/src/app-section.c b/src/app-section.c
index 35a842f..e7a2e1d 100644
--- a/src/app-section.c
+++ b/src/app-section.c
@@ -89,6 +89,7 @@ static void action_state_changed (GActionGroup *group,
static void action_removed (GActionGroup *group,
const gchar *action_name,
gpointer user_data);
+static gboolean action_draws_attention (GVariant *state);
/* GObject Boilerplate */
G_DEFINE_TYPE (AppSection, app_section, G_TYPE_OBJECT);
@@ -376,6 +377,44 @@ app_section_get_draws_attention (AppSection *self)
return priv->draws_attention;
}
+void
+app_section_clear_draws_attention (AppSection *self)
+{
+ AppSectionPrivate * priv = self->priv;
+ gchar **action_names;
+ gchar **it;
+
+ if (priv->actions == NULL)
+ return;
+
+ action_names = g_action_group_list_actions (priv->actions);
+
+ for (it = action_names; *it; it++) {
+ GVariant *state;
+
+ state = g_action_group_get_action_state (priv->actions, *it);
+ if (!state)
+ continue;
+
+ /* clear draws-attention while preserving other state */
+ if (action_draws_attention (state)) {
+ guint32 count;
+ gint64 time;
+ const gchar *str;
+ GVariant *new_state;
+
+ g_variant_get (state, "(ux&sb)", &count, &time, &str, NULL);
+
+ new_state = g_variant_new ("(uxsb)", count, time, str, FALSE);
+ g_action_group_change_action_state (priv->actions, *it, new_state);
+ }
+
+ g_variant_unref (state);
+ }
+
+ g_strfreev (action_names);
+}
+
static void
application_vanished (GDBusConnection *bus,
const gchar *name,
diff --git a/src/app-section.h b/src/app-section.h
index 935f7a2..9b2c99d 100644
--- a/src/app-section.h
+++ b/src/app-section.h
@@ -57,6 +57,7 @@ GActionGroup * app_section_get_actions (AppSection *self);
GMenuModel * app_section_get_menu (AppSection *appitem);
GAppInfo * app_section_get_app_info (AppSection *appitem);
gboolean app_section_get_draws_attention (AppSection *appitem);
+void app_section_clear_draws_attention (AppSection *appitem);
void app_section_set_object_path (AppSection *self,
GDBusConnection *bus,
const gchar *bus_name,
diff --git a/src/messages-service.c b/src/messages-service.c
index 209abe5..2fa36b2 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -216,12 +216,20 @@ service_shutdown (IndicatorService * service, gpointer user_data)
}
static void
+app_section_remove_attention (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ AppSection *section = value;
+ app_section_clear_draws_attention (section);
+}
+
+static void
clear_action_activate (GSimpleAction *simple,
GVariant *param,
gpointer user_data)
{
- MessageServiceDbus *msg_service = user_data;
- message_service_dbus_set_attention(msg_service, FALSE);
+ g_hash_table_foreach (applications, app_section_remove_attention, NULL);
}
static void
@@ -352,7 +360,7 @@ main (int argc, char ** argv)
g_bus_get (G_BUS_TYPE_SESSION, NULL, got_bus, NULL);
actions = g_simple_action_group_new ();
- g_simple_action_group_add_entries (actions, entries, G_N_ELEMENTS (entries), dbus_interface);
+ g_simple_action_group_add_entries (actions, entries, G_N_ELEMENTS (entries), NULL);
action_muxer = g_action_muxer_new ();
g_action_muxer_insert (action_muxer, NULL, G_ACTION_GROUP (actions));