2022-08-23 09:11:54 +00:00
|
|
|
from gi.repository import Gtk, Gdk, Adw
|
|
|
|
|
|
|
|
from .constants import rootdir
|
2022-08-23 17:57:53 +00:00
|
|
|
from .modules.utils import to_slug_case, buglog
|
2022-08-23 09:11:54 +00:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
@Gtk.Template(resource_path=f"{rootdir}/ui/builtin_preset_row.ui")
|
|
|
|
class GradienceBuiltinPresetRow(Adw.ActionRow):
|
|
|
|
__gtype_name__ = "GradienceBuiltinPresetRow"
|
|
|
|
|
|
|
|
apply_button = Gtk.Template.Child("apply_button")
|
|
|
|
|
2022-08-23 09:12:16 +00:00
|
|
|
def __init__(self, name, toast_overlay, author="", **kwargs):
|
2022-08-23 09:11:54 +00:00
|
|
|
super().__init__(**kwargs)
|
2022-08-23 09:12:16 +00:00
|
|
|
|
2022-08-23 09:11:54 +00:00
|
|
|
self.name = name
|
|
|
|
|
|
|
|
self.set_name(name)
|
|
|
|
self.set_title(name)
|
|
|
|
self.set_subtitle(author)
|
2022-08-23 09:12:16 +00:00
|
|
|
|
2022-08-23 09:11:54 +00:00
|
|
|
self.app = Gtk.Application.get_default()
|
2022-08-23 09:12:16 +00:00
|
|
|
|
2022-08-23 09:11:54 +00:00
|
|
|
self.toast_overlay = toast_overlay
|
|
|
|
|
|
|
|
apply_button = Gtk.Template.Child("apply_button")
|
|
|
|
|
|
|
|
@Gtk.Template.Callback()
|
|
|
|
def on_apply_button_clicked(self, *_args):
|
2022-08-23 17:57:53 +00:00
|
|
|
buglog("apply")
|
2022-08-23 09:12:16 +00:00
|
|
|
|
2022-08-23 09:26:16 +00:00
|
|
|
self.app.load_preset_from_resource(
|
2022-08-23 09:25:42 +00:00
|
|
|
f"{rootdir}/presets/"
|
|
|
|
+ to_slug_case(self.name) + ".json"
|
|
|
|
)
|