Add a shortcuts window

This commit is contained in:
JosephMcc 2017-12-04 03:22:03 -08:00
parent 6383f71fa0
commit 6159ad5be2
6 changed files with 368 additions and 2 deletions

View File

@ -0,0 +1,330 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.17 -->
<object class="GtkShortcutsWindow" id="shortcuts-xed">
<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="visible">1</property>
<property name="title" translatable="yes">Documents</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;N</property>
<property name="title" translatable="yes">Create a new document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;O</property>
<property name="title" translatable="yes">Open a document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;S</property>
<property name="title" translatable="yes">Save the document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;S</property>
<property name="title" translatable="yes">Save the document with a new filename</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;L</property>
<property name="title" translatable="yes">Save all the documents</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;W</property>
<property name="title" translatable="yes">Close the document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;W</property>
<property name="title" translatable="yes">Close all the documents</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Down</property>
<property name="title" translatable="yes">Switch to the next document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;Alt&gt;Page_Up</property>
<property name="title" translatable="yes">Switch to the previous document</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;Alt&gt;1...9</property>
<property name="title" translatable="yes">Switch to the first - ninth document</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Windows and Panes</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">F9</property>
<property name="title" translatable="yes">Show side pane</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;F9</property>
<property name="title" translatable="yes">Show bottom pane</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">F11</property>
<property name="title" translatable="yes">Fullscreen on / off</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<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">Find and Replace</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;F</property>
<property name="title" translatable="yes">Find</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;G</property>
<property name="title" translatable="yes">Find the next match</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;Shift&gt;G</property>
<property name="title" translatable="yes">Find the previous match</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;H</property>
<property name="title" translatable="yes">Find and Replace</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;I</property>
<property name="title" translatable="yes">Go to line</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Copy and Paste</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;C</property>
<property name="title" translatable="yes">Copy selected text to clipboard</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;X</property>
<property name="title" translatable="yes">Cut selected text to clipboard</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;V</property>
<property name="title" translatable="yes">Paste text from clipboard</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Undo and Redo</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;Z</property>
<property name="title" translatable="yes">Undo previous command</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;Y</property>
<property name="title" translatable="yes">Redo previous command</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Selection</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;A</property>
<property name="title" translatable="yes">Select all text</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Editing</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">Insert</property>
<property name="title" translatable="yes">Toggle insert / overwrite</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;D</property>
<property name="title" translatable="yes">Delete current line</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Up</property>
<property name="title" translatable="yes">Move current line up</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Down</property>
<property name="title" translatable="yes">Move current line down</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Left</property>
<property name="title" translatable="yes">Move current word left</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Right</property>
<property name="title" translatable="yes">Move current word right</property>
</object>
</child>
<!--
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;U</property>
<property name="title" translatable="yes">Convert to uppercase</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;L</property>
<property name="title" translatable="yes">Convert to lowercase</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;asciitilde</property>
<property name="title" translatable="yes">Invert case</property>
</object>
</child>
-->
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;a</property>
<property name="title" translatable="yes">Increment number at cursor</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;x</property>
<property name="title" translatable="yes">Decrement number at cursor</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Tools</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;shift&gt;F7</property>
<property name="title" translatable="yes">Check spelling</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;P</property>
<property name="title" translatable="yes">Print the document</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -123,6 +123,8 @@
<menu name="HelpMenu" action="Help"> <menu name="HelpMenu" action="Help">
<menuitem name="HelpContentsMenu" action="HelpContents"/> <menuitem name="HelpContentsMenu" action="HelpContents"/>
<menuitem name="HelpAboutMenu" action="HelpAbout"/> <menuitem name="HelpAboutMenu" action="HelpAbout"/>
<menuitem name="HelpAboutMenu" action="HelpAbout"/>
<menuitem name="HelpShortcutsMenu" action="HelpShortcuts"/>
</menu> </menu>
</menubar> </menubar>

View File

@ -6,6 +6,7 @@
<file preprocess="xml-stripblanks">ui/xed-preferences-dialog.ui</file> <file preprocess="xml-stripblanks">ui/xed-preferences-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/xed-print-preferences.ui</file> <file preprocess="xml-stripblanks">ui/xed-print-preferences.ui</file>
<file preprocess="xml-stripblanks">ui/xed-searchbar.ui</file> <file preprocess="xml-stripblanks">ui/xed-searchbar.ui</file>
<file preprocess="xml-stripblanks">ui/xed-shortcuts.ui</file>
<file preprocess="xml-stripblanks">ui/xed-view-frame.ui</file> <file preprocess="xml-stripblanks">ui/xed-view-frame.ui</file>
<file>css/xed-style.css</file> <file>css/xed-style.css</file>
</gresource> </gresource>

View File

@ -46,7 +46,7 @@
void _xed_cmd_help_contents (GtkAction *action, void _xed_cmd_help_contents (GtkAction *action,
XedWindow *window) XedWindow *window)
{ {
xed_debug(DEBUG_COMMANDS); xed_debug (DEBUG_COMMANDS);
xed_app_show_help (XED_APP (g_application_get_default ()), GTK_WINDOW (window), NULL, NULL); xed_app_show_help (XED_APP (g_application_get_default ()), GTK_WINDOW (window), NULL, NULL);
} }
@ -67,3 +67,33 @@ void _xed_cmd_help_about (GtkAction *action,
"website", "http://github.com/linuxmint/xed", "website", "http://github.com/linuxmint/xed",
NULL); NULL);
} }
void
_xed_cmd_help_keyboard_shortcuts (GtkAction *action,
XedWindow *window)
{
static GtkWidget *shortcuts_window;
xed_debug (DEBUG_COMMANDS);
if (shortcuts_window == NULL)
{
GtkBuilder *builder;
builder = gtk_builder_new_from_resource ("/org/x/editor/ui/xed-shortcuts.ui");
shortcuts_window = GTK_WIDGET (gtk_builder_get_object (builder, "shortcuts-xed"));
g_signal_connect (shortcuts_window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &shortcuts_window);
g_object_unref (builder);
}
if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (shortcuts_window)))
{
gtk_window_set_transient_for (GTK_WINDOW (shortcuts_window), GTK_WINDOW (window));
}
gtk_widget_show_all (shortcuts_window);
gtk_window_present (GTK_WINDOW (shortcuts_window));
}

View File

@ -66,6 +66,7 @@ void _xed_cmd_documents_move_to_new_window (GtkAction *action, XedWindow *window
void _xed_cmd_help_contents (GtkAction *action, XedWindow *window); void _xed_cmd_help_contents (GtkAction *action, XedWindow *window);
void _xed_cmd_help_about (GtkAction *action, XedWindow *window); void _xed_cmd_help_about (GtkAction *action, XedWindow *window);
void _xed_cmd_help_keyboard_shortcuts (GtkAction *action, XedWindow *window);
void _xed_cmd_file_close_tab (XedTab *tab, XedWindow *window); void _xed_cmd_file_close_tab (XedTab *tab, XedWindow *window);

View File

@ -67,6 +67,8 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
N_("Open the xed manual"), G_CALLBACK (_xed_cmd_help_contents) }, N_("Open the xed manual"), G_CALLBACK (_xed_cmd_help_contents) },
{ "HelpAbout", "help-about-symbolic", N_("_About"), NULL, { "HelpAbout", "help-about-symbolic", N_("_About"), NULL,
N_("About this application"), G_CALLBACK (_xed_cmd_help_about) }, N_("About this application"), G_CALLBACK (_xed_cmd_help_about) },
{ "HelpShortcuts", NULL, N_("_Keyboard Shortcuts"), NULL,
N_("Show the keyboard shortcuts dialog"), G_CALLBACK (_xed_cmd_help_keyboard_shortcuts) },
/* Fullscreen toolbar */ /* Fullscreen toolbar */
{ "LeaveFullscreen", "view-restore-symbolic", NULL, { "LeaveFullscreen", "view-restore-symbolic", NULL,