Skip to content

Commit

Permalink
background change animation added
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Nov 20, 2024
1 parent f7d2bd2 commit 7a9f25e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 28 deletions.
81 changes: 61 additions & 20 deletions src/data/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,43 @@
<property name="skip-pager-hint">True</property>
<property name="decorated">False</property>
<child>
<object class="GtkStack" id="ui_stack_window">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="transition-duration">500</property>
<property name="transition-type">under-up</property>
<child>
<object class="GtkStack" id="ui_stack_image">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="transition-duration">500</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkImage" id="ui_image_1">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="name">image1</property>
<property name="title" translatable="yes">image1</property>
</packing>
</child>
<child>
<object class="GtkImage" id="ui_image_2">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="name">image2</property>
<property name="title" translatable="yes">image2</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkBox" id="ui_box_loginscreen">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -147,11 +178,11 @@
<child>
<object class="GtkBox" id="ui_box_username">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkStack" id="ui_stack_username">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="can-focus">False</property>
<property name="transition-duration">100</property>
<property name="transition-type">crossfade</property>
<child>
Expand Down Expand Up @@ -206,7 +237,7 @@
<property name="width-request">31</property>
<property name="height-request">31</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<child>
<object class="GtkImage" id="ui_icon_userselect">
Expand Down Expand Up @@ -245,7 +276,7 @@
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="visibility">False</property>
<property name="invisible-char">*</property>
<property name="invisible-char"></property>
<property name="caps-lock-warning">False</property>
<property name="placeholder-text" translatable="yes">Password</property>
<property name="input-purpose">password</property>
Expand All @@ -266,7 +297,7 @@
<property name="width-request">31</property>
<property name="height-request">31</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<child>
<object class="GtkImage" id="ui_icon_eye">
Expand Down Expand Up @@ -302,6 +333,7 @@
<property name="width-request">22</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">8</property>
<property name="margin-start">8</property>
</object>
<packing>
Expand All @@ -315,10 +347,12 @@
<property name="label" translatable="yes">Login</property>
<property name="width-request">128</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-left">20</property>
<property name="margin-right">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<style>
Expand All @@ -336,6 +370,7 @@
<property name="width-request">22</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-right">8</property>
<property name="margin-end">8</property>
</object>
<packing>
Expand Down Expand Up @@ -370,7 +405,7 @@
</object>
<packing>
<property name="name">page_main</property>
<property name="title">page_main</property>
<property name="title" translatable="yes">page_main</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -404,7 +439,7 @@
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="visibility">False</property>
<property name="invisible-char">*</property>
<property name="invisible-char"></property>
<property name="secondary-icon-name">view-reveal-symbolic</property>
<property name="placeholder-text" translatable="yes">New Password</property>
<style>
Expand All @@ -423,7 +458,7 @@
<property name="can-focus">True</property>
<property name="valign">center</property>
<property name="visibility">False</property>
<property name="invisible-char">*</property>
<property name="invisible-char"></property>
<property name="secondary-icon-name">view-reveal-symbolic</property>
<property name="placeholder-text" translatable="yes">New Password Again</property>
<style>
Expand Down Expand Up @@ -518,7 +553,7 @@
</object>
<packing>
<property name="name">page_reset_password</property>
<property name="title">page_reset_password</property>
<property name="title" translatable="yes">page_reset_password</property>
<property name="position">1</property>
</packing>
</child>
Expand Down Expand Up @@ -626,7 +661,7 @@ and restart the computer ?</property>
</object>
<packing>
<property name="name">page_restart</property>
<property name="title">page_restart</property>
<property name="title" translatable="yes">page_restart</property>
<property name="position">2</property>
</packing>
</child>
Expand Down Expand Up @@ -734,7 +769,7 @@ and power off the computer ?</property>
</object>
<packing>
<property name="name">page_poweroff</property>
<property name="title">page_poweroff</property>
<property name="title" translatable="yes">page_poweroff</property>
<property name="position">3</property>
</packing>
</child>
Expand Down Expand Up @@ -878,13 +913,16 @@ and power off the computer ?</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="margin-left">10</property>
<property name="margin-start">10</property>
<property name="spacing">6</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkImage" id="ui_icon_numlock">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">3</property>
<property name="margin-right">4</property>
<property name="margin-start">3</property>
<property name="margin-end">4</property>
<property name="margin-top">3</property>
Expand All @@ -906,6 +944,8 @@ and power off the computer ?</property>
<object class="GtkImage" id="ui_icon_capslock">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">3</property>
<property name="margin-right">3</property>
<property name="margin-start">3</property>
<property name="margin-end">3</property>
<property name="margin-top">3</property>
Expand Down Expand Up @@ -936,6 +976,7 @@ and power off the computer ?</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="margin-left">13</property>
<property name="margin-start">13</property>
<property name="spacing">13</property>
<child>
Expand Down Expand Up @@ -964,7 +1005,7 @@ and power off the computer ?</property>
<child>
<object class="GtkButton" id="ui_button_note">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
Expand Down Expand Up @@ -1032,7 +1073,7 @@ and power off the computer ?</property>
<child>
<object class="GtkButton" id="ui_button_network">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
Expand Down Expand Up @@ -1066,7 +1107,7 @@ and power off the computer ?</property>
<child>
<object class="GtkButton" id="ui_button_powermenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
Expand Down Expand Up @@ -1100,7 +1141,7 @@ and power off the computer ?</property>
<child>
<object class="GtkButton" id="ui_button_options">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
Expand Down Expand Up @@ -1180,7 +1221,7 @@ and power off the computer ?</property>
</style>
</object>
<packing>
<property name="name">main_page</property>
<property name="index">1</property>
</packing>
</child>
</object>
Expand Down
18 changes: 10 additions & 8 deletions src/module/gtkwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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")+"&")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7a9f25e

Please sign in to comment.