Make batch actions work again

This commit is contained in:
heliguy
2023-12-08 04:14:37 -05:00
parent e8fb7ef981
commit c93d30e3ff
6 changed files with 72 additions and 48 deletions

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 8 1 c -3.851562 0 -6.96875 3.117188 -6.96875 6.96875 s 3.117188 6.96875 6.96875 6.96875 s 6.96875 -3.117188 6.96875 -6.96875 s -3.117188 -6.96875 -6.96875 -6.96875 z m -3 3.96875 h 1 h 0.03125 c 0.253906 0.011719 0.511719 0.128906 0.6875 0.3125 l 1.28125 1.28125 l 1.3125 -1.28125 c 0.265625 -0.230469 0.445312 -0.304688 0.6875 -0.3125 h 1 v 1 c 0 0.285156 -0.035156 0.550781 -0.25 0.75 l -1.28125 1.28125 l 1.25 1.25 c 0.1875 0.1875 0.28125 0.453125 0.28125 0.71875 v 1 h -1 c -0.265625 0 -0.53125 -0.09375 -0.71875 -0.28125 l -1.28125 -1.28125 l -1.28125 1.28125 c -0.1875 0.1875 -0.453125 0.28125 -0.71875 0.28125 h -1 v -1 c 0 -0.265625 0.09375 -0.53125 0.28125 -0.71875 l 1.28125 -1.25 l -1.28125 -1.28125 c -0.210938 -0.195312 -0.304688 -0.46875 -0.28125 -0.75 z m 0 0" fill="#222222"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -600 -600)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -600 -600)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -600 -600)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="16px" viewBox="0 0 16 16" width="16px"><filter id="a" height="100%" width="100%" x="0%" y="0%"><feColorMatrix color-interpolation-filters="sRGB" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/></filter><mask id="b"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.5"/></g></mask><clipPath id="c"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="d"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.7"/></g></mask><clipPath id="e"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><mask id="f"><g filter="url(#a)"><path d="m -1.6 -1.6 h 19.2 v 19.2 h -19.2 z" fill-opacity="0.35"/></g></mask><clipPath id="g"><path d="m 0 0 h 1600 v 1200 h -1600 z"/></clipPath><path d="m 5.039062 3 c -1.109374 0 -2 0.890625 -2 2 v 6 c 0 1.109375 0.890626 2 2 2 h 5.953126 c 1.109374 0 2 -0.890625 2 -2 v -6 c 0 -1.109375 -0.890626 -2 -2 -2 z m 2.980469 1 c 0.542969 0 0.980469 0.4375 0.980469 0.984375 v 3.035156 c 0 0.542969 -0.4375 0.980469 -0.980469 0.980469 c -0.546875 0 -0.984375 -0.4375 -0.984375 -0.980469 v -3.035156 c 0 -0.546875 0.4375 -0.984375 0.984375 -0.984375 z m -0.019531 5.734375 c 0.699219 0 1.265625 0.566406 1.265625 1.265625 s -0.566406 1.265625 -1.265625 1.265625 s -1.265625 -0.566406 -1.265625 -1.265625 s 0.566406 -1.265625 1.265625 -1.265625 z m 0 0" fill="#222222"/><g mask="url(#b)"><g clip-path="url(#c)" transform="matrix(1 0 0 1 -956 -610)"><path d="m 550 182 c -0.351562 0.003906 -0.695312 0.101562 -1 0.28125 v 3.4375 c 0.304688 0.179688 0.648438 0.277344 1 0.28125 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 c -0.339844 0 -0.679688 0.058594 -1 0.175781 v 6.824219 h 4 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#d)"><g clip-path="url(#e)" transform="matrix(1 0 0 1 -956 -610)"><path d="m 569 182 v 4 c 1.105469 0 2 -0.894531 2 -2 s -0.894531 -2 -2 -2 z m 0 5 v 7 h 3 v -4 c 0 -1.65625 -1.34375 -3 -3 -3 z m 0 0"/></g></g><g mask="url(#f)"><g clip-path="url(#g)" transform="matrix(1 0 0 1 -956 -610)"><path d="m 573 182.269531 v 3.449219 c 0.613281 -0.355469 0.996094 -1.007812 1 -1.71875 c 0 -0.714844 -0.382812 -1.375 -1 -1.730469 z m 0 4.90625 v 6.824219 h 2 v -4 c 0 -1.269531 -0.800781 -2.402344 -2 -2.824219 z m 0 0"/></g></g></svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -174,13 +174,13 @@ template $WarehouseWindow: Adw.ApplicationWindow {
[end]
Button batch_uninstall_button {
icon-name: "user-trash-symbolic";
icon-name: "cross-filled-symbolic";
tooltip-text: _("Uninstall Selected Apps");
}
[end]
Button batch_clean_button {
icon-name: "brush-symbolic";
icon-name: "user-trash-symbolic";
tooltip-text: _("Send Selected Apps' Data to the Trash");
}

View File

@@ -132,20 +132,23 @@ class AppRow(Adw.ActionRow):
uninstall_item = Gio.MenuItem.new(_("Uninstall"), f"win.uninstall{index}")
row_menu_model.append_item(uninstall_item)
if os.path.exists(parent_window.user_data_path + self.app_id):
data_menu_model = Gio.Menu()
data_menu_model = Gio.Menu()
parent_window.create_action(("open-data" + str(index)), lambda *_, path=(parent_window.user_data_path + self.app_id): parent_window.openDataFolder(path))
open_data_item = Gio.MenuItem.new(_("Open User Data Folder"), f"win.open-data{index}")
open_data_item.set_attribute_value("hidden-when", GLib.Variant.new_string("action-disabled"))
data_menu_model.append_item(open_data_item)
parent_window.create_action(("open-data" + str(index)), lambda *_, path=(parent_window.user_data_path + self.app_id): parent_window.openDataFolder(path))
open_data_item = Gio.MenuItem.new(_("Open User Data Folder"), f"win.open-data{index}")
open_data_item.set_attribute_value("hidden-when", GLib.Variant.new_string("action-disabled"))
data_menu_model.append_item(open_data_item)
parent_window.create_action(("trash" + str(index)), lambda *_, name=self.app_name, id=self.app_id, index=index: parent_window.trashData(name, id, index))
trash_item = Gio.MenuItem.new(_("Trash User Data"), f"win.trash{index}")
trash_item.set_attribute_value("hidden-when", GLib.Variant.new_string("action-disabled"))
data_menu_model.append_item(trash_item)
parent_window.create_action(("trash" + str(index)), lambda *_, name=self.app_name, id=self.app_id, index=index: parent_window.trashData(name, id, index))
trash_item = Gio.MenuItem.new(_("Trash User Data"), f"win.trash{index}")
trash_item.set_attribute_value("hidden-when", GLib.Variant.new_string("action-disabled"))
data_menu_model.append_item(trash_item)
row_menu_model.append_section(None, data_menu_model)
row_menu_model.append_section(None, data_menu_model)
if not os.path.exists(parent_window.user_data_path + self.app_id):
parent_window.lookup_action(f"open-data{self.index}").set_enabled(False)
parent_window.lookup_action(f"trash{self.index}").set_enabled(False)
parent_window.create_action(("mask" + str(index)), lambda *_, id=self.app_id, type=self.install_type, index=index: parent_window.maskFlatpak(self))
mask_item = Gio.MenuItem.new(_("Disable Updates"), f"win.mask{index}")

View File

@@ -31,5 +31,7 @@
<file preprocess="xml-stripblanks" alias="arrow2-top-right-symbolic.svg">../data/icons/arrow2-top-right-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="software-update-available-symbolic.svg">../data/icons/software-update-available-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="software-update-urgent-symbolic.svg">../data/icons/software-update-urgent-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="cross-filled-symbolic.svg">../data/icons/cross-filled-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="important-small-symbolic.svg">../data/icons/important-small-symbolic.svg</file>
</gresource>
</gresources>

View File

@@ -156,10 +156,13 @@ class WarehouseWindow(Adw.ApplicationWindow):
dialog = Adw.MessageDialog.new(self, _("Uninstall Selected Apps?"), _("It will not be possible to use these apps after removal."))
# Check to see if at least one app in the list has user data
for i in range(len(self.flatpak_rows)):
if not self.flatpak_rows[1]:
continue # Skip if not selected
if os.path.exists(f"{self.user_data_path}{self.flatpak_rows[i][6][2]}"):
i = 0
while(True):
current = self.flatpaks_list_box.get_row_at_index(i)
i += 1
if(current == None):
break
if current.tickbox.get_active() and os.path.exists(f"{self.user_data_path}{current.app_id}"):
has_user_data = True
break
@@ -304,6 +307,8 @@ class WarehouseWindow(Adw.ApplicationWindow):
def refresh_list_of_flatpaks(self, widget, should_toast):
if self.currently_uninstalling:
return
if should_toast:
self.toast_overlay.add_toast(Adw.Toast.new(_("List refreshed")))
self.flatpaks_list_box.remove_all()
self.generate_list_of_flatpaks()
self.batch_mode_button.set_active(False)
@@ -415,25 +420,24 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.batch_uninstall_button.set_sensitive(should_enable)
def onBatchCleanResponse(self, dialog, response, _a):
if response == "cancel":
return 1
show_success = True
for i in range(len(self.flatpak_rows)):
if not self.flatpak_rows[i][1]:
continue # Skip if not selected
app_id = self.flatpak_rows[i][6][2]
app_name = self.flatpak_rows[i][6][0]
path = f"{self.user_data_path}{app_id}"
trash = self.my_utils.trashFolder(path)
i = 0
trashReturnCodes = 0
while(True):
current = self.flatpaks_list_box.get_row_at_index(i)
i += 1
if current == None:
break
if current.tickbox.get_active() == False:
continue
trash = self.my_utils.trashFolder(f"{self.user_data_path}{current.app_id}")
if trash == 1:
show_success = False
self.toast_overlay.add_toast(Adw.Toast.new(_("No user data for {}").format(app_name)))
elif trash == 2:
show_success = False
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not trash user data")))
if show_success:
self.toast_overlay.add_toast(Adw.Toast.new(_("Trashed user data")))
#self.refresh_list_of_flatpaks(_a, False)
self.toast_overlay.add_toast(Adw.Toast.new(_("{} has no data to trash").format(current.app_name)))
continue
if trash == 2:
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not trash {}'s data").format(current.app_name)))
continue
self.lookup_action(f"open-data{current.index}").set_enabled(False) # Disable the Open User Data dropdown option when the data was deleted
self.lookup_action(f"trash{current.index}").set_enabled(False) # Disable the Trash User Data dropdown option when the data was deleted
def batchCleanHandler(self, widget):
dialog = Adw.MessageDialog.new(self, _("Trash Selected Apps' User Data?"), _("Your files and data for these apps will be sent to the trash."))
@@ -444,10 +448,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
dialog.connect("response", self.onBatchCleanResponse, dialog.choose_finish)
Gtk.Window.present(dialog)
def batchSelectAllButtonHandler(self, widget):
self.set_select_all(widget.get_active())
@@ -490,25 +490,40 @@ class WarehouseWindow(Adw.ApplicationWindow):
def copyNames(self, widget, _a):
to_copy = ""
for i in range(len(self.flatpak_rows)):
if self.flatpak_rows[i][1]:
to_copy += f"{(self.flatpak_rows[i][6][0])}\n"
i = 0
while(True):
current = self.flatpaks_list_box.get_row_at_index(i)
i += 1
if(current == None):
break
if current.tickbox.get_active():
to_copy += f"{current.app_name}\n"
self.clipboard.set(to_copy)
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app names")))
def copyIDs(self, widget, _a):
to_copy = ""
for i in range(len(self.flatpak_rows)):
if self.flatpak_rows[i][1]:
to_copy += f"{(self.flatpak_rows[i][6][2])}\n"
i = 0
while(True):
current = self.flatpaks_list_box.get_row_at_index(i)
i += 1
if(current == None):
break
if current.tickbox.get_active():
to_copy += f"{current.app_id}\n"
self.clipboard.set(to_copy)
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app IDs")))
def copyRefs(self, widget, _a):
to_copy = ""
for i in range(len(self.flatpak_rows)):
if self.flatpak_rows[i][1]:
to_copy += f"{(self.flatpak_rows[i][6][8])}\n"
i = 0
while(True):
current = self.flatpaks_list_box.get_row_at_index(i)
i += 1
if(current == None):
break
if current.tickbox.get_active():
to_copy += f"{current.app_ref}\n"
self.clipboard.set(to_copy)
self.toast_overlay.add_toast(Adw.Toast.new(_("Copied selected app refs")))