Remotes copy and Filter work

Add a button to copy the remote name from the remotes manager window
Continue work on the filter
This commit is contained in:
heliguy
2023-09-23 23:38:43 -04:00
parent b8e9c1f0de
commit af2e225dc8
5 changed files with 69 additions and 26 deletions

View File

@@ -13,6 +13,10 @@ class FilterWindow(Adw.Window):
remotes_list = Gtk.Template.Child()
runtimes_row = Gtk.Template.Child()
def key_handler(self, _a, event, _c, _d):
if event == Gdk.KEY_Escape:
self.close()
def runtimesHandler(self, switch, _a):
print(switch.get_active())
@@ -37,16 +41,20 @@ class FilterWindow(Adw.Window):
self.my_utils = myUtils(self)
self.host_remotes = self.my_utils.getHostRemotes()
self.filter_list = "the guh"
event_controller = Gtk.EventControllerKey()
# Window Things
self.set_transient_for(main_window)
self.add_controller(event_controller)
# Connections
self.apply_button.connect("clicked", lambda *_: main_window.updateFilter(self.filter_list))
self.apply_button.connect("clicked", lambda *_: self.close())
self.cancel_button.connect("clicked", lambda *_: self.close())
self.runtimes_row.connect("notify::active", self.runtimesHandler)
event_controller.connect("key-pressed", self.key_handler)
# Calls
self.generateList()

View File

@@ -81,7 +81,7 @@ class WarehouseApplication(Adw.Application):
def filters_shortcut(self, widget, _):
window = self.props.active_window
window.filterWindowHandler(window)
window.filterWindowKeyboardHandler(window)
def do_activate(self):
"""Called when the application is activated.

View File

@@ -165,6 +165,11 @@ class RemotesWindow(Adw.Window):
self.remotes_list.remove_all()
self.host_remotes = self.my_utils.getHostRemotes()
self.host_flatpaks = self.get_host_flatpaks()
def rowCopyHandler(widget, to_copy):
self.app_window.clipboard.set(to_copy)
self.make_toast(_("Copied {}").format(to_copy))
if self.host_remotes[0][0] == '':
no_remotes = Adw.StatusPage(icon_name="error-symbolic", title=_("No Remotes"), description=_("Warehouse cannot see the list of remotes or the system has no remotes added"))
self.stack.add_child(no_remotes)
@@ -182,9 +187,13 @@ class RemotesWindow(Adw.Window):
label = Gtk.Label(label=("{} wide").format(install_type))
label.add_css_class("subtitle")
remote_row.add_suffix(label)
copy_button = Gtk.Button(icon_name="edit-copy-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("Copy remote name"))
copy_button.add_css_class("flat")
copy_button.connect("clicked", rowCopyHandler, name)
remove_button = Gtk.Button(icon_name="user-trash-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("Remove {}").format(name))
remove_button.add_css_class("flat")
remove_button.connect("clicked", self.remove_handler, i)
remote_row.add_suffix(copy_button)
remote_row.add_suffix(remove_button)
def __init__(self, main_window, **kwargs):
@@ -220,6 +229,7 @@ class RemotesWindow(Adw.Window):
self.outer_box.append(self.remotes_list)
self.remotes_list.append(self.user_data_row)
self.remotes_list.add_css_class("boxed-list")
self.app_window = main_window
self.add_button.connect("clicked", self.add_handler)

View File

@@ -26,18 +26,18 @@ template WarehouseWindow : Adw.ApplicationWindow {
tooltip-text: _("Main Menu");
menu-model: primary_menu;
}
[end]
ToggleButton filter_button {
icon-name: "funnel-symbolic";
tooltip-text: _("Filter Apps List");
}
[end]
ToggleButton batch_mode_button {
icon-name: "selection-mode-symbolic";
tooltip-text: _("Toggle Selection Mode");
}
[end]
Button filter_button {
icon-name: "funnel-symbolic";
tooltip-text: _("Filter Apps List");
}
}
[top]
SearchBar search_bar {

View File

@@ -169,7 +169,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.batch_actions_enable(False)
self.selected_host_flatpak_indexes = []
self.should_select_all = self.batch_select_all_button.get_active()
self.main_stack.set_visible_child(self.main_box)
@@ -195,28 +195,48 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.host_flatpaks = get_host_flatpaks()
def windowSetEmpty(has_row):
self.batch_mode_button.set_sensitive(has_row)
self.search_button.set_sensitive(has_row)
if has_row:
self.main_stack.set_visible_child(self.main_box)
else:
self.batch_mode_button.set_active(False)
self.main_stack.set_visible_child(self.no_flatpaks)
# Setting up filter stuff
self.show_runtimes = self.filter_list[0]
self.filter_install_type = self.filter_list[1]
self.filter_remotes_list = self.filter_list[2]
print(self.filter_list)
for index in range(len(self.host_flatpaks)):
app_name = self.host_flatpaks[index][0]
app_id = self.host_flatpaks[index][2]
app_ref = self.host_flatpaks[index][8]
flatpak_row = Adw.ActionRow(title=GLib.markup_escape_text(app_name))
flatpak_row.add_prefix(self.my_utils.findAppIcon(app_id))
flatpak_row.set_subtitle(self.host_flatpaks[index][8])
# Check the filter and skip row if it does not meet the filter
if (not self.show_runtimes) and "runtime" in self.host_flatpaks[index][12]:
print("skip runtime", app_id)
continue
if self.show_runtimes:
flatpak_row.set_subtitle(self.host_flatpaks[index][8])
else:
flatpak_row.set_subtitle(self.host_flatpaks[index][2])
if (not 'all' in self.filter_install_type) and (not self.host_flatpaks[index][7] in self.filter_install_type):
print(self.filter_install_type)
print("skip install type", app_name)
continue
if (not 'all' in self.filter_remotes_list) and (not self.host_flatpaks[index][6] in self.filter_remotes_list):
print(self.filter_install_type)
print("skip remote", app_name)
continue
properties_button = Gtk.Button(icon_name="info-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("View Properties"))
properties_button.add_css_class("flat")
@@ -245,12 +265,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.list_of_flatpaks.append(flatpak_row)
if not self.list_of_flatpaks.get_row_at_index(0):
self.main_stack.set_visible_child(self.no_flatpaks)
self.search_button.set_visible(False)
self.search_bar.set_visible(False)
self.batch_mode_button.set_visible(False)
return
print(self.list_of_flatpaks.get_row_at_index(0))
windowSetEmpty(self.list_of_flatpaks.get_row_at_index(0))
def refresh_list_of_flatpaks(self, widget, should_toast):
self.list_of_flatpaks.remove_all()
@@ -373,17 +389,27 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app refs")))
def filterWindowHandler(self, widget):
filtwin = FilterWindow(self)
filtwin.present()
if widget.get_active():
# filtwin = FilterWindow(self)
# filtwin.present()
self.filter_list = [False, ["user"], ["kdeapps"]]
self.refresh_list_of_flatpaks(self, False)
else:
self.filter_list = [False, ["all"], ["all"]]
self.refresh_list_of_flatpaks(self, False)
def filterWindowKeyboardHandler(self, widget):
self.filter_button.set_active(not self.filter_button.get_active())
def updateFilter(self, filter):
self.filter_list = filter
self.refresh_list_of_flatpaks(self, True)
print(self.filter_list)
self.refresh_list_of_flatpaks(self, False)
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.my_utils = myUtils(self)
self.filter_list = [False, ["all"], ["all"]]
self.list_of_flatpaks.set_filter_func(self.filter_func)
self.set_size_request(0, 230)
self.generate_list_of_flatpaks()
@@ -404,7 +430,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.create_action("copy-ids", self.copyIDs)
self.create_action("copy-refs", self.copyRefs)
self.filter_button.connect("clicked", self.filterWindowHandler)
self.filter_button.connect("toggled", self.filterWindowHandler)
self.filter_list = ""