Commit c3437464 authored by Philipp Hörist's avatar Philipp Hörist

Refactor OptionsDialog

- Rename Option to Setting, it fits better
- Settings inherit from Gtk.ListBoxRow
parent cc375071
......@@ -3,36 +3,9 @@ from collections import namedtuple
from gajim.common.i18n import _
Option = namedtuple('Option', 'kind label type value name callback data desc enabledif props')
Option.__new__.__defaults__ = (None,) * len(Option._fields) # type: ignore
EncryptionData = namedtuple('EncryptionData', 'additional_data')
EncryptionData.__new__.__defaults__ = (None,) # type: ignore
@unique
class OptionKind(IntEnum):
ENTRY = 0
SWITCH = 1
SPIN = 2
ACTION = 3
LOGIN = 4
DIALOG = 5
CALLBACK = 6
PROXY = 7
HOSTNAME = 8
PRIORITY = 9
FILECHOOSER = 10
CHANGEPASSWORD = 11
@unique
class OptionType(IntEnum):
ACCOUNT_CONFIG = 0
CONFIG = 1
VALUE = 2
ACTION = 3
DIALOG = 4
class AvatarSize(IntEnum):
TAB = 16
......
......@@ -83,17 +83,17 @@ popover#EmoticonPopover { padding: 5px; background-color: @theme_unfocused_base_
#FeaturesInfoGrid > list > label { padding:10px; color: @insensitive_fg_color; font-weight: bold; }
#FeaturesInfoGrid > list > row.activatable:active { box-shadow: none; }
/* OptionsBox */
#OptionsBox > row { border-bottom: 1px solid; border-color: @theme_unfocused_bg_color; }
#OptionsBox > row:last-child { border-bottom: 0px}
#OptionsBox > row.activatable:active { box-shadow: none; }
#OptionsBox > row { padding: 10px 20px 10px 10px; }
#OptionsBox > row:not(.activatable) label { color: @insensitive_fg_color }
/* GenericOption */
/* SettingsBox */
#SettingsBox > row { border-bottom: 1px solid; border-color: @theme_unfocused_bg_color; }
#SettingsBox > row:last-child { border-bottom: 0px}
#SettingsBox > row.activatable:active { box-shadow: none; }
#SettingsBox > row { padding: 10px 20px 10px 10px; }
#SettingsBox > row:not(.activatable) label { color: @insensitive_fg_color }
/* GenericSetting */
#SubDescription { color: @insensitive_fg_color;}
#GenericOptionBox { margin-left: 30px; }
#GenericOptionBox > label { padding-right: 3px; }
#GenericSettingBox { margin-left: 30px; }
#GenericSettingBox > label { padding-right: 3px; }
/* Generic Popover Menu with Buttons */
.PopoverButtonListbox { padding-left: 0px; padding-right: 0px; }
......
This diff is collapsed.
......@@ -21,6 +21,9 @@ from enum import unique
Filter = namedtuple('Filter', 'name pattern default')
Setting = namedtuple('Setting', 'kind label type value name callback data desc enabledif props')
Setting.__new__.__defaults__ = (None,) * len(Setting._fields) # type: ignore
@unique
class Theme(IntEnum):
NOT_DARK = 0
......@@ -36,3 +39,28 @@ class GajimIconSet(Enum):
JABBERBULB = 'jabberbulb'
SUN = 'sun'
WROOP = 'wroop'
@unique
class SettingKind(IntEnum):
ENTRY = 0
SWITCH = 1
SPIN = 2
ACTION = 3
LOGIN = 4
DIALOG = 5
CALLBACK = 6
PROXY = 7
HOSTNAME = 8
PRIORITY = 9
FILECHOOSER = 10
CHANGEPASSWORD = 11
@unique
class SettingType(IntEnum):
ACCOUNT_CONFIG = 0
CONFIG = 1
VALUE = 2
ACTION = 3
DIALOG = 4
......@@ -22,17 +22,16 @@ from gi.repository import GLib
from gajim.common import app
from gajim.common import ged
from gajim.common.i18n import _
from gajim.common.const import Option
from gajim.common.const import OptionKind
from gajim.common.const import OptionType
from gajim.common.const import StyleAttr
from gajim.gtk import util
from gajim.gtk.util import get_builder
from gajim.gtk.util import get_image_button
from gajim.gtk.dialogs import ErrorDialog
from gajim.options_dialog import OptionsDialog
from gajim.gtk.settings import SettingsDialog
from gajim.gtk.const import Setting
from gajim.gtk.const import SettingKind
from gajim.gtk.const import SettingType
UNDECLARED = 'http://www.gajim.org/xmlns/undeclared'
......@@ -191,31 +190,31 @@ class XMLConsoleWindow(Gtk.Window):
self.filter_dialog.present()
return
options = [
Option(OptionKind.SWITCH, 'Presence',
OptionType.VALUE, self.presence,
callback=self.on_option, data='presence'),
Setting(SettingKind.SWITCH, 'Presence',
SettingType.VALUE, self.presence,
callback=self.on_option, data='presence'),
Option(OptionKind.SWITCH, 'Message',
OptionType.VALUE, self.message,
callback=self.on_option, data='message'),
Setting(SettingKind.SWITCH, 'Message',
SettingType.VALUE, self.message,
callback=self.on_option, data='message'),
Option(OptionKind.SWITCH, 'Iq', OptionType.VALUE, self.iq,
callback=self.on_option, data='iq'),
Setting(SettingKind.SWITCH, 'Iq', SettingType.VALUE, self.iq,
callback=self.on_option, data='iq'),
Option(OptionKind.SWITCH, 'Stream\nManagement',
OptionType.VALUE, self.stream,
callback=self.on_option, data='stream'),
Setting(SettingKind.SWITCH, 'Stream\nManagement',
SettingType.VALUE, self.stream,
callback=self.on_option, data='stream'),
Option(OptionKind.SWITCH, 'In', OptionType.VALUE, self.incoming,
callback=self.on_option, data='incoming'),
Setting(SettingKind.SWITCH, 'In', SettingType.VALUE, self.incoming,
callback=self.on_option, data='incoming'),
Option(OptionKind.SWITCH, 'Out', OptionType.VALUE, self.outgoing,
callback=self.on_option, data='outgoing'),
Setting(SettingKind.SWITCH, 'Out', SettingType.VALUE, self.outgoing,
callback=self.on_option, data='outgoing'),
]
self.filter_dialog = OptionsDialog(self, 'Filter',
Gtk.DialogFlags.DESTROY_WITH_PARENT,
options, self.account)
self.filter_dialog = SettingsDialog(self, 'Filter',
Gtk.DialogFlags.DESTROY_WITH_PARENT,
options, self.account)
self.filter_dialog.connect('destroy', self.on_filter_destroyed)
def on_filter_destroyed(self, win):
......
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