forked from clan/clan-core
prepare gtk4 migration
This commit is contained in:
parent
07a0e1db09
commit
40ee264321
@ -8,7 +8,7 @@ from clan_cli import vms
|
||||
|
||||
from clan_vm_manager.windows.flash import FlashUSBWindow
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
|
||||
import multiprocessing as mp
|
||||
|
||||
|
@ -4,19 +4,19 @@ from typing import Literal
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version('Adw', '1')
|
||||
from clan_cli.errors import ClanError
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import Gtk, Adw
|
||||
|
||||
Severity = Literal["Error"] | Literal["Warning"] | Literal["Info"] | str
|
||||
|
||||
|
||||
def show_error_dialog(error: ClanError, severity: Severity | None = "Error") -> None:
|
||||
message = str(error)
|
||||
dialog = Gtk.MessageDialog(
|
||||
None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, severity
|
||||
dialog = Adw.MessageDialog(
|
||||
parent=None, heading=severity, body=message
|
||||
)
|
||||
print("error:", message)
|
||||
dialog.format_secondary_text(message)
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
dialog.add_response("ok", "ok")
|
||||
dialog.choose()
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
|
||||
@ -11,16 +11,17 @@ class ClanJoinPage(Gtk.Box):
|
||||
def __init__(self, *, stack: Gtk.Stack) -> None:
|
||||
super().__init__()
|
||||
self.page = Gtk.Box(
|
||||
orientation=Gtk.Orientation.VERTICAL, spacing=6, expand=True
|
||||
orientation=Gtk.Orientation.VERTICAL, spacing=6
|
||||
)
|
||||
self.set_border_width(10)
|
||||
# self.set_border_width(10)
|
||||
self.stack = stack
|
||||
|
||||
button = Gtk.Button(label="Back to list", margin_left=10)
|
||||
button = Gtk.Button(label="Back to list")
|
||||
button.connect("clicked", self.switch)
|
||||
self.add(button)
|
||||
self.append(button)
|
||||
|
||||
self.add(Gtk.Label("Join cLan"))
|
||||
label = Gtk.Label.new("Join cLan")
|
||||
self.append(label)
|
||||
|
||||
def switch(self, widget: Gtk.Widget) -> None:
|
||||
self.stack.set_visible_child_name("list")
|
||||
|
@ -1,48 +1,48 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Callable, Any
|
||||
|
||||
from gi.repository import Gdk, GdkPixbuf, Gtk
|
||||
from gi.repository import Gdk, GdkPixbuf, Gtk, Adw
|
||||
|
||||
from ..interfaces import Callbacks
|
||||
from ..models import VMBase, VMStatus
|
||||
from .context_menu import VmMenu
|
||||
# from .context_menu import VmMenu
|
||||
|
||||
|
||||
class ClanEditForm(Gtk.ListBox):
|
||||
class ClanEditForm(Gtk.Box):
|
||||
def __init__(self, *, selected: VMBase | None) -> None:
|
||||
super().__init__()
|
||||
self.page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True)
|
||||
self.set_border_width(10)
|
||||
self.page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
# self.set_border_width(10)
|
||||
self.selected = selected
|
||||
self.set_selection_mode(0)
|
||||
# self.set_selection_mode(0)
|
||||
|
||||
if self.selected:
|
||||
row = Gtk.ListBoxRow()
|
||||
row.add(Gtk.Label(f"\n {self.selected.name}"))
|
||||
self.add(row)
|
||||
label = Gtk.Box()
|
||||
label.append(Gtk.Label.new(f"\n {self.selected.name}"))
|
||||
self.append(label)
|
||||
|
||||
# ---------- row 1 --------
|
||||
row = Gtk.ListBoxRow()
|
||||
row_layout = Gtk.Box(spacing=6, expand=True)
|
||||
# row = Gtk.ListBoxRow()
|
||||
# row_layout = Gtk.Box(spacing=6)
|
||||
|
||||
# Doc: pack_start/end takes alignment params Expand, Fill, Padding
|
||||
row_layout.pack_start(Gtk.Label("Memory Size in MiB"), False, False, 5)
|
||||
row_layout.pack_start(
|
||||
Gtk.SpinButton.new_with_range(512, 4096, 256), True, True, 0
|
||||
)
|
||||
# # Doc: pack_start/end takes alignment params Expand, Fill, Padding
|
||||
# row_layout.append(Gtk.Label.new("Memory Size in MiB"))
|
||||
# row_layout.append(
|
||||
# Gtk.SpinButton.new_with_range(512, 4096, 256)
|
||||
# )
|
||||
|
||||
row.add(row_layout)
|
||||
self.add(row)
|
||||
# row.append(row_layout)
|
||||
# self.append(row)
|
||||
|
||||
# ----------- row 2 -------
|
||||
# # ----------- row 2 -------
|
||||
|
||||
row = Gtk.ListBoxRow()
|
||||
row_layout = Gtk.Box(spacing=6, expand=True)
|
||||
# row = Gtk.ListBoxRow()
|
||||
# row_layout = Gtk.Box(spacing=6)
|
||||
|
||||
row_layout.pack_start(Gtk.Label("CPU Count"), False, False, 5)
|
||||
row_layout.pack_end(Gtk.SpinButton.new_with_range(1, 5, 1), True, True, 0)
|
||||
# row_layout.append(Gtk.Label("CPU Count"))
|
||||
# row_layout.append(Gtk.SpinButton.new_with_range(1, 5, 1))
|
||||
|
||||
row.add(row_layout)
|
||||
self.add(row)
|
||||
# row.append(row_layout)
|
||||
# self.append(row)
|
||||
|
||||
def switch(self, widget: Gtk.Widget) -> None:
|
||||
self.show_list()
|
||||
@ -52,14 +52,14 @@ class ClanEdit(Gtk.Box):
|
||||
def __init__(
|
||||
self, *, remount_list: Callable[[], None], selected_vm: VMBase | None
|
||||
) -> None:
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL, expand=True)
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL, )
|
||||
|
||||
self.show_list = remount_list
|
||||
self.selected = selected_vm
|
||||
|
||||
self.toolbar = ClanEditToolbar(on_save_clicked=self.on_save)
|
||||
self.add(self.toolbar)
|
||||
self.add(ClanEditForm(selected=self.selected))
|
||||
# self.toolbar = ClanEditToolbar(on_save_clicked=self.on_save)
|
||||
# self.add(self.toolbar)
|
||||
self.append(ClanEditForm(selected=self.selected))
|
||||
|
||||
def on_save(self, widget: Gtk.Widget) -> None:
|
||||
print("Save clicked saving values")
|
||||
@ -90,7 +90,7 @@ class ClanList(Gtk.Box):
|
||||
selected_vm: VMBase | None,
|
||||
vms: list[VMBase],
|
||||
) -> None:
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL, expand=True)
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL, )
|
||||
|
||||
self.remount_edit_view = remount_edit
|
||||
self.remount_list_view = remount_list
|
||||
@ -100,17 +100,17 @@ class ClanList(Gtk.Box):
|
||||
|
||||
self.selected_vm: VMBase | None = selected_vm
|
||||
|
||||
self.toolbar = ClanListToolbar(
|
||||
selected_vm=selected_vm,
|
||||
on_start_clicked=self.on_start_clicked,
|
||||
on_stop_clicked=self.on_stop_clicked,
|
||||
on_edit_clicked=self.on_edit_clicked,
|
||||
on_join_clan_clicked=self.on_join_clan_clicked,
|
||||
on_flash_clicked=self.on_flash_clicked,
|
||||
)
|
||||
self.add(self.toolbar)
|
||||
# self.toolbar = ClanListToolbar(
|
||||
# selected_vm=selected_vm,
|
||||
# on_start_clicked=self.on_start_clicked,
|
||||
# on_stop_clicked=self.on_stop_clicked,
|
||||
# on_edit_clicked=self.on_edit_clicked,
|
||||
# on_join_clan_clicked=self.on_join_clan_clicked,
|
||||
# on_flash_clicked=self.on_flash_clicked,
|
||||
# )
|
||||
# self.add(self.toolbar)
|
||||
|
||||
self.add(
|
||||
self.append(
|
||||
ClanListView(
|
||||
vms=vms,
|
||||
on_select_row=self.on_select_vm,
|
||||
@ -143,13 +143,13 @@ class ClanList(Gtk.Box):
|
||||
self.remount_edit_view()
|
||||
|
||||
def on_select_vm(self, vm: VMBase) -> None:
|
||||
self.toolbar.set_selected_vm(vm)
|
||||
# self.toolbar.set_selected_vm(vm)
|
||||
|
||||
self.set_selected(vm)
|
||||
self.selected_vm = vm
|
||||
|
||||
|
||||
class ClanListToolbar(Gtk.Toolbar):
|
||||
class ClanListToolbar(Gtk.Box):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@ -164,23 +164,23 @@ class ClanListToolbar(Gtk.Toolbar):
|
||||
|
||||
self.start_button = Gtk.ToolButton(label="Start")
|
||||
self.start_button.connect("clicked", on_start_clicked)
|
||||
self.add(self.start_button)
|
||||
self.append(self.start_button)
|
||||
|
||||
self.stop_button = Gtk.ToolButton(label="Stop")
|
||||
self.stop_button.connect("clicked", on_stop_clicked)
|
||||
self.add(self.stop_button)
|
||||
self.append(self.stop_button)
|
||||
|
||||
self.edit_button = Gtk.ToolButton(label="Edit")
|
||||
self.edit_button.connect("clicked", on_edit_clicked)
|
||||
self.add(self.edit_button)
|
||||
self.append(self.edit_button)
|
||||
|
||||
self.join_clan_button = Gtk.ToolButton(label="Join Clan")
|
||||
self.join_clan_button.connect("clicked", on_join_clan_clicked)
|
||||
self.add(self.join_clan_button)
|
||||
self.append(self.join_clan_button)
|
||||
|
||||
self.flash_button = Gtk.ToolButton(label="Write to USB")
|
||||
self.flash_button.connect("clicked", on_flash_clicked)
|
||||
self.add(self.flash_button)
|
||||
self.append(self.flash_button)
|
||||
|
||||
self.set_selected_vm(selected_vm)
|
||||
|
||||
@ -195,7 +195,7 @@ class ClanListToolbar(Gtk.Toolbar):
|
||||
self.stop_button.set_sensitive(False)
|
||||
|
||||
|
||||
class ClanEditToolbar(Gtk.Toolbar):
|
||||
class ClanEditToolbar(Gtk.Box):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
@ -208,7 +208,7 @@ class ClanEditToolbar(Gtk.Toolbar):
|
||||
self.save_button = Gtk.ToolButton(label="Save")
|
||||
self.save_button.connect("clicked", on_save_clicked)
|
||||
|
||||
self.add(self.save_button)
|
||||
self.append(self.save_button)
|
||||
|
||||
|
||||
class ClanListView(Gtk.Box):
|
||||
@ -220,29 +220,29 @@ class ClanListView(Gtk.Box):
|
||||
vms: list[VMBase],
|
||||
on_double_click: Callable[[VMBase], None],
|
||||
) -> None:
|
||||
super().__init__(expand=True)
|
||||
super().__init__()
|
||||
self.vms: list[VMBase] = vms
|
||||
self.on_select_row = on_select_row
|
||||
self.on_double_click = on_double_click
|
||||
self.context_menu: VmMenu | None = None
|
||||
# self.context_menu: VmMenu | None = None
|
||||
|
||||
store_types = VMBase.name_to_type_map().values()
|
||||
|
||||
self.list_store = Gtk.ListStore(*store_types)
|
||||
self.tree_view = Gtk.TreeView(self.list_store, expand=True)
|
||||
for vm in self.vms:
|
||||
self.insertVM(vm)
|
||||
# self.list_store = Gtk.ListStore(*store_types)
|
||||
# self.tree_view = Gtk.TreeView(self.list_store)
|
||||
# for vm in self.vms:
|
||||
# self.insertVM(vm)
|
||||
|
||||
setColRenderers(self.tree_view)
|
||||
# setColRenderers(self.tree_view)
|
||||
|
||||
self.set_selected_vm(selected_vm)
|
||||
selection = self.tree_view.get_selection()
|
||||
selection.connect("changed", self._on_select_row)
|
||||
self.tree_view.connect("row-activated", self._on_double_click)
|
||||
self.tree_view.connect("button-press-event", self._on_button_pressed)
|
||||
# selection = self.tree_view.get_selection()
|
||||
# selection.connect("changed", self._on_select_row)
|
||||
# self.tree_view.connect("row-activated", self._on_double_click)
|
||||
# self.tree_view.connect("button-press-event", self._on_button_pressed)
|
||||
|
||||
self.set_border_width(10)
|
||||
self.add(self.tree_view)
|
||||
# self.set_border_width(10)
|
||||
# self.append(self.tree_view)
|
||||
|
||||
def find_vm(self, vm: VMBase) -> int:
|
||||
for idx, row in enumerate(self.list_store):
|
||||
@ -257,13 +257,13 @@ class ClanListView(Gtk.Box):
|
||||
idx = self.find_vm(vm)
|
||||
selection.select_path(idx)
|
||||
|
||||
def insertVM(self, vm: VMBase) -> None:
|
||||
values = list(vm.list_data().values())
|
||||
icon_idx = VMBase.to_idx("Icon")
|
||||
values[icon_idx] = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filename=values[icon_idx], width=64, height=64, preserve_aspect_ratio=True
|
||||
)
|
||||
self.list_store.append(values)
|
||||
# def insertVM(self, vm: VMBase) -> None:
|
||||
# values = list(vm.list_data().values())
|
||||
# icon_idx = VMBase.to_idx("Icon")
|
||||
# values[icon_idx] = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
# filename=values[icon_idx], width=64, height=64, preserve_aspect_ratio=True
|
||||
# )
|
||||
# self.list_store.append(values)
|
||||
|
||||
def _on_select_row(self, selection: Gtk.TreeSelection) -> None:
|
||||
model, row = selection.get_selected()
|
||||
@ -271,58 +271,58 @@ class ClanListView(Gtk.Box):
|
||||
vm = VMBase(*model[row])
|
||||
self.on_select_row(vm)
|
||||
|
||||
def _on_button_pressed(
|
||||
self, tree_view: Gtk.TreeView, event: Gdk.EventButton
|
||||
) -> None:
|
||||
if self.context_menu:
|
||||
self.context_menu.destroy()
|
||||
self.context_menu = None
|
||||
# def _on_button_pressed(
|
||||
# self, tree_view: Gtk.TreeView, event: Any
|
||||
# ) -> None:
|
||||
# # if self.context_menu:
|
||||
# # self.context_menu.destroy()
|
||||
# # self.context_menu = None
|
||||
|
||||
if event.button == 3:
|
||||
path, column, x, y = tree_view.get_path_at_pos(event.x, event.y)
|
||||
if path is not None:
|
||||
vm = VMBase(*self.list_store[path[0]])
|
||||
print(event)
|
||||
print(f"Right click on {vm.url}")
|
||||
self.context_menu = VmMenu(vm)
|
||||
self.context_menu.popup_at_pointer(event)
|
||||
# if event.button == 3:
|
||||
# path, column, x, y = tree_view.get_path_at_pos(event.x, event.y)
|
||||
# if path is not None:
|
||||
# vm = VMBase(*self.list_store[path[0]])
|
||||
# print(event)
|
||||
# print(f"Right click on {vm.url}")
|
||||
# # self.context_menu = VmMenu(vm)
|
||||
# # self.context_menu.popup_at_pointer(event)
|
||||
|
||||
def _on_double_click(
|
||||
self, tree_view: Gtk.TreeView, path: Gtk.TreePath, column: Gtk.TreeViewColumn
|
||||
) -> None:
|
||||
# Get the selection object of the tree view
|
||||
selection = tree_view.get_selection()
|
||||
model, row = selection.get_selected()
|
||||
# def _on_double_click(
|
||||
# self, tree_view: Gtk.TreeView, path: Gtk.TreePath, column: Gtk.TreeViewColumn
|
||||
# ) -> None:
|
||||
# # Get the selection object of the tree view
|
||||
# selection = tree_view.get_selection()
|
||||
# model, row = selection.get_selected()
|
||||
|
||||
if row is not None:
|
||||
vm = VMBase(*model[row])
|
||||
self.on_double_click(vm)
|
||||
# if row is not None:
|
||||
# vm = VMBase(*model[row])
|
||||
# self.on_double_click(vm)
|
||||
|
||||
|
||||
def setColRenderers(tree_view: Gtk.TreeView) -> None:
|
||||
for idx, (key, gtype) in enumerate(VMBase.name_to_type_map().items()):
|
||||
col: Gtk.TreeViewColumn = None
|
||||
# def setColRenderers(tree_view: Gtk.TreeView) -> None:
|
||||
# for idx, (key, gtype) in enumerate(VMBase.name_to_type_map().items()):
|
||||
# col: Gtk.TreeViewColumn = None
|
||||
|
||||
if key.startswith("_"):
|
||||
continue
|
||||
# if key.startswith("_"):
|
||||
# continue
|
||||
|
||||
if issubclass(gtype, GdkPixbuf.Pixbuf):
|
||||
renderer = Gtk.CellRendererPixbuf()
|
||||
col = Gtk.TreeViewColumn(key, renderer, pixbuf=idx)
|
||||
elif issubclass(gtype, bool):
|
||||
renderer = Gtk.CellRendererToggle()
|
||||
col = Gtk.TreeViewColumn(key, renderer, active=idx)
|
||||
elif issubclass(gtype, str):
|
||||
renderer = Gtk.CellRendererText()
|
||||
col = Gtk.TreeViewColumn(key, renderer, text=idx)
|
||||
else:
|
||||
raise Exception(f"Unknown type: {gtype}")
|
||||
# if issubclass(gtype, GdkPixbuf.Pixbuf):
|
||||
# renderer = Gtk.CellRendererPixbuf()
|
||||
# col = Gtk.TreeViewColumn(key, renderer, pixbuf=idx)
|
||||
# elif issubclass(gtype, bool):
|
||||
# renderer = Gtk.CellRendererToggle()
|
||||
# col = Gtk.TreeViewColumn(key, renderer, active=idx)
|
||||
# elif issubclass(gtype, str):
|
||||
# renderer = Gtk.CellRendererText()
|
||||
# col = Gtk.TreeViewColumn(key, renderer, text=idx)
|
||||
# else:
|
||||
# raise Exception(f"Unknown type: {gtype}")
|
||||
|
||||
# CommonSetup for all columns
|
||||
if col:
|
||||
col.set_resizable(True)
|
||||
col.set_expand(True)
|
||||
col.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
|
||||
col.set_property("alignment", 0.5)
|
||||
col.set_sort_column_id(idx)
|
||||
tree_view.append_column(col)
|
||||
# # CommonSetup for all columns
|
||||
# if col:
|
||||
# col.set_resizable(True)
|
||||
# col.set_expand(True)
|
||||
# col.set_property("sizing", Gtk.TreeViewColumnSizing.AUTOSIZE)
|
||||
# col.set_property("alignment", 0.5)
|
||||
# col.set_sort_column_id(idx)
|
||||
# tree_view.append_column(col)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from ..models import VMBase
|
||||
@ -21,7 +21,7 @@ class VmMenu(Gtk.Menu):
|
||||
menu_item = Gtk.MenuItem(label=item[0])
|
||||
menu_item.connect("activate", item[1])
|
||||
self.append(menu_item)
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
|
||||
def start_vm(self, widget: Gtk.Widget) -> None:
|
||||
print("start_vm")
|
||||
|
@ -7,7 +7,7 @@ from clan_vm_manager.errors.show_error import show_error_dialog
|
||||
|
||||
from ..interfaces import Callbacks, InitialFlashValues
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
|
||||
from gi.repository import Gio, Gtk
|
||||
|
||||
@ -29,19 +29,19 @@ class FlashUSBWindow(Gtk.ApplicationWindow):
|
||||
# Initialize the main wincbsdow
|
||||
# self.cbs = cbs
|
||||
self.set_title("cLAN Manager")
|
||||
self.connect("delete-event", self.on_quit)
|
||||
# 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)
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, )
|
||||
self.append(vbox)
|
||||
|
||||
button = Gtk.ToolButton()
|
||||
button.set_icon_name("go-previous")
|
||||
button.connect("clicked", self.switch)
|
||||
|
||||
toolbar = Gtk.Toolbar(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
toolbar.add(button)
|
||||
vbox.add(toolbar)
|
||||
# toolbar = Gtk.Toolbar(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
# toolbar.add(button)
|
||||
# vbox.add(toolbar)
|
||||
|
||||
self.stack = Gtk.Stack()
|
||||
|
||||
@ -52,10 +52,10 @@ class FlashUSBWindow(Gtk.ApplicationWindow):
|
||||
"Details",
|
||||
)
|
||||
|
||||
vbox.add(self.stack)
|
||||
vbox.append(self.stack)
|
||||
|
||||
# Must be called AFTER all components were added
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
|
||||
def switch(self, widget: Gtk.Widget) -> None:
|
||||
pass
|
||||
|
@ -12,9 +12,11 @@ from clan_vm_manager.errors.show_error import show_error_dialog
|
||||
|
||||
from ..interfaces import Callbacks, InitialJoinValues
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
|
||||
from gi.repository import GdkPixbuf, Gio, Gtk
|
||||
|
||||
from gi.repository import GdkPixbuf, Gio, Gtk, Adw
|
||||
|
||||
|
||||
class Trust(Gtk.Box):
|
||||
@ -36,16 +38,16 @@ class Trust(Gtk.Box):
|
||||
preserve_aspect_ratio=True,
|
||||
)
|
||||
)
|
||||
layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True)
|
||||
layout.set_border_width(20)
|
||||
layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
# layout.set_border_width(20)
|
||||
layout.set_spacing(20)
|
||||
|
||||
if self.url is not None:
|
||||
self.entry = Gtk.Label(label=str(self.url))
|
||||
layout.add(icon)
|
||||
layout.add(Gtk.Label(label="Clan URL"))
|
||||
layout.append(icon)
|
||||
layout.append(Gtk.Label(label="Clan URL"))
|
||||
else:
|
||||
layout.add(Gtk.Label(label="Enter Clan URL"))
|
||||
layout.append(Gtk.Label(label="Enter Clan URL"))
|
||||
self.entry = Gtk.Entry()
|
||||
# Autocomplete
|
||||
# TODO: provide intelligent suggestions
|
||||
@ -60,7 +62,7 @@ class Trust(Gtk.Box):
|
||||
self.entry.set_completion(completion)
|
||||
self.entry.set_placeholder_text("clan://")
|
||||
|
||||
layout.add(self.entry)
|
||||
layout.append(self.entry)
|
||||
|
||||
if self.url is None:
|
||||
trust_button = Gtk.Button(label="Load cLAN-URL")
|
||||
@ -68,9 +70,9 @@ class Trust(Gtk.Box):
|
||||
trust_button = Gtk.Button(label="Trust cLAN-URL")
|
||||
|
||||
trust_button.connect("clicked", self.on_trust_clicked)
|
||||
layout.add(trust_button)
|
||||
layout.append(trust_button)
|
||||
|
||||
self.set_center_widget(layout)
|
||||
self.append(layout)
|
||||
|
||||
def on_trust_clicked(self, widget: Gtk.Widget) -> None:
|
||||
try:
|
||||
@ -86,6 +88,7 @@ class Trust(Gtk.Box):
|
||||
self.on_trust(uri.get_internal(), item.flake)
|
||||
|
||||
except ClanError as e:
|
||||
pass
|
||||
show_error_dialog(e)
|
||||
|
||||
|
||||
@ -103,34 +106,34 @@ class Details(Gtk.Box):
|
||||
preserve_aspect_ratio=True,
|
||||
)
|
||||
)
|
||||
layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, expand=True)
|
||||
layout.set_border_width(20)
|
||||
layout = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, )
|
||||
# layout.set_border_width(20)
|
||||
|
||||
upper = Gtk.Box(orientation="vertical")
|
||||
upper.set_spacing(20)
|
||||
upper.add(Gtk.Label(label="Clan URL"))
|
||||
upper.add(icon)
|
||||
upper.append(Gtk.Label(label="Clan URL"))
|
||||
upper.append(icon)
|
||||
|
||||
label = Gtk.Label(label=str(url))
|
||||
|
||||
upper.add(label)
|
||||
upper.append(label)
|
||||
|
||||
description_label = Gtk.Label(label=flake.description)
|
||||
upper.add(description_label)
|
||||
upper.append(description_label)
|
||||
|
||||
lower = Gtk.Box(orientation="horizontal", expand=True)
|
||||
lower = Gtk.Box(orientation="horizontal", )
|
||||
lower.set_spacing(20)
|
||||
|
||||
join_button = Gtk.Button(label="Join")
|
||||
join_button.connect("clicked", self.on_join)
|
||||
join_action_area = Gtk.Box(orientation="horizontal", expand=False)
|
||||
join_button_area = Gtk.Box(orientation="vertical", expand=False)
|
||||
join_action_area.pack_end(join_button_area, expand=False, fill=False, padding=0)
|
||||
join_button_area.pack_end(join_button, expand=False, fill=False, padding=0)
|
||||
join_action_area = Gtk.Box(orientation="horizontal", )
|
||||
join_button_area = Gtk.Box(orientation="vertical", )
|
||||
join_action_area.append(join_button_area)
|
||||
join_button_area.append(join_button)
|
||||
join_details = Gtk.Label(label="Info")
|
||||
|
||||
join_details_area = Gtk.Box(orientation="horizontal", expand=False)
|
||||
join_label_area = Gtk.Box(orientation="vertical", expand=False)
|
||||
join_details_area = Gtk.Box(orientation="horizontal", )
|
||||
join_label_area = Gtk.Box(orientation="vertical", )
|
||||
|
||||
for info in [
|
||||
f"Memory: {flake.clan_name}",
|
||||
@ -139,19 +142,19 @@ class Details(Gtk.Box):
|
||||
]:
|
||||
details_label = Gtk.Label(label=info)
|
||||
details_label.set_justify(Gtk.Justification.LEFT)
|
||||
join_label_area.pack_end(details_label, expand=False, fill=False, padding=0)
|
||||
join_label_area.append(details_label)
|
||||
|
||||
join_label_area.pack_end(join_details, expand=False, fill=False, padding=0)
|
||||
join_details_area.pack_start(
|
||||
join_label_area, expand=False, fill=False, padding=0
|
||||
join_label_area.append(join_details)
|
||||
join_details_area.append(
|
||||
join_label_area
|
||||
)
|
||||
|
||||
lower.pack_start(join_details_area, expand=True, fill=True, padding=0)
|
||||
lower.pack_end(join_action_area, expand=True, fill=True, padding=0)
|
||||
layout.pack_start(upper, expand=False, fill=False, padding=0)
|
||||
layout.add(lower)
|
||||
lower.append(join_details_area)
|
||||
lower.append(join_action_area)
|
||||
layout.append(upper)
|
||||
layout.append(lower)
|
||||
|
||||
self.add(layout)
|
||||
self.append(layout)
|
||||
|
||||
def on_join(self, widget: Gtk.Widget) -> None:
|
||||
# TODO: @Qubasa
|
||||
@ -163,21 +166,34 @@ class JoinWindow(Gtk.ApplicationWindow):
|
||||
def __init__(self, initial_values: InitialJoinValues, cbs: Callbacks) -> None:
|
||||
super().__init__()
|
||||
# Initialize the main wincbsdow
|
||||
|
||||
self.cbs = cbs
|
||||
self.set_title("cLAN Manager")
|
||||
self.connect("delete-event", self.on_quit)
|
||||
# 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)
|
||||
# menu = Gtk.Menu()
|
||||
# menu_bar = Gtk.MenuBar()
|
||||
|
||||
button = Gtk.ToolButton()
|
||||
button.set_icon_name("go-previous")
|
||||
button.connect("clicked", self.switch)
|
||||
# main_menu = Gtk.MenuItem("Menu")
|
||||
# menu_item = Gtk.MenuItem("Start", "Start the selected clan")
|
||||
|
||||
toolbar = Gtk.Toolbar(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
toolbar.add(button)
|
||||
vbox.add(toolbar)
|
||||
# menu_bar.append(main_menu)
|
||||
# main_menu.set_submenu(menu)
|
||||
# menu.append(menu_item)
|
||||
# vbox.add(menu_bar)
|
||||
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
self.set_child(vbox)
|
||||
|
||||
# button = Gtk.ToolButton()
|
||||
# button.set_icon_name("go-previous")
|
||||
# button.connect("clicked", self.switch)
|
||||
|
||||
# toolbar = Gtk.Toolbar(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
# toolbar.add(button)
|
||||
# vbox.add(toolbar)
|
||||
|
||||
self.stack = Gtk.Stack()
|
||||
|
||||
@ -188,12 +204,12 @@ class JoinWindow(Gtk.ApplicationWindow):
|
||||
"Trust",
|
||||
)
|
||||
|
||||
vbox.add(self.stack)
|
||||
vbox.append(self.stack)
|
||||
|
||||
# vbox.add(Gtk.Entry(text=str(initial_values.url)))
|
||||
|
||||
# Must be called AFTER all components were added
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
|
||||
def on_trust(self, url: str, flake: FlakeConfig) -> None:
|
||||
self.stack.add_titled(
|
||||
@ -201,7 +217,7 @@ class JoinWindow(Gtk.ApplicationWindow):
|
||||
"details",
|
||||
"Details",
|
||||
)
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
self.stack.set_visible_child_name("details")
|
||||
|
||||
def switch(self, widget: Gtk.Widget) -> None:
|
||||
|
@ -4,7 +4,7 @@ import gi
|
||||
|
||||
from ..models import VMBase, get_initial_vms
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Gtk", "4.0")
|
||||
|
||||
from gi.repository import Gio, Gtk
|
||||
|
||||
@ -17,12 +17,12 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
||||
def __init__(self, cbs: Callbacks) -> None:
|
||||
super().__init__()
|
||||
self.set_title("cLAN Manager")
|
||||
self.connect("delete-event", self.on_quit)
|
||||
# self.connect("delete-event", self.on_quit)
|
||||
self.set_default_size(800, 600)
|
||||
self.cbs = cbs
|
||||
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, expand=True)
|
||||
self.add(vbox)
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6, )
|
||||
self.set_child(vbox)
|
||||
self.stack = Gtk.Stack()
|
||||
|
||||
clan_list = ClanList(
|
||||
@ -45,10 +45,10 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
||||
"Edit",
|
||||
)
|
||||
|
||||
vbox.add(self.stack)
|
||||
vbox.append(self.stack)
|
||||
|
||||
# Must be called AFTER all components were added
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
|
||||
def set_selected(self, sel: VMBase | None) -> None:
|
||||
self.selected_vm = sel
|
||||
@ -75,7 +75,7 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
||||
selected_vm=self.selected_vm,
|
||||
)
|
||||
self.stack.add_titled(clan_list, "list", "List")
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
self.stack.set_visible_child_name("list")
|
||||
|
||||
def remount_edit_view(self) -> None:
|
||||
@ -88,7 +88,7 @@ class OverviewWindow(Gtk.ApplicationWindow):
|
||||
"edit",
|
||||
"Edit",
|
||||
)
|
||||
self.show_all()
|
||||
# self.show_all()
|
||||
self.stack.set_visible_child_name("edit")
|
||||
|
||||
def on_quit(self, *args: Any) -> None:
|
||||
|
@ -4,13 +4,13 @@
|
||||
, copyDesktopItems
|
||||
, pygobject3
|
||||
, wrapGAppsHook
|
||||
, gtk3
|
||||
, spice-gtk
|
||||
, gtk4
|
||||
, gnome
|
||||
, gobject-introspection
|
||||
, clan-cli
|
||||
, makeDesktopItem
|
||||
, ipdb
|
||||
, libadwaita
|
||||
}:
|
||||
let
|
||||
source = ./.;
|
||||
@ -33,7 +33,7 @@ python3.pkgs.buildPythonApplication {
|
||||
gobject-introspection
|
||||
];
|
||||
|
||||
buildInputs = [ spice-gtk gtk3 gnome.adwaita-icon-theme ];
|
||||
buildInputs = [ gtk4 libadwaita gnome.adwaita-icon-theme ];
|
||||
propagatedBuildInputs = [ pygobject3 clan-cli ];
|
||||
|
||||
# also re-expose dependencies so we test them in CI
|
||||
|
Loading…
Reference in New Issue
Block a user