From 07a9eeefc4e329803aa504ed381d3fa211aa515a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Canek=20Pel=C3=A1ez=20Vald=C3=A9s?= Date: Wed, 20 Feb 2019 18:36:21 -0600 Subject: [PATCH] Add shortcuts dialog. --- data/mlm.gresource.xml | 2 + data/shortcuts.ui | 79 +++++++++++++++++++++++++ meson.build | 3 +- src/application/application-window.vala | 11 ++++ src/application/application.vala | 10 ++++ src/application/shortcuts-window.vala | 27 +++++++++ 6 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 data/shortcuts.ui create mode 100644 src/application/shortcuts-window.vala diff --git a/data/mlm.gresource.xml b/data/mlm.gresource.xml index 2cab537..b24f07a 100644 --- a/data/mlm.gresource.xml +++ b/data/mlm.gresource.xml @@ -3,5 +3,7 @@ mlm.css mlm.ui + mlm.svg + shortcuts.ui diff --git a/data/shortcuts.ui b/data/shortcuts.ui new file mode 100644 index 0000000..57c5d70 --- /dev/null +++ b/data/shortcuts.ui @@ -0,0 +1,79 @@ + + + + + diff --git a/meson.build b/meson.build index 04992ce..08f6efd 100644 --- a/meson.build +++ b/meson.build @@ -134,7 +134,8 @@ mlm_gui_sources = [ 'src/application/encoder.vala', 'src/application/main.vala', 'src/application/media.vala', - 'src/application/player.vala' + 'src/application/player.vala', + 'src/application/shortcuts-window.vala' ] mlm_gui_dependencies = [ diff --git a/src/application/application-window.vala b/src/application/application-window.vala index df4dffa..9e26092 100644 --- a/src/application/application-window.vala +++ b/src/application/application-window.vala @@ -157,6 +157,8 @@ namespace MLM { [GtkChild] private Gtk.Label filename_label; + /* The shortcuts dialog. */ + private ShortcutsWindow shortcuts; /* The MLM application. */ private Application mlm; /* The file tags. */ @@ -462,6 +464,15 @@ namespace MLM { "wrap-license", true); } + /** + * Shows the shortcuts dialog. + */ + public void show_shortcuts_dialog() { + if (shortcuts == null) + shortcuts = new ShortcutsWindow(); + shortcuts.show_all(); + } + /* Selects an image from a file. */ private uint8[]? select_image(string title) { var dialog = diff --git a/src/application/application.vala b/src/application/application.vala index d8c1c58..912515d 100644 --- a/src/application/application.vala +++ b/src/application/application.vala @@ -90,6 +90,11 @@ namespace MLM { action.activate.connect(stop_encoder); add_action(action); + action = new GLib.SimpleAction("shortcuts", null); + action.activate.connect(shortcuts); + add_action(action); + set_accels_for_action("app.shortcuts", new string[]{"T"}); + action = new GLib.SimpleAction("about", null); action.activate.connect(about); add_action(action); @@ -242,6 +247,11 @@ namespace MLM { tags.update(); } + /* The shortcuts action. */ + private void shortcuts() { + window.show_shortcuts_dialog(); + } + /* Compares two files by path. */ private int compare_files_by_path(GLib.File a, GLib.File b) { return a.get_path().collate(b.get_path()); diff --git a/src/application/shortcuts-window.vala b/src/application/shortcuts-window.vala new file mode 100644 index 0000000..96c5ce3 --- /dev/null +++ b/src/application/shortcuts-window.vala @@ -0,0 +1,27 @@ +/* + * This file is part of mlm. + * + * Copyright © 2016-2018 Canek Peláez Valdés + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +namespace MLM { + + /** + * Class for shortcuts windows. + */ + [GtkTemplate (ui = "/mx/unam/MLM/shortcuts.ui")] + public class ShortcutsWindow : Gtk.ShortcutsWindow {} +} -- GitLab