mirror of
https://github.com/Snigdha-OS/snigdhaos-welcome.git
synced 2025-09-21 06:24:56 +02:00
⚡️ perf: add inline explanation
This commit is contained in:
@@ -1,22 +1,39 @@
|
|||||||
import gi
|
import gi
|
||||||
|
|
||||||
|
# Required to specify the version of the Gtk library to use
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
|
||||||
|
# Custom class `Stack` inheriting from `Gtk.Stack`
|
||||||
class Stack(Gtk.Stack):
|
class Stack(Gtk.Stack):
|
||||||
def __init__(self, transition_type):
|
def __init__(self, transition_type):
|
||||||
|
# Call the initializer of the parent class
|
||||||
super(Stack, self).__init__()
|
super(Stack, self).__init__()
|
||||||
|
|
||||||
# self.set_transition_type(Gtk.StackTransitionType.ROTATE_LEFT)
|
# Determine the transition type based on the input argument
|
||||||
|
# If the input is "ROTATE_LEFT", set it to the corresponding Gtk transition type
|
||||||
if transition_type == "ROTATE_LEFT":
|
if transition_type == "ROTATE_LEFT":
|
||||||
transition_type = Gtk.StackTransitionType.ROTATE_LEFT
|
transition_type = Gtk.StackTransitionType.ROTATE_LEFT
|
||||||
|
|
||||||
|
# If the input is "CROSSFADE", set it to the corresponding Gtk transition type
|
||||||
if transition_type == "CROSSFADE":
|
if transition_type == "CROSSFADE":
|
||||||
transition_type = Gtk.StackTransitionType.CROSSFADE
|
transition_type = Gtk.StackTransitionType.CROSSFADE
|
||||||
|
|
||||||
|
# Set the stack transition type (animation between stack pages)
|
||||||
self.set_transition_type(transition_type)
|
self.set_transition_type(transition_type)
|
||||||
|
|
||||||
|
# Allow the widget to expand horizontally to fill available space
|
||||||
self.set_hexpand(True)
|
self.set_hexpand(True)
|
||||||
|
|
||||||
|
# Allow the widget to expand vertically to fill available space
|
||||||
self.set_vexpand(True)
|
self.set_vexpand(True)
|
||||||
|
|
||||||
|
# Set the duration of the transition animation in milliseconds
|
||||||
self.set_transition_duration(500)
|
self.set_transition_duration(500)
|
||||||
|
|
||||||
|
# Disable horizontal homogeneity, allowing child widgets to have different widths
|
||||||
self.set_hhomogeneous(False)
|
self.set_hhomogeneous(False)
|
||||||
|
|
||||||
|
# Disable vertical homogeneity, allowing child widgets to have different heights
|
||||||
self.set_vhomogeneous(False)
|
self.set_vhomogeneous(False)
|
||||||
|
Reference in New Issue
Block a user