mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-09-14 16:42:31 +00:00
format
This commit is contained in:
parent
b6105f6302
commit
b7c6be25e7
1 changed files with 37 additions and 35 deletions
36
src/main.py
36
src/main.py
|
@ -36,6 +36,7 @@ from .app_type_dialog import AdwcustomizerAppTypeDialog
|
||||||
from .custom_css_group import AdwcustomizerCustomCSSGroup
|
from .custom_css_group import AdwcustomizerCustomCSSGroup
|
||||||
from .plugins_list import AdwcustomizerPluginsList
|
from .plugins_list import AdwcustomizerPluginsList
|
||||||
|
|
||||||
|
|
||||||
def to_slug_case(non_slug):
|
def to_slug_case(non_slug):
|
||||||
return re.sub(r"[^0-9a-z]+", "-", anyascii(non_slug).lower()).strip("-")
|
return re.sub(r"[^0-9a-z]+", "-", anyascii(non_slug).lower()).strip("-")
|
||||||
|
|
||||||
|
@ -141,7 +142,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
"line": traceback.format_exc().strip(),
|
"line": traceback.format_exc().strip(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.win.toast_overlay.add_toast(Adw.Toast(title=_("Failed to load preset")))
|
self.win.toast_overlay.add_toast(
|
||||||
|
Adw.Toast(title=_("Failed to load preset")))
|
||||||
|
|
||||||
self.props.active_window.update_errors(self.global_errors)
|
self.props.active_window.update_errors(self.global_errors)
|
||||||
|
|
||||||
|
@ -174,7 +176,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
|
|
||||||
self.portal.open_uri(
|
self.portal.open_uri(
|
||||||
parent,
|
parent,
|
||||||
"file://" + os.path.join(os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config" ), "presets"),
|
"file://" + os.path.join(os.environ.get("XDG_CONFIG_HOME",
|
||||||
|
os.environ["HOME"] + "/.config"), "presets"),
|
||||||
Xdp.OpenUriFlags.NONE,
|
Xdp.OpenUriFlags.NONE,
|
||||||
None,
|
None,
|
||||||
open_dir_callback,
|
open_dir_callback,
|
||||||
|
@ -214,7 +217,6 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
|
|
||||||
self.reload_variables()
|
self.reload_variables()
|
||||||
|
|
||||||
|
|
||||||
def rgba_from_argb(self, argb, alpha=None) -> str:
|
def rgba_from_argb(self, argb, alpha=None) -> str:
|
||||||
base = "rgba({}, {}, {}, {})"
|
base = "rgba({}, {}, {}, {})"
|
||||||
|
|
||||||
|
@ -236,13 +238,7 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
for color in palettes.values():
|
for color in palettes.values():
|
||||||
i += 1
|
i += 1
|
||||||
palette[str(i)] = hexFromArgb(color.tone(int(tone.get_string())))
|
palette[str(i)] = hexFromArgb(color.tone(int(tone.get_string())))
|
||||||
|
|
||||||
print(palette)
|
|
||||||
|
|
||||||
self.pref_palette_shades["monet"].update_shades(palette)
|
self.pref_palette_shades["monet"].update_shades(palette)
|
||||||
|
|
||||||
print(monet_theme)
|
|
||||||
print(theme)
|
|
||||||
if monet_theme == "automatic":
|
if monet_theme == "automatic":
|
||||||
if self.style_manager.get_dark():
|
if self.style_manager.get_dark():
|
||||||
monet_theme = "dark"
|
monet_theme = "dark"
|
||||||
|
@ -419,7 +415,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
if args[0].get_string().startswith("custom-"):
|
if args[0].get_string().startswith("custom-"):
|
||||||
self.load_preset_from_file(
|
self.load_preset_from_file(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config" ),
|
os.environ.get("XDG_CONFIG_HOME",
|
||||||
|
os.environ["HOME"] + "/.config"),
|
||||||
"presets",
|
"presets",
|
||||||
args[0].get_string().replace("custom-", "", 1) + ".json",
|
args[0].get_string().replace("custom-", "", 1) + ".json",
|
||||||
)
|
)
|
||||||
|
@ -451,7 +448,6 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
|
|
||||||
box.append(label)
|
box.append(label)
|
||||||
box.append(switch)
|
box.append(switch)
|
||||||
print(dir(switch))
|
|
||||||
|
|
||||||
dialog.set_extra_child(box)
|
dialog.set_extra_child(box)
|
||||||
|
|
||||||
|
@ -478,7 +474,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
"Saving preset to <tt>{0}</tt>. If that preset already exists, it will be overwritten!"
|
"Saving preset to <tt>{0}</tt>. If that preset already exists, it will be overwritten!"
|
||||||
).format(
|
).format(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config" ),
|
os.environ.get("XDG_CONFIG_HOME",
|
||||||
|
os.environ["HOME"] + "/.config"),
|
||||||
"presets",
|
"presets",
|
||||||
to_slug_case(self.preset_name) + ".json",
|
to_slug_case(self.preset_name) + ".json",
|
||||||
)
|
)
|
||||||
|
@ -510,7 +507,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
"Saving preset to <tt>{0}</tt>. If that preset already exists, it will be overwritten!"
|
"Saving preset to <tt>{0}</tt>. If that preset already exists, it will be overwritten!"
|
||||||
).format(
|
).format(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config" ),
|
os.environ.get("XDG_CONFIG_HOME",
|
||||||
|
os.environ["HOME"] + "/.config"),
|
||||||
"presets",
|
"presets",
|
||||||
to_slug_case(preset_entry.get_text()) + ".json",
|
to_slug_case(preset_entry.get_text()) + ".json",
|
||||||
)
|
)
|
||||||
|
@ -529,7 +527,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
if response == "save":
|
if response == "save":
|
||||||
with open(
|
with open(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
os.environ.get("XDG_CONFIG_HOME", os.environ["HOME"] + "/.config" ),
|
os.environ.get("XDG_CONFIG_HOME",
|
||||||
|
os.environ["HOME"] + "/.config"),
|
||||||
"presets",
|
"presets",
|
||||||
to_slug_case(entry.get_text()) + ".json",
|
to_slug_case(entry.get_text()) + ".json",
|
||||||
),
|
),
|
||||||
|
@ -544,7 +543,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
}
|
}
|
||||||
file.write(json.dumps(object_to_write, indent=4))
|
file.write(json.dumps(object_to_write, indent=4))
|
||||||
self.clear_dirty()
|
self.clear_dirty()
|
||||||
self.win.toast_overlay.add_toast(Adw.Toast(title=_("Scheme successfully saved!")))
|
self.win.toast_overlay.add_toast(
|
||||||
|
Adw.Toast(title=_("Scheme successfully saved!")))
|
||||||
|
|
||||||
def apply_color_scheme(self, widget, response, switch):
|
def apply_color_scheme(self, widget, response, switch):
|
||||||
if response == "apply":
|
if response == "apply":
|
||||||
|
@ -590,7 +590,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
os.path.join(gtk3_dir, "gtk.css"), "w", encoding="utf-8"
|
os.path.join(gtk3_dir, "gtk.css"), "w", encoding="utf-8"
|
||||||
) as file:
|
) as file:
|
||||||
file.write(gtk3_css)
|
file.write(gtk3_css)
|
||||||
self.win.toast_overlay.add_toast(Adw.Toast(title=_("Scheme set successfully!")))
|
self.win.toast_overlay.add_toast(
|
||||||
|
Adw.Toast(title=_("Scheme set successfully!")))
|
||||||
|
|
||||||
def reset_color_scheme(self, widget, response):
|
def reset_color_scheme(self, widget, response):
|
||||||
if response == "reset":
|
if response == "reset":
|
||||||
|
@ -613,7 +614,8 @@ class AdwcustomizerApplication(Adw.Application):
|
||||||
file.delete()
|
file.delete()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.win.toast_overlay.add_toast(Adw.Toast(title=_("Reset successfully!")))
|
self.win.toast_overlay.add_toast(
|
||||||
|
Adw.Toast(title=_("Reset successfully!")))
|
||||||
|
|
||||||
def show_about_window(self, *_args):
|
def show_about_window(self, *_args):
|
||||||
about = Adw.AboutWindow(
|
about = Adw.AboutWindow(
|
||||||
|
|
Loading…
Reference in a new issue