[gnome-tweak-tool] Attach CSS selectors to all tweaks and groups
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] Attach CSS selectors to all tweaks and groups
- Date: Sun, 18 Aug 2013 19:49:44 +0000 (UTC)
commit 5460ff17dbeec592c7342e33201a51469c46ac95
Author: John Stowers <john stowers gmail com>
Date: Tue Aug 6 17:25:28 2013 +0200
Attach CSS selectors to all tweaks and groups
data/shell.css | 13 +++++++++++++
gtweak/tweakmodel.py | 4 +++-
gtweak/tweaks/tweak_group_interface.py | 2 +-
gtweak/tweaks/tweak_group_test.py | 12 +++++++-----
gtweak/tweaks/tweak_group_windows.py | 2 +-
gtweak/widgets.py | 13 +++++++++----
6 files changed, 34 insertions(+), 12 deletions(-)
---
diff --git a/data/shell.css b/data/shell.css
index 40c2eeb..bafcfe2 100644
--- a/data/shell.css
+++ b/data/shell.css
@@ -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 {
diff --git a/gtweak/tweakmodel.py b/gtweak/tweakmodel.py
index 1741f6e..b291223 100644
--- a/gtweak/tweakmodel.py
+++ b/gtweak/tweakmodel.py
@@ -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,
diff --git a/gtweak/tweaks/tweak_group_interface.py b/gtweak/tweaks/tweak_group_interface.py
index 5121a77..d8ead3b 100644
--- a/gtweak/tweaks/tweak_group_interface.py
+++ b/gtweak/tweaks/tweak_group_interface.py
@@ -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(),
diff --git a/gtweak/tweaks/tweak_group_test.py b/gtweak/tweaks/tweak_group_test.py
index b5aa035..e342e18 100644
--- a/gtweak/tweaks/tweak_group_test.py
+++ b/gtweak/tweaks/tweak_group_test.py
@@ -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))
]
diff --git a/gtweak/tweaks/tweak_group_windows.py b/gtweak/tweaks/tweak_group_windows.py
index 7091be2..667792d 100644
--- a/gtweak/tweaks/tweak_group_windows.py
+++ b/gtweak/tweaks/tweak_group_windows.py
@@ -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"),
diff --git a/gtweak/widgets.py b/gtweak/widgets.py
index f60236d..79b3ccf 100644
--- a/gtweak/widgets.py
+++ b/gtweak/widgets.py
@@ -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")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]