Commit 2cb10529 authored by Matthias Clasen's avatar Matthias Clasen

widget-factory: Show accelerators

We set this up manually here. This could be automated by
constructing the menubar from a menu model.
parent 144083d4
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment