Philipp Hörist pushed to branch master at gajim / gajim
Commits: 432f6d6b by Daniel Brötzmann at 2020-03-19T20:44:40+01:00 Features: Add gsound and geoclue detection
- - - - - fab86bfc by Daniel Brötzmann at 2020-03-19T20:44:40+01:00 FeaturesDialog: Convert to Gtk.ApplicationWindow
- - - - -
4 changed files:
- gajim/app_actions.py - gajim/data/style/gajim.css - gajim/gtk/const.py - gajim/gtk/features.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -27,7 +27,6 @@ from gajim.gtk.dialogs import ShortcutsWindow from gajim.gtk.single_message import SingleMessageWindow from gajim.gtk.about import AboutDialog from gajim.gtk.privacy_list import PrivacyListsWindow -from gajim.gtk.features import FeaturesDialog from gajim.gtk.history import HistoryWindow from gajim.gtk.discovery import ServiceDiscoveryWindow from gajim.gtk.util import open_window @@ -231,7 +230,7 @@ def on_keyboard_shortcuts(_action, _param):
def on_features(_action, _param): - FeaturesDialog() + open_window('Features')
def on_about(_action, _param):
===================================== gajim/data/style/gajim.css ===================================== @@ -63,6 +63,7 @@ popover#EmoticonPopover { padding: 5px; background-color: @theme_unfocused_base_ #ServerInfo > row.activatable:active { box-shadow: none; }
/* Features Info */ +#FeaturesInfoGrid { padding: 6px; } #FeaturesInfoGrid > list { border: 1px solid; border-color: @borders; } #FeaturesInfoGrid > list > row:first-child { border-top: 1px solid; border-color: @borders; } #FeaturesInfoGrid > list > row { padding: 10px 20px 10px 10px; }
===================================== gajim/gtk/const.py ===================================== @@ -132,4 +132,5 @@ WINDOW_MODULES = { 'RemoveAccount': 'gajim.gtk.remove_account', 'ChangePassword': 'gajim.gtk.change_password', 'PluginsWindow': 'gajim.plugins.gui', + 'Features': 'gajim.gtk.features', }
===================================== gajim/gtk/features.py ===================================== @@ -20,23 +20,27 @@ # along with Gajim. If not, see http://www.gnu.org/licenses/.
import os +import sys from collections import namedtuple
import gi from gi.repository import Gtk +from gi.repository import Gdk
from gajim.common import app from gajim.common.i18n import _
-class FeaturesDialog(Gtk.Dialog): +class Features(Gtk.ApplicationWindow): def __init__(self): - super().__init__(title=_('Features'), - transient_for=None, - destroy_with_parent=True) - - self.set_transient_for(app.interface.roster.window) + Gtk.ApplicationWindow.__init__(self) + self.set_application(app.app) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_show_menubar(False) + self.set_name('Features') + self.set_title(_('Features')) self.set_resizable(False) + self.set_transient_for(app.interface.roster.window)
grid = Gtk.Grid() grid.set_name('FeaturesInfoGrid') @@ -45,24 +49,25 @@ class FeaturesDialog(Gtk.Dialog):
self.feature_listbox = Gtk.ListBox() self.feature_listbox.set_selection_mode(Gtk.SelectionMode.NONE) - self.feature_listbox.set_header_func(self.header_func, _('Features')) + self.feature_listbox.set_header_func(self._header_func, _('Features'))
grid.attach(self.feature_listbox, 0, 0, 1, 1)
- box = self.get_content_area() + box = Gtk.Box() box.pack_start(grid, True, True, 0) box.set_property('margin', 12) box.set_spacing(18) + self.add(box)
- self.connect('response', self.on_response) + self.connect('key-press-event', self._on_key_press)
- for feature in self.get_features(): - self.add_feature(feature) + for feature in self._get_features(): + self._add_feature(feature)
self.show_all()
@staticmethod - def header_func(row, before, user_data): + def _header_func(row, before, user_data): if before: row.set_header(None) else: @@ -70,20 +75,23 @@ class FeaturesDialog(Gtk.Dialog): label.set_halign(Gtk.Align.START) row.set_header(label)
- def on_response(self, _dialog, response): - if response == Gtk.ResponseType.OK: + def _on_key_press(self, _widget, event): + if event.keyval == Gdk.KEY_Escape: self.destroy()
- def add_feature(self, feature): + def _add_feature(self, feature): item = FeatureItem(feature) self.feature_listbox.add(item) item.get_parent().set_tooltip_text(item.tooltip)
- def get_features(self): + def _get_features(self): Feature = namedtuple('Feature', ['name', 'available', 'tooltip', 'dependency_u', 'dependency_w', 'enabled'])
+ notification_sounds_available = ( + app.is_installed('GSOUND') or sys.platform in ('win32', 'darwin')) + notification_sounds_enabled = app.config.get('sounds_on') spell_check_enabled = app.config.get('use_speller')
auto_status = [app.config.get('autoaway'), app.config.get('autoxa')] @@ -98,7 +106,7 @@ class FeaturesDialog(Gtk.Dialog): _('Feature not available under Windows'), None), Feature(_('Automatic Status'), - self.idle_available(), + self._idle_available(), _('Enables Gajim to measure your computer's idle time in ' 'order to set your Status automatically'), _('Requires: libxss'), @@ -112,8 +120,21 @@ class FeaturesDialog(Gtk.Dialog): _('Requires: pybonjour and bonjour SDK running (%(url)s)') % {'url': 'https://developer.apple.com/opensource/)%27%7D, None), + Feature(_('Location detection'), + app.is_installed('GEOCLUE'), + _('Enables Gajim to be location-aware, if the user decides ' + 'to publish the device’s location'), + _('Requires: geoclue'), + _('Feature is not available under Windows'), + None), + Feature(_('Notification Sounds'), + notification_sounds_available, + _('Enables Gajim to play sounds for various notifications'), + _('Requires: gsound'), + _('No additional requirements'), + notification_sounds_enabled), Feature(_('Secure Password Storage'), - self.some_keyring_available(), + self._some_keyring_available(), _('Enables Gajim to store Passwords securely instead of ' 'storing them in plaintext'), _('Requires: libsecret and a provider (such as GNOME ' @@ -138,7 +159,7 @@ class FeaturesDialog(Gtk.Dialog): ]
@staticmethod - def some_keyring_available(): + def _some_keyring_available(): if os.name == 'nt': return True try: @@ -149,7 +170,7 @@ class FeaturesDialog(Gtk.Dialog): return True
@staticmethod - def idle_available(): + def _idle_available(): from gajim.common import idle return idle.Monitor.is_available()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/ad3e2103a8c3e6fd8e2e0270b676200b...