From 7a9f25eaa93ff3104f8d6cb60514cb46d14a1bc9 Mon Sep 17 00:00:00 2001 From: sulincix Date: Wed, 20 Nov 2024 14:32:38 +0300 Subject: [PATCH] background change animation added --- src/data/main.ui | 81 +++++++++++++++++++++++++++++++---------- src/module/gtkwindow.py | 18 +++++---- 2 files changed, 71 insertions(+), 28 deletions(-) diff --git a/src/data/main.ui b/src/data/main.ui index 612a0cf..2e47277 100644 --- a/src/data/main.ui +++ b/src/data/main.ui @@ -9,12 +9,43 @@ True False - + True False - 500 - under-up + + True + True + True + 500 + crossfade + + + True + False + + + image1 + image1 + + + + + True + False + + + image2 + image2 + 1 + + + + + -1 + + + True False @@ -147,11 +178,11 @@ True - True + False True - True + False 100 crossfade @@ -206,7 +237,7 @@ 31 31 True - False + True True @@ -245,7 +276,7 @@ True center False - * + False Password password @@ -266,7 +297,7 @@ 31 31 True - False + True True @@ -302,6 +333,7 @@ 22 True False + 8 8 @@ -315,10 +347,12 @@ Login 128 True - False + True True center center + 20 + 20 20 20 - main_page + 1 diff --git a/src/module/gtkwindow.py b/src/module/gtkwindow.py index 83722d8..e03bd1b 100644 --- a/src/module/gtkwindow.py +++ b/src/module/gtkwindow.py @@ -16,6 +16,7 @@ def __init__(self): self.__last_hash = gsettings_get("last-hash").split("\n") def __init_variables(self): + self.image_status = True self.greeter_loaded = False self.__blocked = False self.width = -1 @@ -33,7 +34,6 @@ def block_delete(*args): # Main window self.o("ui_window_main").connect("destroy", Gtk.main_quit) self.o("ui_window_main").connect("delete-event", block_delete) - self.o("ui_window_main").connect("draw", self.__draw_window) # Login button and password entry enter self.o("ui_button_login").connect("clicked", self.event_login_button) self.o("ui_entry_password").connect( @@ -75,6 +75,7 @@ def block_delete(*args): self.o("ui_button_username").connect( "clicked", self.__event_username_button) + def __init_gui(self): # Show main window and present self.o("ui_window_main").show() @@ -106,12 +107,6 @@ def __init_gui(self): ############### Window event ############### - def __draw_window(self, widget, context): - if self.background_pixbuf: - Gdk.cairo_set_source_pixbuf(context, self.background_pixbuf, 0, 0) - context.rectangle(0, 0, self.width, self.height) - context.fill() - def __screen_keyboard_event(self, event, data): if get("touch-mode", False): os.system(get("screen-keyboard", "onboard", "keyboard")+"&") @@ -354,7 +349,14 @@ def set_background(self, bg=None): self.background_pixbuf = px except Exception as e: print(str(e)) - GLib.idle_add(self.o("ui_window_main").queue_draw) + if self.image_status: + self.o("ui_image_2").set_from_pixbuf(self.background_pixbuf) + self.o("ui_stack_image").set_visible_child_name("image2") + else: + self.o("ui_image_1").set_from_pixbuf(self.background_pixbuf) + self.o("ui_stack_image").set_visible_child_name("image1") + self.image_status = not self.image_status + def apply_scale(self): # buttons 64px