From f71c190b1fd98c340ade0871f636986e66781821 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 18 May 2023 03:47:00 +0200 Subject: [PATCH] Creating external image configuration tool UI + connection to cinnamon extension settings --- .gitignore | 2 + .../extension.js | 26 +- .../image-configurator.glade | 856 ++++++++++++++++++ .../image-configurator/image-configurator.py | 80 ++ .../settings-schema.json | 32 +- 5 files changed, 965 insertions(+), 31 deletions(-) create mode 100644 .gitignore create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.glade create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f54ae76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.glade~ +*.glade# \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/extension.js b/cinnamon-dynamic-wallpaper@TobiZog/extension.js index 443c0bd..a68465e 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/extension.js +++ b/cinnamon-dynamic-wallpaper@TobiZog/extension.js @@ -9,6 +9,7 @@ const UUID = "cinnamon-dynamic-wallpaper@TobiZog"; const APPNAME = "Cinnamon Dynamic Wallpaper" +const DIRECTORY = imports.ui.extensionSystem.extensionMeta[UUID]; /********** Imports **********/ @@ -18,6 +19,7 @@ const St = imports.gi.St; const Main = imports.ui.main; const Util = imports.misc.util; const Settings = imports.ui.settings; +const { find_program_in_path } = imports.gi.GLib; /********** Global Variables **********/ @@ -41,13 +43,6 @@ CinnamonDynamicWallpaperExtension.prototype = { */ _init: function(uuid) { this.settings = new Settings.AppletSettings(this, uuid); - - // Display the welcome notification on activation - this.showNotification( - APPNAME, - "Welcome to " + APPNAME + "! Open the settings and configure the extensions.", - true - ); }, @@ -93,8 +88,9 @@ CinnamonDynamicWallpaperExtension.prototype = { * Callback for settings-schema * Opens the external heic-importer window */ - configCustomImageSet: function() { - // todo + openImageConfigurator: function() { + global.log(DIRECTORY.path + "/image-configurator/image-configurator.py") + Util.spawnCommandLine("/usr/bin/env python3 " + DIRECTORY.path + "/image-configurator/image-configurator.py"); }, @@ -127,6 +123,18 @@ function init(extensionMeta) { * @returns The extension object */ function enable() { + // Check for necessary software + if (!find_program_in_path('heif-convert')) { + Util.spawnCommandLine("apturl apt://libheif-examples"); + } + + // Display the welcome notification on activation + extension.showNotification( + APPNAME, + "Welcome to " + APPNAME + "! Open the settings and configure the extensions.", + true + ); + return extension; } diff --git a/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.glade b/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.glade new file mode 100644 index 0000000..fa26e63 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.glade @@ -0,0 +1,856 @@ + + + + + + + *.heic + + + + + + + + + + False + center + 1000 + 768 + ../icons/icon.png + + + + True + True + in + + + True + False + natural + + + True + False + 8 + 8 + 8 + 8 + True + vertical + 4 + + + True + False + 0.009999999776482582 + in + + + True + False + 12 + + + + True + False + 8 + 8 + 8 + 8 + 8 + 8 + True + + + True + False + Use an included or a custom image set? + + + 0 + 0 + 2 + + + + + Use an included image set + True + True + False + True + True + + + + 1 + 0 + + + + + Import a heic-file + True + True + False + True + True + rb_included_image_set + + + + 1 + 1 + + + + + + + + + True + False + 4 + 4 + Image Source + + + + + False + True + 0 + + + + + True + False + 0.009999999776482582 + in + + + True + False + 12 + + + + True + False + 8 + 8 + 8 + 8 + 8 + 8 + True + + + 36 + True + False + Select an image-set + + + 0 + 0 + + + + + False + True + filefilter1 + + + + 1 + 1 + + + + + 36 + False + True + Choose the file, which you want to use + + + 0 + 1 + + + + + True + False + image_set_list_store + True + 0 + + + False + + + + + 1 + 0 + + + + + + + + + True + False + 4 + 4 + Image Set + + + + + False + True + 1 + + + + + True + False + True + 0.009999999776482582 + in + + + True + False + 8 + 8 + 8 + + + + True + False + 8 + 8 + True + True + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + 30 + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Morning Twilight + + + + + 0 + 0 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Sunrise + + + + + 1 + 0 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Morning + + + + + 2 + 0 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Noon + + + + + 0 + 1 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Afternoon + + + + + 1 + 1 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Evening + + + + + 2 + 1 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Sunset + + + + + 0 + 2 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Night Twilight + + + + + 1 + 2 + + + + + True + False + 0.5 + in + + + True + False + 8 + 8 + 8 + 8 + + + True + False + vertical + + + True + False + True + gtk-missing-image + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + False + 4 + 4 + Night + + + + + 2 + 2 + + + + + + + + + True + False + 4 + 4 + Preview + + + + + False + True + 2 + + + + + + + + + + + True + False + Cinnamon Dynamic Wallpaper + Image Configuration + True + + + gtk-apply + True + True + True + True + True + + + + + + + diff --git a/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.py b/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.py new file mode 100644 index 0000000..39cafa3 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/image-configurator/image-configurator.py @@ -0,0 +1,80 @@ +import gi, os + +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk + +UI_FILE = os.path.dirname(os.path.abspath(__file__)) + "/image-configurator.glade" + +class ImageConfigurator: + def __init__(self) -> None: + self.builder = Gtk.Builder() + self.builder.add_from_file(UI_FILE) + self.builder.connect_signals(self) + + # Get all resources from the glade file + self.imageSetText = self.builder.get_object("lb_image_set") + self.imageSetCb = self.builder.get_object("cb_image_set") + + self.fileChooserText = self.builder.get_object("lb_heic_file") + self.fileChooserFc = self.builder.get_object("fc_heic_file") + self.image_set_list_store = self.builder.get_object("image_set_list_store") + + self.img_previews = [ + self.builder.get_object("img_preview_1"), + self.builder.get_object("img_preview_2"), + self.builder.get_object("img_preview_3"), + self.builder.get_object("img_preview_4"), + self.builder.get_object("img_preview_5"), + self.builder.get_object("img_preview_6"), + self.builder.get_object("img_preview_7"), + self.builder.get_object("img_preview_8"), + self.builder.get_object("img_preview_9") + ] + + # Predefinition + self.image_set_list_store.append(["Big Sur Beach 2"]) + self.image_set_list_store.append(["Firewatch"]) + self.image_set_list_store.append(["Lakeside"]) + + + def showMainWindow(self): + window = self.builder.get_object("main_window") + window.show_all() + + Gtk.main() + + + def changeImage(self, imageId: int, imageURI: str): + self.img_previews[imageId].set_from_file(os.path.dirname(os.path.abspath(__file__)) + "/" + imageURI) + + + def onRadioIncludedImageSet(self, rb): + if rb.get_active(): + self.imageSetText.set_visible(True) + self.imageSetCb.set_visible(True) + + self.fileChooserText.set_visible(False) + self.fileChooserFc.set_visible(False) + + + def onRadioExternalImageSet(self, rb): + if rb.get_active(): + self.fileChooserText.set_visible(True) + self.fileChooserFc.set_visible(True) + + self.imageSetText.set_visible(False) + self.imageSetCb.set_visible(False) + + + def onApply(self, *args): + # todo + Gtk.main_quit() + + + def onDestroy(self, *args): + Gtk.main_quit() + + +ic = ImageConfigurator() +ic.showMainWindow() + diff --git a/cinnamon-dynamic-wallpaper@TobiZog/settings-schema.json b/cinnamon-dynamic-wallpaper@TobiZog/settings-schema.json index 7e40fa9..03eb7ba 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/settings-schema.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/settings-schema.json @@ -9,7 +9,7 @@ "type": "page", "title": "Configuration", "sections": [ - "sec_image_set", + "sec_image_configuration", "sec_location" ] }, @@ -21,13 +21,12 @@ "sec_github" ] }, - "sec_image_set": { + "sec_image_configuration": { "type": "section", "title": "Image set", "keys": [ - "sw_template_enabled", - "rg_choose_template", - "btn_config_custom_image_set" + "lb_image_configuration", + "btn_config_images" ] }, "sec_location": { @@ -57,25 +56,14 @@ ] } }, - "sw_template_enabled": { - "type": "switch", - "default": true, - "description": "Use a included image set" + "lb_image_configuration": { + "type": "label", + "description": "Choose an included image set or import a heic-file with the Image Configurator" }, - "rg_choose_template": { - "type": "radiogroup", - "default": "", - "description": "Choose a set of images", - "options": { - "": "" - }, - "dependency": "sw_template_enabled" - }, - "btn_config_custom_image_set": { + "btn_config_images": { "type": "button", - "description": "Create your own image set from images", - "callback": "configCustomImageSet", - "dependency": "!sw_template_enabled" + "description": "Image Configurator", + "callback": "openImageConfigurator" }, "sw_auto_location": { "type": "switch",