forked from numixproject/numix-gtk-theme
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
oomox_plugin.py
221 lines (198 loc) · 6.41 KB
/
oomox_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import os
from typing import TYPE_CHECKING
from gi.repository import Gtk
from oomox_gui.export_common import CommonGtkThemeExportDialog, CommonGtkThemeExportDialogOptions
from oomox_gui.i18n import translate
from oomox_gui.plugin_api import OomoxThemePlugin
if TYPE_CHECKING:
from typing import Any, Final
from oomox_gui.preview import ThemePreview
from oomox_gui.theme_file import ThemeT
PLUGIN_DIR: "Final" = os.path.dirname(os.path.realpath(__file__))
GTK_THEME_DIR: "Final" = PLUGIN_DIR
class OomoxThemeExportDialogOptions(CommonGtkThemeExportDialogOptions):
GTK3_CURRENT_VERSION_ONLY = "self.OPTIONS.GTK3_CURRENT_VERSION_ONLY"
EXPORT_CINNAMON_THEME = "self.OPTIONS.EXPORT_CINNAMON_THEME"
class OomoxThemeExportDialog(CommonGtkThemeExportDialog):
OPTIONS = OomoxThemeExportDialogOptions()
timeout = 100
config_name = "gtk_theme_oomox"
def do_export(self) -> None:
export_path = os.path.expanduser(
self.option_widgets[self.OPTIONS.DEFAULT_PATH].get_text(),
)
new_destination_dir, theme_name = export_path.rsplit("/", 1)
self.command = [
"bash",
os.path.join(GTK_THEME_DIR, "change_color.sh"),
"--hidpi", str(self.export_config[self.OPTIONS.GTK2_HIDPI]),
"--target-dir", new_destination_dir,
"--output", theme_name,
self.temp_theme_path,
]
make_opts = []
if self.export_config[self.OPTIONS.GTK3_CURRENT_VERSION_ONLY]:
if Gtk.get_minor_version() >= 20: # noqa: PLR2004
make_opts += ["gtk320"]
else:
make_opts += ["gtk3"]
else:
make_opts += ["gtk3", "gtk320"]
if self.export_config[self.OPTIONS.EXPORT_CINNAMON_THEME]:
make_opts += ["css_cinnamon"]
if make_opts:
self.command += [
"--make-opts", " ".join(make_opts),
]
super().do_export()
def __init__(
self,
transient_for: Gtk.Window,
colorscheme: "ThemeT",
theme_name: str,
**kwargs: "Any",
) -> None:
super().__init__(
transient_for=transient_for,
colorscheme=colorscheme,
theme_name=theme_name,
add_options={
self.OPTIONS.GTK3_CURRENT_VERSION_ONLY: {
"default": False,
"display_name": translate(
"Generate theme only for the current _GTK+3 version\n"
"instead of both 3.18 and 3.20+",
),
},
self.OPTIONS.EXPORT_CINNAMON_THEME: {
"default": False,
"display_name": translate("Generate theme for _Cinnamon"),
},
},
**kwargs,
)
class Plugin(OomoxThemePlugin):
name = "oomox"
display_name = "Oomox"
description = (
"GTK+2, GTK+3, Cinnamon, Metacity,\n"
"Openbox, Unity, Xfwm\n"
"(GTK+4, Qt5ct, Qt6ct and others have been moved"
"to Base16 Export Plugin)"
)
about_text = translate("The default theme, originally based on Numix GTK theme.")
about_links = [
{
"name": translate("Homepage"),
"url": "https://github.com/themix-project/oomox-gtk-theme/",
},
]
export_dialog = OomoxThemeExportDialog
gtk_preview_dir = os.path.join(PLUGIN_DIR, "gtk_preview_css/")
enabled_keys_gtk = [
"BG",
"FG",
"HDR_BG",
"HDR_FG",
"SEL_BG",
"SEL_FG",
"ACCENT_BG",
"TXT_BG",
"TXT_FG",
"BTN_BG",
"BTN_FG",
"HDR_BTN_BG",
"HDR_BTN_FG",
"WM_BORDER_FOCUS",
"WM_BORDER_UNFOCUS",
]
enabled_keys_options = [
"ROUNDNESS",
"SPACING",
"GRADIENT",
"GTK3_GENERATE_DARK",
]
theme_model_gtk = [
{
"key": "CARET1_FG",
"type": "color",
"fallback_key": "TXT_FG",
"display_name": translate("Textbox Caret"),
},
{
"key": "CARET2_FG",
"type": "color",
"fallback_key": "TXT_FG",
"display_name": translate("BiDi Textbox Caret"),
},
]
theme_model_options = [
{
"key": "CARET_SIZE",
"type": "float",
"fallback_value": 0.04, # GTK's default
"display_name": translate("Textbox Caret Aspect Ratio"),
},
{
"type": "separator",
"display_name": translate("GTK3 Theme Options"),
"value_filter": {
"THEME_STYLE": "oomox",
},
},
{
"key": "SPACING",
"type": "int",
"fallback_value": 3,
"display_name": translate("Spacing"),
},
{
"key": "OUTLINE_WIDTH",
"type": "int",
"fallback_value": 1,
"display_name": translate("Focused Outline Width"),
},
{
"key": "BTN_OUTLINE_WIDTH",
"type": "int",
"fallback_value": 1,
"display_name": translate("Focused Button Outline Width"),
},
{
"key": "BTN_OUTLINE_OFFSET",
"type": "int",
"fallback_value": -3,
"min_value": -20,
"display_name": translate("Focused Button Outline Offset"),
},
{
"key": "GTK3_GENERATE_DARK",
"type": "bool",
"fallback_value": True,
"display_name": translate("Add Dark Variant"),
},
{
"type": "separator",
"display_name": translate("Desktop Environments"),
"value_filter": {
"THEME_STYLE": "oomox",
},
},
{
"key": "CINNAMON_OPACITY",
"type": "float",
"fallback_value": 1.0,
"max_value": 1.0,
"display_name": translate("Cinnamon: Opacity"),
},
{
"key": "UNITY_DEFAULT_LAUNCHER_STYLE",
"type": "bool",
"fallback_value": False,
"display_name": translate("Unity: Use Default Launcher Style"),
},
]
def preview_before_load_callback(
self, preview_object: "ThemePreview", colorscheme: "ThemeT", # noqa: ARG002
) -> None:
preview_object.WM_BORDER_WIDTH = 2