Commit 5460ff17 authored by John Stowers's avatar John Stowers

Attach CSS selectors to all tweaks and groups

parent 3e1e6645
......@@ -21,6 +21,19 @@
padding-top: 10px;
}
/* individual tweak theme changes */
.list-row.tweak#tweak-test-foo {
background-color: red;
}
.list-row.tweak.title#title-tweak-test {
background-color: blue;
}
.list.tweak-group#group-tweak-test {
background-color: green;
}
.list-row.tweak.title#title-theme {
padding-top: 3px;
}
/* NOT WORKING
.main-container {
......
......@@ -53,6 +53,7 @@ class Tweak(object):
def __init__(self, name, description, **options):
self.name = name
self.description = description
self.uid = options.get("uid", self.__class__.__name__)
self.group_name = options.get("group_name",_("Miscellaneous"))
self.loaded = options.get("loaded", True)
self.widget_sort_hint = None
......@@ -73,9 +74,10 @@ class Tweak(object):
self._notification = Notification(summary, desc)
class TweakGroup(object):
def __init__(self, name, *tweaks):
def __init__(self, name, *tweaks, **options):
self.name = name
self.tweaks = [t for t in tweaks if t.loaded]
self.uid = options.get('uid', self.__class__.__name__)
class TweakModel(Gtk.ListStore):
(COLUMN_NAME,
......
......@@ -124,7 +124,7 @@ TWEAK_GROUPS = [
#GSettingsSwitchTweak("Buttons Icons","org.gnome.desktop.interface", "buttons-have-icons"),
#GSettingsSwitchTweak("Menu Icons","org.gnome.desktop.interface", "menus-have-icons"),
DarkThemeSwitcher(),
Title("Theme", ""),
Title("Theme", "", uid="title-theme"),
WindowThemeSwitcher(),
GtkThemeSwitcher(),
IconThemeSwitcher(),
......
......@@ -20,7 +20,7 @@ from __future__ import print_function
from gi.repository import Gtk
from gtweak.tweakmodel import Tweak
from gtweak.widgets import ListBoxTweakGroup, build_label_beside_widget
from gtweak.widgets import ListBoxTweakGroup, Title, build_label_beside_widget
class _TestInfoTweak(Gtk.Box, Tweak):
def __init__(self, name, description, **options):
......@@ -59,15 +59,17 @@ class _TestButtonTweak(Gtk.Box, Tweak):
TWEAK_GROUPS = [
ListBoxTweakGroup(
"Test Many Settings",
*[_TestTweak("name: " + str(d), "desc: " + str(d)) for d in range(50)]),
*[_TestTweak("name: " + str(d), "desc: " + str(d)) for d in range(10)],
uid="group-tweak-test"),
ListBoxTweakGroup(
"Test Settings",
_TestTweak("foo bar", "does foo bar"),
_TestTweak("foo bar", "does foo bar", uid="tweak-test-foo"),
_TestTweak("foo baz", "does foo baz"),
_TestInfoTweak("long string "*10, "long description "*10, _test_button_name="short"),
_TestInfoTweak("foo info", "info widget", _tweak_info="Information"),
_TestInfoTweak("foo warning", "info widget", _tweak_warning="Warning"),
_TestButtonTweak("Notify Information", "foo bar", _need_action=True),
_TestButtonTweak("Notify Logout", "foo bar log", _need_logout=True))
Title("Test Notifications", "", uid="title-tweak-test"),
_TestButtonTweak("Shows Information", "foo bar", _need_action=True),
_TestButtonTweak("Needs Logout", "foo bar log", _need_logout=True))
]
......@@ -22,7 +22,7 @@ from gtweak.widgets import ListBoxTweakGroup, GSettingsComboEnumTweak, Title
TWEAK_GROUPS = [
ListBoxTweakGroup(TWEAK_GROUP_WINDOWS,
GSettingsComboEnumTweak("Focus Mode", "org.gnome.desktop.wm.preferences", "focus-mode"),
Title("Titlebar Actions", ""),
Title("Titlebar Actions", "", uid="title-titlebar-actions"),
GSettingsComboEnumTweak("Double-click","org.gnome.desktop.wm.preferences", "action-double-click-titlebar"),
GSettingsComboEnumTweak("Middle-click","org.gnome.desktop.wm.preferences", "action-middle-click-titlebar"),
GSettingsComboEnumTweak("Secondary-click","org.gnome.desktop.wm.preferences", "action-right-click-titlebar"),
......
......@@ -162,6 +162,8 @@ class _GSettingsTweak(Tweak):
schema_name = adjust_schema_for_overrides(schema_name, key_name, options)
self.schema_name = schema_name
self.key_name = key_name
if 'uid' not in options:
options['uid'] = key_name
try:
self.settings = GSettingsSetting(schema_name, **options)
Tweak.__init__(self,
......@@ -212,17 +214,20 @@ class _DependableMixin(object):
self.set_sensitive(sensitive)
class ListBoxTweakGroup(Gtk.ListBox, TweakGroup):
def __init__(self, name, *tweaks):
def __init__(self, name, *tweaks, **options):
if 'uid' not in options:
options['uid'] = self.__class__.__name__
Gtk.ListBox.__init__(self,
selection_mode=Gtk.SelectionMode.NONE)
selection_mode=Gtk.SelectionMode.NONE,
name=options['uid'])
self.get_style_context().add_class("tweak-group")
TweakGroup.__init__(self, name, *tweaks)
TweakGroup.__init__(self, name, *tweaks, **options)
self._sg = Gtk.SizeGroup(
mode=Gtk.SizeGroupMode.HORIZONTAL)
self._sg.props.ignore_hidden = True
for t in self.tweaks:
row = Gtk.ListBoxRow()
row = Gtk.ListBoxRow(name=t.uid)
row.get_style_context().add_class("tweak")
if isinstance(t, Title):
row.get_style_context().add_class("title")
......
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