mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
use snake case in all function names
This commit is contained in:
@@ -55,7 +55,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
self.set_title(self.app_name)
|
||||
self.set_subtitle(self.app_id)
|
||||
self.add_prefix(self.my_utils.findAppIcon(self.app_id))
|
||||
self.add_prefix(self.my_utils.find_app_icon(self.app_id))
|
||||
|
||||
self.is_runtime = False
|
||||
if len(current_flatpak[13]) == 0:
|
||||
@@ -143,7 +143,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
self.tickbox = Gtk.CheckButton(visible=False) # visible=self.in_batch_mode
|
||||
self.tickbox.add_css_class("selection-mode")
|
||||
self.tickbox.connect("toggled", parent_window.rowSelectHandler)
|
||||
self.tickbox.connect("toggled", parent_window.row_select_handler)
|
||||
self.add_suffix(self.tickbox)
|
||||
self.set_activatable_widget(self.tickbox)
|
||||
self.set_activatable(False)
|
||||
@@ -161,7 +161,7 @@ class AppRow(Adw.ActionRow):
|
||||
("copy-name" + str(index)),
|
||||
lambda *_, name=self.app_name, toast=_(
|
||||
"Copied name"
|
||||
): parent_window.copyItem(name, toast),
|
||||
): parent_window.copy_item(name, toast),
|
||||
)
|
||||
copy_menu_model.append_item(
|
||||
Gio.MenuItem.new(_("Copy Name"), f"win.copy-name{index}")
|
||||
@@ -169,7 +169,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("copy-id" + str(index)),
|
||||
lambda *_, id=self.app_id, toast=_("Copied ID"): parent_window.copyItem(
|
||||
lambda *_, id=self.app_id, toast=_("Copied ID"): parent_window.copy_item(
|
||||
id, toast
|
||||
),
|
||||
)
|
||||
@@ -179,7 +179,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("copy-ref" + str(index)),
|
||||
lambda *_, ref=self.app_ref, toast=_("Copied ref"): parent_window.copyItem(
|
||||
lambda *_, ref=self.app_ref, toast=_("Copied ref"): parent_window.copy_item(
|
||||
ref, toast
|
||||
),
|
||||
)
|
||||
@@ -191,7 +191,7 @@ class AppRow(Adw.ActionRow):
|
||||
("copy-command" + str(index)),
|
||||
lambda *_, ref=self.app_ref, toast=_(
|
||||
"Copied launch command"
|
||||
): parent_window.copyItem(f"flatpak run {ref}", toast),
|
||||
): parent_window.copy_item(f"flatpak run {ref}", toast),
|
||||
)
|
||||
copy_menu_model.append_item(
|
||||
Gio.MenuItem.new(_("Copy Launch Command"), f"win.copy-command{index}")
|
||||
@@ -202,7 +202,7 @@ class AppRow(Adw.ActionRow):
|
||||
if "runtime" not in parent_window.host_flatpaks[index][12]:
|
||||
parent_window.create_action(
|
||||
("run" + str(index)),
|
||||
lambda *_a, ref=self.app_ref, name=self.app_name: parent_window.runAppThread(
|
||||
lambda *_a, ref=self.app_ref, name=self.app_name: parent_window.run_app_thread(
|
||||
ref, _("Opened {}").format(name)
|
||||
),
|
||||
)
|
||||
@@ -211,7 +211,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("uninstall" + str(index)),
|
||||
lambda *_: parent_window.uninstallButtonHandler(
|
||||
lambda *_: parent_window.uninstall_button_handler(
|
||||
self, self.app_name, self.app_ref, self.app_id
|
||||
),
|
||||
)
|
||||
@@ -224,7 +224,7 @@ class AppRow(Adw.ActionRow):
|
||||
("open-data" + str(index)),
|
||||
lambda *_, path=(
|
||||
parent_window.user_data_path + self.app_id
|
||||
): parent_window.openDataFolder(path),
|
||||
): parent_window.open_data_folder(path),
|
||||
)
|
||||
open_data_item = Gio.MenuItem.new(
|
||||
_("Open User Data Folder"), f"win.open-data{index}"
|
||||
@@ -236,7 +236,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("trash" + str(index)),
|
||||
lambda *_, name=self.app_name, id=self.app_id, index=index: parent_window.trashData(
|
||||
lambda *_, name=self.app_name, id=self.app_id, index=index: parent_window.trash_data(
|
||||
name, id, index
|
||||
),
|
||||
)
|
||||
@@ -254,7 +254,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("mask" + str(index)),
|
||||
lambda *_, id=self.app_id, type=self.install_type, index=index: parent_window.maskFlatpak(
|
||||
lambda *_, id=self.app_id, type=self.install_type, index=index: parent_window.mask_flatpak(
|
||||
self
|
||||
),
|
||||
)
|
||||
@@ -266,7 +266,7 @@ class AppRow(Adw.ActionRow):
|
||||
|
||||
parent_window.create_action(
|
||||
("unmask" + str(index)),
|
||||
lambda *_, id=self.app_id, type=self.install_type, index=index: parent_window.maskFlatpak(
|
||||
lambda *_, id=self.app_id, type=self.install_type, index=index: parent_window.mask_flatpak(
|
||||
self
|
||||
),
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ class myUtils:
|
||||
self.new_env = dict(os.environ)
|
||||
self.new_env["LC_ALL"] = "C"
|
||||
|
||||
def trashFolder(self, path):
|
||||
def trash_folder(self, path):
|
||||
if not os.path.exists(path):
|
||||
print("error in common.trashFolder: path does not exists. path =", path)
|
||||
return 1
|
||||
@@ -31,10 +31,10 @@ class myUtils:
|
||||
print("error in common.trashFolder: CalledProcessError:", e)
|
||||
return 2
|
||||
|
||||
def getSizeWithFormat(self, path):
|
||||
return self.getSizeFormat(self.getDirectorySize(path))
|
||||
def get_size_with_format(self, path):
|
||||
return self.get_size_format(self.get_dir_size(path))
|
||||
|
||||
def getSizeFormat(self, b):
|
||||
def get_size_format(self, b):
|
||||
factor = 1000
|
||||
suffix = "B"
|
||||
for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
|
||||
@@ -43,7 +43,7 @@ class myUtils:
|
||||
b /= factor
|
||||
return f"{b:.1f}{suffix}"
|
||||
|
||||
def getDirectorySize(self, directory):
|
||||
def get_dir_size(self, directory):
|
||||
"""Returns the `directory` size in bytes."""
|
||||
total = 0
|
||||
try:
|
||||
@@ -57,7 +57,7 @@ class myUtils:
|
||||
elif entry.is_dir():
|
||||
# if it's a directory, recursively call this function
|
||||
try:
|
||||
total += self.getDirectorySize(entry.path)
|
||||
total += self.get_dir_size(entry.path)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except NotADirectoryError:
|
||||
@@ -71,7 +71,7 @@ class myUtils:
|
||||
# Adding 4000 seems to make it more accurate to whatever data we can't scan from within the sandbox
|
||||
return total + 4000
|
||||
|
||||
def findAppIcon(self, app_id):
|
||||
def find_app_icon(self, app_id):
|
||||
icon_theme = Gtk.IconTheme.new()
|
||||
icon_theme.add_search_path("/var/lib/flatpak/exports/share/icons/")
|
||||
icon_theme.add_search_path(
|
||||
@@ -97,7 +97,7 @@ class myUtils:
|
||||
image.set_icon_size(Gtk.IconSize.LARGE)
|
||||
return image
|
||||
|
||||
def getHostUpdates(self):
|
||||
def get_host_updates(self):
|
||||
list = []
|
||||
output = subprocess.run(
|
||||
["flatpak-spawn", "--host", "flatpak", "update"],
|
||||
@@ -118,7 +118,7 @@ class myUtils:
|
||||
|
||||
return list
|
||||
|
||||
def getHostPins(self):
|
||||
def get_host_pins(self):
|
||||
output = subprocess.run(
|
||||
["flatpak-spawn", "--host", "flatpak", "pin"],
|
||||
capture_output=True,
|
||||
@@ -130,7 +130,7 @@ class myUtils:
|
||||
data[i] = data[i].strip()
|
||||
return data
|
||||
|
||||
def getHostRemotes(self):
|
||||
def get_host_remotes(self):
|
||||
output = subprocess.run(
|
||||
[
|
||||
"flatpak-spawn",
|
||||
@@ -152,7 +152,7 @@ class myUtils:
|
||||
data.append(row)
|
||||
return data
|
||||
|
||||
def getHostFlatpaks(self):
|
||||
def get_host_flatpaks(self):
|
||||
output = subprocess.run(
|
||||
["flatpak-spawn", "--host", "flatpak", "list", "--columns=all"],
|
||||
capture_output=True,
|
||||
@@ -178,8 +178,8 @@ class myUtils:
|
||||
sorted_array = sorted(data, key=lambda item: item[0].lower())
|
||||
return sorted_array
|
||||
|
||||
def getDependentRuntimes(self):
|
||||
paks = self.getHostFlatpaks()
|
||||
def get_dependent_runtimes(self):
|
||||
paks = self.get_host_flatpaks()
|
||||
dependent_runtimes = []
|
||||
for i in range(len(paks)):
|
||||
current = paks[i]
|
||||
@@ -190,7 +190,7 @@ class myUtils:
|
||||
print("Could not get dependent runtime")
|
||||
return dependent_runtimes
|
||||
|
||||
def getHostMasks(self, user_or_system):
|
||||
def get_host_masks(self, user_or_system):
|
||||
output = subprocess.run(
|
||||
["flatpak-spawn", "--host", "flatpak", "mask", f"--{user_or_system}"],
|
||||
capture_output=True,
|
||||
@@ -202,7 +202,7 @@ class myUtils:
|
||||
lines[i] = lines[i].strip()
|
||||
return lines
|
||||
|
||||
def maskFlatpak(self, app_id, user_or_system, remove=False):
|
||||
def mask_flatpak(self, app_id, user_or_system, remove=False):
|
||||
command = [
|
||||
"flatpak-spawn",
|
||||
"--host",
|
||||
@@ -225,7 +225,7 @@ class myUtils:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def downgradeFlatpak(self, ref, commit, install_type="system"):
|
||||
def downgrade_flatpak(self, ref, commit, install_type="system"):
|
||||
command = [
|
||||
"flatpak-spawn",
|
||||
"--host",
|
||||
@@ -248,7 +248,7 @@ class myUtils:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def uninstallFlatpak(self, ref_arr, type_arr, should_trash, progress_bar=None):
|
||||
def uninstall_flatpak(self, ref_arr, type_arr, should_trash, progress_bar=None):
|
||||
self.uninstall_success = True
|
||||
print(ref_arr)
|
||||
to_uninstall = []
|
||||
@@ -313,7 +313,7 @@ class myUtils:
|
||||
self.uninstall_success = False
|
||||
|
||||
if should_trash:
|
||||
host_paks = self.getHostFlatpaks()
|
||||
host_paks = self.get_host_flatpaks()
|
||||
host_refs = []
|
||||
for i in range(len(host_paks)):
|
||||
host_refs.append(host_paks[i][8])
|
||||
@@ -322,13 +322,13 @@ class myUtils:
|
||||
if apps[i][0] in host_refs:
|
||||
print(f"{apps[i][1]} is still installed")
|
||||
else:
|
||||
self.trashFolder(f"{self.user_data_path}{apps[i][1]}")
|
||||
self.trash_folder(f"{self.user_data_path}{apps[i][1]}")
|
||||
|
||||
if progress_bar:
|
||||
GLib.idle_add(progress_bar.set_visible, False)
|
||||
GLib.idle_add(progress_bar.set_fraction, 0.0)
|
||||
|
||||
def installFlatpak(self, app_arr, remote, user_or_system, progress_bar=None):
|
||||
def install_flatpak(self, app_arr, remote, user_or_system, progress_bar=None):
|
||||
self.install_success = True
|
||||
fails = []
|
||||
|
||||
@@ -379,7 +379,7 @@ class myUtils:
|
||||
GLib.idle_add(progress_bar.set_visible, False)
|
||||
GLib.idle_add(progress_bar.set_fraction, 0.0)
|
||||
|
||||
def runApp(self, ref):
|
||||
def run_app(self, ref):
|
||||
self.run_app_error = False
|
||||
self.run_app_error_message = ""
|
||||
try:
|
||||
@@ -393,7 +393,7 @@ class myUtils:
|
||||
self.run_app_error_message = str(e)
|
||||
self.run_app_error = True
|
||||
|
||||
def getInstallType(self, type_arr):
|
||||
def get_install_type(self, type_arr):
|
||||
if "disabled" in type_arr:
|
||||
return "disabled"
|
||||
if "user" in type_arr:
|
||||
@@ -401,7 +401,7 @@ class myUtils:
|
||||
if "system" in type_arr:
|
||||
return "system"
|
||||
|
||||
def snapshotApps(
|
||||
def snapshot_apps(
|
||||
self,
|
||||
epoch,
|
||||
app_snapshot_path_arr,
|
||||
|
||||
@@ -29,12 +29,12 @@ class DowngradeWindow(Adw.Window):
|
||||
if event == Gdk.KEY_Escape:
|
||||
self.close()
|
||||
|
||||
def selectionHandler(self, button, index):
|
||||
def selection_handler(self, button, index):
|
||||
self.apply_button.set_sensitive(True)
|
||||
if button.get_active():
|
||||
self.commit_to_use = self.versions[index][0]
|
||||
|
||||
def getCommits(self):
|
||||
def get_commits(self):
|
||||
output = subprocess.run(
|
||||
[
|
||||
"flatpak-spawn",
|
||||
@@ -75,7 +75,7 @@ class DowngradeWindow(Adw.Window):
|
||||
for i in range(len(commits)):
|
||||
self.versions.append([commits[i], changes[i], dates[i]])
|
||||
|
||||
def commitsCallback(self):
|
||||
def commits_callback(self):
|
||||
self.progress_bar.set_visible(False)
|
||||
self.should_pulse = False
|
||||
group_button = Gtk.CheckButton(visible=False)
|
||||
@@ -102,7 +102,7 @@ class DowngradeWindow(Adw.Window):
|
||||
)
|
||||
row.set_tooltip_text(_("Commit Hash: {}").format(version[0]))
|
||||
select = Gtk.CheckButton()
|
||||
select.connect("toggled", self.selectionHandler, i)
|
||||
select.connect("toggled", self.selection_handler, i)
|
||||
select.set_group(group_button)
|
||||
|
||||
version.append(select)
|
||||
@@ -111,11 +111,11 @@ class DowngradeWindow(Adw.Window):
|
||||
self.versions_group.add(row)
|
||||
self.set_title(self.window_title)
|
||||
|
||||
def generateList(self):
|
||||
task = Gio.Task.new(None, None, lambda *_: self.commitsCallback())
|
||||
task.run_in_thread(lambda *_: self.getCommits())
|
||||
def generate_list(self):
|
||||
task = Gio.Task.new(None, None, lambda *_: self.commits_callback())
|
||||
task.run_in_thread(lambda *_: self.get_commits())
|
||||
|
||||
def downgradeCallack(self):
|
||||
def downgrade_callack(self):
|
||||
self.progress_bar.set_visible(False)
|
||||
self.should_pulse = False
|
||||
self.disconnect(self.no_close)
|
||||
@@ -129,7 +129,7 @@ class DowngradeWindow(Adw.Window):
|
||||
return
|
||||
|
||||
if self.mask_row.get_active():
|
||||
if self.my_utils.maskFlatpak(self.app_id, self.install_type) != 0:
|
||||
if self.my_utils.mask_flatpak(self.app_id, self.install_type) != 0:
|
||||
self.parent_window.toast_overlay.add_toast(
|
||||
Adw.Toast.new(
|
||||
_("Could not disable updates for {}").format(self.app_name)
|
||||
@@ -139,12 +139,12 @@ class DowngradeWindow(Adw.Window):
|
||||
self.parent_window.refresh_list_of_flatpaks(self, False)
|
||||
self.close()
|
||||
|
||||
def downgradeThread(self):
|
||||
self.response = self.my_utils.downgradeFlatpak(
|
||||
def downgrade_thread(self):
|
||||
self.response = self.my_utils.downgrade_flatpak(
|
||||
self.app_ref, self.commit_to_use, self.install_type
|
||||
)
|
||||
|
||||
def onApply(self):
|
||||
def on_apply(self):
|
||||
self.set_title(_("Downgrading…"))
|
||||
self.no_close = self.connect("close-request", lambda event: True)
|
||||
self.main_toolbar_view.set_sensitive(False)
|
||||
@@ -152,8 +152,8 @@ class DowngradeWindow(Adw.Window):
|
||||
self.progress_bar.set_visible(True)
|
||||
self.pulser()
|
||||
|
||||
task = Gio.Task.new(None, None, lambda *_: self.downgradeCallack())
|
||||
task.run_in_thread(lambda *_: self.downgradeThread())
|
||||
task = Gio.Task.new(None, None, lambda *_: self.downgrade_callack())
|
||||
task.run_in_thread(lambda *_: self.downgrade_thread())
|
||||
|
||||
def __init__(self, parent_window, flatpak_row, index, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
@@ -178,7 +178,7 @@ class DowngradeWindow(Adw.Window):
|
||||
# Connections
|
||||
event_controller.connect("key-pressed", self.key_handler)
|
||||
self.cancel_button.connect("clicked", lambda *_: self.close())
|
||||
self.apply_button.connect("clicked", lambda *_: self.onApply())
|
||||
self.apply_button.connect("clicked", lambda *_: self.on_apply())
|
||||
|
||||
# Apply
|
||||
self.pulser()
|
||||
@@ -191,6 +191,6 @@ class DowngradeWindow(Adw.Window):
|
||||
)
|
||||
)
|
||||
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
|
||||
self.present()
|
||||
|
||||
@@ -20,7 +20,7 @@ class FilterWindow(Adw.Window):
|
||||
if event == Gdk.KEY_Escape:
|
||||
self.close()
|
||||
|
||||
def isListApplicable(self):
|
||||
def is_list_applicable(self):
|
||||
self.apply_button.set_sensitive(True)
|
||||
|
||||
if not self.filter_list[0] == True and not self.filter_list[1] == True:
|
||||
@@ -44,22 +44,22 @@ class FilterWindow(Adw.Window):
|
||||
self.apply_button.set_sensitive(False)
|
||||
return
|
||||
|
||||
def appsHandler(self, switch, _a):
|
||||
def apps_handler(self, switch, _a):
|
||||
self.filter_list[0] = switch.get_active()
|
||||
self.isListApplicable()
|
||||
self.is_list_applicable()
|
||||
|
||||
def runtimesHandler(self, switch, _a):
|
||||
def runtimes_handler(self, switch, _a):
|
||||
self.filter_list[1] = switch.get_active()
|
||||
self.isListApplicable()
|
||||
self.is_list_applicable()
|
||||
|
||||
def remotesEnableHandler(self, switch, is_enabled):
|
||||
def remotes_enable_handler(self, switch, is_enabled):
|
||||
self.remotes_expander.set_enable_expansion(is_enabled)
|
||||
|
||||
for i in range(len(self.remote_checkboxes)):
|
||||
self.remote_checkboxes[i].set_active(not is_enabled)
|
||||
|
||||
def remoteCheckHandler(self, checkbox, install_type, remote):
|
||||
install_type = self.my_utils.getInstallType(install_type)
|
||||
def remotes_check_handler(self, checkbox, install_type, remote):
|
||||
install_type = self.my_utils.get_install_type(install_type)
|
||||
if checkbox.get_active():
|
||||
self.filter_list[2].append(install_type)
|
||||
self.filter_list[3].append(remote)
|
||||
@@ -67,17 +67,17 @@ class FilterWindow(Adw.Window):
|
||||
self.filter_list[2].remove(install_type)
|
||||
self.filter_list[3].remove(remote)
|
||||
|
||||
self.isListApplicable()
|
||||
self.is_list_applicable()
|
||||
|
||||
def runtimesEnableHandler(self, switch, is_enabled):
|
||||
def runtimes_enable_handler(self, switch, is_enabled):
|
||||
self.runtimes_expander.set_enable_expansion(is_enabled)
|
||||
|
||||
for i in range(len(self.runtime_checkboxes)):
|
||||
self.runtime_checkboxes[i].set_active(not is_enabled)
|
||||
|
||||
self.isListApplicable()
|
||||
self.is_list_applicable()
|
||||
|
||||
def runtimeCheckHandler(self, checkbox, runtime):
|
||||
def runtimes_check_handler(self, checkbox, runtime):
|
||||
if checkbox.get_active():
|
||||
if self.filter_list[4] == "all":
|
||||
self.filter_list[4] = []
|
||||
@@ -85,13 +85,13 @@ class FilterWindow(Adw.Window):
|
||||
else:
|
||||
self.filter_list[4].remove(runtime)
|
||||
|
||||
self.isListApplicable()
|
||||
self.is_list_applicable()
|
||||
|
||||
def generateList(self):
|
||||
def generate_list(self):
|
||||
self.remotes_expander_switch = Gtk.Switch(valign=Gtk.Align.CENTER)
|
||||
self.runtimes_expander_switch = Gtk.Switch(valign=Gtk.Align.CENTER)
|
||||
|
||||
dependent_runtimes = self.my_utils.getDependentRuntimes()
|
||||
dependent_runtimes = self.my_utils.get_dependent_runtimes()
|
||||
|
||||
if (
|
||||
len(self.host_remotes) < 2
|
||||
@@ -132,7 +132,7 @@ class FilterWindow(Adw.Window):
|
||||
remote_row.add_suffix(remote_check)
|
||||
remote_row.set_activatable_widget(remote_check)
|
||||
remote_check.connect(
|
||||
"toggled", self.remoteCheckHandler, install_type, name
|
||||
"toggled", self.remotes_check_handler, install_type, name
|
||||
)
|
||||
self.remote_checkboxes.append(remote_check)
|
||||
remote_check.set_active(True)
|
||||
@@ -140,7 +140,7 @@ class FilterWindow(Adw.Window):
|
||||
print("Could not make remote row")
|
||||
if total < 2:
|
||||
self.remotes_expander.set_visible(False)
|
||||
self.remotes_expander_switch.connect("state-set", self.remotesEnableHandler)
|
||||
self.remotes_expander_switch.connect("state-set", self.remotes_enable_handler)
|
||||
self.remotes_expander.add_suffix(self.remotes_expander_switch)
|
||||
|
||||
self.runtime_checkboxes = []
|
||||
@@ -148,23 +148,23 @@ class FilterWindow(Adw.Window):
|
||||
current = dependent_runtimes[i]
|
||||
runtime_row = Adw.ActionRow(title=current)
|
||||
runtime_check = Gtk.CheckButton()
|
||||
runtime_check.connect("toggled", self.runtimeCheckHandler, current)
|
||||
runtime_check.connect("toggled", self.runtimes_check_handler, current)
|
||||
runtime_check.set_active(True)
|
||||
self.runtime_checkboxes.append(runtime_check)
|
||||
runtime_row.add_suffix(runtime_check)
|
||||
runtime_row.set_activatable_widget(runtime_check)
|
||||
self.runtimes_expander.add_row(runtime_row)
|
||||
self.runtimes_expander_switch.connect("state-set", self.runtimesEnableHandler)
|
||||
self.runtimes_expander_switch.connect("state-set", self.runtimes_enable_handler)
|
||||
self.runtimes_expander.add_suffix(self.runtimes_expander_switch)
|
||||
|
||||
def setHas_apply_button_been_clicked(self, is_clicked):
|
||||
def set_has_apply_button_been_clicked(self, is_clicked):
|
||||
self.has_apply_button_been_clicked = is_clicked
|
||||
if not self.remotes_expander_switch.get_active():
|
||||
self.filter_list[3] = "all"
|
||||
if not self.runtimes_expander_switch.get_active():
|
||||
self.filter_list[4] = "all"
|
||||
|
||||
def disableFilterToggle(self, _widget):
|
||||
def disable_filter_toggle(self, _widget):
|
||||
self.app_window.filter_button.set_active(self.has_apply_button_been_clicked)
|
||||
|
||||
def __init__(self, main_window, **kwargs):
|
||||
@@ -172,7 +172,7 @@ class FilterWindow(Adw.Window):
|
||||
|
||||
# Create Variables
|
||||
self.my_utils = myUtils(self)
|
||||
self.host_remotes = self.my_utils.getHostRemotes()
|
||||
self.host_remotes = self.my_utils.get_host_remotes()
|
||||
self.host_flatpaks = main_window.host_flatpaks
|
||||
self.filter_list = [False, False, [], [], []]
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
@@ -185,26 +185,26 @@ class FilterWindow(Adw.Window):
|
||||
|
||||
# Connections
|
||||
self.apply_button.connect(
|
||||
"clicked", lambda *_: self.setHas_apply_button_been_clicked(True)
|
||||
"clicked", lambda *_: self.set_has_apply_button_been_clicked(True)
|
||||
)
|
||||
self.apply_button.connect(
|
||||
"clicked", lambda *_: main_window.applyFilter(self.filter_list)
|
||||
"clicked", lambda *_: main_window.apply_filter(self.filter_list)
|
||||
)
|
||||
self.apply_button.connect("clicked", lambda *_: self.close())
|
||||
|
||||
self.cancel_button.connect("clicked", lambda *_: self.close())
|
||||
|
||||
self.connect("close-request", self.disableFilterToggle)
|
||||
self.connect("close-request", self.disable_filter_toggle)
|
||||
|
||||
self.apps_switch.connect("state-set", self.appsHandler)
|
||||
self.runtimes_switch.connect("state-set", self.runtimesHandler)
|
||||
self.apps_switch.connect("state-set", self.apps_handler)
|
||||
self.runtimes_switch.connect("state-set", self.runtimes_handler)
|
||||
event_controller.connect("key-pressed", self.key_handler)
|
||||
|
||||
# Calls
|
||||
self.apps_switch.set_active(True)
|
||||
self.set_size_request(260, 230)
|
||||
if not self.host_remotes[0][0] == "":
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
else:
|
||||
self.remotes_expander.set_visible(False)
|
||||
self.runtimes_expander.set_visible(False)
|
||||
|
||||
@@ -39,7 +39,7 @@ class OrphansWindow(Adw.Window):
|
||||
if event == Gdk.KEY_Escape:
|
||||
self.close()
|
||||
|
||||
def selectionHandler(self, widget, dir_name):
|
||||
def selection_handler(self, widget, dir_name):
|
||||
if widget.get_active():
|
||||
self.selected_dirs.append(dir_name)
|
||||
else:
|
||||
@@ -61,15 +61,15 @@ class OrphansWindow(Adw.Window):
|
||||
self.install_button.set_sensitive(True)
|
||||
self.trash_button.set_sensitive(True)
|
||||
|
||||
def selectAllHandler(self, button):
|
||||
def select_all_handler(self, button):
|
||||
self.should_select_all = button.get_active()
|
||||
if not button.get_active():
|
||||
self.install_button.set_sensitive(False)
|
||||
self.trash_button.set_sensitive(False)
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
|
||||
def installCallback(self, *_args):
|
||||
self.generateList()
|
||||
def install_callback(self, *_args):
|
||||
self.generate_list()
|
||||
self.progress_bar.set_visible(False)
|
||||
self.app_window.refresh_list_of_flatpaks(self, False)
|
||||
self.disconnect(self.no_close_id) # Make window able to close
|
||||
@@ -81,31 +81,31 @@ class OrphansWindow(Adw.Window):
|
||||
Adw.Toast.new(_("Could not install some apps"))
|
||||
)
|
||||
|
||||
def installHandler(self):
|
||||
def install_handler(self):
|
||||
self.main_stack.set_visible_child(self.installing)
|
||||
self.search_button.set_sensitive(False)
|
||||
self.set_title(self.window_title)
|
||||
self.keep_checking = True
|
||||
task = Gio.Task.new(None, None, self.installCallback)
|
||||
task = Gio.Task.new(None, None, self.install_callback)
|
||||
task.run_in_thread(
|
||||
lambda _task, _obj, _data, _cancellable, id_list=self.selected_dirs, remote=self.selected_remote, app_type=self.selected_remote_type, progress_bar=self.progress_bar: self.my_utils.installFlatpak(
|
||||
lambda _task, _obj, _data, _cancellable, id_list=self.selected_dirs, remote=self.selected_remote, app_type=self.selected_remote_type, progress_bar=self.progress_bar: self.my_utils.install_flatpak(
|
||||
id_list, remote, app_type, progress_bar
|
||||
)
|
||||
)
|
||||
|
||||
def installButtonHandler(self, button):
|
||||
def install_button_handler(self, button):
|
||||
def remote_select_handler(button, index):
|
||||
if not button.get_active():
|
||||
return
|
||||
self.selected_remote = self.host_remotes[index][0]
|
||||
self.selected_remote_type = self.my_utils.getInstallType(
|
||||
self.selected_remote_type = self.my_utils.get_install_type(
|
||||
self.host_remotes[index][7]
|
||||
)
|
||||
|
||||
def onResponse(dialog, response_id, _function):
|
||||
def on_response(dialog, response_id, _function):
|
||||
if response_id == "cancel":
|
||||
return
|
||||
self.installHandler()
|
||||
self.install_handler()
|
||||
self.progress_bar.set_visible(True)
|
||||
self.action_bar.set_visible(False)
|
||||
self.no_close_id = self.connect(
|
||||
@@ -145,7 +145,7 @@ class OrphansWindow(Adw.Window):
|
||||
remote_select.connect("toggled", remote_select_handler, i)
|
||||
remote_row.set_activatable_widget(remote_select)
|
||||
|
||||
type = self.my_utils.getInstallType(type_arr)
|
||||
type = self.my_utils.get_install_type(type_arr)
|
||||
if type == "user":
|
||||
remote_row.set_subtitle(_("User wide"))
|
||||
elif type == "system":
|
||||
@@ -168,23 +168,23 @@ class OrphansWindow(Adw.Window):
|
||||
if total_added > 1:
|
||||
dialog.set_extra_child(remotes_scroll)
|
||||
|
||||
dialog.connect("response", onResponse, dialog.choose_finish)
|
||||
dialog.connect("response", on_response, dialog.choose_finish)
|
||||
dialog.present()
|
||||
|
||||
def trashHandler(self, button):
|
||||
def onResponse(dialog, response_id, _function):
|
||||
def trash_handler(self, button):
|
||||
def on_response(dialog, response_id, _function):
|
||||
if response_id == "cancel":
|
||||
return
|
||||
for i in range(len(self.selected_dirs)):
|
||||
path = self.user_data_path + self.selected_dirs[i]
|
||||
self.my_utils.trashFolder(path)
|
||||
self.my_utils.trash_folder(path)
|
||||
self.select_all_button.set_active(False)
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
|
||||
dialog = Adw.MessageDialog.new(
|
||||
self, _("Trash folders?"), _("These folders will be sent to the trash.")
|
||||
)
|
||||
dialog.connect("response", onResponse, dialog.choose_finish)
|
||||
dialog.connect("response", on_response, dialog.choose_finish)
|
||||
dialog.set_close_response("cancel")
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.add_response("continue", _("Continue"))
|
||||
@@ -199,18 +199,18 @@ class OrphansWindow(Adw.Window):
|
||||
Adw.Toast.new(_("Could not open folder"))
|
||||
)
|
||||
|
||||
def sizeCallBack(self, row_index):
|
||||
def size_callback(self, row_index):
|
||||
row = self.list_of_data.get_row_at_index(row_index)
|
||||
row.set_subtitle(f"~{self.data_rows[row_index][1]}")
|
||||
|
||||
def sizeThread(self, index, path):
|
||||
size = self.my_utils.getSizeWithFormat(path)
|
||||
def size_thread(self, index, path):
|
||||
size = self.my_utils.get_size_with_format(path)
|
||||
self.data_rows[index].append(size)
|
||||
|
||||
# Create the list of folders in the window
|
||||
def generateList(self):
|
||||
def generate_list(self):
|
||||
self.data_rows = []
|
||||
self.host_flatpaks = self.my_utils.getHostFlatpaks()
|
||||
self.host_flatpaks = self.my_utils.get_host_flatpaks()
|
||||
|
||||
if self.host_flatpaks == [["", ""]]:
|
||||
self.app_window.toast_overlay.add_toast(
|
||||
@@ -245,10 +245,10 @@ class OrphansWindow(Adw.Window):
|
||||
path = self.user_data_path + dir_name
|
||||
index = len(self.data_rows) - 1
|
||||
task = Gio.Task.new(
|
||||
None, None, lambda *_, index=index: self.sizeCallBack(index)
|
||||
None, None, lambda *_, index=index: self.size_callback(index)
|
||||
)
|
||||
task.run_in_thread(
|
||||
lambda _task, _obj, _data, _cancellable, *_, index=index: self.sizeThread(
|
||||
lambda _task, _obj, _data, _cancellable, *_, index=index: self.size_thread(
|
||||
index, path
|
||||
)
|
||||
)
|
||||
@@ -266,7 +266,7 @@ class OrphansWindow(Adw.Window):
|
||||
|
||||
select_button = Gtk.CheckButton()
|
||||
select_button.add_css_class("selection-mode")
|
||||
select_button.connect("toggled", self.selectionHandler, dir_name)
|
||||
select_button.connect("toggled", self.selection_handler, dir_name)
|
||||
select_button.set_active(self.should_select_all)
|
||||
dir_row.add_suffix(select_button)
|
||||
dir_row.set_activatable_widget(select_button)
|
||||
@@ -314,8 +314,8 @@ class OrphansWindow(Adw.Window):
|
||||
self.my_utils = myUtils(
|
||||
self
|
||||
) # Access common utils and set the window to this window
|
||||
self.host_remotes = self.my_utils.getHostRemotes()
|
||||
self.host_flatpaks = self.my_utils.getHostFlatpaks()
|
||||
self.host_remotes = self.my_utils.get_host_remotes()
|
||||
self.host_flatpaks = self.my_utils.get_host_flatpaks()
|
||||
|
||||
self.progress_bar = Gtk.ProgressBar(visible=False)
|
||||
self.progress_bar.add_css_class("osd")
|
||||
@@ -324,17 +324,17 @@ class OrphansWindow(Adw.Window):
|
||||
self.set_modal(True)
|
||||
self.set_transient_for(main_window)
|
||||
self.set_size_request(260, 230)
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
event_controller.connect("key-pressed", self.key_handler)
|
||||
self.add_controller(event_controller)
|
||||
|
||||
self.install_button.connect("clicked", self.installButtonHandler)
|
||||
self.install_button.connect("clicked", self.install_button_handler)
|
||||
if self.host_remotes[0][0] == "":
|
||||
self.install_button.set_visible(False)
|
||||
self.trash_button.connect("clicked", self.trashHandler)
|
||||
self.select_all_button.connect("toggled", self.selectAllHandler)
|
||||
self.trash_button.connect("clicked", self.trash_handler)
|
||||
self.select_all_button.connect("toggled", self.select_all_handler)
|
||||
self.main_overlay.add_overlay(self.progress_bar)
|
||||
|
||||
self.list_of_data.set_filter_func(self.filter_func)
|
||||
|
||||
@@ -31,7 +31,7 @@ class PropertiesWindow(Adw.Window):
|
||||
eol_runtime_banner = Gtk.Template.Child()
|
||||
mask_banner = Gtk.Template.Child()
|
||||
|
||||
def copyItem(self, to_copy, to_toast=None):
|
||||
def copy_item(self, to_copy, to_toast=None):
|
||||
self.get_clipboard().set(to_copy)
|
||||
if to_toast:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied {}").format(to_toast)))
|
||||
@@ -48,7 +48,7 @@ class PropertiesWindow(Adw.Window):
|
||||
except GLib.GError:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not show details")))
|
||||
|
||||
def getSizeCallback(self, *args):
|
||||
def get_size_callback(self, *args):
|
||||
self.open_data.set_visible(True)
|
||||
self.open_data.connect("clicked", self.open_button_handler)
|
||||
self.trash_data.set_visible(True)
|
||||
@@ -56,11 +56,11 @@ class PropertiesWindow(Adw.Window):
|
||||
self.data_row.set_subtitle(f"~{self.size}")
|
||||
self.spinner.set_visible(False)
|
||||
|
||||
def getSizeThread(self, *args):
|
||||
self.size = self.my_utils.getSizeWithFormat(self.user_data_path)
|
||||
def get_size_thread(self, *args):
|
||||
self.size = self.my_utils.get_size_with_format(self.user_data_path)
|
||||
|
||||
def generateUpper(self):
|
||||
image = self.my_utils.findAppIcon(self.app_id)
|
||||
def generate_upper(self):
|
||||
image = self.my_utils.find_app_icon(self.app_id)
|
||||
self.runtime.set_subtitle(self.current_flatpak[13])
|
||||
if image.get_paintable() == None:
|
||||
self.app_icon.set_from_icon_name(image.get_icon_name())
|
||||
@@ -68,8 +68,8 @@ class PropertiesWindow(Adw.Window):
|
||||
self.app_icon.set_from_paintable(image.get_paintable())
|
||||
|
||||
if os.path.exists(self.user_data_path):
|
||||
task = Gio.Task.new(None, None, self.getSizeCallback)
|
||||
task.run_in_thread(self.getSizeThread)
|
||||
task = Gio.Task.new(None, None, self.get_size_callback)
|
||||
task.run_in_thread(self.get_size_thread)
|
||||
else:
|
||||
self.data_row.set_title(_("No User Data"))
|
||||
self.spinner.set_visible(False)
|
||||
@@ -80,7 +80,7 @@ class PropertiesWindow(Adw.Window):
|
||||
if self.app_ref in self.parent_window.dependent_runtimes:
|
||||
self.view_apps.set_visible(True)
|
||||
|
||||
def generateLower(self):
|
||||
def generate_lower(self):
|
||||
column_headers = [
|
||||
_("Name"),
|
||||
_("Description"),
|
||||
@@ -106,29 +106,31 @@ class PropertiesWindow(Adw.Window):
|
||||
row.set_subtitle(GLib.markup_escape_text(self.current_flatpak[i]))
|
||||
row.connect(
|
||||
"activated",
|
||||
lambda *_a, row=row: self.copyItem(row.get_subtitle(), row.get_title()),
|
||||
lambda *_a, row=row: self.copy_item(
|
||||
row.get_subtitle(), row.get_title()
|
||||
),
|
||||
)
|
||||
self.lower.add(row)
|
||||
|
||||
def viewAppsHandler(self, widget):
|
||||
def view_apps_handler(self, widget):
|
||||
self.parent_window.should_open_filter_window = False
|
||||
self.parent_window.filter_button.set_active(True)
|
||||
self.parent_window.applyFilter([True, False, ["all"], ["all"], [self.app_ref]])
|
||||
self.parent_window.should_open_filter_window = True
|
||||
self.close()
|
||||
|
||||
def showPropertiesHandler(self):
|
||||
def show_properties_handler(self):
|
||||
runtime = self.current_flatpak[13]
|
||||
for i in range(len(self.host_flatpaks)):
|
||||
if runtime in self.host_flatpaks[i][8]:
|
||||
PropertiesWindow(i, self.host_flatpaks, self.parent_window)
|
||||
|
||||
def trashDataHandler(self):
|
||||
def onResponse(_none, response, widget):
|
||||
def trash_data_handler(self):
|
||||
def on_response(_none, response, widget):
|
||||
if response == "cancel":
|
||||
return
|
||||
|
||||
if self.my_utils.trashFolder(self.user_data_path) == 0:
|
||||
if self.my_utils.trash_folder(self.user_data_path) == 0:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Trashed user data")))
|
||||
self.data_row.set_title(_("No User Data"))
|
||||
self.data_row.set_subtitle("")
|
||||
@@ -146,7 +148,7 @@ class PropertiesWindow(Adw.Window):
|
||||
dialog.set_close_response("cancel")
|
||||
dialog.add_response("continue", _("Trash Data"))
|
||||
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||
dialog.connect("response", onResponse, dialog.choose_finish)
|
||||
dialog.connect("response", on_response, dialog.choose_finish)
|
||||
dialog.present()
|
||||
|
||||
def __init__(self, flatpak_index, host_flatpaks, parent_window, **kwargs):
|
||||
@@ -167,16 +169,16 @@ class PropertiesWindow(Adw.Window):
|
||||
self.details.connect("activated", self.show_details)
|
||||
self.runtime_copy.connect(
|
||||
"clicked",
|
||||
lambda *_: self.copyItem(
|
||||
lambda *_: self.copy_item(
|
||||
self.runtime.get_subtitle(), self.runtime.get_title()
|
||||
),
|
||||
)
|
||||
self.runtime_properties.connect("clicked", lambda *_: self.close())
|
||||
self.runtime_properties.connect(
|
||||
"clicked", lambda *_: self.showPropertiesHandler()
|
||||
"clicked", lambda *_: self.show_properties_handler()
|
||||
)
|
||||
self.view_apps.connect("activated", self.viewAppsHandler)
|
||||
self.trash_data.connect("clicked", lambda *_: self.trashDataHandler())
|
||||
self.view_apps.connect("activated", self.view_apps_handler)
|
||||
self.trash_data.connect("clicked", lambda *_: self.trash_data_handler())
|
||||
|
||||
if "eol" in self.current_flatpak[12]:
|
||||
self.eol_app_banner.set_revealed(True)
|
||||
@@ -194,9 +196,9 @@ class PropertiesWindow(Adw.Window):
|
||||
).format(self.app_name)
|
||||
)
|
||||
|
||||
if self.app_id in self.my_utils.getHostMasks(
|
||||
if self.app_id in self.my_utils.get_host_masks(
|
||||
"system"
|
||||
) or self.app_id in self.my_utils.getHostMasks("user"):
|
||||
) or self.app_id in self.my_utils.get_host_masks("user"):
|
||||
self.mask_banner.set_revealed(True)
|
||||
self.mask_banner.set_title(
|
||||
_("{} is masked and will not be updated").format(self.app_name)
|
||||
@@ -210,8 +212,8 @@ class PropertiesWindow(Adw.Window):
|
||||
event_controller.connect("key-pressed", key_handler)
|
||||
self.add_controller(event_controller)
|
||||
|
||||
self.generateUpper()
|
||||
self.generateLower()
|
||||
self.generate_upper()
|
||||
self.generate_lower()
|
||||
|
||||
self.set_title(_("{} Properties").format(self.app_name))
|
||||
self.set_size_request(260, 230)
|
||||
|
||||
@@ -197,7 +197,7 @@ class RemotesWindow(Adw.Window):
|
||||
"eye-not-looking-symbolic"
|
||||
)
|
||||
|
||||
self.host_remotes = self.my_utils.getHostRemotes()
|
||||
self.host_remotes = self.my_utils.get_host_remotes()
|
||||
self.host_flatpaks = self.get_host_flatpaks()
|
||||
for i in range(len(self.rows_in_list)):
|
||||
self.remotes_list.remove(self.rows_in_list[i])
|
||||
@@ -287,7 +287,7 @@ class RemotesWindow(Adw.Window):
|
||||
remote_row.add_suffix(copy_button)
|
||||
remote_row.add_suffix(more)
|
||||
|
||||
install_type = self.my_utils.getInstallType(install_type)
|
||||
install_type = self.my_utils.get_install_type(install_type)
|
||||
if install_type == "disabled":
|
||||
if not self.show_disabled_button.get_active():
|
||||
continue
|
||||
@@ -368,7 +368,7 @@ class RemotesWindow(Adw.Window):
|
||||
],
|
||||
]
|
||||
|
||||
host_remotes = self.my_utils.getHostRemotes()
|
||||
host_remotes = self.my_utils.get_host_remotes()
|
||||
host_remotes_names = []
|
||||
|
||||
total_added = 0
|
||||
@@ -541,7 +541,7 @@ class RemotesWindow(Adw.Window):
|
||||
if link != "":
|
||||
url_update(url_entry)
|
||||
|
||||
def addRemoteFromFileThread(self, filepath, system_or_user, name):
|
||||
def add_remote_file_thread(self, filepath, system_or_user, name):
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
@@ -570,7 +570,7 @@ class RemotesWindow(Adw.Window):
|
||||
e,
|
||||
)
|
||||
|
||||
def addRemoteFromFile(self, filepath):
|
||||
def add_remote_file(self, filepath):
|
||||
def response(dialog, response, _a):
|
||||
if response == "cancel":
|
||||
self.should_pulse = False
|
||||
@@ -582,7 +582,7 @@ class RemotesWindow(Adw.Window):
|
||||
|
||||
task = Gio.Task.new(None, None, self.addRemoteCallback)
|
||||
task.run_in_thread(
|
||||
lambda *_: self.addRemoteFromFileThread(
|
||||
lambda *_: self.add_remote_file_thread(
|
||||
filepath, user_or_system, name_row.get_text()
|
||||
)
|
||||
)
|
||||
@@ -652,11 +652,11 @@ class RemotesWindow(Adw.Window):
|
||||
def file_callback(self, object, result):
|
||||
try:
|
||||
file = object.open_finish(result)
|
||||
self.addRemoteFromFile(file.get_path())
|
||||
self.add_remote_file(file.get_path())
|
||||
except GLib.GError:
|
||||
pass
|
||||
|
||||
def addFromFileHandler(self, widet):
|
||||
def add_file_handler(self, widet):
|
||||
filter = Gtk.FileFilter(name=_("Flatpak Repos"))
|
||||
filter.add_suffix("flatpakrepo")
|
||||
filters = Gio.ListStore.new(Gtk.FileFilter)
|
||||
@@ -692,7 +692,7 @@ class RemotesWindow(Adw.Window):
|
||||
self.add_from_file.add_suffix(
|
||||
Gtk.Image.new_from_icon_name("right-large-symbolic")
|
||||
)
|
||||
self.add_from_file.connect("activated", self.addFromFileHandler)
|
||||
self.add_from_file.connect("activated", self.add_file_handler)
|
||||
self.custom_remote.add_suffix(
|
||||
Gtk.Image.new_from_icon_name("right-large-symbolic")
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ class SearchInstallWindow(
|
||||
|
||||
is_debug = GLib.environ_getenv(GLib.get_environ(), "G_MESSAGES_DEBUG") == "all"
|
||||
|
||||
def searchResponse(self, a, b):
|
||||
def search_response(self, a, b):
|
||||
self.results_list_box.remove_all()
|
||||
print(self.search_results)
|
||||
if (self.is_debug and len(self.search_results) == 5) or (
|
||||
@@ -66,7 +66,7 @@ class SearchInstallWindow(
|
||||
def on_check(self, button):
|
||||
print(button.get_active())
|
||||
|
||||
def searchThread(self):
|
||||
def search_thread(self):
|
||||
command = [
|
||||
"flatpak-spawn",
|
||||
"--host",
|
||||
@@ -90,20 +90,20 @@ class SearchInstallWindow(
|
||||
data = sorted(data, key=lambda item: item[0].lower())
|
||||
self.search_results = data
|
||||
|
||||
def onSearch(self, widget):
|
||||
def on_search(self, widget):
|
||||
self.main_stack.set_visible_child(self.loading_page)
|
||||
self.to_search = self.search_entry.get_text()
|
||||
if len(self.to_search) < 1 or " " in self.to_search:
|
||||
self.results_list_box.remove_all()
|
||||
self.main_stack.set_visible_child(self.blank_page)
|
||||
return
|
||||
task = Gio.Task.new(None, None, self.searchResponse)
|
||||
task.run_in_thread(lambda *_: self.searchThread())
|
||||
task = Gio.Task.new(None, None, self.search_response)
|
||||
task.run_in_thread(lambda *_: self.search_thread())
|
||||
|
||||
def set_choice(self, index):
|
||||
print(index)
|
||||
|
||||
def remotesChooserCreator(self):
|
||||
def remotes_chooser_creator(self):
|
||||
remotes_pop = Gtk.Popover()
|
||||
remotes_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
# remotes_pop.set_size_request(400, 1) # why?
|
||||
@@ -142,15 +142,15 @@ class SearchInstallWindow(
|
||||
self.add_controller(event_controller)
|
||||
self.set_transient_for(parent_window)
|
||||
# self.search_bar.connect_entry(self.search_entry)
|
||||
self.search_entry.connect("activate", self.onSearch)
|
||||
self.search_button.connect("clicked", self.onSearch)
|
||||
self.search_entry.connect("activate", self.on_search)
|
||||
self.search_button.connect("clicked", self.on_search)
|
||||
self.search_entry.connect("changed", lambda *_: self.search_entry.grab_focus())
|
||||
# self.search_entry.set_key_capture_widget(self.results_list_box)
|
||||
self.search_entry.grab_focus()
|
||||
|
||||
self.host_remotes = self.my_utils.getHostRemotes()
|
||||
self.host_remotes = self.my_utils.get_host_remotes()
|
||||
if len(self.host_remotes) > 1:
|
||||
self.remotesChooserCreator()
|
||||
self.remotes_chooser_creator()
|
||||
|
||||
self.remote_to_search = []
|
||||
self.main_stack.set_visible_child(self.blank_page)
|
||||
|
||||
@@ -29,7 +29,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
loading_label = Gtk.Template.Child()
|
||||
action_bar = Gtk.Template.Child()
|
||||
|
||||
def showListOrEmpty(self):
|
||||
def show_list_or_empty(self):
|
||||
try:
|
||||
self.disconnect(self.no_close_id) # Make window able to close
|
||||
except:
|
||||
@@ -44,12 +44,12 @@ class SnapshotsWindow(Adw.Window):
|
||||
self.main_stack.set_visible_child(self.no_snapshots)
|
||||
return "empty"
|
||||
|
||||
def generateList(self):
|
||||
def generate_list(self):
|
||||
if not os.path.exists(self.app_user_data):
|
||||
self.new_snapshot.set_sensitive(False)
|
||||
self.new_snapshot.set_tooltip_text(_("There is no User Data to Snapshot"))
|
||||
|
||||
if self.showListOrEmpty() == "empty":
|
||||
if self.show_list_or_empty() == "empty":
|
||||
return
|
||||
|
||||
snapshot_files = os.listdir(self.snapshots_of_app_path)
|
||||
@@ -62,7 +62,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
|
||||
for i in range(len(to_trash)):
|
||||
# Trash all files that aren't snapshots
|
||||
a = self.my_utils.trashFolder(f"{self.snapshots_of_app_path}{to_trash[i]}")
|
||||
a = self.my_utils.trash_folder(f"{self.snapshots_of_app_path}{to_trash[i]}")
|
||||
if a == 0:
|
||||
snapshot_files.remove(to_trash[i])
|
||||
|
||||
@@ -74,8 +74,8 @@ class SnapshotsWindow(Adw.Window):
|
||||
self.create_row(snapshot_files[i])
|
||||
|
||||
def create_row(self, file):
|
||||
def sizeThread(*args):
|
||||
size = self.my_utils.getSizeWithFormat(self.snapshots_of_app_path + file)
|
||||
def size_thread(*args):
|
||||
size = self.my_utils.get_size_with_format(self.snapshots_of_app_path + file)
|
||||
GLib.idle_add(lambda *_a: row.set_subtitle(f"~{size}"))
|
||||
|
||||
split_file = file.removesuffix(".tar.zst").split("_")
|
||||
@@ -83,7 +83,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
row = Adw.ActionRow(title=time)
|
||||
|
||||
task = Gio.Task()
|
||||
task.run_in_thread(sizeThread)
|
||||
task.run_in_thread(size_thread)
|
||||
|
||||
label = Gtk.Label(
|
||||
label=_("Version {}").format(split_file[1]),
|
||||
@@ -110,12 +110,12 @@ class SnapshotsWindow(Adw.Window):
|
||||
def on_response(dialog, response, func):
|
||||
if response == "cancel":
|
||||
return
|
||||
a = self.my_utils.trashFolder(self.snapshots_of_app_path + file)
|
||||
a = self.my_utils.trash_folder(self.snapshots_of_app_path + file)
|
||||
if a == 0:
|
||||
self.snapshots_group.remove(row)
|
||||
if not self.snapshots_group.get_row_at_index(0):
|
||||
self.my_utils.trashFolder(self.snapshots_of_app_path)
|
||||
self.showListOrEmpty()
|
||||
self.my_utils.trash_folder(self.snapshots_of_app_path)
|
||||
self.show_list_or_empty()
|
||||
else:
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Could not trash snapshot"))
|
||||
@@ -133,11 +133,11 @@ class SnapshotsWindow(Adw.Window):
|
||||
dialog.connect("response", on_response, dialog.choose_finish)
|
||||
dialog.present()
|
||||
|
||||
def createSnapshot(self):
|
||||
def create_snapshot(self):
|
||||
epoch = int(time.time())
|
||||
|
||||
def thread():
|
||||
response = self.my_utils.snapshotApps(
|
||||
response = self.my_utils.snapshot_apps(
|
||||
epoch,
|
||||
[self.snapshots_of_app_path],
|
||||
[self.app_version],
|
||||
@@ -150,7 +150,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
)
|
||||
)
|
||||
return
|
||||
if self.showListOrEmpty() == "list":
|
||||
if self.show_list_or_empty() == "list":
|
||||
self.create_row(f"{epoch}_{self.app_version}.tar.zst")
|
||||
|
||||
self.no_close_id = self.connect(
|
||||
@@ -197,7 +197,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
self.parent_window.refresh_list_of_flatpaks(self, False)
|
||||
|
||||
self.new_snapshot.set_tooltip_text("")
|
||||
self.showListOrEmpty()
|
||||
self.show_list_or_empty()
|
||||
|
||||
def on_response(dialog, response, func):
|
||||
if response == "cancel":
|
||||
@@ -205,7 +205,7 @@ class SnapshotsWindow(Adw.Window):
|
||||
to_apply = self.snapshots_of_app_path + file
|
||||
to_trash = self.app_user_data
|
||||
if os.path.exists(to_trash):
|
||||
a = self.my_utils.trashFolder(to_trash)
|
||||
a = self.my_utils.trash_folder(to_trash)
|
||||
if a != 0:
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Could not apply snapshot"))
|
||||
@@ -279,11 +279,11 @@ class SnapshotsWindow(Adw.Window):
|
||||
file.make_directory()
|
||||
|
||||
# Calls
|
||||
self.generateList()
|
||||
self.generate_list()
|
||||
self.open_folder_button.connect(
|
||||
"clicked", self.open_button_handler, self.snapshots_of_app_path
|
||||
)
|
||||
self.new_snapshot.connect("clicked", lambda *_: self.createSnapshot())
|
||||
self.new_snapshot.connect("clicked", lambda *_: self.create_snapshot())
|
||||
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
event_controller.connect("key-pressed", self.key_handler)
|
||||
|
||||
160
src/window.py
160
src/window.py
@@ -93,24 +93,24 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.is_result = True
|
||||
return True
|
||||
|
||||
def removeRow(self, row):
|
||||
def remove_row(self, row):
|
||||
row[5].set_active(False)
|
||||
row[0] = False
|
||||
row[2].set_visible(False)
|
||||
|
||||
def uninstallButtonsEnable(self, should_enable):
|
||||
def uninstall_buttons_enable(self, should_enable):
|
||||
if self.currently_uninstalling:
|
||||
return
|
||||
self.refresh_button.set_sensitive(should_enable)
|
||||
if not should_enable:
|
||||
self.batch_uninstall_button.set_sensitive(False)
|
||||
|
||||
def uninstallFlatpakCallback(self, _a, _b):
|
||||
def uninstall_flatpak_callback(self, _a, _b):
|
||||
self.currently_uninstalling = False
|
||||
self.refresh_list_of_flatpaks(_a, False)
|
||||
self.main_toolbar_view.set_sensitive(True)
|
||||
self.disconnect(self.no_close)
|
||||
self.uninstallButtonsEnable(True)
|
||||
self.uninstall_buttons_enable(True)
|
||||
self.main_stack.set_visible_child(self.main_box)
|
||||
self.search_button.set_sensitive(True)
|
||||
if self.my_utils.uninstall_success:
|
||||
@@ -121,12 +121,12 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
Adw.Toast.new(_("Could not uninstall some apps"))
|
||||
)
|
||||
|
||||
def uninstallFlatpakThread(self, ref_arr, id_arr, type_arr, should_trash):
|
||||
self.my_utils.uninstallFlatpak(
|
||||
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
|
||||
)
|
||||
|
||||
def uninstallFlatpak(self, should_trash):
|
||||
def uninstall_flatpak(self, should_trash):
|
||||
ref_arr = []
|
||||
id_arr = []
|
||||
type_arr = []
|
||||
@@ -140,17 +140,17 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
type_arr.append(current.install_type)
|
||||
i += 1
|
||||
self.set_title(self.main_window_title)
|
||||
task = Gio.Task.new(None, None, self.uninstallFlatpakCallback)
|
||||
task = Gio.Task.new(None, None, self.uninstall_flatpak_callback)
|
||||
task.run_in_thread(
|
||||
lambda _task, _obj, _data, _cancellable, ref_arr=ref_arr, id_arr=id_arr, type_arr=type_arr, should_trash=should_trash: self.uninstallFlatpakThread(
|
||||
lambda _task, _obj, _data, _cancellable, ref_arr=ref_arr, id_arr=id_arr, type_arr=type_arr, should_trash=should_trash: self.uninstall_flatpak_thread(
|
||||
ref_arr, id_arr, type_arr, should_trash
|
||||
)
|
||||
)
|
||||
|
||||
def batchUninstallButtonHandler(self, _widget):
|
||||
def batch_uninstall_button_handler(self, _widget):
|
||||
has_user_data = False
|
||||
|
||||
def batchUninstallResponse(_idk, response_id, _widget):
|
||||
def batch_uninstall_response(_idk, response_id, _widget):
|
||||
if response_id == "cancel":
|
||||
return 1
|
||||
|
||||
@@ -159,14 +159,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
except:
|
||||
should_trash = False
|
||||
|
||||
self.uninstallButtonsEnable(False)
|
||||
self.uninstall_buttons_enable(False)
|
||||
|
||||
self.no_close = self.connect(
|
||||
"close-request", lambda event: True
|
||||
) # Make window unable to close
|
||||
self.main_stack.set_visible_child(self.uninstalling)
|
||||
self.search_button.set_sensitive(False)
|
||||
self.uninstallFlatpak(should_trash)
|
||||
self.uninstall_flatpak(should_trash)
|
||||
|
||||
# Create Widgets
|
||||
dialog = Adw.MessageDialog.new(
|
||||
@@ -225,7 +225,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
header.add_css_class("h4")
|
||||
|
||||
# Connections
|
||||
dialog.connect("response", batchUninstallResponse, dialog.choose_finish)
|
||||
dialog.connect("response", batch_uninstall_response, dialog.choose_finish)
|
||||
|
||||
# Calls
|
||||
dialog.set_close_response("cancel")
|
||||
@@ -234,14 +234,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||
Gtk.Window.present(dialog)
|
||||
|
||||
def uninstallButtonHandler(self, row, name, ref, id):
|
||||
def uninstall_button_handler(self, row, name, ref, id):
|
||||
if self.currently_uninstalling:
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Cannot uninstall while already uninstalling"))
|
||||
)
|
||||
return
|
||||
|
||||
def uninstallResponse(_idk, response_id, _widget):
|
||||
def uninstall_response(_idk, response_id, _widget):
|
||||
if response_id == "cancel":
|
||||
return 1
|
||||
|
||||
@@ -253,14 +253,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if response_id == "purge":
|
||||
should_trash = True
|
||||
|
||||
self.uninstallButtonsEnable(False)
|
||||
self.uninstall_buttons_enable(False)
|
||||
|
||||
self.no_close = self.connect(
|
||||
"close-request", lambda event: True
|
||||
) # Make window unable to close
|
||||
self.main_stack.set_visible_child(self.uninstalling)
|
||||
self.search_button.set_sensitive(False)
|
||||
self.uninstallFlatpak(should_trash)
|
||||
self.uninstall_flatpak(should_trash)
|
||||
|
||||
row.tickbox.set_active(True)
|
||||
|
||||
@@ -306,10 +306,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.add_response("continue", _("Uninstall"))
|
||||
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||
dialog.connect("response", uninstallResponse, dialog.choose_finish)
|
||||
dialog.connect("response", uninstall_response, dialog.choose_finish)
|
||||
Gtk.Window.present(dialog)
|
||||
|
||||
def windowSetEmpty(self, is_empty):
|
||||
def window_set_empty(self, is_empty):
|
||||
self.batch_mode_button.set_sensitive(not is_empty)
|
||||
self.search_button.set_sensitive(not is_empty)
|
||||
self.filter_button.set_sensitive(not is_empty)
|
||||
@@ -328,12 +328,12 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.flatpaks_list_box.insert(row, index)
|
||||
|
||||
def generate_list_of_flatpaks(self):
|
||||
self.host_flatpaks = self.my_utils.getHostFlatpaks()
|
||||
self.dependent_runtimes = self.my_utils.getDependentRuntimes()
|
||||
self.host_flatpaks = self.my_utils.get_host_flatpaks()
|
||||
self.dependent_runtimes = self.my_utils.get_dependent_runtimes()
|
||||
self.set_title(self.main_window_title)
|
||||
self.eol_list = []
|
||||
self.system_mask_list = self.my_utils.getHostMasks("system")
|
||||
self.user_mask_list = self.my_utils.getHostMasks("user")
|
||||
self.system_mask_list = self.my_utils.get_host_masks("system")
|
||||
self.user_mask_list = self.my_utils.get_host_masks("user")
|
||||
|
||||
for index in range(len(self.host_flatpaks)):
|
||||
try:
|
||||
@@ -345,10 +345,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
for index in range(len(self.host_flatpaks)):
|
||||
self.create_row(index)
|
||||
|
||||
self.applyFilter()
|
||||
self.apply_filter()
|
||||
|
||||
# self.windowSetEmpty(not self.flatpaks_list_box.get_row_at_index(0))
|
||||
self.batchActionsEnable(False)
|
||||
self.batch_actions_enable(False)
|
||||
|
||||
def refresh_list_of_flatpaks(self, widget, should_toast):
|
||||
if self.currently_uninstalling:
|
||||
@@ -359,17 +359,17 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.generate_list_of_flatpaks()
|
||||
self.batch_mode_button.set_active(False)
|
||||
|
||||
def openDataFolder(self, path):
|
||||
def open_data_folder(self, path):
|
||||
try:
|
||||
Gio.AppInfo.launch_default_for_uri(f"file://{path}", None)
|
||||
except GLib.GError:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not open folder")))
|
||||
|
||||
def trashData(self, name, id, index):
|
||||
def onContinue(dialog, response):
|
||||
def trash_data(self, name, id, index):
|
||||
def on_continue(dialog, response):
|
||||
if response == "cancel":
|
||||
return
|
||||
result = self.my_utils.trashFolder(f"{self.user_data_path}{id}")
|
||||
result = self.my_utils.trash_folder(f"{self.user_data_path}{id}")
|
||||
if result != 0:
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("Could not trash user data"))
|
||||
@@ -389,10 +389,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.set_close_response("cancel")
|
||||
dialog.add_response("continue", _("Trash Data"))
|
||||
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||
dialog.connect("response", onContinue)
|
||||
dialog.connect("response", on_continue)
|
||||
dialog.present()
|
||||
|
||||
def maskFlatpak(self, row):
|
||||
def mask_flatpak(self, row):
|
||||
is_masked = (
|
||||
row.mask_label.get_visible()
|
||||
) # Check the visibility of the mask label to see if the flatpak is masked
|
||||
@@ -410,18 +410,18 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.lookup_action(f"mask{row.index}").set_enabled(is_masked)
|
||||
self.lookup_action(f"unmask{row.index}").set_enabled(not is_masked)
|
||||
|
||||
def onContinue(dialog, response):
|
||||
def on_continue(dialog, response):
|
||||
if response == "cancel":
|
||||
return
|
||||
task = Gio.Task.new(None, None, lambda *_: callback())
|
||||
task.run_in_thread(
|
||||
lambda *_: result.append(
|
||||
self.my_utils.maskFlatpak(row.app_id, row.install_type, is_masked)
|
||||
self.my_utils.mask_flatpak(row.app_id, row.install_type, is_masked)
|
||||
)
|
||||
)
|
||||
|
||||
if is_masked:
|
||||
onContinue(self, None)
|
||||
on_continue(self, None)
|
||||
else:
|
||||
dialog = Adw.MessageDialog.new(
|
||||
self, _("Disable Updates for {}?").format(row.app_name)
|
||||
@@ -434,15 +434,15 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.set_close_response("cancel")
|
||||
dialog.add_response("continue", _("Disable Updates"))
|
||||
dialog.connect("response", onContinue)
|
||||
dialog.connect("response", on_continue)
|
||||
dialog.present()
|
||||
|
||||
def copyItem(self, to_copy, to_toast=None):
|
||||
def copy_item(self, to_copy, to_toast=None):
|
||||
self.clipboard.set(to_copy)
|
||||
if to_toast:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(to_toast))
|
||||
|
||||
def runCallback(self, _a, _b):
|
||||
def run_callback(self, _a, _b):
|
||||
if not self.my_utils.run_app_error:
|
||||
return
|
||||
|
||||
@@ -459,10 +459,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.set_close_response("ok")
|
||||
dialog.present()
|
||||
|
||||
def runAppThread(self, ref, to_toast=None):
|
||||
def run_app_thread(self, ref, to_toast=None):
|
||||
self.run_app_error = False
|
||||
task = Gio.Task.new(None, None, self.runCallback)
|
||||
task.run_in_thread(lambda *_: self.my_utils.runApp(ref))
|
||||
task = Gio.Task.new(None, None, self.run_callback)
|
||||
task.run_in_thread(lambda *_: self.my_utils.run_app(ref))
|
||||
if to_toast:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(to_toast))
|
||||
|
||||
@@ -479,18 +479,18 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if not widget.get_active():
|
||||
self.batch_select_all_button.set_active(False)
|
||||
|
||||
def batchKeyHandler(self, _b, event, _c, _d):
|
||||
def batch_key_handler(self, _b, event, _c, _d):
|
||||
if event == Gdk.KEY_Escape:
|
||||
self.batch_mode_button.set_active(False)
|
||||
|
||||
def batchActionsEnable(self, should_enable):
|
||||
def batch_actions_enable(self, should_enable):
|
||||
self.batch_copy_button.set_sensitive(should_enable)
|
||||
self.batch_clean_button.set_sensitive(should_enable)
|
||||
self.batch_snapshot_button.set_sensitive(should_enable)
|
||||
if not self.currently_uninstalling:
|
||||
self.batch_uninstall_button.set_sensitive(should_enable)
|
||||
|
||||
def onBatchCleanResponse(self, dialog, response, _a):
|
||||
def on_batch_clean_response(self, dialog, response, _a):
|
||||
if response == "cancel":
|
||||
return
|
||||
i = 0
|
||||
@@ -502,7 +502,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
break
|
||||
if current.tickbox.get_active() == False:
|
||||
continue
|
||||
trash = self.my_utils.trashFolder(f"{self.user_data_path}{current.app_id}")
|
||||
trash = self.my_utils.trash_folder(f"{self.user_data_path}{current.app_id}")
|
||||
if trash == 1:
|
||||
self.toast_overlay.add_toast(
|
||||
Adw.Toast.new(_("{} has no data to trash").format(current.app_name))
|
||||
@@ -522,7 +522,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
False
|
||||
) # Disable the Trash User Data dropdown option when the data was deleted
|
||||
|
||||
def batchCleanHandler(self, widget):
|
||||
def batch_clean_handler(self, widget):
|
||||
dialog = Adw.MessageDialog.new(
|
||||
self,
|
||||
_("Trash Selected Apps' User Data?"),
|
||||
@@ -532,14 +532,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.add_response("continue", _("Trash Data"))
|
||||
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
|
||||
dialog.connect("response", self.onBatchCleanResponse, dialog.choose_finish)
|
||||
dialog.connect("response", self.on_batch_clean_response, dialog.choose_finish)
|
||||
Gtk.Window.present(dialog)
|
||||
|
||||
def batchSelectAllButtonHandler(self, widget):
|
||||
def select_all_handler(self, widget):
|
||||
self.set_select_all(widget.get_active())
|
||||
|
||||
def batchSnapshotHandler(self, widget):
|
||||
def batchSnapshotResponse(dialog, response, _a):
|
||||
def batch_snapshot_handler(self, widget):
|
||||
def batch_snapshot_response(dialog, response, _a):
|
||||
if response == "cancel":
|
||||
return
|
||||
i = 0
|
||||
@@ -566,7 +566,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
app_data_arr.append(f"{self.user_data_path}{current.app_id}")
|
||||
|
||||
def thread():
|
||||
capture = self.my_utils.snapshotApps(
|
||||
capture = self.my_utils.snapshot_apps(
|
||||
epoch,
|
||||
snapshot_arr,
|
||||
app_ver_arr,
|
||||
@@ -608,7 +608,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
dialog.set_close_response("cancel")
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.add_response("continue", _("Create Snapshots"))
|
||||
dialog.connect("response", batchSnapshotResponse, dialog.choose_finish)
|
||||
dialog.connect("response", batch_snapshot_response, dialog.choose_finish)
|
||||
Gtk.Window.present(dialog)
|
||||
|
||||
def set_select_all(self, should_select_all):
|
||||
@@ -619,7 +619,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
current.tickbox.set_active(should_select_all)
|
||||
i += 1
|
||||
|
||||
def rowSelectHandler(self, tickbox):
|
||||
def row_select_handler(self, tickbox):
|
||||
if tickbox.get_active() == True:
|
||||
self.total_selected += 1
|
||||
else:
|
||||
@@ -628,10 +628,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if self.total_selected == 0:
|
||||
buttons_enable = False
|
||||
self.set_title(self.main_window_title)
|
||||
self.batchActionsEnable(False)
|
||||
self.batch_actions_enable(False)
|
||||
else:
|
||||
self.set_title(f"{self.total_selected} Selected")
|
||||
self.batchActionsEnable(True)
|
||||
self.batch_actions_enable(True)
|
||||
|
||||
def create_action(self, name, callback, shortcuts=None):
|
||||
"""Add a window action.
|
||||
@@ -648,7 +648,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if shortcuts:
|
||||
self.set_accels_for_action(f"app.{name}", shortcuts)
|
||||
|
||||
def copyNames(self, widget, _a):
|
||||
def copy_names(self, widget, _a):
|
||||
to_copy = ""
|
||||
i = 0
|
||||
while True:
|
||||
@@ -661,7 +661,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.clipboard.set(to_copy)
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app names")))
|
||||
|
||||
def copyIDs(self, widget, _a):
|
||||
def copy_IDs(self, widget, _a):
|
||||
to_copy = ""
|
||||
i = 0
|
||||
while True:
|
||||
@@ -674,7 +674,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.clipboard.set(to_copy)
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app IDs")))
|
||||
|
||||
def copyRefs(self, widget, _a):
|
||||
def copy_refs(self, widget, _a):
|
||||
to_copy = ""
|
||||
i = 0
|
||||
while True:
|
||||
@@ -687,17 +687,17 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.clipboard.set(to_copy)
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app refs")))
|
||||
|
||||
def filterWindowHandler(self, widget):
|
||||
def filter_window_handler(self, widget):
|
||||
if widget.get_active() and self.should_open_filter_window:
|
||||
filtwin = FilterWindow(self)
|
||||
filtwin.present()
|
||||
else:
|
||||
self.applyFilter()
|
||||
self.apply_filter()
|
||||
|
||||
def filterWindowKeyboardHandler(self, widget):
|
||||
def filter_window_keyboard_handler(self, widget):
|
||||
self.filter_button.set_active(not self.filter_button.get_active())
|
||||
|
||||
def applyFilter(self, filter=default_filter):
|
||||
def apply_filter(self, filter=default_filter):
|
||||
for i in range(len(self.filter_list)):
|
||||
current = self.filter_list[i]
|
||||
if "user" == current:
|
||||
@@ -749,7 +749,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.main_stack.set_visible_child(self.main_box)
|
||||
self.search_button.set_sensitive(True)
|
||||
|
||||
def installCallback(self, _a, _b):
|
||||
def install_callback(self, _a, _b):
|
||||
self.main_stack.set_visible_child(self.main_box)
|
||||
self.search_button.set_sensitive(True)
|
||||
if self.my_utils.install_success:
|
||||
@@ -758,8 +758,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
else:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not install app")))
|
||||
|
||||
def installThread(self, filepath, user_or_system):
|
||||
self.my_utils.installFlatpak(
|
||||
def install_thread(self, filepath, user_or_system):
|
||||
self.my_utils.install_flatpak(
|
||||
[filepath], None, user_or_system, self.main_progress_bar
|
||||
)
|
||||
|
||||
@@ -774,8 +774,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
if system_check.get_active():
|
||||
user_or_system = "system"
|
||||
|
||||
task = Gio.Task.new(None, None, self.installCallback)
|
||||
task.run_in_thread(lambda *_: self.installThread(filepath, user_or_system))
|
||||
task = Gio.Task.new(None, None, self.install_callback)
|
||||
task.run_in_thread(lambda *_: self.install_thread(filepath, user_or_system))
|
||||
|
||||
name = filepath.split("/")
|
||||
name = name[len(name) - 1]
|
||||
@@ -823,7 +823,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
elif filepath.endswith(".flatpakrepo"):
|
||||
remotes_window = RemotesWindow(self)
|
||||
remotes_window.present()
|
||||
remotes_window.addRemoteFromFile(filepath)
|
||||
remotes_window.add_remote_file(filepath)
|
||||
else:
|
||||
self.toast_overlay.add_toast(Adw.Toast.new(_("File type not supported")))
|
||||
|
||||
@@ -875,7 +875,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.new_env["LC_ALL"] = "C"
|
||||
|
||||
if self.host_flatpaks == [["", ""]]:
|
||||
self.windowSetEmpty(True)
|
||||
self.window_set_empty(True)
|
||||
return
|
||||
|
||||
self.flatpaks_list_box.set_filter_func(self.filter_func)
|
||||
@@ -890,24 +890,24 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.search_bar.connect("notify", self.on_change)
|
||||
self.refresh_button.connect("clicked", self.refresh_list_of_flatpaks, True)
|
||||
self.batch_mode_button.connect("toggled", self.batch_mode_handler)
|
||||
self.batch_clean_button.connect("clicked", self.batchCleanHandler)
|
||||
self.batch_uninstall_button.connect("clicked", self.batchUninstallButtonHandler)
|
||||
self.batch_select_all_button.connect(
|
||||
"clicked", self.batchSelectAllButtonHandler
|
||||
self.batch_clean_button.connect("clicked", self.batch_clean_handler)
|
||||
self.batch_uninstall_button.connect(
|
||||
"clicked", self.batch_uninstall_button_handler
|
||||
)
|
||||
self.batch_snapshot_button.connect("clicked", self.batchSnapshotHandler)
|
||||
self.batchActionsEnable(False)
|
||||
self.batch_select_all_button.connect("clicked", self.select_all_handler)
|
||||
self.batch_snapshot_button.connect("clicked", self.batch_snapshot_handler)
|
||||
self.batch_actions_enable(False)
|
||||
event_controller = Gtk.EventControllerKey()
|
||||
event_controller.connect("key-pressed", self.batchKeyHandler)
|
||||
event_controller.connect("key-pressed", self.batch_key_handler)
|
||||
self.add_controller(event_controller)
|
||||
self.main_overlay.add_overlay(self.main_progress_bar)
|
||||
self.should_open_filter_window = True
|
||||
|
||||
self.create_action("copy-names", self.copyNames)
|
||||
self.create_action("copy-ids", self.copyIDs)
|
||||
self.create_action("copy-refs", self.copyRefs)
|
||||
self.create_action("copy-names", self.copy_names)
|
||||
self.create_action("copy-ids", self.copy_IDs)
|
||||
self.create_action("copy-refs", self.copy_refs)
|
||||
|
||||
self.filter_button.connect("toggled", self.filterWindowHandler)
|
||||
self.filter_button.connect("toggled", self.filter_window_handler)
|
||||
|
||||
file_drop = Gtk.DropTarget.new(Gio.File, Gdk.DragAction.COPY)
|
||||
file_drop.connect("drop", self.drop_callback)
|
||||
|
||||
Reference in New Issue
Block a user