mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Fromat with black
This commit is contained in:
@@ -141,7 +141,9 @@ class AppRow(Adw.ActionRow):
|
||||
)
|
||||
self.add_suffix(properties_button)
|
||||
|
||||
self.tickbox = Gtk.CheckButton(visible=False, tooltip_text=_("Select")) # visible=self.in_batch_mode
|
||||
self.tickbox = Gtk.CheckButton(
|
||||
visible=False, tooltip_text=_("Select")
|
||||
) # visible=self.in_batch_mode
|
||||
self.tickbox.add_css_class("selection-mode")
|
||||
self.tickbox.connect("toggled", parent_window.row_select_handler)
|
||||
self.add_suffix(self.tickbox)
|
||||
@@ -149,7 +151,9 @@ class AppRow(Adw.ActionRow):
|
||||
self.set_activatable(False)
|
||||
|
||||
self.row_menu = Gtk.MenuButton(
|
||||
icon_name="view-more-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("View More")
|
||||
icon_name="view-more-symbolic",
|
||||
valign=Gtk.Align.CENTER,
|
||||
tooltip_text=_("View More"),
|
||||
)
|
||||
self.row_menu.add_css_class("flat")
|
||||
row_menu_model = Gio.Menu()
|
||||
@@ -199,7 +203,10 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
row_menu_model.append_submenu(_("Copy"), copy_menu_model)
|
||||
|
||||
if "runtime" not in parent_window.host_flatpaks[index][12] and self.app_id != "io.github.flattool.Warehouse":
|
||||
if (
|
||||
"runtime" not in parent_window.host_flatpaks[index][12]
|
||||
and self.app_id != "io.github.flattool.Warehouse"
|
||||
):
|
||||
parent_window.create_action(
|
||||
("run" + str(index)),
|
||||
lambda *_a, ref=self.app_ref, name=self.app_name: parent_window.run_app_thread(
|
||||
|
||||
@@ -252,7 +252,9 @@ class myUtils:
|
||||
print(response)
|
||||
return 0
|
||||
|
||||
def uninstall_flatpak(self, ref_arr, type_arr, should_trash, progress_bar=None, status_label=None):
|
||||
def uninstall_flatpak(
|
||||
self, ref_arr, type_arr, should_trash, progress_bar=None, status_label=None
|
||||
):
|
||||
self.uninstall_success = True
|
||||
print(ref_arr)
|
||||
to_uninstall = []
|
||||
@@ -281,7 +283,12 @@ class myUtils:
|
||||
try:
|
||||
print(apps)
|
||||
if status_label:
|
||||
GLib.idle_add(status_label.set_label, _("Working on {}\n{} out of {}").format(apps[i][0], i + 1, len(apps)))
|
||||
GLib.idle_add(
|
||||
status_label.set_label,
|
||||
_("Working on {}\n{} out of {}").format(
|
||||
apps[i][0], i + 1, len(apps)
|
||||
),
|
||||
)
|
||||
subprocess.run(
|
||||
command, capture_output=False, check=True, env=self.new_env
|
||||
)
|
||||
@@ -335,7 +342,9 @@ class myUtils:
|
||||
GLib.idle_add(progress_bar.set_visible, False)
|
||||
GLib.idle_add(progress_bar.set_fraction, 0.0)
|
||||
|
||||
def install_flatpak(self, app_arr, remote, user_or_system, progress_bar=None, status_label=None):
|
||||
def install_flatpak(
|
||||
self, app_arr, remote, user_or_system, progress_bar=None, status_label=None
|
||||
):
|
||||
self.install_success = True
|
||||
fails = []
|
||||
|
||||
@@ -348,7 +357,12 @@ class myUtils:
|
||||
command.append(app_arr[i])
|
||||
try:
|
||||
if status_label:
|
||||
GLib.idle_add(status_label.set_label, _("Working on {}\n{} out of {}").format(app_arr[i], i + 1, len(app_arr)))
|
||||
GLib.idle_add(
|
||||
status_label.set_label,
|
||||
_("Working on {}\n{} out of {}").format(
|
||||
app_arr[i], i + 1, len(app_arr)
|
||||
),
|
||||
)
|
||||
subprocess.run(
|
||||
command, capture_output=False, check=True, env=self.new_env
|
||||
)
|
||||
|
||||
@@ -24,7 +24,9 @@ class DowngradeWindow(Adw.Window):
|
||||
outerbox = Gtk.Template.Child()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def selection_handler(self, button, index):
|
||||
|
||||
@@ -4,6 +4,7 @@ import subprocess
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
|
||||
@Gtk.Template(resource_path="/io/github/flattool/Warehouse/../data/ui/filter.ui")
|
||||
class FilterWindow(Adw.Window):
|
||||
__gtype_name__ = "FilterWindow"
|
||||
@@ -15,7 +16,9 @@ class FilterWindow(Adw.Window):
|
||||
reset_button = Gtk.Template.Child()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def gsettings_bool_set(self, key, value):
|
||||
@@ -40,11 +43,15 @@ class FilterWindow(Adw.Window):
|
||||
|
||||
def row_subtitle_updater(self):
|
||||
if self.total_runtimes_selected > 0:
|
||||
self.runtimes_expander.set_subtitle(_("{} selected").format(self.total_runtimes_selected))
|
||||
self.runtimes_expander.set_subtitle(
|
||||
_("{} selected").format(self.total_runtimes_selected)
|
||||
)
|
||||
else:
|
||||
self.runtimes_expander.set_subtitle("")
|
||||
if self.total_remotes_selected > 0:
|
||||
self.remotes_expander.set_subtitle(_("{} selected").format(self.total_remotes_selected))
|
||||
self.remotes_expander.set_subtitle(
|
||||
_("{} selected").format(self.total_remotes_selected)
|
||||
)
|
||||
else:
|
||||
self.remotes_expander.set_subtitle("")
|
||||
|
||||
@@ -84,7 +91,9 @@ class FilterWindow(Adw.Window):
|
||||
self.remotes_string += f"{remote}<>{install_type};"
|
||||
else:
|
||||
self.total_remotes_selected -= 1
|
||||
self.remotes_string = self.remotes_string.replace(f"{remote}<>{install_type};", "")
|
||||
self.remotes_string = self.remotes_string.replace(
|
||||
f"{remote}<>{install_type};", ""
|
||||
)
|
||||
if len(self.remotes_string) < 1:
|
||||
self.remotes_string += "all"
|
||||
self.settings.set_string("remotes-list", self.remotes_string)
|
||||
@@ -196,8 +205,14 @@ class FilterWindow(Adw.Window):
|
||||
|
||||
# Connections
|
||||
event_controller.connect("key-pressed", self.key_handler)
|
||||
self.show_apps_switch.connect("state-set", lambda button, state: self.gsettings_bool_set("show-apps", state))
|
||||
self.show_runtimes_switch.connect("state-set", lambda button, state: self.gsettings_bool_set("show-runtimes", state))
|
||||
self.show_apps_switch.connect(
|
||||
"state-set",
|
||||
lambda button, state: self.gsettings_bool_set("show-apps", state),
|
||||
)
|
||||
self.show_runtimes_switch.connect(
|
||||
"state-set",
|
||||
lambda button, state: self.gsettings_bool_set("show-runtimes", state),
|
||||
)
|
||||
self.reset_button.connect("clicked", lambda *_: self.reset_filter_gsettings())
|
||||
|
||||
# Calls
|
||||
|
||||
@@ -71,7 +71,9 @@ class WarehouseApplication(Adw.Application):
|
||||
self.create_action("set-filter", self.filters_shortcut, ["<primary>t"])
|
||||
self.create_action("install-from-file", self.install_from_file, ["<primary>o"])
|
||||
self.create_action("open-menu", self.main_menu_shortcut, ["F10"])
|
||||
self.create_action("open-search-install", self.open_search_install, ["<primary>i"])
|
||||
self.create_action(
|
||||
"open-search-install", self.open_search_install, ["<primary>i"]
|
||||
)
|
||||
|
||||
gtk_version = (
|
||||
str(Gtk.MAJOR_VERSION)
|
||||
|
||||
@@ -37,7 +37,9 @@ class OrphansWindow(Adw.Window):
|
||||
is_result = False
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def selection_handler(self, widget, dir_name):
|
||||
|
||||
@@ -32,7 +32,9 @@ class PropertiesWindow(Adw.Window):
|
||||
mask_banner = Gtk.Template.Child()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def copy_item(self, to_copy, to_toast=None):
|
||||
@@ -106,7 +108,9 @@ class PropertiesWindow(Adw.Window):
|
||||
if self.current_flatpak[i] == "":
|
||||
continue
|
||||
|
||||
row = Adw.ActionRow(title=column_headers[i], tooltip_text=_("Copy"), activatable=True)
|
||||
row = Adw.ActionRow(
|
||||
title=column_headers[i], tooltip_text=_("Copy"), activatable=True
|
||||
)
|
||||
row.add_suffix(Gtk.Image.new_from_icon_name("edit-copy-symbolic"))
|
||||
row.set_subtitle(GLib.markup_escape_text(self.current_flatpak[i]))
|
||||
row.add_css_class("property")
|
||||
|
||||
@@ -27,7 +27,9 @@ class RemotesWindow(Adw.Window):
|
||||
rows_in_popular_list = []
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
if keyval == Gdk.KEY_o and state == Gdk.ModifierType.CONTROL_MASK:
|
||||
self.add_file_handler()
|
||||
@@ -229,7 +231,9 @@ class RemotesWindow(Adw.Window):
|
||||
remote_row = Adw.ActionRow(title=title)
|
||||
|
||||
more = Gtk.MenuButton(
|
||||
icon_name="view-more-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("View More")
|
||||
icon_name="view-more-symbolic",
|
||||
valign=Gtk.Align.CENTER,
|
||||
tooltip_text=_("View More"),
|
||||
)
|
||||
more.add_css_class("flat")
|
||||
options = Gtk.Popover()
|
||||
|
||||
@@ -4,6 +4,7 @@ import subprocess
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
|
||||
class RemoteRow(Adw.ActionRow):
|
||||
def __init__(self, remote, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -21,6 +22,7 @@ class RemoteRow(Adw.ActionRow):
|
||||
self.set_subtitle(_("{} wide").format(self.install_type))
|
||||
self.add_suffix(Gtk.Image.new_from_icon_name("right-large-symbolic"))
|
||||
|
||||
|
||||
class ResultRow(Adw.ActionRow):
|
||||
def __init__(self, flatpak, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -34,15 +36,18 @@ class ResultRow(Adw.ActionRow):
|
||||
self.set_subtitle(GLib.markup_escape_text(f"{app_id}\n{description}"))
|
||||
self.check = Gtk.CheckButton()
|
||||
self.check.add_css_class("selection-mode")
|
||||
self.add_suffix(Gtk.Label(
|
||||
label = GLib.markup_escape_text(version),
|
||||
wrap = True,
|
||||
hexpand = True,
|
||||
justify = Gtk.Justification.RIGHT,
|
||||
))
|
||||
self.add_suffix(
|
||||
Gtk.Label(
|
||||
label=GLib.markup_escape_text(version),
|
||||
wrap=True,
|
||||
hexpand=True,
|
||||
justify=Gtk.Justification.RIGHT,
|
||||
)
|
||||
)
|
||||
self.add_suffix(self.check)
|
||||
self.set_activatable_widget(self.check)
|
||||
|
||||
|
||||
@Gtk.Template(
|
||||
resource_path="/io/github/flattool/Warehouse/../data/ui/search_install.ui"
|
||||
)
|
||||
@@ -75,14 +80,16 @@ class SearchInstallWindow(
|
||||
progress_bar = Gtk.Template.Child()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def reset(self):
|
||||
self.results = []
|
||||
self.results_list.remove_all()
|
||||
self.inner_stack.set_visible_child(self.blank_page)
|
||||
|
||||
|
||||
def check_handler(self, button, row):
|
||||
if button.get_active():
|
||||
self.selected.append(row.flatpak)
|
||||
@@ -106,7 +113,9 @@ class SearchInstallWindow(
|
||||
self.back_button.set_sensitive(False)
|
||||
self.search_remote = self.host_remotes[0][0]
|
||||
self.install_type = self.host_remotes[0][7]
|
||||
self.nav_view.connect("popped", lambda *_: self.nav_view.push(self.results_page))
|
||||
self.nav_view.connect(
|
||||
"popped", lambda *_: self.nav_view.push(self.results_page)
|
||||
)
|
||||
self.nav_view.set_animate_transitions(False)
|
||||
|
||||
if self.host_remotes[0][1] == "-":
|
||||
@@ -115,7 +124,9 @@ class SearchInstallWindow(
|
||||
self.title = _("Search {}").format(self.host_remotes[0][1])
|
||||
|
||||
self.set_title(self.title)
|
||||
self.search_entry.set_placeholder_text(_("Search {}").format(self.search_remote))
|
||||
self.search_entry.set_placeholder_text(
|
||||
_("Search {}").format(self.search_remote)
|
||||
)
|
||||
self.search_entry.grab_focus()
|
||||
return
|
||||
self.nav_view.connect("popped", lambda *_: self.set_title(""))
|
||||
@@ -130,7 +141,7 @@ class SearchInstallWindow(
|
||||
row.check.set_active(row.flatpak in self.selected)
|
||||
row.check.connect("toggled", self.check_handler, row)
|
||||
row.set_tooltip_text(row.flatpak[2])
|
||||
if self.search_remote in row.flatpak[5].split(','):
|
||||
if self.search_remote in row.flatpak[5].split(","):
|
||||
self.results_list.append(row)
|
||||
if self.results_list.get_row_at_index(0):
|
||||
self.inner_stack.set_visible_child(self.results_scroll)
|
||||
@@ -142,7 +153,9 @@ class SearchInstallWindow(
|
||||
self.selected = []
|
||||
self.install_type = row.install_type
|
||||
self.search_remote = row.remote[0]
|
||||
self.search_entry.set_placeholder_text(_("Search {}").format(self.search_remote))
|
||||
self.search_entry.set_placeholder_text(
|
||||
_("Search {}").format(self.search_remote)
|
||||
)
|
||||
self.title = _("Search {}").format(row.get_title())
|
||||
self.set_title(self.title)
|
||||
self.nav_view.push(self.results_page)
|
||||
@@ -157,11 +170,23 @@ class SearchInstallWindow(
|
||||
if query == "":
|
||||
self.inner_stack.set_visible_child(self.blank_page)
|
||||
return
|
||||
|
||||
def search_thread(*args):
|
||||
command = ['flatpak-spawn', '--host', 'flatpak', 'search', '--columns=all', query]
|
||||
output = subprocess.run(
|
||||
command, capture_output=True, text=True, env=self.new_env
|
||||
).stdout.strip().split('\n')
|
||||
command = [
|
||||
"flatpak-spawn",
|
||||
"--host",
|
||||
"flatpak",
|
||||
"search",
|
||||
"--columns=all",
|
||||
query,
|
||||
]
|
||||
output = (
|
||||
subprocess.run(
|
||||
command, capture_output=True, text=True, env=self.new_env
|
||||
)
|
||||
.stdout.strip()
|
||||
.split("\n")
|
||||
)
|
||||
for elm in output:
|
||||
self.results.append(elm.split("\t"))
|
||||
|
||||
@@ -169,7 +194,7 @@ class SearchInstallWindow(
|
||||
if len(self.results) > 50:
|
||||
self.inner_stack.set_visible_child(self.too_many)
|
||||
return
|
||||
if ['No matches found'] in self.results:
|
||||
if ["No matches found"] in self.results:
|
||||
self.inner_stack.set_visible_child(self.no_results)
|
||||
return
|
||||
self.generate_results_list()
|
||||
@@ -185,22 +210,32 @@ class SearchInstallWindow(
|
||||
self.set_title(_("Install From The Web"))
|
||||
|
||||
def thread(*args):
|
||||
self.my_utils.install_flatpak(paks, self.search_remote, self.install_type, self.progress_bar, self.installing_status)
|
||||
self.my_utils.install_flatpak(
|
||||
paks,
|
||||
self.search_remote,
|
||||
self.install_type,
|
||||
self.progress_bar,
|
||||
self.installing_status,
|
||||
)
|
||||
|
||||
def done(*args):
|
||||
self.parent_window.refresh_list_of_flatpaks(None, False)
|
||||
self.disconnect(self.no_close_id) # Make window able to close
|
||||
if self.my_utils.install_success:
|
||||
self.close()
|
||||
self.parent_window.toast_overlay.add_toast(Adw.Toast.new(_("Installed successfully")))
|
||||
self.parent_window.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Installed successfully"))
|
||||
)
|
||||
else:
|
||||
self.progress_bar.set_visible(False)
|
||||
self.nav_view.pop()
|
||||
self.outer_stack.set_visible_child(self.nav_view)
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Some apps didn't install")))
|
||||
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Some apps didn't install"))
|
||||
)
|
||||
|
||||
self.no_close_id = self.connect(
|
||||
"close-request", lambda event: True
|
||||
"close-request", lambda event: True
|
||||
) # Make window unable to close
|
||||
task = Gio.Task.new(None, None, done)
|
||||
task.run_in_thread(thread)
|
||||
|
||||
@@ -30,7 +30,9 @@ class SnapshotsWindow(Adw.Window):
|
||||
action_bar = Gtk.Template.Child()
|
||||
|
||||
def key_handler(self, controller, keyval, keycode, state):
|
||||
if keyval == Gdk.KEY_Escape or (keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK):
|
||||
if keyval == Gdk.KEY_Escape or (
|
||||
keyval == Gdk.KEY_w and state == Gdk.ModifierType.CONTROL_MASK
|
||||
):
|
||||
self.close()
|
||||
|
||||
def show_list_or_empty(self):
|
||||
|
||||
@@ -115,7 +115,11 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
|
||||
def uninstall_flatpak_thread(self, ref_arr, id_arr, type_arr, should_trash):
|
||||
self.my_utils.uninstall_flatpak(
|
||||
ref_arr, type_arr, should_trash, self.main_progress_bar, self.uninstalling_status
|
||||
ref_arr,
|
||||
type_arr,
|
||||
should_trash,
|
||||
self.main_progress_bar,
|
||||
self.uninstalling_status,
|
||||
)
|
||||
|
||||
def uninstall_flatpak(self, should_trash):
|
||||
@@ -343,6 +347,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.batch_actions_enable(False)
|
||||
self.main_stack.set_visible_child(self.main_box)
|
||||
self.apply_filter()
|
||||
|
||||
# Stop list window from opening with the list at the bottom by focusing the first visible row item
|
||||
for index in range(len(self.host_flatpaks)):
|
||||
if self.flatpaks_list_box.get_row_at_index(index).is_visible():
|
||||
self.flatpaks_list_box.get_row_at_index(index).grab_focus()
|
||||
@@ -396,7 +402,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
current.set_is_visible(visible)
|
||||
total_visible += visible
|
||||
i += 1
|
||||
if(total_visible == 0) or (runtimes_list != ['all'] and show_runtimes):
|
||||
if (total_visible == 0) or (runtimes_list != ["all"] and show_runtimes):
|
||||
self.window_set_empty(True)
|
||||
self.main_stack.set_visible_child(self.no_matches)
|
||||
else:
|
||||
@@ -657,7 +663,9 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
i = 0
|
||||
while self.flatpaks_list_box.get_row_at_index(i) != None:
|
||||
current = self.flatpaks_list_box.get_row_at_index(i)
|
||||
if (current.get_visible() == True) and (current.app_id != "io.github.flattool.Warehouse"):
|
||||
if (current.get_visible() == True) and (
|
||||
current.app_id != "io.github.flattool.Warehouse"
|
||||
):
|
||||
current.tickbox.set_active(should_select_all)
|
||||
i += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user