diff --git a/CHANGELOG b/CHANGELOG
index 4efd516..5a7d60c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+# Version 2.2
+- Bugfixes
+- Migrate code to MVVM pattern
+- Adding option to change the location provider
+- Adding example image for dynamic background color
+
# Version 2.1
- Bugfixes
- Smaller UI for displays with reduced resolution (< 1000px height)
diff --git a/README.md b/README.md
index 1dfe71c..a18df08 100644
--- a/README.md
+++ b/README.md
@@ -11,11 +11,11 @@ This extension switches the background image of your Cinnamon desktop multiple t
- 10 day periods
- HEIF converter
- Image configuration assistent with simple one-click setup for image choices
-- Online location estimation or offline with manual latitude and longitude input
+- Online location estimation (three provider) or offline with manual latitude and longitude input
- Time periods individual configured by user
- Offline sun angles estimation
- Image stretching over multiple displays or repeat image for every display
-- Show image on lock screen
+- Creating a color gradient based on the current wallpaper for images which not fill the whole screen
### Tested Cinnamon versions
- 5.4 (Mint 21)
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example
new file mode 100644
index 0000000..7cfe217
Binary files /dev/null and b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example differ
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg
new file mode 100644
index 0000000..6fc12d6
Binary files /dev/null and b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg differ
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.png b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.png
new file mode 100644
index 0000000..fac85f3
Binary files /dev/null and b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.png differ
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade
index 0f3435a..ab958c3 100644
--- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade
+++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade
@@ -2471,6 +2471,23 @@
8
8
vertical
+ 8
+
+
+
+ False
+ True
+ 0
+
+
+
+
+ False
+ True
+ 3
+ 1
+
+
+
+
+ True
+ False
+ start
+ Dynamic Background color
+
+
+
+
+
+ False
+ True
+ 2
+
+
+
+
+ True
+ False
+ none
+ False
True
@@ -2542,7 +2590,7 @@
False
start
True
- Dynamic Background color
+ Use dynamic Background color to create a gradient
False
@@ -2554,7 +2602,6 @@
True
True
-
False
@@ -2571,7 +2618,19 @@
False
True
3
- 0
+ 3
+
+
+
+
+ True
+ False
+ images/dynamic_background_example.png
+
+
+ False
+ True
+ 4
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/main.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/main.py
index dc5bd96..518ba70 100755
--- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/main.py
+++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/main.py
@@ -1,6 +1,6 @@
#!/usr/bin/python3
-import sys
+import sys, datetime
from view.main_window import *
from model.main_view_model import *
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py
index a26479e..69a1aa6 100644
--- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py
+++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py
@@ -1,4 +1,4 @@
-import os
+import os, time
from PIL import Image
from gi.repository import Gio, Gdk
@@ -83,6 +83,7 @@ class Main_View_Model:
def refresh_location(self) -> bool:
""" Updating the location by IP, store the result to cinnamon_prefs
+ Run it in a parallel thread to avoid UI freeze!
Returns:
bool: Successful or not
@@ -108,10 +109,12 @@ class Main_View_Model:
hour = raw_str[0:raw_str.find(":")]
minute = raw_str[raw_str.find(":") + 1:]
+ time(1, 2)
+
return time(hour=int(hour), minute=int(minute))
- def time_to_string_converter(self, time: time) -> str:
+ def time_to_string_converter(self, _time: time) -> str:
""" Convert a time object to a string like "12:34"
Args:
@@ -120,7 +123,7 @@ class Main_View_Model:
Returns:
str: Converted string
"""
- return "{:0>2}:{:0>2}".format(time.hour, time.minute)
+ return "{:0>2}:{:0>2}".format(_time.hour, _time.minute)
def calulate_time_periods(self) -> list[time]:
@@ -139,7 +142,6 @@ class Main_View_Model:
# Time periods have to be estimate by coordinates
if self.cinnamon_prefs.period_source == PeriodSourceEnum.NETWORKLOCATION:
# Get coordinates from the network
- self.refresh_location()
self.suntimes.calc_suntimes(self.cinnamon_prefs.latitude_auto, self.cinnamon_prefs.longitude_auto)
elif self.cinnamon_prefs.period_source == PeriodSourceEnum.CUSTOMLOCATION:
diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py
index 646362b..14e849d 100644
--- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py
+++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py
@@ -8,8 +8,8 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf
# Packages
-import subprocess
-from datetime import timedelta
+import subprocess, threading, time
+from datetime import timedelta, datetime, date
# Local scripts
from model.main_view_model import *
@@ -335,7 +335,7 @@ class Main_Window:
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_src)
- # Scaling the images smaller for screens
+ # Scaling the images for smaller screens
if self.view_model.screen_height < self.view_model.breakpoint_ui:
pixbuf = pixbuf.scale_simple(221, 128, GdkPixbuf.InterpType.BILINEAR)
else:
@@ -356,7 +356,9 @@ class Main_Window:
label_txt = self.view_model.time_to_string_converter(start_times[i]) + " - "
if i != 9:
- label_txt += self.view_model.time_to_string_converter(start_times[i + 1])
+ diff = timedelta(hours=start_times[i + 1].hour, minutes=start_times[i + 1].minute) - timedelta(minutes=1)
+ prev_time = time(hour=diff.seconds // 3600, minute=diff.seconds // 60 % 60)
+ label_txt += self.view_model.time_to_string_converter(prev_time)
else:
label_txt += "23:59"
@@ -627,16 +629,21 @@ class Main_Window:
Args:
combobox (Gtk.ComboBox): The used ComboBox
"""
+ def network_refresh_thread():
+ success = self.view_model.refresh_location()
+
+ if success:
+ self.lb_current_location.set_text(\
+ "Latitude: " + str(self.view_model.cinnamon_prefs.latitude_auto) + ", Longitude: " + str(self.view_model.cinnamon_prefs.longitude_auto))
+ else:
+ self.dialogs.message_dialog("Error during fetching location. Are you connected to the network?", Gtk.MessageType.ERROR)
+ self.lb_current_location.set_text("Latitude: ?, Longitude: ?")
+
+
self.view_model.cinnamon_prefs.network_location_provider = self.get_active_combobox_item(combobox)
- success = self.view_model.refresh_location()
-
- if success:
- self.lb_current_location.set_text(\
- "Latitude: " + str(self.view_model.cinnamon_prefs.latitude_auto) + ", Longitude: " + str(self.view_model.cinnamon_prefs.longitude_auto))
- else:
- self.dialogs.message_dialog("Error during fetching location. Are you connected to the network?", Gtk.MessageType.ERROR)
- self.lb_current_location.set_text("Latitude: ?, Longitude: ?")
+ thread = threading.Thread(target=network_refresh_thread)
+ thread.start()
def on_etr_longitude_changed(self, entry: Gtk.Entry):