Philipp Hörist pushed to branch gajim_1.1 at gajim / gajim
Commits: c2d69774 by Philipp Hörist at 2019-01-08T19:07:00Z Use custom link handler in AboutDialog
Fixes #9525
- - - - - af4e06ca by André Apitzsch at 2019-01-08T19:07:27Z Bump copyright year
- - - - - 5329190d by Sebastiaan Lokhorst at 2019-01-08T19:18:47Z Fix Bonjour (pybonjour) on macOS
- - - - - 2ad179df by Philipp Hörist at 2019-01-08T19:20:12Z Better determine language cross platform
- - - - - ad5a8fd3 by Philipp Hörist at 2019-01-08T19:21:47Z Pass xml:lang to nbxmpp
- - - - - f29bf456 by Philipp Hörist at 2019-01-08T21:32:40Z Raise nbxmpp version
- - - - -
10 changed files:
- README.md - data/gajim-history-manager.1 - data/gajim-remote.1 - data/gajim.1 - gajim/common/app.py - gajim/common/connection.py - gajim/common/i18n.py - gajim/gajim.py - gajim/gtk/about.py - setup.cfg
Changes:
===================================== README.md ===================================== @@ -7,7 +7,7 @@ - python3-gi - python3-gi-cairo - gir1.2-gtk-3.0 (>=3.22) -- python3-nbxmpp +- python3-nbxmpp (>=0.6.9,<0.7.0) - python3-openssl (>=0.14) - python3-cssutils (>=1.0.2) - python3-keyring @@ -17,7 +17,7 @@
- python3-pil (pillow) for support of webp avatars - python3-gnupg to enable GPG encryption -- For zeroconf (bonjour) you need python3-dbus +- For zeroconf you need python3-dbus on Linux or [pybonjour](https://dev.gajim.org/lovetox/pybonjour-python3) on Windows/macOS - gir1.2-gspell-1 and hunspell-LANG where lang is your locale eg. en, fr etc - gir1.2-secret-1 for GNOME Keyring or KDE support as password storage - D-Bus running to have gajim-remote working @@ -86,7 +86,7 @@ Execute gajim with --verbose
That is all, **enjoy**!
-(C) 2003-2018 +(C) 2003-2019 The Gajim Team [https://gajim.org%5D(https://gajim.org)
===================================== data/gajim-history-manager.1 ===================================== @@ -46,7 +46,7 @@ and .Pa THANKS , for a complete list. .Sh COPYRIGHT -Copyright (C) 2003-2018 Gajim Team +Copyright (C) 2003-2019 Gajim Team .Pp .Nm 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.
===================================== data/gajim-remote.1 ===================================== @@ -89,7 +89,7 @@ and .Pa THANKS , for a complete list. .Sh COPYRIGHT -Copyright (C) 2003-2018 Gajim Team +Copyright (C) 2003-2019 Gajim Team .Pp .Nm 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.
===================================== data/gajim.1 ===================================== @@ -93,7 +93,7 @@ and with contributions and patches merged from many individuals around the world. See the About Dialog for a complete list. .Sh COPYRIGHT -Copyright (C) 2003-2018 Gajim Team +Copyright (C) 2003-2019 Gajim Team .Pp .Nm 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/common/app.py ===================================== @@ -200,12 +200,14 @@ def detect_dependencies():
# ZEROCONF try: - if os.name == 'nt': - import pybonjour # pylint: disable=unused-variable - _dependencies['PYBONJOUR'] = True - else: - import dbus # pylint: disable=unused-variable - _dependencies['PYTHON-DBUS'] = True + import pybonjour # pylint: disable=unused-variable + _dependencies['PYBONJOUR'] = True + except Exception: + pass + + try: + import dbus # pylint: disable=unused-variable + _dependencies['PYTHON-DBUS'] = True except Exception: pass
===================================== gajim/common/connection.py ===================================== @@ -56,6 +56,7 @@ from gajim.common import app from gajim.common import gpg from gajim.common import passwords from gajim.common import idle +from gajim.common import i18n from gajim.common.i18n import _ from gajim.common.connection_handlers import * from gajim.common.contacts import GC_Contact @@ -1037,7 +1038,8 @@ class Connection(CommonConnection, ConnectionHandlers): con = nbxmpp.NonBlockingClient( domain=self._hostname, caller=self, - idlequeue=app.idlequeue) + idlequeue=app.idlequeue, + lang=i18n.LANG)
# increase default timeout for server responses nbxmpp.dispatcher_nb.DEFAULT_TIMEOUT_SECONDS = \
===================================== gajim/common/i18n.py ===================================== @@ -69,6 +69,22 @@ def iter_locale_dirs(): if locale_dir.is_dir(): yield str(locale_dir)
+def get_default_lang(): + if os.name == "nt": + import ctypes + windll = ctypes.windll.kernel32 + lang = locale.windows_locale[windll.GetUserDefaultUILanguage()] + return lang[:2] + + if sys.platform == "darwin": + from AppKit import NSLocale + return NSLocale.currentLocale().languageCode() + + default = locale.getdefaultlocale()[0] + if default is not None: + return default[:2] + return 'en' + def initialize_direction_mark(): from gi.repository import Gtk
@@ -137,15 +153,13 @@ try: except locale.Error as error: print(error)
-if os.name == 'nt': - try: - # en_US, fr_FR, el_GR etc.. - default = locale.getdefaultlocale()[0] - if default is not None: - LANG = default[:2] - except (ValueError, locale.Error): - pass - os.environ['LANG'] = LANG +try: + LANG = get_default_lang() + print('Found default language: %s' % LANG) +except Exception as error: + print('Failed to determine default language') + import traceback + traceback.print_exc()
# Search for the translation in all locale dirs for dir_ in iter_locale_dirs():
===================================== gajim/gajim.py ===================================== @@ -27,7 +27,7 @@ from distutils.version import LooseVersion as V # Install _() in namespace from gajim.common import i18n
-_MIN_NBXMPP_VER = "0.6.8" +_MIN_NBXMPP_VER = "0.6.9" _MIN_GTK_VER = "3.22.0"
===================================== gajim/gtk/about.py ===================================== @@ -14,10 +14,12 @@
import nbxmpp
+from gi.repository import Gdk from gi.repository import Gtk from gi.repository import GObject
from gajim.common import app +from gajim.common.helpers import launch_browser_mailer from gajim.common.i18n import _ from gajim.common.const import DEVS_CURRENT from gajim.common.const import DEVS_PAST @@ -31,7 +33,7 @@ class AboutDialog(Gtk.AboutDialog): self.set_transient_for(app.interface.roster.window) self.set_name('Gajim') self.set_version(app.version) - self.set_copyright('Copyright © 2003-2018 Gajim Team') + self.set_copyright('Copyright © 2003-2019 Gajim Team') self.set_license_type(Gtk.License.GPL_3_0_ONLY) self.set_website('https://gajim.org/')
@@ -65,3 +67,25 @@ class AboutDialog(Gtk.AboutDialog): 'response', lambda dialog, *args: Gtk.AboutDialog.do_close(dialog))
self.show() + self.connect('activate-link', self._on_activate_link) + # See https://gitlab.gnome.org/GNOME/gtk/issues/1561 + self._connect_link_handler(self) + + @staticmethod + def _on_activate_link(_label, uri): + # We have to use this, because the default GTK handler + # is not cross-platform compatible + launch_browser_mailer(None, uri) + return Gdk.EVENT_STOP + + def _connect_link_handler(self, parent): + def _find_child(parent_): + if not hasattr(parent_, 'get_children'): + return + + for child in parent_.get_children(): + if isinstance(child, Gtk.Label): + if 'href' in child.get_label(): + child.connect('activate-link', self._on_activate_link) + _find_child(child) + _find_child(parent)
===================================== setup.cfg ===================================== @@ -22,7 +22,7 @@ test_suite = test install_requires = cssutils>=1.0.2 keyring - nbxmpp>=0.6.8,<0.7.0 + nbxmpp>=0.6.9,<0.7.0 precis-i18n>=1.0.0 pyOpenSSL>=0.12
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/3bd5843fc915479908613e2557a952d727...