Changelog, Readme, dynamic background example image

This commit is contained in:
2024-02-04 16:08:05 +01:00
parent 34e44f4b3c
commit 14497e21f2
9 changed files with 96 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python3
import sys
import sys, datetime
from view.main_window import *
from model.main_view_model import *

View File

@@ -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:

View File

@@ -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):