Commit 07a9eeef authored by Canek Peláez's avatar Canek Peláez
Browse files

Add shortcuts dialog.

parent 48c4eb45
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3,5 +3,7 @@
  <gresource prefix="/mx/unam/MLM">
    <file>mlm.css</file>
    <file preprocess="xml-stripblanks">mlm.ui</file>
    <file preprocess="xml-stripblanks">mlm.svg</file>
    <file preprocess="xml-stripblanks">shortcuts.ui</file>
  </gresource>
</gresources>

data/shortcuts.ui

0 → 100644
+79 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <requires lib="gtk+" version="3.20"/>
  <template class="MLMShortcutsWindow" parent="GtkShortcutsWindow">
    <property name="visible">false</property>
    <property name="modal">true</property>
    <property name="icon">resource:///mx/unam/MLM/mlm.svg</property>
    <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
    <child>
      <object class="GtkShortcutsSection" id="all">
        <property name="visible">true</property>
        <property name="section-name">main</property>
        <property name="title">Main shortcuts</property>
        <property name="max-height">10</property>
        <child>
          <object class="GtkShortcutsGroup" id="global">
            <property name="visible">true</property>
            <property name="title">Global</property>
            <child>
              <object class="GtkShortcutsShortcut" id="shortcuts">
                <property name="visible">true</property>
                <property name="title">Show shortcuts dialog</property>
                <property name="accelerator">&lt;ctrl&gt;t</property>
              </object>
            </child>
            <child>
              <object class="GtkShortcutsShortcut" id="about">
                <property name="visible">true</property>
                <property name="title">Show about dialog</property>
                <property name="accelerator">&lt;ctrl&gt;b</property>
              </object>
            </child>
            <child>
              <object class="GtkShortcutsShortcut" id="quit">
                <property name="visible">true</property>
                <property name="title">Quit application</property>
                <property name="accelerator">&lt;ctrl&gt;q</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkShortcutsGroup" id="tags">
            <property name="visible">true</property>
            <property name="title">Tags</property>
            <child>
              <object class="GtkShortcutsShortcut" id="previous">
                <property name="visible">true</property>
                <property name="title">Go to previous file</property>
                <property name="accelerator">&lt;ctrl&gt;Page_Up</property>
              </object>
            </child>
            <child>
              <object class="GtkShortcutsShortcut" id="next">
                <property name="visible">true</property>
                <property name="title">Go to next file</property>
                <property name="accelerator">&lt;ctrl&gt;Page_Down</property>
              </object>
            </child>
            <child>
              <object class="GtkShortcutsShortcut" id="save">
                <property name="visible">true</property>
                <property name="title">Save file</property>
                <property name="accelerator">&lt;ctrl&gt;s</property>
              </object>
            </child>
            <child>
              <object class="GtkShortcutsShortcut" id="play">
                <property name="visible">true</property>
                <property name="title">Play file</property>
                <property name="accelerator">&lt;ctrl&gt;space</property>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </template>
</interface>
+2 −1
Original line number Diff line number Diff line
@@ -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 = [
+11 −0
Original line number Diff line number Diff line
@@ -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 =
+10 −0
Original line number Diff line number Diff line
@@ -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[]{"<Ctrl>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());
Loading