Commit fab86bfc authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist
Browse files

FeaturesDialog: Convert to Gtk.ApplicationWindow

parent 432f6d6b
......@@ -27,7 +27,6 @@
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):
......
......@@ -63,6 +63,7 @@ #ServerInfo > label { padding:10px; color: @insensitive_fg_color; font-weight: b
#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; }
......
......@@ -132,4 +132,5 @@ def __str__(self):
'RemoveAccount': 'gajim.gtk.remove_account',
'ChangePassword': 'gajim.gtk.change_password',
'PluginsWindow': 'gajim.plugins.gui',
'Features': 'gajim.gtk.features',
}
......@@ -25,19 +25,22 @@
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')
......@@ -46,24 +49,25 @@ def __init__(self):
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:
......@@ -71,16 +75,16 @@ def header_func(row, before, user_data):
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'])
......@@ -102,7 +106,7 @@ def get_features(self):
_('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'),
......@@ -130,7 +134,7 @@ def get_features(self):
_('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 '
......@@ -155,7 +159,7 @@ def get_features(self):
]
@staticmethod
def some_keyring_available():
def _some_keyring_available():
if os.name == 'nt':
return True
try:
......@@ -166,7 +170,7 @@ def some_keyring_available():
return True
@staticmethod
def idle_available():
def _idle_available():
from gajim.common import idle
return idle.Monitor.is_available()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment