From 1ae898bf0b18748efe49cb53a975fea3bba405b2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 26 Apr 2020 22:14:10 -0400 Subject: gtk-demo: Add a shortcuts window Its not very impressive here, but still good to have. --- demos/gtk-demo/demo.gresource.xml | 3 +++ demos/gtk-demo/help-overlay.ui | 25 +++++++++++++++++++++++++ demos/gtk-demo/main.c | 11 +++++++++++ demos/gtk-demo/main.ui | 4 ++++ 4 files changed, 43 insertions(+) create mode 100644 demos/gtk-demo/help-overlay.ui (limited to 'demos') diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml index 850750e5ef..19a2f8a168 100644 --- a/demos/gtk-demo/demo.gresource.xml +++ b/demos/gtk-demo/demo.gresource.xml @@ -309,4 +309,7 @@ icons/16x16/status/battery-caution-charging-symbolic.symbolic.png icons/16x16/categories/applications-other.png + + help-overlay.ui + diff --git a/demos/gtk-demo/help-overlay.ui b/demos/gtk-demo/help-overlay.ui new file mode 100644 index 0000000000..ae172ee7a6 --- /dev/null +++ b/demos/gtk-demo/help-overlay.ui @@ -0,0 +1,25 @@ + + + + + + + General + + + F1 + Show About Dialog + + + + + <Control>q + Quit + + + + + + + + diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index 53f2f04d9b..a31036d916 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -1186,6 +1186,14 @@ main (int argc, char **argv) { "quit", activate_quit, NULL, NULL, NULL }, { "inspector", activate_inspector, NULL, NULL, NULL }, }; + struct { + const gchar *action_and_target; + const gchar *accelerators[2]; + } accels[] = { + { "app.about", { "F1", NULL } }, + { "app.quit", { "q", NULL } }, + }; + int i; /* Most code in gtk-demo is intended to be exemplary, but not * these few lines, which are just a hack so gtk-demo will work @@ -1203,6 +1211,9 @@ main (int argc, char **argv) app_entries, G_N_ELEMENTS (app_entries), app); + for (i = 0; i < G_N_ELEMENTS (accels); i++) + gtk_application_set_accels_for_action (app, accels[i].action_and_target, accels[i].accelerators); + g_application_add_main_option (G_APPLICATION (app), "version", 0, 0, G_OPTION_ARG_NONE, "Show program version", NULL); g_application_add_main_option (G_APPLICATION (app), "run", 0, 0, G_OPTION_ARG_STRING, "Run an example", "EXAMPLE"); g_application_add_main_option (G_APPLICATION (app), "list", 0, 0, G_OPTION_ARG_NONE, "List examples", NULL); diff --git a/demos/gtk-demo/main.ui b/demos/gtk-demo/main.ui index d4cc88a96f..5256095fc6 100644 --- a/demos/gtk-demo/main.ui +++ b/demos/gtk-demo/main.ui @@ -6,6 +6,10 @@ _Inspector app.inspector + + _Keyboard Shortcuts + win.show-help-overlay + _About GTK Demo app.about -- cgit v1.2.1