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

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -2471,6 +2471,23 @@
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Scaling</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
@@ -2492,6 +2509,7 @@
<property name="margin-end">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@@ -2522,6 +2540,36 @@
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Dynamic Background color</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkListBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
<property name="activate-on-single-click">False</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
@@ -2542,7 +2590,7 @@
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Dynamic Background color</property>
<property name="label" translatable="yes">Use dynamic Background color to create a gradient</property>
</object>
<packing>
<property name="expand">False</property>
@@ -2554,7 +2602,6 @@
<object class="GtkSwitch" id="sw_dynamic_background_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
<signal name="state-set" handler="on_sw_dynamic_background_color_state_set" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -2571,7 +2618,19 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">3</property>
<property name="position">0</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixbuf">images/dynamic_background_example.png</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>

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