summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2014-01-06 14:05:59 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2014-01-06 16:36:45 +0100
commitf7c5dfdeef65948371c0211ab253eea5edeae695 (patch)
treee91263e1ec1fa1da68151548f412dca1628a2db9 /examples
parentd28ca4cdce0dd6f103af4e6227af985558c32e56 (diff)
downloadgtk+-f7c5dfdeef65948371c0211ab253eea5edeae695.tar.gz
bloatpad: fix the action associated with the notification
Notifications can only be associated with application actions, but clear is a window action. Introduce a "clear-all" action that forwards to clear on all windows. https://bugzilla.gnome.org/show_bug.cgi?id=721633
Diffstat (limited to 'examples')
-rw-r--r--examples/bloatpad.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/examples/bloatpad.c b/examples/bloatpad.c
index 66ae90daa9..fc2415e69d 100644
--- a/examples/bloatpad.c
+++ b/examples/bloatpad.c
@@ -138,6 +138,18 @@ activate_clear (GSimpleAction *action,
}
static void
+activate_clear_all (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkApplication *app = GTK_APPLICATION (user_data);
+ GList *iter;
+
+ for (iter = gtk_application_get_windows (app); iter; iter = iter->next)
+ g_action_group_activate_action (iter->data, "clear", NULL);
+}
+
+static void
text_buffer_changed_cb (GtkTextBuffer *buffer,
BloatPad *app)
{
@@ -170,7 +182,7 @@ text_buffer_changed_cb (GtkTextBuffer *buffer,
GNotification *n;
n = g_notification_new ("Three lines of text");
g_notification_set_body (n, "Keep up the good work!");
- g_notification_add_button (n, "Start over", "app.clear");
+ g_notification_add_button (n, "Start over", "app.clear-all");
g_application_send_notification (G_APPLICATION (app), "three-lines", n);
g_object_unref (n);
}
@@ -450,7 +462,8 @@ static GActionEntry app_entries[] = {
{ "about", about_activated, NULL, NULL, NULL },
{ "quit", quit_activated, NULL, NULL, NULL },
{ "edit-accels", edit_accels },
- { "time-active", NULL, NULL, "false", time_active_changed }
+ { "time-active", NULL, NULL, "false", time_active_changed },
+ { "clear-all", activate_clear_all }
};
static void