Add Gtk.ShortcutsWindows to application (resolve #14)
This commit is contained in:
parent
38c21cb468
commit
03fa9c4db7
5 changed files with 164 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
<gresource prefix="/de/coderkun/mcg">
|
||||
<file>gtk.glade</file>
|
||||
<file>gtk.css</file>
|
||||
<file>gtk.shortcuts.ui</file>
|
||||
<file>menu.ui</file>
|
||||
<file>mcg.svg</file>
|
||||
<file>noise-texture.png</file>
|
||||
|
|
|
|||
123
data/gtk.shortcuts.ui
Normal file
123
data/gtk.shortcuts.ui
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.18"/>
|
||||
<object class="GtkShortcutsWindow" id="shortcuts-dialog">
|
||||
<property name="modal">True</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsSection">
|
||||
<property name="visible">1</property>
|
||||
<property name="section-name">shortcuts</property>
|
||||
<property name="title" translatable="yes">Application</property>
|
||||
<property name="max-height">10</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">General</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>KP_1</property>
|
||||
<property name="title" translatable="yes">Switch to the Connection panel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>KP_2</property>
|
||||
<property name="title" translatable="yes">Switch to the Cover panel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>KP_3</property>
|
||||
<property name="title" translatable="yes">Switch to the Playlist panel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>KP_4</property>
|
||||
<property name="title" translatable="yes">Switch to the Library panel</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>k</property>
|
||||
<property name="title" translatable="yes">Show the keyboard shortcuts (this dialog)</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>i</property>
|
||||
<property name="title" translatable="yes">Open the info dialog</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>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">Player</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>c</property>
|
||||
<property name="title" translatable="yes">Connect or disconnect</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>p</property>
|
||||
<property name="title" translatable="yes">Switch between play and pause</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>r</property>
|
||||
<property name="title" translatable="yes">Clear the playlist</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Cover Panel</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><alt>Return F11</property>
|
||||
<property name="title" translatable="yes">Show the cover in fullscreen mode</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Library Panel</property>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><primary>f</property>
|
||||
<property name="title" translatable="yes">Search the library</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
@ -47,6 +47,11 @@
|
|||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="action">app.shortcuts</attribute>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="accel"><Primary>k</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="action">app.info</attribute>
|
||||
<attribute name="label" translatable="yes">Info</attribute>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ class Application(Gtk.Application):
|
|||
def __init__(self):
|
||||
Gtk.Application.__init__(self, application_id=Application.ID, flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
self._window = None
|
||||
self._shortcuts_window = None
|
||||
self._info_dialog = None
|
||||
self._verbosity = logging.WARNING
|
||||
self.add_main_option_entries([
|
||||
|
|
@ -68,6 +69,14 @@ class Application(Gtk.Application):
|
|||
self._window.present()
|
||||
|
||||
|
||||
def on_menu_shortcuts(self, action, value):
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(Application.DOMAIN)
|
||||
builder.add_from_resource(self._get_resource_path('gtk.shortcuts.ui'))
|
||||
shortcuts_dialog = widgets.ShortcutsDialog(builder, self._window)
|
||||
shortcuts_dialog.present()
|
||||
|
||||
|
||||
def on_menu_info(self, action, value):
|
||||
if not self._info_dialog:
|
||||
self._info_dialog = widgets.InfoDialog(self._builder)
|
||||
|
|
@ -119,6 +128,9 @@ class Application(Gtk.Application):
|
|||
|
||||
|
||||
def _setup_actions(self):
|
||||
action = Gio.SimpleAction.new("shortcuts", None)
|
||||
action.connect('activate', self.on_menu_shortcuts)
|
||||
self.add_action(action)
|
||||
action = Gio.SimpleAction.new("info", None)
|
||||
action.connect('activate', self.on_menu_info)
|
||||
self.add_action(action)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,25 @@ from mcg.zeroconf import ZeroconfProvider
|
|||
|
||||
|
||||
|
||||
class ShortcutsDialog():
|
||||
|
||||
|
||||
def __init__(self, builder, window):
|
||||
# Widgets
|
||||
self._window = builder.get_object('shortcuts-dialog')
|
||||
self._window.set_transient_for(window.get())
|
||||
|
||||
|
||||
def get(self):
|
||||
return self._window
|
||||
|
||||
|
||||
def present(self):
|
||||
self._window.present()
|
||||
|
||||
|
||||
|
||||
|
||||
class InfoDialog():
|
||||
|
||||
|
||||
|
|
@ -183,6 +202,10 @@ class Window():
|
|||
self._appwindow.add_action(self._panel_action)
|
||||
|
||||
|
||||
def get(self):
|
||||
return self._appwindow
|
||||
|
||||
|
||||
def present(self):
|
||||
self._appwindow.present()
|
||||
self._appwindow.resize(800, 600)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue