From 6f6a8d3f39b9d18106b1b472f7a42a34cb9bcaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Tue, 24 Jan 2017 15:24:39 +0100 Subject: [PATCH 1/2] Use GtkShortcutsWindow to display keyboard shortcuts. --- data/gui/shortcuts_window.ui | 285 +++++++++++++++++++++++++++++++++++ src/roster_window.py | 4 +- src/shortcuts_window.py | 38 +++++ 3 files changed, 325 insertions(+), 2 deletions(-) create mode 100644 data/gui/shortcuts_window.ui create mode 100644 src/shortcuts_window.py diff --git a/data/gui/shortcuts_window.ui b/data/gui/shortcuts_window.ui new file mode 100644 index 000000000..b93ec815f --- /dev/null +++ b/data/gui/shortcuts_window.ui @@ -0,0 +1,285 @@ + + + + + + 1 + chat + Chat Shortcuts + + + 1 + Message composition + + + 1 + Return + Send the message + + + + + 1 + <shift>Return <ctrl>Return + Create a new line + + + + + 1 + <alt>m + Select an emoticon + + + + + 1 + Tab + Complete a command or a nick + + + + + 1 + <ctrl>Up + Previous sent message + + + + + 1 + <ctrl>Down + Next sent messages + + + + + 1 + <ctrl><alt>Up + Quote previous message + + + + + 1 + <ctrl><alt>Down + Quote next message + + + + + 1 + <ctrl>u + Clear message entry + + + + + + + 1 + Appearance + + + 1 + <alt>c + Toggle full / compact view + + + + + + + 1 + Recent history + + + 1 + <shift>Page_Up + Scroll up + + + + + 1 + <shift>Page_Down + Sroll down + + + + + 1 + <ctrl>l + Clear + + + + + + + 1 + Tabs + + + 1 + <alt>Left <ctrl>Page_Up + Switch to the previous tab + + + + + 1 + <alt>Right <ctrl>Page_Down + Switch to the next tab + + + + + 1 + <Alt>1...9 + Switch to the first - ninth tab + + + + + 1 + <ctrl><shift>Tab + Switch to the previous unread tab + + + + + 1 + <ctrl>Tab + Switch to the next unread tab + + + + + 1 + Escape <ctrl>w <ctrl>F4 + Close chat + + + + + + + + + 1 + roster + Roster Shortcuts + + + 1 + General + + + 1 + <ctrl><shift>a + Accounts + + + + + 1 + <ctrl>p + Preferences + + + + + 1 + <ctrl>t + File transfers + + + + + 1 + <ctrl>n + Start a new chat + + + + + 1 + <ctrl>j + Join a group chat + + + + + 1 + <ctrl>s + Set the status message + + + + + 1 + <ctrl>q + Quit Gajim + + + + + + + 1 + Appearance + + + 1 + <ctrl>o + Show offline contacts + + + + + 1 + <ctrl>y + Show only active contacts + + + + + 1 + <ctrl>k + Enable roster filtering + + + + + + + 1 + Contacts + + + 1 + <ctrl>i + Contact information + + + + + 1 + F2 + Rename contact + + + + + 1 + Delete + Delete contact + + + + + + + + diff --git a/src/roster_window.py b/src/roster_window.py index b169e0073..324b412e8 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -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() diff --git a/src/shortcuts_window.py b/src/shortcuts_window.py new file mode 100644 index 000000000..ea07dbc91 --- /dev/null +++ b/src/shortcuts_window.py @@ -0,0 +1,38 @@ +# -*- 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 . +## + +import gtkgui_helpers + + +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 + +show = ShortcutsWindow().show From 058562b92e6b3f0cb0e7900cb239dfd8c0bb74d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Tue, 24 Jan 2017 16:39:09 +0100 Subject: [PATCH 2/2] Backward compatible keyboard shortcuts information. Use GtkShortcutsWindow if supported, otherwise just point the user to the wiki page with keyboard shortcuts. --- src/shortcuts_window.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/shortcuts_window.py b/src/shortcuts_window.py index ea07dbc91..dd0bb1f14 100644 --- a/src/shortcuts_window.py +++ b/src/shortcuts_window.py @@ -16,8 +16,13 @@ ## along with Gajim. If not, see . ## +from gi.repository import Gtk + import gtkgui_helpers +from common import helpers + +__all__ = ['show'] class ShortcutsWindow: def __init__(self): @@ -35,4 +40,11 @@ class ShortcutsWindow: def _on_window_destroy(self, widget): self.window = None -show = ShortcutsWindow().show +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