[gtk+] widget-factory: Add accelerators for some actions
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget-factory: Add accelerators for some actions
- Date: Sun, 20 Jul 2014 05:09:16 +0000 (UTC)
commit 48b9b4520b9bee794c712d3846142f6b86aa9284
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 20 00:15:03 2014 -0400
widget-factory: Add accelerators for some actions
With this, Ctrl-Q will close the window, and Ctrl-D will
toggle the dark theme. The accelerators are currently not
shown in the (manually constructed) menus.
demos/widget-factory/widget-factory.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 97f65b6..e666f08 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -561,6 +561,15 @@ activate (GApplication *app)
{ "search", activate_search, NULL, NULL, NULL },
{ "delete", activate_delete, NULL, NULL, NULL }
};
+ struct {
+ const gchar *action_and_target;
+ const gchar *accelerators[2];
+ } accels[] = {
+ { "win.dark", { "<Primary>d", NULL } },
+ { "win.search", { "<Primary>s", NULL } },
+ { "win.delete", { "Delete", NULL } }
+ };
+ gint i;
builder = gtk_builder_new_from_resource ("/org/gtk/WidgetFactory/widget-factory.ui");
gtk_builder_add_callback_symbol (builder, "on_entry_icon_release", (GCallback)on_entry_icon_release);
@@ -572,6 +581,9 @@ activate (GApplication *app)
win_entries, G_N_ELEMENTS (win_entries),
window);
+ for (i = 0; i < G_N_ELEMENTS (accels); i++)
+ gtk_application_set_accels_for_action (GTK_APPLICATION (app), accels[i].action_and_target,
accels[i].accelerators);
+
widget = (GtkWidget *)gtk_builder_get_object (builder, "statusbar");
gtk_statusbar_push (GTK_STATUSBAR (widget), 0, "All systems are operating normally.");
g_action_map_add_action (G_ACTION_MAP (window),
@@ -665,6 +677,14 @@ main (int argc, char *argv[])
{ "dessert", NULL, "s", "'bars'", NULL },
{ "pay", NULL, "s", NULL, NULL }
};
+ struct {
+ const gchar *action_and_target;
+ const gchar *accelerators[2];
+ } accels[] = {
+ { "app.about", { "F1", NULL } },
+ { "app.quit", { "<Primary>q", NULL } },
+ };
+ gint i;
gint status;
app = gtk_application_new ("org.gtk.WidgetFactory", G_APPLICATION_NON_UNIQUE);
@@ -672,6 +692,8 @@ main (int argc, char *argv[])
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
app);
+ for (i = 0; i < G_N_ELEMENTS (accels); i++)
+ gtk_application_set_accels_for_action (GTK_APPLICATION (app), accels[i].action_and_target,
accels[i].accelerators);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]