summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-09-25 17:08:28 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2020-09-25 17:08:28 +0100
commitd466bb11ee22c12e634979698f37aef4e4817172 (patch)
tree48b3463d14f06462c41bc127596c5e78030bdf4a
parentb1d258fe08344c9f38f59476d8930f1aaae74908 (diff)
parente5119b9788eec1908381b0fee00d2ed105c782bc (diff)
downloadgnome-dictionary-d466bb11ee22c12e634979698f37aef4e4817172.tar.gz
Merge branch 'libreajans/gnome-dictionary-helpoverlay'
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/gdict-app-menus.ui4
-rw-r--r--src/gdict-app.c61
-rw-r--r--src/gdict-help-overlay.ui170
-rw-r--r--src/gdict.gresource.xml1
5 files changed, 229 insertions, 8 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 07fd624..859bc71 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,6 +13,7 @@ src/gdict-app.c
src/gdict-client-context.c
src/gdict-database-chooser.c
src/gdict-defbox.c
+src/gdict-help-overlay.ui
src/gdict-pref-dialog.c
src/gdict-pref-dialog.ui
src/gdict-print.c
diff --git a/src/gdict-app-menus.ui b/src/gdict-app-menus.ui
index e8b6107..5c045d5 100644
--- a/src/gdict-app-menus.ui
+++ b/src/gdict-app-menus.ui
@@ -94,6 +94,10 @@
<attribute name="action">app.preferences</attribute>
</item>
<item>
+ <attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
+ <attribute name="action">win.show-help-overlay</attribute>
+ </item>
+ <item>
<attribute name="label" translatable="yes">_Help</attribute>
<attribute name="action">app.help</attribute>
<attribute name="accel">F1</attribute>
diff --git a/src/gdict-app.c b/src/gdict-app.c
index 12021f2..86af0d7 100644
--- a/src/gdict-app.c
+++ b/src/gdict-app.c
@@ -168,13 +168,28 @@ gdict_app_cmd_quit (GSimpleAction *action,
g_list_foreach (windows, (GFunc)gtk_widget_destroy, NULL);
}
+static void
+gdict_app_cmd_close (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GtkApplication *app = user_data;
+ GList *windows;
+
+ windows = gtk_application_get_windows (app);
+
+ if (windows != NULL)
+ gtk_window_close (windows->data);
+}
+
static const GActionEntry app_entries[] =
{
{ "new", gdict_app_cmd_new, NULL, NULL, NULL },
{ "preferences", gdict_app_cmd_preferences, NULL, NULL, NULL },
{ "help", gdict_app_cmd_help, NULL, NULL, NULL },
{ "about", gdict_app_cmd_about, NULL, NULL, NULL },
- { "quit", gdict_app_cmd_quit, NULL, NULL, NULL }
+ { "quit", gdict_app_cmd_quit, NULL, NULL, NULL },
+ { "close", gdict_app_cmd_close, NULL, NULL, NULL }
};
static void
@@ -324,17 +339,47 @@ gdict_app_activate (GApplication *application)
static void
gdict_app_startup (GApplication *application)
{
- static const char *lookup_accels[2] = { "<Primary>l", NULL };
- static const char *escape_accels[2] = { "Escape", NULL };
+ static const gchar *action_accels[] =
+ {
+ /* Win shortcuts */
+ "win.save-as", "<Primary>s", NULL,
+ "win.preview", "<Primary><Shift>p", NULL ,
+ "win.print", "<Primary>p", NULL,
+ "win.find", "<Primary>f", NULL,
+ "win.previous-def", "Page_Up", NULL,
+ "win.next-def", "Page_Down", NULL,
+ "win.first-def", "Home", NULL,
+ "win.last-def", "End", NULL,
+ "win.view-sidebar", "F9", NULL,
+ "win.view-speller", "<Primary>t", NULL,
+ "win.view-source", "<Primary>d", NULL,
+ "win.view-strat", "<Primary>r", NULL,
+ "win.lookup", "<Primary>l", NULL,
+ "win.escape", "Escape", NULL,
+ "win.help-overlay-ui", "<Primary>question", NULL,
+ /* App shortcuts */
+ "app.new", "<Primary>n", NULL,
+ "app.preferences", "<Primary>comma", NULL,
+ "app.help", "F1", NULL,
+ "app.close", "<Primary>w", NULL,
+ "app.quit", "<Primary>q", NULL,
+ NULL /* Terminating NULL */
+ };
+
+ g_set_application_name (_("Dictionary"));
G_APPLICATION_CLASS (gdict_app_parent_class)->startup (application);
- g_action_map_add_action_entries (G_ACTION_MAP (application),
- app_entries, G_N_ELEMENTS (app_entries),
- application);
+ g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries,
+ G_N_ELEMENTS (app_entries), application);
- gtk_application_set_accels_for_action (GTK_APPLICATION (application), "win.lookup", lookup_accels);
- gtk_application_set_accels_for_action (GTK_APPLICATION (application), "win.escape", escape_accels);
+ GtkApplication *gtk_app = GTK_APPLICATION (application);
+ for (const char **it = action_accels;
+ it[0] != NULL;
+ it += g_strv_length ((char **) it) + 1)
+ {
+ gtk_application_set_accels_for_action (gtk_app, it[0], &it[1]);
+ }
}
static void
diff --git a/src/gdict-help-overlay.ui b/src/gdict-help-overlay.ui
new file mode 100644
index 0000000..209afdb
--- /dev/null
+++ b/src/gdict-help-overlay.ui
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkShortcutsWindow" id="help_overlay">
+ <property name="modal">true</property>
+ <child>
+ <object class="GtkShortcutsSection">
+ <property name="visible">true</property>
+ <property name="section-name">shortcuts</property>
+ <property name="max-height">13</property>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">General</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">F1</property>
+ <property name="title" translatable="yes" context="shortcut window">Show help</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Show keyboard shortcuts</property>
+ <property name="accelerator">&lt;Primary&gt;question</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;N</property>
+ <property name="title" translatable="yes" context="shortcut window">Open a new window</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;W</property>
+ <property name="title" translatable="yes" context="shortcut window">Close current window</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Quit</property>
+ <property name="accelerator">&lt;Primary&gt;Q</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;comma</property>
+ <property name="title" translatable="yes" context="shortcut window">Preferences</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">F9</property>
+ <property name="title" translatable="yes" context="shortcut window">View sidebar</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Dictionary definitions</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;T</property>
+ <property name="title" translatable="yes" context="shortcut window">Similar words</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;D</property>
+ <property name="title" translatable="yes" context="shortcut window">Dictionary sources</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;R</property>
+ <property name="title" translatable="yes" context="shortcut window">Available strategies</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Navigate within a definition</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">Page_Up</property>
+ <property name="title" translatable="yes" context="shortcut window">Previous definition</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">Page_Down</property>
+ <property name="title" translatable="yes" context="shortcut window">Next definition</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">Home</property>
+ <property name="title" translatable="yes" context="shortcut window">First definition</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">End</property>
+ <property name="title" translatable="yes" context="shortcut window">Last definition</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsGroup">
+ <property name="visible">true</property>
+ <property name="title" translatable="yes" context="shortcut window">Others</property>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;L</property>
+ <property name="title" translatable="yes" context="shortcut window">Search within a definition</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;F</property>
+ <property name="title" translatable="yes" context="shortcut window">Find in text</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;S</property>
+ <property name="title" translatable="yes" context="shortcut window">Save as copy</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;&lt;Shift&gt;S</property>
+ <property name="title" translatable="yes" context="shortcut window">Print preview</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">true</property>
+ <property name="accelerator">&lt;Primary&gt;P</property>
+ <property name="title" translatable="yes" context="shortcut window">Print</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/gdict.gresource.xml b/src/gdict.gresource.xml
index d95716e..d16f4a6 100644
--- a/src/gdict.gresource.xml
+++ b/src/gdict.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/Dictionary">
<file preprocess="xml-stripblanks" alias="gtk/menus.ui">gdict-app-menus.ui</file>
+ <file preprocess="xml-stripblanks" alias="gtk/help-overlay.ui">gdict-help-overlay.ui</file>
<file preprocess="xml-stripblanks">gdict-app-window.ui</file>
<file preprocess="xml-stripblanks">gdict-pref-dialog.ui</file>
<file preprocess="xml-stripblanks">gdict-source-dialog.ui</file>