diff --git a/cinnamon-dynamic-wallpaper@TobiZog/preferences.py b/cinnamon-dynamic-wallpaper@TobiZog/preferences.py new file mode 100644 index 0000000..2acd436 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/preferences.py @@ -0,0 +1,131 @@ +#!/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 new file mode 100644 index 0000000..1eb2e02 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/prefs.glade @@ -0,0 +1,373 @@ + + + + + + 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 + + + + + +