clan_vm_manager: Renamed Views to ViewStack
This commit is contained in:
parent
11c3b6f353
commit
47ae5981f6
@ -7,20 +7,20 @@ gi.require_version("Adw", "1")
|
|||||||
from gi.repository import Adw
|
from gi.repository import Adw
|
||||||
|
|
||||||
|
|
||||||
class Views:
|
class ViewStack:
|
||||||
"""
|
"""
|
||||||
This is a singleton.
|
This is a singleton.
|
||||||
It is initialized with the first call of use()
|
It is initialized with the first call of use()
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
Views.use().set_visible()
|
ViewStack.use().set_visible()
|
||||||
|
|
||||||
Views.use() can also be called before the data is needed. e.g. to eliminate/reduce waiting time.
|
ViewStack.use() can also be called before the data is needed. e.g. to eliminate/reduce waiting time.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_instance: "None | Views" = None
|
_instance: "None | ViewStack" = None
|
||||||
view: Adw.ViewStack
|
view: Adw.ViewStack
|
||||||
|
|
||||||
# Make sure the VMS class is used as a singleton
|
# Make sure the VMS class is used as a singleton
|
||||||
@ -28,7 +28,7 @@ class Views:
|
|||||||
raise RuntimeError("Call use() instead")
|
raise RuntimeError("Call use() instead")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def use(cls: Any) -> "Views":
|
def use(cls: Any) -> "ViewStack":
|
||||||
if cls._instance is None:
|
if cls._instance is None:
|
||||||
cls._instance = cls.__new__(cls)
|
cls._instance = cls.__new__(cls)
|
||||||
cls.view = Adw.ViewStack()
|
cls.view = Adw.ViewStack()
|
||||||
|
@ -6,7 +6,7 @@ import gi
|
|||||||
from clan_cli.history.list import list_history
|
from clan_cli.history.list import list_history
|
||||||
|
|
||||||
from clan_vm_manager.components.interfaces import ClanConfig
|
from clan_vm_manager.components.interfaces import ClanConfig
|
||||||
from clan_vm_manager.singletons.use_views import Views
|
from clan_vm_manager.singletons.use_views import ViewStack
|
||||||
from clan_vm_manager.singletons.use_vms import ClanStore
|
from clan_vm_manager.singletons.use_vms import ClanStore
|
||||||
from clan_vm_manager.views.details import Details
|
from clan_vm_manager.views.details import Details
|
||||||
from clan_vm_manager.views.list import ClanList
|
from clan_vm_manager.views.list import ClanList
|
||||||
@ -39,7 +39,7 @@ class MainWindow(Adw.ApplicationWindow):
|
|||||||
threading.Thread(target=self._populate_vms).start()
|
threading.Thread(target=self._populate_vms).start()
|
||||||
|
|
||||||
# Initialize all views
|
# Initialize all views
|
||||||
stack_view = Views.use().view
|
stack_view = ViewStack.use().view
|
||||||
|
|
||||||
scroll = Gtk.ScrolledWindow()
|
scroll = Gtk.ScrolledWindow()
|
||||||
scroll.set_propagate_natural_height(True)
|
scroll.set_propagate_natural_height(True)
|
||||||
|
Loading…
Reference in New Issue
Block a user