mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Add files for remote select dialog
This commit is contained in:
15
src/gtk/attempt_install_dialog.blp
Normal file
15
src/gtk/attempt_install_dialog.blp
Normal file
@@ -0,0 +1,15 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $AttemptInstallDialog : Adw.AlertDialog {
|
||||
heading: _("Attempt an Install?");
|
||||
body: _("Warehouse will try to install the matching packages.");
|
||||
responses [
|
||||
cancel: _("Cancel"),
|
||||
continue: _("Install") suggested,
|
||||
]
|
||||
Adw.PreferencesGroup preferences_group {
|
||||
title: _("Choose a Remote");
|
||||
description: _("Select a remote to attempt to install from");
|
||||
}
|
||||
}
|
||||
51
src/gtk/attempt_install_dialog.py
Normal file
51
src/gtk/attempt_install_dialog.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from gi.repository import Adw, Gtk
|
||||
from .host_info import HostInfo
|
||||
from .error_toast import ErrorToast
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/gtk/attempt_install_dialog.ui")
|
||||
class AttemptInstallDialog(Adw.AlertDialog):
|
||||
__gtype_name__ = "AttemptInstallDialog"
|
||||
gtc = Gtk.Template.Child
|
||||
|
||||
preferences_group = gtc()
|
||||
|
||||
def generate_list(self):
|
||||
for installation, remotes in HostInfo.remotes.items():
|
||||
for remote in remotes:
|
||||
if remote.disabled:
|
||||
continue
|
||||
|
||||
row = Adw.ActionRow(title=remote.title, subtitle=_("Installation: {}").format(installation))
|
||||
row.remote_name = remote.name
|
||||
row.remote_installation = installation
|
||||
button = Gtk.CheckButton()
|
||||
row.add_prefix(button)
|
||||
row.check_button = button
|
||||
row.set_activatable_widget(button)
|
||||
self.rows.append(row)
|
||||
self.preferences_group.add(row)
|
||||
if len(self.rows) > 1:
|
||||
button.set_group(self.rows[0].check_button)
|
||||
|
||||
def on_response(self, dialog, response):
|
||||
if response != "continue":
|
||||
return
|
||||
|
||||
for row in self.rows:
|
||||
if row.check_button.get_active():
|
||||
print(row.remote_installation, row.remote_name)
|
||||
return
|
||||
|
||||
def __init__(self, callback, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Extra Object Creation
|
||||
self.rows = []
|
||||
self.callback = callback
|
||||
|
||||
# Apply
|
||||
self.generate_list()
|
||||
self.present(HostInfo.main_window)
|
||||
|
||||
# Connections
|
||||
self.connect("response", self.on_response)
|
||||
@@ -8,6 +8,7 @@ blueprints = custom_target('blueprints',
|
||||
'gtk/help-overlay.blp',
|
||||
'gtk/loading_status.blp',
|
||||
'gtk/installation_chooser.blp',
|
||||
'gtk/attempt_install_dialog.blp',
|
||||
'main_window/window.blp',
|
||||
'packages_page/packages_page.blp',
|
||||
'packages_page/filters_page.blp',
|
||||
@@ -77,6 +78,7 @@ warehouse_sources = [
|
||||
'gtk/loading_status.py',
|
||||
'gtk/installation_chooser.py',
|
||||
'gtk/app_row.py',
|
||||
'gtk/attempt_install_dialog.py',
|
||||
'main_window/window.py',
|
||||
'package_install_worker.py',
|
||||
'packages_page/uninstall_dialog.py',
|
||||
|
||||
@@ -8,6 +8,8 @@ template $RemoteRow : Adw.ActionRow {
|
||||
margin-end: 6;
|
||||
wrap: true;
|
||||
wrap-mode: word_char;
|
||||
natural-wrap-mode: none;
|
||||
halign: end;
|
||||
hexpand: true;
|
||||
justify: right;
|
||||
}
|
||||
@@ -52,4 +54,4 @@ Popover menu_pop {
|
||||
halign: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ template $UserDataPage : Adw.BreakpointBin {
|
||||
icon-name: "folder-open-symbolic";
|
||||
tooltip-text: _("Open User Data Folder");
|
||||
}
|
||||
|
||||
[start]
|
||||
Button test_button {
|
||||
label: "test";
|
||||
}
|
||||
|
||||
[end]
|
||||
MenuButton sort_button {
|
||||
popover: sort_pop;
|
||||
|
||||
@@ -5,6 +5,7 @@ from .data_subpage import DataSubpage
|
||||
from .host_info import HostInfo
|
||||
from .sidebar_button import SidebarButton
|
||||
from .loading_status import LoadingStatus
|
||||
from .attempt_install_dialog import AttemptInstallDialog
|
||||
import os, subprocess
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/user_data_page/user_data_page.ui")
|
||||
@@ -37,6 +38,8 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
select_all_button = gtc()
|
||||
copy_button = gtc()
|
||||
trash_button = gtc()
|
||||
|
||||
test_button = gtc()
|
||||
|
||||
# Referred to in the main window
|
||||
# It is used to determine if a new page should be made or not
|
||||
@@ -243,6 +246,8 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
self.sort_size.connect("clicked", self.sort_button_handler)
|
||||
self.bpt.connect("apply", self.breakpoint_handler, True)
|
||||
self.bpt.connect("unapply", self.breakpoint_handler, False)
|
||||
|
||||
self.test_button.connect("clicked", lambda *_: AttemptInstallDialog(None))
|
||||
|
||||
# Apply again
|
||||
self.loading_view.set_content(LoadingStatus(_("Loading User Data"), _("This should only take a moment")))
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<file preprocess="xml-stripblanks">gtk/loading_status.ui</file>
|
||||
<file preprocess="xml-stripblanks">gtk/app_row.ui</file>
|
||||
<file preprocess="xml-stripblanks">gtk/installation_chooser.ui</file>
|
||||
<file preprocess="xml-stripblanks">gtk/attempt_install_dialog.ui</file>
|
||||
<file preprocess="xml-stripblanks">main_window/window.ui</file>
|
||||
<file preprocess="xml-stripblanks">packages_page/packages_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">packages_page/filters_page.ui</file>
|
||||
|
||||
Reference in New Issue
Block a user