First steps to refreshing a row item

This commit is contained in:
heliguy
2023-11-15 02:34:50 -05:00
parent 77138a2631
commit f9fb3fa47a
3 changed files with 32 additions and 28 deletions

View File

@@ -24,6 +24,7 @@ class AppRow(Adw.ActionRow):
current_flatpak = host_flatpaks[index]
self.index = index
self.app_name = current_flatpak[0]
self.app_id = current_flatpak[2]
self.origin_remote = current_flatpak[6]
@@ -42,14 +43,8 @@ class AppRow(Adw.ActionRow):
info_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, valign=Gtk.Align.CENTER, halign=Gtk.Align.CENTER, hexpand=True, vexpand=True, spacing=6)
# justify=Gtk.Justification.RIGHT
mask_label = Gtk.Label(label=_("Updates Disabled"), visible=False, hexpand=True, wrap=True, valign=Gtk.Align.CENTER, tooltip_text=_("{} is masked and will not be updated").format(self.app_name))
mask_label.add_css_class("warning")
if self.app_id in parent_window.system_mask_list or self.app_id in parent_window.user_mask_list:
mask_label.set_visible(True)
# parent_window.lookup_action(f"mask{index}").set_enabled(False)
# else:
# parent_window.lookup_action(f"unmask{index}").set_enabled(False)
self.mask_label = Gtk.Label(label=_("Updates Disabled"), visible=False, hexpand=True, wrap=True, valign=Gtk.Align.CENTER, tooltip_text=_("{} is masked and will not be updated").format(self.app_name))
self.mask_label.add_css_class("warning")
eol_app_label = Gtk.Label(label=_("App EOL"), visible=True, hexpand=True, wrap=True, valign=Gtk.Align.CENTER, tooltip_text=_("{} has reached its End of Life and will not receive any security updates").format(self.app_name))
eol_app_label.add_css_class("error")
@@ -72,10 +67,10 @@ class AppRow(Adw.ActionRow):
info_button = Gtk.MenuButton(visible=False, valign=Gtk.Align.CENTER, popover=info_pop, icon_name="software-update-urgent-symbolic")
info_button.add_css_class("flat")
info_box.append(mask_label)
info_box.append(self.mask_label)
self.add_suffix(info_button)
if(mask_label.get_visible() == True or eol_app_label.get_visible() == True or eol_runtime_label == True):
if(self.mask_label.get_visible() == True or eol_app_label.get_visible() == True or eol_runtime_label == True):
info_button.set_visible(True)
@@ -151,9 +146,15 @@ class AppRow(Adw.ActionRow):
snapshot_item = Gio.MenuItem.new(_("Manage Snapshots"), f"win.snapshot{index}")
advanced_menu_model.append_item(snapshot_item)
parent_window.create_action(("downgrade" + str(index)), lambda *_, row=current_flatpak: DowngradeWindow(parent_window, row))
parent_window.create_action(("downgrade" + str(index)), lambda *_, row=current_flatpak, index=index: DowngradeWindow(parent_window, row, index))
downgrade_item = Gio.MenuItem.new(_("Downgrade"), f"win.downgrade{index}")
advanced_menu_model.append_item(downgrade_item)
if self.app_id in parent_window.system_mask_list or self.app_id in parent_window.user_mask_list:
self.mask_label.set_visible(True)
parent_window.lookup_action(f"mask{index}").set_enabled(False)
else:
parent_window.lookup_action(f"unmask{index}").set_enabled(False)
row_menu_model.append_section(None, advanced_menu_model)
self.row_menu.set_menu_model(row_menu_model)

View File

@@ -102,11 +102,11 @@ class DowngradeWindow(Adw.Window):
return
if self.mask_row.get_active():
if self.my_utils.maskFlatpak(self.app_id, self.install_type) == 0:
self.flatpak_row[7].set_visible(True)
else:
if self.my_utils.maskFlatpak(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)))
self.parent_window.flatpaks_list_box.remove(self.parent_window.flatpaks_list_box.get_row_at_index(self.index))
self.parent_window.create_row(self.index)
self.close()
def downgradeThread(self):
@@ -123,7 +123,7 @@ class DowngradeWindow(Adw.Window):
task = Gio.Task.new(None, None, lambda *_: self.downgradeCallack())
task.run_in_thread(lambda *_: self.downgradeThread())
def __init__(self, parent_window, flatpak_row, **kwargs):
def __init__(self, parent_window, flatpak_row, index, **kwargs):
super().__init__(**kwargs)
# Create Variables
@@ -140,6 +140,7 @@ class DowngradeWindow(Adw.Window):
self.flatpak_row = flatpak_row
self.response = 0
self.window_title = _("Downgrade {}").format(self.app_name)
self.index = index
event_controller = Gtk.EventControllerKey()
# Connections

View File

@@ -60,6 +60,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
installing = Gtk.Template.Child()
uninstalling = Gtk.Template.Child()
no_matches = Gtk.Template.Child()
loading_flatpaks = Gtk.Template.Child()
main_progress_bar = Gtk.ProgressBar(visible=False, can_target=False)
main_progress_bar.add_css_class("osd")
@@ -271,18 +272,15 @@ class WarehouseWindow(Adw.ApplicationWindow):
else:
self.main_stack.set_visible_child(self.main_box)
def create_rows(self):
for index in range(len(self.host_flatpaks)):
row = AppRow(self, self.host_flatpaks, index)
self.flatpaks_list_box.insert(row, index)
self.applyFilter()
def create_row(self, index):
row = AppRow(self, self.host_flatpaks, index)
self.flatpaks_list_box.insert(row, index)
def generate_list_of_flatpaks(self):
self.host_flatpaks = self.my_utils.getHostFlatpaks()
self.set_title(self.main_window_title)
self.flatpak_rows = []
self.should_select_all = self.batch_select_all_button.get_active()
self.main_stack.set_visible_child(self.main_box)
self.batch_select_all_button.set_active(False)
self.eol_list = []
self.system_mask_list = self.my_utils.getHostMasks("system")
@@ -295,17 +293,18 @@ class WarehouseWindow(Adw.ApplicationWindow):
except:
print("Could not find EOL")
task = Gio.Task()
task.run_in_thread(lambda *_: GLib.idle_add(lambda *_: self.create_rows()))
for index in range(len(self.host_flatpaks)):
self.create_row(index)
self.applyFilter()
# self.windowSetEmpty(not self.flatpaks_list_box.get_row_at_index(0))
self.batchActionsEnable(False)
self.main_stack.set_visible_child(self.main_box)
def refresh_list_of_flatpaks(self, widget, should_toast):
if self.currently_uninstalling:
return
task = Gio.Task()
self.generate_list_of_flatpaks()
def openDataFolder(self, path):
@@ -336,7 +335,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
dialog.present()
def maskFlatpak(self, id, type, index):
is_masked = self.flatpak_rows[index][7].get_visible() # Check the visibility of the mask label to see if the flatpak is masked
is_masked = self.flatpaks_list_box.get_row_at_index(index).mask_label.get_visible() # Check the visibility of the mask label to see if the flatpak is masked
result = []
name = self.host_flatpaks[index][0]
@@ -344,7 +343,7 @@ class WarehouseWindow(Adw.ApplicationWindow):
if result[0] == 1:
self.toast_overlay.add_toast(Adw.Toast.new(_("Could disable updates for {}").format(name)))
return
self.flatpak_rows[index][7].set_visible(not is_masked)
self.flatpaks_list_box.get_row_at_index(index).mask_label.set_visible(not is_masked)
self.lookup_action(f"mask{index}").set_enabled(is_masked)
self.lookup_action(f"unmask{index}").set_enabled(not is_masked)
@@ -708,7 +707,10 @@ class WarehouseWindow(Adw.ApplicationWindow):
return
self.flatpaks_list_box.set_filter_func(self.filter_func)
self.generate_list_of_flatpaks()
task = Gio.Task()
task.run_in_thread(lambda *_: GLib.idle_add(lambda *_: self.generate_list_of_flatpaks()))
self.search_entry.connect("search-changed", self.on_invalidate)
self.search_bar.connect_entry(self.search_entry)
self.search_bar.connect("notify", self.on_change)