Added join window
This commit is contained in:
parent
6b8216b3ac
commit
7d22f7c9fc
@ -1,11 +1,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
from .app import Application
|
|
||||||
from clan_cli.clan_uri import ClanURI
|
|
||||||
|
|
||||||
from .windows.join import register_join_parser
|
from .windows.join import register_join_parser
|
||||||
from .windows.overview import show_overview, OverviewWindow
|
from .windows.overview import register_overview_parser, show_overview
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
@ -19,6 +15,8 @@ def main() -> None:
|
|||||||
)
|
)
|
||||||
register_join_parser(subparser.add_parser("join", help="join a clan"))
|
register_join_parser(subparser.add_parser("join", help="join a clan"))
|
||||||
|
|
||||||
|
register_overview_parser(subparser.add_parser("overview", help="overview screen"))
|
||||||
|
|
||||||
# Executed when no command is given
|
# Executed when no command is given
|
||||||
parser.set_defaults(func=show_overview)
|
parser.set_defaults(func=show_overview)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
from .models import VMBase
|
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gio, Gtk
|
from gi.repository import Gio, Gtk
|
||||||
|
|
||||||
from .constants import constants
|
from .constants import constants
|
||||||
from .ui.clan_join_page import ClanJoinPage
|
|
||||||
from .ui.clan_select_list import ClanEdit, ClanList
|
|
||||||
|
|
||||||
|
|
||||||
class Application(Gtk.Application):
|
class Application(Gtk.Application):
|
||||||
@ -30,7 +24,8 @@ class Application(Gtk.Application):
|
|||||||
def do_activate(self) -> None:
|
def do_activate(self) -> None:
|
||||||
win = self.props.active_window
|
win = self.props.active_window
|
||||||
if not win:
|
if not win:
|
||||||
win = self.window(application=self)
|
win = self.window
|
||||||
|
win.set_application(self)
|
||||||
win.present()
|
win.present()
|
||||||
|
|
||||||
# TODO: For css styling
|
# TODO: For css styling
|
||||||
|
@ -1,16 +1,46 @@
|
|||||||
from ..app import Application
|
|
||||||
import argparse
|
import argparse
|
||||||
from .overview import OverviewWindow
|
from typing import Any
|
||||||
|
|
||||||
|
import gi
|
||||||
from clan_cli.clan_uri import ClanURI
|
from clan_cli.clan_uri import ClanURI
|
||||||
|
|
||||||
|
from ..app import Application
|
||||||
|
|
||||||
|
gi.require_version("Gtk", "3.0")
|
||||||
|
from gi.repository import Gio, Gtk
|
||||||
|
|
||||||
|
|
||||||
|
class JoinWindow(Gtk.ApplicationWindow):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
# Initialize the main window
|
||||||
|
self.set_title("cLAN Manager")
|
||||||
|
self.connect("delete-event", self.on_quit)
|
||||||
|
self.set_default_size(800, 600)
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
vbox.add(self.stack)
|
||||||
|
|
||||||
|
# Must be called AFTER all components were added
|
||||||
|
self.show_all()
|
||||||
|
|
||||||
|
def on_quit(self, *args: Any) -> None:
|
||||||
|
Gio.Application.quit(self.get_application())
|
||||||
|
|
||||||
|
|
||||||
def show_join(args: argparse.Namespace) -> None:
|
def show_join(args: argparse.Namespace) -> None:
|
||||||
print(f"Joining clan {args.clan_uri}")
|
print(f"Joining clan {args.clan_uri}")
|
||||||
app = Application(OverviewWindow)
|
app = Application(JoinWindow())
|
||||||
return app.run()
|
return app.run()
|
||||||
|
|
||||||
|
|
||||||
def register_join_parser(parser: argparse.ArgumentParser) -> None:
|
def register_join_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
parser.add_argument("clan_uri", type=ClanURI, help="clan URI to join")
|
parser.add_argument("clan_uri", type=ClanURI, help="clan URI to join")
|
||||||
parser.set_defaults(func=show_join)
|
parser.set_defaults(func=show_join)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import sys
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@ -6,18 +5,18 @@ import gi
|
|||||||
from ..models import VMBase
|
from ..models import VMBase
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gio, Gtk
|
|
||||||
|
|
||||||
from ..constants import constants
|
|
||||||
from ..ui.clan_join_page import ClanJoinPage
|
|
||||||
from ..ui.clan_select_list import ClanEdit, ClanList
|
|
||||||
from ..app import Application
|
|
||||||
from clan_cli.clan_uri import ClanURI
|
|
||||||
import argparse
|
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
|
||||||
|
|
||||||
|
|
||||||
class OverviewWindow(Gtk.ApplicationWindow):
|
class OverviewWindow(Gtk.ApplicationWindow):
|
||||||
def __init__(self, application: Gtk.Application) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__(application=application)
|
super().__init__()
|
||||||
# Initialize the main window
|
# Initialize the main window
|
||||||
self.set_title("cLAN Manager")
|
self.set_title("cLAN Manager")
|
||||||
self.connect("delete-event", self.on_quit)
|
self.connect("delete-event", self.on_quit)
|
||||||
@ -89,15 +88,10 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
|||||||
Gio.Application.quit(self.get_application())
|
Gio.Application.quit(self.get_application())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def show_overview(args: argparse.Namespace) -> None:
|
def show_overview(args: argparse.Namespace) -> None:
|
||||||
app = Application(OverviewWindow)
|
app = Application(OverviewWindow())
|
||||||
return app.run()
|
return app.run()
|
||||||
|
|
||||||
|
|
||||||
def register_overview_parser(parser: argparse.ArgumentParser) -> None:
|
def register_overview_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
parser.add_argument("clan_uri", type=ClanURI, help="clan URI to join")
|
|
||||||
parser.set_defaults(func=show_overview)
|
parser.set_defaults(func=show_overview)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user