diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade index 3875c92..a66556a 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.glade @@ -9,16 +9,96 @@ 5 10 - + 23 1 10 - + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + + 23 + 1 + 10 + + 59 1 10 + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + 59 + 1 + 10 + + + 57 + 1 + 10 + + + 58 + 1 + 10 + *.heic @@ -600,7 +680,7 @@ - + True False gtk-missing-image @@ -1313,178 +1393,105 @@ True True - + + True False - True + 8 + 8 + True - - + + True + False + Period 1 + + + + + + 0 + 0 + + + + + True + False + Period 2 + + + + + + 1 + 0 + + + + + True + False + Period 3 + + + + + + 2 + 0 + + + + + True + False + Period 4 + + + + + + 3 + 0 + + + + + True + False + Period 5 + + + + + + 4 + 0 + + + + True False - - True - False - Period 1 - - - - - - 0 - 0 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 0 - - - - - True - False - 8 - 8 - : - - - - - - 4 - 0 - - - - + True True + 8 + 8 8 8 + 23 vertical - adjustment_hours + adjustment_hours5 + 23 + - 3 - 0 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 1 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 1 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 2 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 3 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 4 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 2 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 3 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 4 + False + True + 0 @@ -1497,70 +1504,48 @@ 8 : - + - 4 - 1 + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes5 + 59 + + + + False + True + 2 True False - 8 - 8 - 8 - 8 - : + - - + - 4 - 2 + False + True + 3 - - True - False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 4 - - - - + True False 8 @@ -1573,296 +1558,37 @@ - 1 - 0 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 1 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 2 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 4 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 0 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 1 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 2 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 4 - - - - - True - False - Period 2 - - - - - - 0 - 1 - - - - - True - False - Period 3 - - - - - - 0 - 2 - - - - - True - False - Period 4 - - - - - - 0 - 3 - - - - - True - False - Period 5 - - - - - - 0 - 4 + False + True + 4 - False - True - 0 + 0 + 3 - - + True False - + True True - 0 - vertical - adjustment_minutes - - - 5 - 0 - - - - - True - True - 0 - vertical - adjustment_hours - - - 3 - 0 - - - - - True - False 8 8 - 00:00 - - - + 23 + vertical + adjustment_hours6 + 23 + - 1 - 0 - - - - - True - False - 8 - 8 - - - - - - - - 2 - 0 + False + True + 0 @@ -1875,268 +1601,48 @@ 8 : - + - 4 - 0 + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes6 + 59 + + + + False + True + 2 True False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 1 - - - - - True - False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 2 - - - - - True - False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - : - - - - - - 4 - 4 - - - - - True - False - 8 - 8 - 8 - 8 - - + - 2 - 1 + False + True + 3 - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 2 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - - - - - - - - 2 - 4 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 1 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 1 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 2 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 3 - - - - - True - True - 0 - vertical - adjustment_minutes - - - 5 - 4 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 3 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 2 - - - - - True - True - 12 - vertical - adjustment_hours - 12 - - - 3 - 4 - - - - + True False 8 @@ -2145,143 +1651,835 @@ 8 00:00 - + - 1 - 1 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 2 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 3 - - - - - True - False - 8 - 8 - 8 - 8 - 00:00 - - - - - - 1 - 4 - - - - - True - False - Period 6 - - - - - - 0 - 0 - - - - - True - False - Period 7 - - - - - - 0 - 1 - - - - - True - False - Period 8 - - - - - - 0 - 2 - - - - - True - False - Period 9 - - - - - - 0 - 3 - - - - - True - False - Period 10 - - - - - - 0 - 4 + False + True + 4 - False - True - 1 + 1 + 3 + + + + + True + False + + + True + True + 8 + 8 + 23 + vertical + adjustment_hours7 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes7 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 2 + 3 + + + + + True + False + + + True + True + 23 + vertical + adjustment_hours8 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes8 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 3 + 3 + + + + + True + False + + + True + True + 8 + 8 + 8 + 8 + 23 + vertical + adjustment_hours9 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 57 + vertical + adjustment_minutes9 + 57 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 23:59 + + + + + + False + True + 4 + + + + + 4 + 3 + + + + + True + False + Period 6 + + + + + + 0 + 2 + + + + + True + False + Period 7 + + + + + + 1 + 2 + + + + + True + False + Period 9 + + + + + + 3 + 2 + + + + + True + False + Period 8 + + + + + + 2 + 2 + + + + + True + False + Period 10 + + + + + + 4 + 2 + + + + + True + False + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 0 + + + + + True + False + - + + + + + + False + True + 1 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 2 + + + + + 0 + 1 + + + + + True + False + + + True + True + 8 + 8 + 8 + 8 + 23 + vertical + adjustment_hours2 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes2 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 2 + 1 + + + + + True + False + + + True + True + 8 + 8 + 8 + 8 + 23 + vertical + adjustment_hours3 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes3 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 3 + 1 + + + + + True + False + + + True + True + 8 + 8 + 8 + 8 + 23 + vertical + adjustment_hours4 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes4 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 4 + 1 + + + + + True + False + + + True + True + 23 + vertical + adjustment_hours1 + 23 + + + + False + True + 0 + + + + + True + False + 8 + 8 + 8 + 8 + : + + + + + + False + True + 1 + + + + + True + True + 59 + vertical + adjustment_minutes1 + 59 + + + + False + True + 2 + + + + + True + False + - + + + + + + False + True + 3 + + + + + True + False + 8 + 8 + 8 + 8 + 00:00 + + + + + + False + True + 4 + + + + + 1 + 1 @@ -2295,6 +2493,18 @@ 3 + + + True + False + gtk-missing-image + + + False + True + 4 + + location_times @@ -2591,4 +2801,30 @@ + + + + + + + + + + 0 + 0 + + + 1 + 1 + + + 2 + 2 + + + 3 + 3 + + + diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py index 0a98199..2aedb16 100755 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/preferences.py @@ -1,7 +1,8 @@ #!/usr/bin/python3 # Imports -import gi, os, subprocess +import gi, os, subprocess, time +from datetime import timedelta from scripts.time_bar_chart import Time_Bar_Chart from scripts.cinnamon_pref_handler import * from scripts.suntimes import * @@ -38,8 +39,7 @@ class Preferences: # Suntimes object self.suntimes = Suntimes(float(self.c_prefs.prefs[PrefenceEnums.LATITUDE_AUTO]), float(self.c_prefs.prefs[PrefenceEnums.LONGITUDE_AUTO])) - - + ########## UI objects ########## ## Image Configuration @@ -49,7 +49,7 @@ class Preferences: self.lbr_image_set = self.builder.get_object("lbr_image_set") self.lbr_heic_file = self.builder.get_object("lbr_heic_file") self.lbr_source_folder = self.builder.get_object("lbr_source_folder") - self.img_bar = self.builder.get_object("img_bar") + self.img_bar_images = self.builder.get_object("img_bar_images") self.sw_expand_over_all_displays = self.builder.get_object("sw_expand_over_all_displays") self.sw_show_on_lock_screen = self.builder.get_object("sw_show_on_lock_screen") self.etr_periods = [ @@ -73,6 +73,36 @@ class Preferences: self.lbr_time_periods = self.builder.get_object("lbr_time_periods") self.etr_longitude = self.builder.get_object("etr_longitude") self.etr_latitude = self.builder.get_object("etr_latitude") + self.img_bar_times = self.builder.get_object("img_bar_times") + self.spb_periods_hour = [ + self.builder.get_object("spb_period_1_hour"), + self.builder.get_object("spb_period_2_hour"), + self.builder.get_object("spb_period_3_hour"), + self.builder.get_object("spb_period_4_hour"), + self.builder.get_object("spb_period_5_hour"), + self.builder.get_object("spb_period_6_hour"), + self.builder.get_object("spb_period_7_hour"), + self.builder.get_object("spb_period_8_hour"), + self.builder.get_object("spb_period_9_hour"), + ] + self.spb_periods_minute = [ + self.builder.get_object("spb_period_1_minute"), + self.builder.get_object("spb_period_2_minute"), + self.builder.get_object("spb_period_3_minute"), + self.builder.get_object("spb_period_4_minute"), + self.builder.get_object("spb_period_5_minute"), + self.builder.get_object("spb_period_6_minute"), + self.builder.get_object("spb_period_7_minute"), + self.builder.get_object("spb_period_8_minute"), + self.builder.get_object("spb_period_9_minute") + ] + self.lb_period_end = [ + self.builder.get_object("lb_period_0_end"), self.builder.get_object("lb_period_1_end"), + self.builder.get_object("lb_period_2_end"), self.builder.get_object("lb_period_3_end"), + self.builder.get_object("lb_period_4_end"), self.builder.get_object("lb_period_5_end"), + self.builder.get_object("lb_period_6_end"), self.builder.get_object("lb_period_7_end"), + self.builder.get_object("lb_period_8_end"), self.builder.get_object("lb_period_9_end"), + ] def show(self): @@ -101,28 +131,11 @@ class Preferences: elif self.c_prefs.prefs[PrefenceEnums.PERIOD_SOURCE] == PeriodSourceEnum.CUSTOMTIMEPERIODS: self.tb_time_periods.set_active(True) - - - ########## Time diagram ########## - - # Stores the start times of the periods in minutes since midnight - time_periods_min = [] - - # Get all time periods. Store the minutes to the list and print the values to the text views - for i in range(0, 10): - time_range = self.suntimes.get_time_period(i) - self.etr_periods[i].set_text(str(time_range[0].hour).rjust(2, '0') + ":" + str(time_range[0].minute).rjust(2, '0') +\ - " - " + str(time_range[1].hour).rjust(2, '0') + ":" + str(time_range[1].minute).rjust(2, '0')) - - time_periods_min.append(time_range[0].hour * 60 + time_range[0].minute) - - # Create time bar - self.time_bar_chart.create_bar_chart(PREFERENCES_URI, 1200, 150, time_periods_min) - - # Load to the view - pixbuf = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar.svg") - self.img_bar.set_from_pixbuf(pixbuf) - + # Time diagram + try: + self.refresh_chart() + except: + pass # Show the main window Gtk.main() @@ -134,8 +147,43 @@ class Preferences: Gtk.main_quit() + #################### Local methods #################### + + + def refresh_chart(self): + # Stores the start times of the periods in minutes since midnight + time_periods_min = [] + + if self.c_prefs.prefs[PrefenceEnums.PERIOD_SOURCE] == PeriodSourceEnum.CUSTOMTIMEPERIODS: + for i in range(0, 10): + time_str = self.c_prefs.prefs["period_%s_custom_start_time" % i] + + time_periods_min.append(int(time_str[0:2]) * 60 + int(time_str[3:5])) + else: + # Get all time periods. Store the minutes to the list and print the values to the text views + for i in range(0, 10): + time_range = self.suntimes.get_time_period(i) + self.etr_periods[i].set_text( + str(time_range[0].hour).rjust(2, '0') + ":" + str(time_range[0].minute).rjust(2, '0') +\ + " - " + str(time_range[1].hour).rjust(2, '0') + ":" + str(time_range[1].minute).rjust(2, '0')) + + time_periods_min.append(time_range[0].hour * 60 + time_range[0].minute) + + # Create time bar + self.time_bar_chart.create_bar_chart_with_polylines(PREFERENCES_URI, 1200, 150, time_periods_min) + self.time_bar_chart.create_bar_chart(PREFERENCES_URI, 1200, 150, time_periods_min) + + # Load to the views + pixbuf = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar_polylines.svg") + self.img_bar_images.set_from_pixbuf(pixbuf) + + pixbuf2 = GdkPixbuf.Pixbuf.new_from_file(PREFERENCES_URI + "/time_bar.svg") + self.img_bar_times.set_from_pixbuf(pixbuf2) + + #################### Callbacks #################### + ## Image Configuration def on_toggle_button_image_set_clicked(self, button): @@ -201,6 +249,8 @@ class Preferences: self.c_prefs.prefs[PrefenceEnums.LATITUDE_AUTO] = float(location["latitude"]) self.c_prefs.prefs[PrefenceEnums.LONGITUDE_AUTO] = float(location["longitude"]) + self.refresh_chart() + def on_toggle_button_custom_location_clicked(self, button): if button.get_active(): @@ -229,6 +279,35 @@ class Preferences: self.lbr_custom_location_longitude.set_visible(False) self.lbr_custom_location_latitude.set_visible(False) self.lbr_time_periods.set_visible(True) + + + for i in range(0, 9): + pref_value = self.c_prefs.prefs["period_%s_custom_start_time" % (i + 1)] + time_parts = [int(pref_value[0:pref_value.find(":")]), int(pref_value[pref_value.find(":") + 1:])] + + self.spb_periods_hour[i].set_value(time_parts[0]) + self.spb_periods_minute[i].set_value(time_parts[1]) + + + + def on_spb_period_value_changed(self, spin_button): + spin_button_name = Gtk.Buildable.get_name(spin_button) + index = int(spin_button_name[11:12]) - 1 + hours = self.spb_periods_hour[index].get_value() + minutes = self.spb_periods_minute[index].get_value() + + time_value = datetime(2024,1,1, int(hours), int(minutes)) + time_str = str(time_value.hour).rjust(2, '0') + ":" + str(time_value.minute).rjust(2, '0') + + self.c_prefs.prefs["period_%s_custom_start_time" % (index + 1)] = time_str + + next_time = time_value - timedelta(minutes=1) + time_str = str(next_time.hour).rjust(2, '0') + ":" + str(next_time.minute).rjust(2, '0') + + # Update the start time of the previous period + self.lb_period_end[index].set_text(time_str) + + self.refresh_chart() def on_spb_network_location_refresh_time_changed(self, spin_button): diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/scripts/time_bar_chart.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/scripts/time_bar_chart.py index 5e3edb8..1bb355b 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/scripts/time_bar_chart.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/scripts/time_bar_chart.py @@ -20,7 +20,7 @@ class Time_Bar_Chart: self.bar_pos_x = [] - def create_bar_chart(self, save_location: str, image_width: int, image_height: int, times: list): + def create_bar_chart_with_polylines(self, save_location: str, image_width: int, image_height: int, times: list): """ Create a time bar chart Args: @@ -36,10 +36,29 @@ class Time_Bar_Chart: self.image_code.insert(0, '' % (image_width, image_height)) self.image_code.append('') + file = open(save_location + "/time_bar_polylines.svg", "w") + for i in self.image_code: + file.write(i + '\n') + + self.image_code.clear() + self.bar_pos_x.clear() + + + def create_bar_chart(self, save_location: str, image_width: int, image_height: int, times: list): + self.create_bar(image_width, image_height, times) + self.create_time_markers(image_width, image_height) + + # Write to file + self.image_code.insert(0, '' % (image_width, image_height)) + self.image_code.append('') + file = open(save_location + "/time_bar.svg", "w") for i in self.image_code: file.write(i + '\n') + self.image_code.clear() + self.bar_pos_x.clear() + def create_bar(self, image_width: int, image_height: int, times: list): """ Generates the code for the horizontal multi-color bar chart @@ -53,7 +72,9 @@ class Time_Bar_Chart: y = 40 width = 0 height = image_height - 80 - times.append(1440) + + if times[len(times) - 1] != 1440: + times.append(1440) # Adding the bar parts for i in range(1, len(times)): diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar_polylines.svg b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar_polylines.svg new file mode 100644 index 0000000..c85ff23 --- /dev/null +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/preferences/time_bar_polylines.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + +0 + +3 + +6 + +9 + +12 + +15 + +18 + +21 + diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json b/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json index ce4660d..1389568 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json @@ -87,44 +87,44 @@ "type": "generic", "default": 0 }, - "period_0_start_time": { + "period_0_custom_start_time": { "type": "generic", - "default": "" + "default": "00:00" }, - "period_1_start_time": { + "period_1_custom_start_time": { "type": "generic", - "default": "" + "default": "05:00" }, - "period_2_start_time": { + "period_2_custom_start_time": { "type": "generic", - "default": "" + "default": "07:00" }, - "period_3_start_time": { + "period_3_custom_start_time": { "type": "generic", - "default": "" + "default": "09:00" }, - "period_4_start_time": { + "period_4_custom_start_time": { "type": "generic", - "default": "" + "default": "11:00" }, - "period_5_start_time": { + "period_5_custom_start_time": { "type": "generic", - "default": "" + "default": "13:00" }, - "period_6_start_time": { + "period_6_custom_start_time": { "type": "generic", - "default": "" + "default": "15:00" }, - "period_7_start_time": { + "period_7_custom_start_time": { "type": "generic", - "default": "" + "default": "17:00" }, - "period_8_start_time": { + "period_8_custom_start_time": { "type": "generic", - "default": "" + "default": "19:00" }, - "period_9_start_time": { + "period_9_custom_start_time": { "type": "generic", - "default": "" + "default": "21:00" } } \ No newline at end of file