Skip to content

Commit

Permalink
Added Keyboard Shortcuts window
Browse files Browse the repository at this point in the history
Coalesce the small, yet disparate shortcut keys available to users
in a separate window.

https://gitlab.gnome.org/GNOME/cheese/issues/9
  • Loading branch information
esoleyman committed May 28, 2019
1 parent 3e40d6f commit 68b69ab
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -194,6 +194,7 @@ noinst_resource_files = \
data/cheese-prefs.ui \
data/headerbar.ui \
data/menus.ui \
data/shortcuts.ui \
data/pixmaps/cheese-1.svg \
data/pixmaps/cheese-2.svg \
data/pixmaps/cheese-3.svg \
Expand Down
4 changes: 4 additions & 0 deletions data/headerbar.ui
Expand Up @@ -12,6 +12,10 @@
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">app.shortcuts</attribute>
</item>
<item>
<attribute name="accel">F1</attribute>
<attribute name="label" translatable="yes">_Help</attribute>
Expand Down
1 change: 1 addition & 0 deletions data/org.gnome.Cheese.gresource.xml
Expand Up @@ -5,6 +5,7 @@
<file>cheese-viewport.json</file>
<file preprocess="xml-stripblanks">cheese-main-window.ui</file>
<file preprocess="xml-stripblanks">cheese-prefs.ui</file>
<file preprocess="xml-stripblanks">shortcuts.ui</file>
<file preprocess="xml-stripblanks">headerbar.ui</file>
<file>pixmaps/cheese-1.svg</file>
<file>pixmaps/cheese-2.svg</file>
Expand Down
60 changes: 60 additions & 0 deletions data/shortcuts.ui
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="shortcuts-cheese">
<property name="modal">1</property>
<child>
<object class="GtkShortcutsSection">
<property name="visible">1</property>
<property name="section-name">shortcuts</property>
<property name="max-height">12</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes">Overview</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">F11</property>
<property name="title" translatable="yes">Fullscreen on / off</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;Q</property>
<property name="title" translatable="yes">Quit the application</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Thumbnails</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;O</property>
<property name="title" translatable="yes">Open</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;ctrl&gt;S</property>
<property name="title" translatable="yes">Save As</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">Delete</property>
<property name="title" translatable="yes">Move to Trash</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="accelerator">&lt;Shift&gt;Delete</property>
<property name="title" translatable="yes">Delete</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
1 change: 1 addition & 0 deletions po/POTFILES.in
Expand Up @@ -5,6 +5,7 @@
[type: gettext/glade]data/cheese-prefs.ui
[type: gettext/glade]data/headerbar.ui
[type: gettext/glade]data/menus.ui
[type: gettext/glade]data/shortcuts.ui
data/org.gnome.Cheese.appdata.xml.in
data/org.gnome.Cheese.desktop.in.in
[type: gettext/gsettings]data/org.gnome.Cheese.gschema.xml
Expand Down
31 changes: 31 additions & 0 deletions src/cheese-application.vala
Expand Up @@ -36,6 +36,8 @@ public class Cheese.Application : Gtk.Application
private Camera camera;
private PreferencesDialog preferences_dialog;

private Gtk.ShortcutsWindow shortcuts_window;

private const GLib.ActionEntry action_entries[] = {
{ "shoot", on_shoot },
{ "mode", on_action_radio, "s", "'photo'", on_mode_change },
Expand All @@ -44,6 +46,7 @@ public class Cheese.Application : Gtk.Application
{ "wide-mode", on_action_toggle, null, "false", on_wide_mode_change },
{ "effects", on_action_toggle, null, "false", on_effects_change },
{ "preferences", on_preferences },
{ "shortcuts", on_shortcuts },
{ "help", on_help },
{ "about", on_about },
{ "quit", on_quit }
Expand Down Expand Up @@ -469,6 +472,34 @@ public class Cheese.Application : Gtk.Application
preferences_dialog.show ();
}

/**
* Show the keyboard shortcuts.
*/
private void on_shortcuts ()
{
if (shortcuts_window == null)
{
var builder = new Gtk.Builder ();
try
{
builder.add_from_resource ("/org/gnome/Cheese/shortcuts.ui");
}
catch (Error e)
{
error ("Error loading shortcuts window UI: %s", e.message);
}

shortcuts_window = builder.get_object ("shortcuts-cheese") as Gtk.ShortcutsWindow;
shortcuts_window.close.connect ( (event) => { shortcuts_window = null; } );
}

if (get_active_window () != shortcuts_window.get_transient_for ())
shortcuts_window.set_transient_for (get_active_window ());

shortcuts_window.show_all ();
shortcuts_window.present ();
}

/**
* Show the Cheese help contents.
*/
Expand Down

0 comments on commit 68b69ab

Please sign in to comment.