Skip to content

Commit 97d7785

Browse files
committed
Simplify how flatpak addons are displayed.
We normally queue up addon install/remove tasks with the flatpak system. This provides us with freed/used disk space values for each addon. Unfortunately it turns out some flatpak apps have so many available addons that it crashes flatpak when you select the app (too many open files). Instead of creating install tasks for every addon, just list them without disk space info (it's usually not significant anyhow).
1 parent 73905da commit 97d7785

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

usr/lib/linuxmint/mintinstall/mintinstall.py

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,14 @@ def do_enter_notify_event(self, event):
160160
return Gdk.EVENT_STOP
161161

162162
class FlatpakAddonRow(Gtk.ListBoxRow):
163-
def __init__(self, app, parent_pkginfo, addon, name_size_group, button_size_group):
163+
def __init__(self, app, parent_pkginfo, addon_pkginfo, name_size_group, button_size_group):
164164
Gtk.ListBoxRow.__init__(self)
165165
self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=4, margin_start=10, margin_end=10, margin_top=4, margin_bottom=4)
166166
self.add(self.box)
167167

168168
self.app = app
169-
self.pkginfo = parent_pkginfo
170-
self.addon = addon
169+
self.parent_pkginfo = parent_pkginfo
170+
self.addon_pkginfo = addon_pkginfo
171171

172172
self.spinner = Gtk.Spinner(active=True, no_show_all=True, visible=True)
173173
self.box.pack_start(self.spinner, False, False, 0)
@@ -183,59 +183,42 @@ def __init__(self, app, parent_pkginfo, addon, name_size_group, button_size_grou
183183
self.action.connect("clicked", self.action_clicked)
184184
self.box.pack_end(self.action, False, False, 0)
185185

186-
info_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4, valign=Gtk.Align.CENTER)
187-
self.box.pack_end(info_box, False, False, 4)
188-
189-
self.size_label = Gtk.Label(use_markup=True, no_show_all=True)
190-
self.size_label.get_style_context().add_class("dim-label")
191-
info_box.pack_start(self.size_label, False, False, 0)
192-
193186
label_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
194187
self.box.pack_start(label_box, False, False, 0)
195188

196-
name = Gtk.Label(label="<b>%s</b>" % addon.get_name(), use_markup=True, xalign=0.0, selectable=True)
189+
name = Gtk.Label(label="<b>%s</b>" % addon_pkginfo.get_display_name(), use_markup=True, xalign=0.0, selectable=True)
197190
name_size_group.add_widget(name)
198191
label_box.pack_start(name, False, False, 0)
199192

200-
summary = Gtk.Label(label=addon.get_summary(), xalign=0.0, wrap=True, max_width_chars=60, selectable=True)
193+
summary = Gtk.Label(label=addon_pkginfo.get_summary(), xalign=0.0, wrap=True, max_width_chars=60, selectable=True)
201194
label_box.pack_start(summary, False, False, 0)
202195

203-
if not self.app.installer.pkginfo_is_installed(self.pkginfo):
196+
if not self.app.installer.pkginfo_is_installed(self.parent_pkginfo):
204197
self.action.hide()
205198
self.set_sensitive(False)
206199
return
207200

208201
self.action.show()
209-
self.prepare_task()
202+
self.update_button()
210203

211-
def prepare_task(self):
212-
self.app.installer.create_addon_task(self.addon, self.pkginfo.remote, self.pkginfo.remote_url,
213-
self.info_ready, self.info_error,
214-
self.installer_finished, self.installer_progress, use_mainloop=True)
215-
216-
def info_ready(self, task):
217-
self.task = task
218-
219-
if task.type == task.INSTALL_TASK:
204+
def update_button(self):
205+
if not self.app.installer.pkginfo_is_installed(self.addon_pkginfo):
220206
self.action.set_label(_("Add"))
221207
self.action.set_sensitive(True)
222208
self.action.get_style_context().add_class("suggested-action")
223209
self.action.get_style_context().remove_class("destructive-action")
224210
self.spinner.hide()
225-
elif task.type == task.UNINSTALL_TASK:
211+
else:
226212
self.action.set_label(_("Remove"))
227213
self.action.set_sensitive(True)
228214
self.action.get_style_context().add_class("destructive-action")
229215
self.action.get_style_context().remove_class("suggested-action")
230216
self.spinner.hide()
231217

232-
# TODO - just size or say 'Size:' ?
233-
if task.freed_size > 0:
234-
self.size_label.set_label(get_size_for_display(task.freed_size))
235-
elif task.install_size > 0:
236-
self.size_label.set_label(get_size_for_display(task.install_size))
237-
238-
self.size_label.show()
218+
def info_ready(self, task):
219+
self.app.installer.execute_task(task)
220+
self.action.set_label("")
221+
self.app.update_activity_widgets()
239222

240223
def info_error(self, task):
241224
self.task = task
@@ -247,14 +230,14 @@ def info_error(self, task):
247230
self.action.get_style_context().remove_class("destructive-action")
248231

249232
def action_clicked(self, widget):
250-
self.app.installer.execute_task(self.task)
251-
252-
self.action.set_label("")
253-
self.app.update_activity_widgets()
233+
self.app.installer.select_pkginfo(self.addon_pkginfo,
234+
self.info_ready, self.info_error,
235+
self.installer_finished, self.installer_progress,
236+
use_mainloop=True)
254237

255238
def installer_finished(self, task):
256239
self.app.update_activity_widgets()
257-
self.prepare_task()
240+
self.update_button()
258241

259242
def installer_progress(self, pkginfo, progress, estimating, status_text=None):
260243
self.spinner.show()
@@ -3091,7 +3074,7 @@ def populate_addons(self, pkginfo):
30913074

30923075
first = True
30933076
for addon in addons:
3094-
print("Discovered addon: %s" % addon.get_name())
3077+
print("Discovered addon: %s" % addon.name)
30953078
first = False
30963079

30973080
row = FlatpakAddonRow(self, pkginfo, addon, name_size_group, button_size_group)

0 commit comments

Comments
 (0)