diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index e666f0864a..d992402fd5 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -546,6 +546,27 @@ row_activated (GtkListBox *box, GtkListBoxRow *row) } } +static void +set_accel (GtkApplication *app, GtkWidget *widget) +{ + GtkWidget *accel_label; + const gchar *action; + gchar **accels; + guint key; + GdkModifierType mods; + + accel_label = gtk_bin_get_child (GTK_BIN (widget)); + g_assert (GTK_IS_ACCEL_LABEL (accel_label)); + + action = gtk_actionable_get_action_name (GTK_ACTIONABLE (widget)); + accels = gtk_application_get_accels_for_action (app, action); + + gtk_accelerator_parse (accels[0], &key, &mods); + gtk_accel_label_set_accel (GTK_ACCEL_LABEL (accel_label), key, mods); + + g_strfreev (accels); +} + static void activate (GApplication *app) { @@ -658,6 +679,12 @@ activate (GApplication *app) populate_colors ((GtkWidget *)gtk_builder_get_object (builder, "munsell")); + set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "quitmenuitem"))); + set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "deletemenuitem"))); + set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "searchmenuitem"))); + set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "darkmenuitem"))); + set_accel (GTK_APPLICATION (app), GTK_WIDGET (gtk_builder_get_object (builder, "aboutmenuitem"))); + gtk_widget_show_all (GTK_WIDGET (window)); g_object_unref (builder);