Fix usage of new remote install type destinction

This commit is contained in:
heliguy
2023-12-17 21:58:59 -05:00
parent edc89360c5
commit fda727c437
4 changed files with 172 additions and 41 deletions

View File

@@ -2,9 +2,25 @@
# Features Currently Being Worked On
### Features that are actively in development and will most likely ship in a coming update
### Features releasing in this upcoming update
- Snapshots (backing up app data)
- Snapshots window and batch applying snapshots
- Properties window upgrade
- Show app details in store
- Manage Remotes window upgrade
- View disabled remotes
- Enable and disable remotes
- Set a filter for a remote
- Combined Popular Remotes window into this window
- Reduce app launch time
- Remove warning labels from the main list, placing them in a popover button now
- View troubleshooting information
- Donation link
-
### Features that will release in future updates
- Installing flatpaks from a search
# Features Being Considered

View File

@@ -57,6 +57,7 @@ class FilterWindow(Adw.Window):
self.remote_checkboxes[i].set_active(not is_enabled)
def remoteCheckHandler(self, checkbox, install_type, remote):
install_type = self.my_utils.getInstallType(install_type)
if checkbox.get_active():
self.filter_list[2].append(install_type)
self.filter_list[3].append(remote)
@@ -97,20 +98,31 @@ class FilterWindow(Adw.Window):
self.runtimes_expander.set_visible(False)
self.remote_checkboxes = []
total = 0
for i in range(len(self.host_remotes)):
try:
name = self.host_remotes[i][0]
title = self.host_remotes[i][1]
install_type = self.host_remotes[i][7]
url = self.host_remotes[i][2]
remote_row = Adw.ActionRow(title=title, subtitle=url)
install_type = self.host_remotes[i][7]
remote_row = Adw.ActionRow(title=title)
if "disabled" in install_type:
continue
total += 1
if title == "-":
remote_row.set_title(name)
self.remotes_expander.add_row(remote_row)
label = Gtk.Label(label=("{} wide").format(install_type))
label.add_css_class("subtitle")
remote_check = Gtk.CheckButton()
remote_row.add_suffix(label)
if "user" in install_type:
remote_row.set_subtitle(_("User wide"))
elif "system" in install_type:
remote_row.set_subtitle(_("System wide"))
else:
remote_row.set_subtitle(_("Unknown install type"))
remote_row.add_suffix(remote_check)
remote_row.set_activatable_widget(remote_check)
remote_check.connect("toggled", self.remoteCheckHandler, install_type, name)
@@ -118,6 +130,8 @@ class FilterWindow(Adw.Window):
remote_check.set_active(True)
except:
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.add_suffix(self.remotes_expander_switch)

View File

@@ -83,14 +83,12 @@ class OrphansWindow(Adw.Window):
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(id_list, remote, app_type, progress_bar))
def installButtonHandler(self, button):
remote_select_buttons = []
def remote_select_handler(button):
def remote_select_handler(button, index):
if not button.get_active():
return
remote_index = remote_select_buttons.index(button)
self.selected_remote = self.host_remotes[remote_index][0]
self.selected_remote_type = self.host_remotes[remote_index][7]
self.selected_remote = self.host_remotes[index][0]
self.selected_remote_type = self.my_utils.getInstallType(self.host_remotes[index][7])
def onResponse(dialog, response_id, _function):
if response_id == "cancel":
@@ -115,28 +113,41 @@ class OrphansWindow(Adw.Window):
remotes_scroll.set_child(remote_list)
remote_list.add_css_class("boxed-list")
total_added = 0
remote_select_buttons = []
for i in range(len(self.host_remotes)):
remote_row = Adw.ActionRow(title=self.host_remotes[i][1])
label = Gtk.Label(label=_("{} wide").format(self.host_remotes[i][7]), valign=Gtk.Align.CENTER)
title = self.host_remotes[i][1]
name = self.host_remotes[i][0]
type_arr = self.host_remotes[i][7]
if "disabled" in type_arr:
continue
remote_row = Adw.ActionRow(title=title)
remote_select = Gtk.CheckButton()
label.add_css_class("subtitle")
remote_select_buttons.append(remote_select)
remote_select.connect("toggled", remote_select_handler)
remote_select.connect("toggled", remote_select_handler, i)
remote_row.set_activatable_widget(remote_select)
type = self.my_utils.getInstallType(type_arr)
if type == "user":
remote_row.set_subtitle(_("User wide"))
elif type == "system":
remote_row.set_subtitle(_("System wide"))
else:
remote_row.set_subtitle(_("Unknown install type"))
if remote_row.get_title() == '-':
remote_row.set_title(self.host_remotes[i][0])
if i > 0:
remote_select.set_group(remote_select_buttons[i-1])
if total_added > 0:
remote_select.set_group(remote_select_buttons[0])
remote_row.add_prefix(remote_select)
remote_row.add_suffix(label)
remote_list.append(remote_row)
total_added += 1
remote_select_buttons[0].set_active(True)
if len(self.host_remotes) > 1:
if total_added > 1:
dialog.set_extra_child(remotes_scroll)
dialog.connect("response", onResponse, dialog.choose_finish)

View File

@@ -57,13 +57,14 @@ class RemotesWindow(Adw.Window):
self.make_toast(_("Could not remove {}").format(title))
self.generate_list()
def remove_handler(self, _widget, index):
def remove_handler(self, _widget, index, popoever):
popoever.popdown()
name = self.host_remotes[index][0]
title = self.host_remotes[index][1]
install_type = self.host_remotes[index][7]
body_text = _("Any installed apps from {} will stop receiving updates").format(name)
dialog = Adw.MessageDialog.new(self, _("Remove {}?").format(name), body_text)
dialog = Adw.MessageDialog.new(self, _("Remove {}?").format(title), body_text)
dialog.set_close_response("cancel")
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("continue", _("Remove"))
@@ -71,10 +72,69 @@ class RemotesWindow(Adw.Window):
dialog.connect("response", self.remove_on_response, dialog.choose_finish, index)
dialog.present()
def view_apps(self, type, id):
def enable_handler(self, button, index):
name = self.host_remotes[index][0]
typeArr = self.host_remotes[index][7]
type = ""
if "system" in typeArr:
type = "system"
else:
type = "user"
try:
command = ['flatpak-spawn', '--host', 'flatpak', 'remote-modify', name, f"--{type}", "--enable"]
subprocess.run(command, capture_output=False, check=True, env=self.new_env)
except subprocess.CalledProcessError as e:
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not enable {}").format(name)))
print(f"error in remotes_window.enable_handler: could not enable remote {name}:", e)
self.generate_list()
def disable_handler(self, button, index, popoever):
def disable_response(_a, response, _b):
if response == "cancel":
return
try:
command = ['flatpak-spawn', '--host', 'flatpak', 'remote-modify', name, f"--{type}", "--disable"]
subprocess.run(command, capture_output=False, check=True, env=self.new_env)
except subprocess.CalledProcessError as e:
self.toast_overlay.add_toast(Adw.Toast.new(_("Could not disable {}").format(name)))
print(f"error in remotes_window.enable_handler: could not disable remote {name}:", e)
self.generate_list()
name = self.host_remotes[index][0]
title = self.host_remotes[index][1]
typeArr = self.host_remotes[index][7]
type = ""
if "system" in typeArr:
type = "system"
else:
type = "user"
popoever.popdown()
body_text = _("Any installed apps from {} will stop receiving updates").format(name)
dialog = Adw.MessageDialog.new(self, _("Disable {}?").format(title), body_text)
dialog.set_close_response("cancel")
dialog.add_response("cancel", _("Cancel"))
dialog.add_response("continue", _("Disable"))
dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE)
dialog.connect("response", disable_response, dialog.choose_finish)
dialog.present()
def view_paks(self, type, id):
if "user" in type:
type = "user"
elif "system" in type:
type = "system"
else:
self.make_toast(_("Could not view apps").format(to_copy))
print("error in remotes_window.view_apps(): remote installation type is not either system or user. type is:", type)
return
self.app_window.should_open_filter_window = False
self.app_window.filter_button.set_active(True)
self.app_window.applyFilter([True, False, [type], [id], ["all"]])
self.app_window.applyFilter([True, True, [type], [id], ["all"]])
self.app_window.should_open_filter_window = True
self.close()
@@ -102,38 +162,68 @@ class RemotesWindow(Adw.Window):
name = self.host_remotes[i][0]
title = self.host_remotes[i][1]
install_type = self.host_remotes[i][7]
remote_row = Adw.ActionRow(title=title, subtitle=name)
remote_row = Adw.ActionRow(title=title)
more = Gtk.MenuButton(icon_name="view-more-symbolic", valign=Gtk.Align.CENTER)
more.add_css_class("flat")
options = Gtk.Popover()
options_box = Gtk.Box(halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER, orientation=Gtk.Orientation.VERTICAL)
filter_button = Gtk.Button()
filter_button.set_child(Adw.ButtonContent(icon_name="funnel-symbolic", label=_("Set Filter")))
filter_button.add_css_class("flat")
filter_button.connect("clicked", lambda *_, i=i: self.view_paks(self.host_remotes[i][7], self.host_remotes[i][0]))
enable_button = Gtk.Button(visible=False)
enable_button.set_child(Adw.ButtonContent(icon_name="eye-open-negative-filled-symbolic", label=_("Enable")))
enable_button.add_css_class("flat")
enable_button.connect("clicked", self.enable_handler, i)
disable_button = Gtk.Button()
disable_button.set_child(Adw.ButtonContent(icon_name="eye-not-looking-symbolic", label=_("Disable")))
disable_button.add_css_class("flat")
disable_button.connect("clicked", self.disable_handler, i, options)
remove_button = Gtk.Button()
remove_button.set_child(Adw.ButtonContent(icon_name="user-trash-symbolic", label=_("Remove")))
remove_button.add_css_class("flat")
remove_button.connect("clicked", self.remove_handler, i, options)
options_box.append(filter_button)
options_box.append(enable_button)
options_box.append(disable_button)
options_box.append(remove_button)
options.set_child(options_box)
more.set_popover(options)
copy_button = Gtk.Button(icon_name="edit-copy-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("Copy remote name"))
copy_button.add_css_class("flat")
copy_button.connect("clicked", rowCopyHandler, name)
remote_row.add_suffix(copy_button)
remote_row.add_suffix(more)
install_type = self.my_utils.getInstallType(install_type)
if install_type == "disabled":
if not self.show_disabled_button.get_active():
continue
remote_row.set_subtitle(_("Disabled"))
enable_button.set_visible(True)
disable_button.set_visible(False)
remote_row.add_css_class("warning")
elif install_type == "user":
remote_row.set_subtitle(_("User wide"))
elif install_type == "system":
remote_row.set_subtitle(_("System wide"))
else:
remote_row.set_subtitle(_("Unknown install type"))
url = self.host_remotes[i][2]
if title == "-":
remote_row.set_title(name)
self.remotes_list.add(remote_row)
label = Gtk.Label(valign=Gtk.Align.CENTER)
if install_type == "disabled":
remote_row.set_subtitle(_("Disabled"))
else:
remote_row.set_subtitle(_("{} wide").format(install_type))
label.add_css_class("subtitle")
# subprocess.run(['wget', f'{self.host_remotes[i][11]}']) Idea to display remote icons... Need internet connection. Not sure if that is worth it
remote_row.add_suffix(label)
filter_button = Gtk.Button(icon_name="funnel-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("View apps from this remote"))
filter_button.add_css_class("flat")
filter_button.connect("clicked", lambda *_, i=i: self.view_apps(self.host_remotes[i][7], self.host_remotes[i][0]))
copy_button = Gtk.Button(icon_name="edit-copy-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("Copy remote name"))
copy_button.add_css_class("flat")
copy_button.connect("clicked", rowCopyHandler, name)
remove_button = Gtk.Button(icon_name="user-trash-symbolic", valign=Gtk.Align.CENTER, tooltip_text=_("Remove {}").format(name))
remove_button.add_css_class("flat")
remove_button.connect("clicked", self.remove_handler, i)
remote_row.add_suffix(filter_button)
remote_row.add_suffix(copy_button)
remote_row.add_suffix(remove_button)
self.rows_in_list.append(remote_row)
self.no_remotes.set_visible(False)
except Exception as e: