soreau,
created on Saturday, 13 September 2025, 05:26:40 (1757741200),
received on Saturday, 13 September 2025, 05:27:18 (1757741238)
Author identity: Scott Moreau <oreaus@gmail.com>
025d22a71e453f24172e590dbb98006251fb3c93
main.py
@@ -246,6 +246,8 @@ class BackgroundWindow(Gtk.Window):
self.time_per_image = 120
if self.transition_ms <= 0:
self.transition_ms = 1000
if len(self.all_sources) <= 1:
self.transition_ms = 0
self.stack.set_transition_duration(self.transition_ms)
if self.time_per_image * 1000 < self.transition_ms:
self.time_per_image = self.transition_ms / 500
@@ -253,16 +255,18 @@ class BackgroundWindow(Gtk.Window):
def change_image(self):
now = GLib.DateTime.new_now_local()
num_images = len(self.all_sources)
# Ping pong between images is required for transition
if self.pic1:
self.picture1.set_filename(str(self.all_sources[now.to_unix() // self.time_per_image % len(self.all_sources)]))
self.picture1.set_filename(str(self.all_sources[now.to_unix() // self.time_per_image % num_images]))
self.stack.set_visible_child(self.picture1)
else:
self.picture2.set_filename(str(self.all_sources[now.to_unix() // self.time_per_image % len(self.all_sources)]))
self.picture2.set_filename(str(self.all_sources[now.to_unix() // self.time_per_image % num_images]))
self.stack.set_visible_child(self.picture2)
self.pic1 = not self.pic1
time_until_next = self.time_per_image - now.to_unix() % self.time_per_image
self.current_timeout = GLib.timeout_add_seconds(time_until_next, self.change_image)
if num_images > 1:
self.current_timeout = GLib.timeout_add_seconds(time_until_next, self.change_image)
return False