From edc1e62ff3f1c63ed7bbac33e50d6aada949e7c1 Mon Sep 17 00:00:00 2001 From: tobias Date: Sun, 10 Dec 2023 00:11:28 +0100 Subject: [PATCH] Migrate time circle to time bar --- .gitignore | 3 +- .../5.4/preferences/preferences.glade | 1141 +++++++++++++++++ .../5.4/preferences/preferences.py | 49 + .../5.4/preferences/time_bar.py | 45 + .../preferences.py | 131 -- .../prefs.glade | 373 ------ 6 files changed, 1237 insertions(+), 505 deletions(-) create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py create mode 100644 cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar.py delete mode 100644 cinnamon-dynamic-wallpaper@TobiZog/preferences.py delete mode 100644 cinnamon-dynamic-wallpaper@TobiZog/prefs.glade diff --git a/.gitignore b/.gitignore index b1a8930..12f8be1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ extracted/ custom_images/ *.txt selected/ -__pycache__ \ No newline at end of file +__pycache__ +*.svg \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade new file mode 100644 index 0000000..8d314ec --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade @@ -0,0 +1,1141 @@ + + + + + + 5 + 120 + 15 + 5 + 10 + + + + *.heic + + + + False + center + 1024 + 768 + center + + + + True + False + crossfade + + + True + False + 24 + 24 + 8 + 8 + vertical + 8 + + + True + False + start + 64 + Behaviour + + + + + + False + True + 0 + + + + + True + False + 64 + 64 + none + False + + + 36 + True + True + + + True + False + 12 + 12 + 12 + 12 + + + True + False + start + Expand image over all displays + + + False + True + 0 + + + + + True + True + end + + + True + True + 1 + + + + + + + + + False + True + 3 + 1 + + + + + True + False + start + 64 + Image Source + + + + + + False + True + 2 + + + + + True + False + 64 + 64 + none + False + + + True + True + + + True + False + center + 8 + start + + + True + True + True + + + True + False + vertical + + + True + False + applications-graphics + 6 + + + False + True + 0 + + + + + True + False + Image Set + + + False + True + 1 + + + + + + + True + True + 0 + + + + + True + True + True + + + True + False + vertical + + + True + False + preferences-desktop-wallpaper + 6 + + + False + True + 0 + + + + + True + False + HEIC file + + + False + True + 1 + + + + + + + True + True + 1 + + + + + True + True + True + + + True + False + vertical + + + True + False + folder-open + 6 + + + False + True + 0 + + + + + True + False + Source Folder + + + False + True + 1 + + + + + + + True + True + 2 + + + + + + + + + True + True + + + True + False + 12 + 12 + 12 + 12 + True + + + True + False + start + True + Select an image set + + + False + True + 0 + + + + + True + False + + + False + True + 1 + + + + + + + + + True + + + True + False + 12 + 12 + 12 + 12 + True + + + True + False + start + True + Select a heic file to import + + + False + True + 0 + + + + + True + False + filefilter1 + + + + False + True + 1 + + + + + + + + + True + + + True + False + 12 + 12 + 12 + 12 + True + + + True + False + start + True + Select a source folder + + + False + True + 0 + + + + + True + False + select-folder + + + + False + True + 1 + + + + + + + + + False + True + 3 + 3 + + + + + True + False + start + 64 + Image Selection + + + + + + False + True + 4 + + + + + True + False + 64 + 64 + vertical + + + + True + False + 8 + 8 + + + 200 + True + False + image-x-generic + 6 + + + 0 + 1 + + + + + 200 + True + False + image-x-generic + 6 + + + 1 + 1 + + + + + 200 + True + False + image-x-generic + 6 + + + 2 + 1 + + + + + 200 + True + False + image-x-generic + 6 + + + 3 + 1 + + + + + 200 + True + False + image-x-generic + 6 + + + 4 + 1 + + + + + True + False + label + + + 0 + 0 + + + + + True + False + label + + + 1 + 0 + + + + + True + False + label + + + 2 + 0 + + + + + True + False + label + + + 3 + 0 + + + + + True + False + label + + + 4 + 0 + + + + + + + + + + + + + + + + + + + + False + True + 0 + + + + + True + False + accessories-dictionary + + + False + True + 1 + + + + + True + False + center + 8 + + + 200 + True + False + image-x-generic + 6 + + + False + True + 0 + + + + + 200 + True + False + image-x-generic + 6 + + + False + True + 1 + + + + + 200 + True + False + image-x-generic + 6 + + + False + True + 2 + + + + + 200 + True + False + image-x-generic + 6 + + + False + True + 3 + + + + + False + True + 2 + + + + + + + + False + True + 5 + + + + + image_config + Image Configuration + + + + + True + False + 24 + 24 + 8 + 8 + vertical + 8 + + + True + False + start + 64 + Period estimation + + + + + + False + True + 0 + + + + + True + False + 64 + 64 + none + False + + + True + True + False + + + True + False + 12 + 12 + 12 + 12 + True + + + True + False + start + Determination mode of the day periods + + + False + True + 0 + + + + + True + False + 0 + True + + Calculate time periods by location + Determe custom time periods + + + + False + + + + + False + True + 1 + + + + + + + + + False + True + 1 + + + + + True + False + start + 64 + Location estimation + + + + + + False + True + 2 + + + + + True + False + 64 + 64 + none + False + + + True + True + + + True + False + + + + + + + + + + + + + True + True + + + True + False + True + + + True + False + start + Interval time to refresh location via network (min) + + + False + True + 0 + + + + + True + True + adjustment1 + + + False + True + 1 + + + + + + + + + True + True + + + True + False + + + + + + + + + + + + + False + True + 3 + + + + + + + + location_times + Location & Times + 1 + + + + + True + False + 24 + 24 + 8 + 8 + vertical + 8 + + + True + False + start + 64 + About the project + + + + + + False + True + 0 + + + + + True + False + 64 + 64 + none + False + + + True + True + + + True + False + 12 + 12 + 12 + 12 + vertical + + + True + False + Based on a location or by user choice, this extensions calculates the periods of a day and switches the background image of your Cinnamon desktop. The extension offers as image sources a set of preconfigured wallpapers, a heic image import by the user or a custom folder with single images. + True + 0 + + + False + True + 0 + + + + + + + + + True + True + + + True + False + 12 + 12 + 12 + 12 + vertical + + + True + False + Developed by TobiZog + + + False + True + 0 + + + + + + + + + True + True + + + True + True + + + True + False + If you need more information or want to rate the extension, you can visit the Cinnamon Spices Website. + + + + + + + + + True + True + + + Cinnamon Dynamic Wallpaper at Cinnamon Spices Website + True + True + True + + + + + + + True + True + + + + + + + + False + True + 1 + + + + + True + False + start + 64 + Source Code + + + + + + False + True + 2 + + + + + True + False + 64 + 64 + none + False + + + True + True + + + True + False + This project is Open Source. You can take a look inside the whole source code of this extension on GitHub. + + + + + + + True + True + + + Source Code on GitHub + True + True + True + + + + + + + False + True + 3 + + + + + about + About + 2 + + + + + + + True + False + 0 + True + + + True + False + stack_main + + + + + gtk-apply + True + True + True + True + True + + + + + + diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py new file mode 100644 index 0000000..329dc17 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +# Imports +import gi, os +from time_bar import create_bar + +gi.require_version("Gtk", "3.0") +from gi.repository import Gtk, GdkPixbuf + + +# Global definitions +GLADE_URI = os.path.dirname(os.path.abspath(__file__)) + "/preferences.glade" + + +class Preferences: + """ Preference window class + """ + def __init__(self) -> None: + self.builder = Gtk.Builder() + self.builder.add_from_file(GLADE_URI) + self.builder.connect_signals(self) + + # Time bar + # todo: Sample times + create_bar(1036, 200, [0, 455, 494, 523, 673, 792, 882, 941, 973, 1013, 1440]) + pixbuf = GdkPixbuf.Pixbuf.new_from_file("time_bar.svg") + self.builder.get_object("img_bar").set_from_pixbuf(pixbuf) + + + def show(self): + """ Display the window to the screen + """ + window = self.builder.get_object("window_main") + window.show_all() + + self.builder.get_object("lbr_heic").set_visible(False) + self.builder.get_object("lbr_folder").set_visible(False) + + Gtk.main() + + + def onDestroy(self, *args): + """ Lifecycle handler when window will be destroyed + """ + Gtk.main_quit() + + +if __name__ == "__main__": + Preferences().show() \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar.py new file mode 100644 index 0000000..34ed484 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar.py @@ -0,0 +1,45 @@ +import math + +def create_bar(image_width, image_height, times): + image_code = [''] + colors = ["00193dff", "05597fff", "54babfff", "bfe3c2ff", "ffbf6bff", "fdb55cff", "f37f73ff", "7f3d85ff", "4a217aff", "00193dff"] + + for i in range(0, 10): + start_point = (((100 / 1440) * times[i] / 100) * image_width) + width = math.ceil((((100 / 1440) * (times[i + 1] - times[i]) / 100) * image_width)) + image_code.append('' % (colors[i], start_point, width)) + + bar_part_mid = start_point + width / 2 + + if (i < 5): + polyline_x = i * 10 + 10 + polyline_y = 0 + image_x = 100 + i * (200 + 8) + elif (i < 9): + polyline_x = (i - 4) * 10 + 160 + polyline_y = 210 + image_x = 200 + (i - 5) * (200 + 8) + + if i < 9: + image_code.append( + '' % + (image_x, polyline_y, image_x, polyline_x, bar_part_mid, polyline_x, bar_part_mid, colors[i]) + ) + + for i in range(0, 8): + image_code.append( + '' % + (i * (image_width // 8), i * (image_width // 8)) + ) + + image_code.append( + '%s' % + (i * (image_width // 8) + 5, i * 3) + ) + + # Write to file + file = open("time_bar.svg", "w") + for i in image_code: + file.write(i + '\n') + + file.write('') \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/preferences.py b/cinnamon-dynamic-wallpaper@TobiZog/preferences.py deleted file mode 100644 index 2acd436..0000000 --- a/cinnamon-dynamic-wallpaper@TobiZog/preferences.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/python3 - -import gi, os, math, cairo - -gi.require_version("Gtk", "3.0") -from gi.repository import Gtk, GdkPixbuf - -GLADE_URI = os.path.dirname(os.path.abspath(__file__)) + "/prefs.glade" - -class Preferences: - def __init__(self) -> None: - self.builder = Gtk.Builder() - self.builder.add_from_file(GLADE_URI) - self.builder.connect_signals(self) - - # 0:00 = 0% - # 7:05 = 29.58 - # 7:39 = 32.08 - # 8:20 = 34.58 - # 11:46 = 49.17 - # 14:32 = 60.42 - # 16:36 = 69.17 - # 17:57 = 74.58 - # 18:41 = 77.92 - # 19:15 = 80 - - # Numbers for test purposes - self.create_doughnut([29.57, 2.51, 2.5, 14.6, 11.26, 8.76, 5.42, 3.35, 2.09]) - - - pixbuf = GdkPixbuf.Pixbuf.new_from_file("example.svg") - self.builder.get_object("image").set_from_pixbuf(pixbuf) - - - def create_doughnut(self, list_of_percentages: list): - color_list = [ - [0.00, 0.10, 0.24], - [0.02, 0.35, 0.50], - [0.33, 0.73, 0.75], - [0.75, 0.89, 0.76], - [1.00, 0.75, 0.42], - [0.99, 0.71, 0.36], - [0.95, 0.50, 0.45], - [0.50, 0.24, 0.52], - [0.29, 0.13, 0.48], - [0.00, 0.10, 0.24], - ] - - image_height = 350 - image_width = 350 - - - with cairo.SVGSurface("example.svg", image_height, image_width) as surface: - # Create the draw object - context = cairo.Context(surface) - - # Calculate sizes - xc, yc = image_height / 2, image_width / 2 - radius = image_height * 0.35 - doughnut_width = image_height * 0.2 - - # -25 turns the graph 45° anti-clockwise - total_percentage = -25 - - # Completes the doughnut to 100% - list_of_percentages.append(100 - sum(list_of_percentages)) - - - context.set_line_width(doughnut_width) - - # Draw the arc parts - for i, percentage in enumerate(list_of_percentages): - print(i) - context.set_source_rgb(color_list[i][0], color_list[i][1], color_list[i][2]) - - if total_percentage != 0: - angle1 = 360 / (100 / total_percentage) * (math.pi/180) - else: - angle1 = 0 - - angle2 = 360 / (100 / (total_percentage + percentage)) * (math.pi/180) - - context.arc(xc, yc, radius, angle1, angle2) - total_percentage += percentage - context.stroke() - - # Draw the times labels - context.set_source_rgb(0.5, 0.5, 0.5) - # context.set_font_size(18) - - # context.move_to(xc - 20, 20) - # context.show_text("00") - - # context.move_to(360, yc) - # context.show_text("06") - - # context.move_to(xc - 20, image_height) - # context.show_text("12") - - # context.move_to(10, yc) - # context.show_text("18") - # context.stroke() - - # Draw the hour strokes - context.set_line_width(2) - lines_list = [ - [[xc, yc - radius + doughnut_width / 2 - 5], [xc, yc - radius + doughnut_width / 2 + 5]], - [[xc + radius - doughnut_width / 2 - 5, yc], [xc + radius - doughnut_width / 2 + 5, yc]], - [[xc, yc + radius - doughnut_width / 2 - 5], [xc, yc + radius - doughnut_width / 2 + 5]], - [[xc - radius + doughnut_width / 2 - 5, yc], [xc - radius + doughnut_width / 2 + 5, yc]], - ] - - for line in lines_list: - context.move_to(line[0][0], line[0][1]) - context.line_to(line[1][0], line[1][1]) - context.stroke() - - - - def show(self): - window = self.builder.get_object("window_main") - window.show_all() - - Gtk.main() - - - def onDestroy(self, *args): - Gtk.main_quit() - -if __name__ == "__main__": - Preferences().show() \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/prefs.glade b/cinnamon-dynamic-wallpaper@TobiZog/prefs.glade deleted file mode 100644 index 1eb2e02..0000000 --- a/cinnamon-dynamic-wallpaper@TobiZog/prefs.glade +++ /dev/null @@ -1,373 +0,0 @@ - - - - - - False - center - 1024 - 768 - center - - - - True - False - crossfade - - - True - False - 48 - 48 - 8 - 8 - vertical - 8 - - - True - False - start - Behaviour - - - - - - False - True - 0 - - - - - True - False - none - False - - - 36 - True - True - - - True - False - 12 - 12 - 12 - 12 - - - True - False - Expand image over all displays - - - True - True - 0 - - - - - True - True - - - False - True - 1 - - - - - - - - - False - True - 3 - 1 - - - - - True - False - start - Image Source - - - - - - False - True - 2 - - - - - True - False - none - False - - - True - True - - - - - - - - False - True - 3 - - - - - True - False - start - Image Selection - - - - - - False - True - 4 - - - - - True - False - none - False - - - True - True - - - - True - False - - - 350 - 350 - True - False - gtk-missing-image - - - 1 - 1 - 2 - 2 - - - - - True - False - ../../../Desktop/lakeside/8.jpg - - - 0 - 0 - - - - - True - False - ../../../Desktop/lakeside/9.jpg - - - 1 - 0 - 2 - - - - - True - False - ../../../Desktop/lakeside/1.jpg - - - 3 - 0 - - - - - True - False - ../../../Desktop/lakeside/2.jpg - - - 3 - 1 - - - - - True - False - ../../../Desktop/lakeside/3.jpg - - - 3 - 2 - - - - - True - False - ../../../Desktop/lakeside/7.jpg - - - 0 - 1 - - - - - True - False - ../../../Desktop/lakeside/6.jpg - - - 0 - 2 - - - - - True - False - ../../../Desktop/lakeside/5.jpg - - - 0 - 3 - 2 - - - - - True - False - ../../../Desktop/lakeside/4.jpg - - - 2 - 3 - 2 - - - - - - - - - False - True - 5 - - - - - - - - image_config - Image Configuration - - - - - True - False - vertical - - - - - - - - - - - - location_times - Location & Times - 1 - - - - - True - False - vertical - - - - - - - - - - - - about - About - 2 - - - - - - - True - False - 0 - True - - - True - False - stack_main - - - - - gtk-apply - True - True - True - True - True - - - - - -