window switcher
This commit is contained in:
@@ -4,16 +4,20 @@ from typing import Any
|
||||
import gi
|
||||
from clan_cli.clan_uri import ClanURI
|
||||
|
||||
from ..app import Application
|
||||
from ..interfaces import Callbacks, InitialJoinValues
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gio, Gtk
|
||||
from typing import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
|
||||
class JoinWindow(Gtk.ApplicationWindow):
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, initial_values: InitialJoinValues, cbs: Callbacks ) -> None:
|
||||
super().__init__()
|
||||
# Initialize the main window
|
||||
# Initialize the main wincbsdow
|
||||
self.cbs = cbs
|
||||
self.set_title("cLAN Manager")
|
||||
self.connect("delete-event", self.on_quit)
|
||||
self.set_default_size(800, 600)
|
||||
@@ -21,28 +25,25 @@ class JoinWindow(Gtk.ApplicationWindow):
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, expand=True)
|
||||
self.add(vbox)
|
||||
|
||||
# Add a notebook layout
|
||||
# https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html#notebook
|
||||
self.notebook = Gtk.Notebook()
|
||||
self.stack = Gtk.Stack()
|
||||
|
||||
self.stack.add_titled(Gtk.Label("Join cLan"), "join", "Join")
|
||||
self.stack.add_titled(Gtk.Label(str(initial_values.url)), "join", "Join")
|
||||
|
||||
vbox.add(self.stack)
|
||||
vbox.add(Gtk.Entry(text=str(initial_values.url)))
|
||||
|
||||
|
||||
button = Gtk.Button(label="To List", )
|
||||
button.connect("clicked", self.switch)
|
||||
vbox.add(button)
|
||||
|
||||
# Must be called AFTER all components were added
|
||||
self.show_all()
|
||||
|
||||
def switch(self, widget: Gtk.Widget) -> None:
|
||||
self.cbs.show_list()
|
||||
|
||||
def on_quit(self, *args: Any) -> None:
|
||||
Gio.Application.quit(self.get_application())
|
||||
|
||||
|
||||
|
||||
def show_join(args: argparse.Namespace) -> None:
|
||||
print(f"Joining clan {args.clan_uri}")
|
||||
app = Application(JoinWindow())
|
||||
return app.run()
|
||||
|
||||
|
||||
def register_join_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument("clan_uri", type=ClanURI, help="clan URI to join")
|
||||
parser.set_defaults(func=show_join)
|
||||
|
||||
@@ -9,7 +9,6 @@ import argparse
|
||||
|
||||
from gi.repository import Gio, Gtk
|
||||
|
||||
from ..app import Application
|
||||
from ..ui.clan_join_page import ClanJoinPage
|
||||
from ..ui.clan_select_list import ClanEdit, ClanList
|
||||
|
||||
@@ -86,12 +85,4 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
||||
|
||||
def on_quit(self, *args: Any) -> None:
|
||||
Gio.Application.quit(self.get_application())
|
||||
|
||||
|
||||
def show_overview(args: argparse.Namespace) -> None:
|
||||
app = Application(OverviewWindow())
|
||||
return app.run()
|
||||
|
||||
|
||||
def register_overview_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.set_defaults(func=show_overview)
|
||||
|
||||
Reference in New Issue
Block a user