Merge branch 'shortcuts-window' into 'master'

Use GtkShortcutsWindow to display keyboard shortcuts.

See merge request !44
This commit is contained in:
Philipp Hörist 2017-01-24 18:01:23 +01:00
commit 7a42970121
3 changed files with 337 additions and 2 deletions

View File

@ -0,0 +1,285 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="shortcuts_window">
<child>
<object class="GtkShortcutsSection">
<property name="visible">1</property>
<property name="section-name">chat</property>
<property name="title" translatable="yes">Chat Shortcuts</property>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Message composition</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">Return</property>
<property name="title" translatable="yes">Send the message</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;shift&gt;Return &lt;ctrl&gt;Return</property>
<property name="title" translatable="yes">Create a new line</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;m</property>
<property name="title" translatable="yes">Select an emoticon</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">Tab</property>
<property name="title" translatable="yes">Complete a command or a nick</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;Up</property>
<property name="title" translatable="yes">Previous sent message</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;Down</property>
<property name="title" translatable="yes">Next sent messages</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;alt&gt;Up</property>
<property name="title" translatable="yes">Quote previous message</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;alt&gt;Down</property>
<property name="title" translatable="yes">Quote next message</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">Clear message entry</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Appearance</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;c</property>
<property name="title" translatable="yes">Toggle full / compact view</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Recent history</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;shift&gt;Page_Up</property>
<property name="title" translatable="yes">Scroll up</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;shift&gt;Page_Down</property>
<property name="title" translatable="yes">Sroll down</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">Clear</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Tabs</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Left &lt;ctrl&gt;Page_Up</property>
<property name="title" translatable="yes">Switch to the previous tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;alt&gt;Right &lt;ctrl&gt;Page_Down</property>
<property name="title" translatable="yes">Switch to the next tab</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 tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;&lt;shift&gt;Tab</property>
<property name="title" translatable="yes">Switch to the previous unread tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;Tab</property>
<property name="title" translatable="yes">Switch to the next unread tab</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">Escape &lt;ctrl&gt;w &lt;ctrl&gt;F4</property>
<property name="title" translatable="yes">Close chat</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsSection">
<property name="visible">1</property>
<property name="section-name">roster</property>
<property name="title" translatable="yes">Roster Shortcuts</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">&lt;ctrl&gt;&lt;shift&gt;a</property>
<property name="title" translatable="yes">Accounts</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">Preferences</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;t</property>
<property name="title" translatable="yes">File transfers</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;n</property>
<property name="title" translatable="yes">Start a new chat</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;j</property>
<property name="title" translatable="yes">Join a group chat</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">Set the status message</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 Gajim</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Appearance</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;o</property>
<property name="title" translatable="yes">Show offline contacts</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">Show only active contacts</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;k</property>
<property name="title" translatable="yes">Enable roster filtering</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkShortcutsGroup">
<property name="visible">1</property>
<property name="title" translatable="yes">Contacts</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">&lt;ctrl&gt;i</property>
<property name="title" translatable="yes">Contact information</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">F2</property>
<property name="title" translatable="yes">Rename contact</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
<property name="accelerator">Delete</property>
<property name="title" translatable="yes">Delete contact</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -56,6 +56,7 @@ import tooltips
import message_control
import adhoc_commands
import features_window
import shortcuts_window
import plugins
import plugins.gui
@ -3852,8 +3853,7 @@ class RosterWindow:
'http://trac.gajim.org/wiki/GajimFaq')
def on_keyboard_shortcuts_menuitem_activate(self, widget):
helpers.launch_browser_mailer('url',
'http://trac.gajim.org/wiki/KeyboardShortcuts')
shortcuts_window.show(self.window)
def on_features_menuitem_activate(self, widget):
features_window.FeaturesWindow()

50
src/shortcuts_window.py Normal file
View File

@ -0,0 +1,50 @@
# -*- coding:utf-8 -*-
## src/shortcuts_window.py
##
## This file is part of Gajim.
##
## Gajim 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; version 3 only.
##
## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
##
from gi.repository import Gtk
import gtkgui_helpers
from common import helpers
__all__ = ['show']
class ShortcutsWindow:
def __init__(self):
self.window = None
def show(self, parent=None):
if self.window is None:
builder = gtkgui_helpers.get_gtk_builder('shortcuts_window.ui')
self.window = builder.get_object('shortcuts_window')
self.window.connect('destroy', self._on_window_destroy)
self.window.set_transient_for(parent)
self.window.show_all()
self.window.present()
def _on_window_destroy(self, widget):
self.window = None
def show_shortcuts_webpage(self, parent=None):
helpers.launch_browser_mailer('url',
'https://dev.gajim.org/gajim/gajim/wikis/help/keyboardshortcuts')
if (3, 19) <= (Gtk.get_major_version(), Gtk.get_minor_version()):
show = ShortcutsWindow().show
else:
show = show_shortcuts_webpage