Add Keyboard Shortcuts window
This commit is contained in:
parent
366246d0f3
commit
efa49fdbd9
@ -91,6 +91,7 @@ def create_hamburger_model(export_menu, tools_menu):
|
||||
|
||||
part = Gio.Menu.new()
|
||||
part.append(gettext("Preferences"), "app.preferences")
|
||||
part.append(gettext("Keyboard Shortcuts"), "app.shortcuts")
|
||||
part.append(gettext("About Gaphor"), "app.about")
|
||||
model.append_section(None, part)
|
||||
|
||||
|
194
gaphor/ui/shortcuts.glade
Normal file
194
gaphor/ui/shortcuts.glade
Normal file
@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.17 -->
|
||||
|
||||
<object class="GtkShortcutsWindow" id="shortcuts-gaphor">
|
||||
<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>
|
||||
|
||||
<!-- Overview shortcuts -->
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Overview</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>z</property>
|
||||
<property name="title" translatable="yes">Undo</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary><Shift>z</property>
|
||||
<property name="title" translatable="yes">Redo</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator">F2</property>
|
||||
<property name="title" translatable="yes">Edit</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>e</property>
|
||||
<property name="title" translatable="yes">Show/Hide Editor</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Ctrl>q</property>
|
||||
<property name="title" translatable="yes">Quit Gaphor</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- File shortcuts -->
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Files</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>n</property>
|
||||
<property name="title" translatable="yes">New</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>o</property>
|
||||
<property name="title" translatable="yes">Open</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>s</property>
|
||||
<property name="title" translatable="yes">Save</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary><Shift>s</property>
|
||||
<property name="title" translatable="yes">Save As</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>q</property>
|
||||
<property name="title" translatable="yes">Quit</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Diagram shortcuts -->
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Diagrams</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>a</property>
|
||||
<property name="title" translatable="yes">Select All</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary><Shift>a</property>
|
||||
<property name="title" translatable="yes">Deselect all</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>c</property>
|
||||
<property name="title" translatable="yes">Copy</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>v</property>
|
||||
<property name="title" translatable="yes">Paste</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator">Delete</property>
|
||||
<property name="title" translatable="yes">Delete</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Zoom shortcuts -->
|
||||
<child>
|
||||
<object class="GtkShortcutsGroup">
|
||||
<property name="visible">1</property>
|
||||
<property name="title" translatable="yes">Zoom</property>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>plus</property>
|
||||
<property name="title" translatable="yes">Zoom In</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>minus</property>
|
||||
<property name="title" translatable="yes">Zoom Out</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">1</property>
|
||||
<property name="accelerator"><Primary>0</property>
|
||||
<property name="title" translatable="yes">Zoom 100%</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
</interface>
|
27
gaphor/ui/shortcuts.py
Normal file
27
gaphor/ui/shortcuts.py
Normal file
@ -0,0 +1,27 @@
|
||||
import importlib
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
from gaphor.abc import ActionProvider, Service
|
||||
from gaphor.core import action
|
||||
from gaphor.ui.actiongroup import create_action_group, set_action_state
|
||||
|
||||
|
||||
class Shortcuts(Service, ActionProvider):
|
||||
def __init__(self, main_window, properties):
|
||||
self.main_window = main_window
|
||||
|
||||
@action(name="app.shortcuts")
|
||||
def open(self):
|
||||
builder = Gtk.Builder()
|
||||
with importlib.resources.path("gaphor.ui", "shortcuts.glade") as glade_file:
|
||||
builder.add_objects_from_file(str(glade_file), ("shortcuts-gaphor",))
|
||||
|
||||
shortcuts = builder.get_object("shortcuts-gaphor")
|
||||
shortcuts.set_transient_for(self.main_window.window)
|
||||
|
||||
shortcuts.show_all()
|
||||
return shortcuts
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
@ -69,6 +69,7 @@ gaphorconvert = 'gaphor.tools.gaphorconvert:main'
|
||||
"recent_files" = "gaphor.ui.recentfiles:RecentFiles"
|
||||
"main_window" = "gaphor.ui.mainwindow:MainWindow"
|
||||
"preferences" = "gaphor.ui.preferences:Preferences"
|
||||
"shortcuts" = "gaphor.ui.shortcuts:Shortcuts"
|
||||
"export_menu" = "gaphor.ui.menufragment:MenuFragment"
|
||||
"tools_menu" = "gaphor.ui.menufragment:MenuFragment"
|
||||
"copy" = "gaphor.services.copyservice:CopyService"
|
||||
|
Loading…
x
Reference in New Issue
Block a user