mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-15 00:34:42 +09:00
Add UI for remote actions
This commit is contained in:
@@ -75,6 +75,13 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.refresh_button.set_sensitive(False)
|
||||
HostInfo.get_flatpaks(callback=self.end_loading)
|
||||
|
||||
def activate_row(self, nav_row):
|
||||
idx = 0
|
||||
while row := self.navigation_row_listbox.get_row_at_index(idx):
|
||||
idx += 1
|
||||
if row.get_child() is nav_row:
|
||||
row.activate()
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@@ -109,7 +116,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
# file_drop.connect("drop", self.drop_callback)
|
||||
self.refresh_button.connect("clicked", self.refresh_handler)
|
||||
|
||||
self.navigation_row_listbox.get_row_at_index(1).activate()
|
||||
self.activate_row(self.remotes_row)
|
||||
self.main_split.set_show_sidebar(True)
|
||||
|
||||
self.start_loading()
|
||||
|
||||
@@ -14,6 +14,7 @@ blueprints = custom_target('blueprints',
|
||||
'user_data_page/user_data_page.blp',
|
||||
'user_data_page/data_subpage.blp',
|
||||
'remotes_page/remotes_page.blp',
|
||||
'remotes_page/remote_row.blp',
|
||||
'change_version_page/change_version_page.blp',
|
||||
),
|
||||
output: '.',
|
||||
@@ -68,6 +69,7 @@ warehouse_sources = [
|
||||
'user_data_page/user_data_page.py',
|
||||
'user_data_page/data_subpage.py',
|
||||
'remotes_page/remotes_page.py',
|
||||
'remotes_page/remote_row.py',
|
||||
'../data/style.css',
|
||||
]
|
||||
|
||||
|
||||
43
src/remotes_page/remote_row.blp
Normal file
43
src/remotes_page/remote_row.blp
Normal file
@@ -0,0 +1,43 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $RemoteRow : Adw.ActionRow {
|
||||
[suffix]
|
||||
Label suffix_label {
|
||||
styles ["subtitle"]
|
||||
margin-end: 6;
|
||||
}
|
||||
[suffix]
|
||||
Button {
|
||||
styles ["flat"]
|
||||
valign: center;
|
||||
icon-name: "funnel-symbolic";
|
||||
tooltip-text: _("Set a Filter for this Remote");
|
||||
}
|
||||
[suffix]
|
||||
MenuButton menu_button {
|
||||
styles ["flat"]
|
||||
valign: center;
|
||||
popover: menu_pop;
|
||||
icon-name: "view-more-symbolic";
|
||||
tooltip-text: _("More Actions");
|
||||
}
|
||||
}
|
||||
|
||||
Popover menu_pop {
|
||||
styles ["menu"]
|
||||
ListBox menu_listbox {
|
||||
Label copy_title {
|
||||
label: _("Copy Title");
|
||||
halign: start;
|
||||
}
|
||||
Label copy_name {
|
||||
label: _("Copy Name");
|
||||
halign: start;
|
||||
}
|
||||
Label remove {
|
||||
label: _("Remove");
|
||||
halign: start;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/remotes_page/remote_row.py
Normal file
46
src/remotes_page/remote_row.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from gi.repository import Adw, Gtk, GLib, Gio, Pango
|
||||
from .host_info import HostInfo
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/remotes_page/remote_row.ui")
|
||||
class RemoteRow(Adw.ActionRow):
|
||||
__gtype_name__ = 'RemoteRow'
|
||||
gtc = Gtk.Template.Child
|
||||
|
||||
suffix_label = gtc()
|
||||
menu_pop = gtc()
|
||||
menu_listbox = gtc()
|
||||
|
||||
copy_title = gtc()
|
||||
copy_name = gtc()
|
||||
remove = gtc()
|
||||
|
||||
def on_menu_action(self, listbox, row):
|
||||
row = row.get_child()
|
||||
if row is self.copy_title:
|
||||
HostInfo.clipboard.set(self.get_title())
|
||||
self.parent_page.toast_overlay.add_toast(Adw.Toast(title=_("Copied title")))
|
||||
elif row is self.copy_name:
|
||||
HostInfo.clipboard.set(self.get_subtitle())
|
||||
self.parent_page.toast_overlay.add_toast(Adw.Toast(title=_("Copied name")))
|
||||
elif row is self.remove:
|
||||
print("remove")
|
||||
self.menu_pop.popdown()
|
||||
|
||||
def idle_stuff(self):
|
||||
self.set_title(self.remote.title)
|
||||
self.set_subtitle(_("Installation: {}").format(self.installation))
|
||||
self.suffix_label.set_label(self.remote.name)
|
||||
|
||||
def __init__(self, parent_page, installation, remote, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Extra Object Creation
|
||||
self.parent_page = parent_page
|
||||
self.remote = remote
|
||||
self.installation = installation
|
||||
|
||||
# Apply
|
||||
GLib.idle_add(lambda *_: self.idle_stuff())
|
||||
|
||||
# Connections
|
||||
self.menu_listbox.connect("row-activated", self.on_menu_action)
|
||||
@@ -28,7 +28,7 @@ template $RemotesPage : Adw.NavigationPage {
|
||||
}
|
||||
}
|
||||
}
|
||||
Adw.ToastOverlay {
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Stack stack {
|
||||
Adw.StatusPage loading_remotes {
|
||||
title: _("Loading Remotes");
|
||||
@@ -50,20 +50,11 @@ template $RemotesPage : Adw.NavigationPage {
|
||||
icon-name: "error-symbolic";
|
||||
}
|
||||
Adw.PreferencesPage content_page {
|
||||
Adw.PreferencesGroup current_remotes {
|
||||
Adw.PreferencesGroup current_remotes_group {
|
||||
title: _("Current Remotes");
|
||||
description: _("Remotes available on your system");
|
||||
Adw.ActionRow {
|
||||
title: "test";
|
||||
}
|
||||
Adw.ActionRow {
|
||||
title: "test";
|
||||
}
|
||||
Adw.ActionRow {
|
||||
title: "test";
|
||||
}
|
||||
}
|
||||
Adw.PreferencesGroup new_remotes {
|
||||
Adw.PreferencesGroup new_remotes_group {
|
||||
title: _("Add Remotes");
|
||||
description: _("Add new remotes to get more software");
|
||||
Adw.ActionRow {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from gi.repository import Adw, Gtk, GLib, Gio
|
||||
from .host_info import HostInfo
|
||||
from .error_toast import ErrorToast
|
||||
from .remote_row import RemoteRow
|
||||
import subprocess
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/remotes_page/remotes_page.ui")
|
||||
@@ -10,9 +11,10 @@ class RemotesPage(Adw.NavigationPage):
|
||||
|
||||
sidebar_button = gtc()
|
||||
search_bar = gtc()
|
||||
toast_overlay = gtc()
|
||||
stack = gtc()
|
||||
current_remotes = gtc()
|
||||
new_remotes = gtc()
|
||||
current_remotes_group = gtc()
|
||||
new_remotes_group = gtc()
|
||||
|
||||
# Statuses
|
||||
loading_remotes = gtc()
|
||||
@@ -26,17 +28,26 @@ class RemotesPage(Adw.NavigationPage):
|
||||
|
||||
def start_loading(self):
|
||||
self.stack.set_visible_child(self.loading_remotes)
|
||||
for row in self.current_remote_rows:
|
||||
self.current_remotes_group.remove(row)
|
||||
self.current_remote_rows.clear()
|
||||
|
||||
def end_loading(self):
|
||||
self.stack.set_visible_child(self.content_page)
|
||||
for install in HostInfo.installations:
|
||||
for remote in HostInfo.remotes[install]:
|
||||
row = RemoteRow(self, install, remote)
|
||||
self.current_remotes_group.add(row)
|
||||
self.current_remote_rows.append(row)
|
||||
|
||||
def __init__(self, main_window, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
# Extra Object Creation
|
||||
self.__class__.instance = self
|
||||
ms = main_window.main_split
|
||||
self.search_bar.set_key_capture_widget(main_window)
|
||||
self.__class__.instance = self
|
||||
self.current_remote_rows = []
|
||||
|
||||
# Connections
|
||||
ms.connect("notify::show-sidebar", lambda *_: self.sidebar_button.set_active(ms.get_show_sidebar()))
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<file preprocess="xml-stripblanks">user_data_page/user_data_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">user_data_page/data_subpage.ui</file>
|
||||
<file preprocess="xml-stripblanks">remotes_page/remotes_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">remotes_page/remote_row.ui</file>
|
||||
<!-- <file preprocess="xml-stripblanks">../data/io.github.flattool.Warehouse.metainfo.xml.in</file> -->
|
||||
</gresource>
|
||||
<gresource prefix="/io/github/flattool/Warehouse/icons/scalable/actions/">
|
||||
|
||||
Reference in New Issue
Block a user