From d086f6567e2cb764d63fb92e92a8234079120a01 Mon Sep 17 00:00:00 2001 From: "Italo F. Capasso B." <44873757+edwood-grant@users.noreply.github.com> Date: Fri, 27 Dec 2024 13:05:38 -0500 Subject: [PATCH] Various fixes in AppListUpdateView (#2237) * Set vexpand property to false to avoid extra unnecesary space in listbox. * Disable refresh_menuitem when clicking it an renabling it when job is complete This is done to avoid multiple update check commands that could create duplicated update element in the list. * Remove updated and installed list along with labels when checking for updates. This commit also toggles the updates message properly when trying to check new updates. Even when the app closes. This removes all installed and updated apps so iit clears the view whn tyring to update again. * Removing the placeholder methods. Sionce this only appear when lists are empty, there not need to explicitly remove since we arealready removing list data. * Fixed a release notes icon bug when installing/cancelling and update The release notes icon would appear when canelling an update of an application that doew nost have a description (and thus the icon should not appear) * Fix for #529 Appcenter sometimes opens the updates view. This also fix an issue where installed apps would not show up if your did not open the AppListUpdateView until the update worker ended. * Use the refrsh action directlt action to update the refresh_menuitem button instead of action_name. This helps to use the shortuct to update elements and makes the sentiive property of the button more consistent when it starts and ends. * Move the clearing of the update_liststore to a better place. Apartfor being a better palce organizational asking. Thsi also avoids a bug when if you the application while listing updates, it will show a bad update list badge and also would keep the incomplete update list when re-opening the app. * Restore the placeholder setup. This is needed for when there are no updates. oops. * Check the vexpand value of list_box after adding the possible items in installed_liststore --------- Co-authored-by: italo-capasso --- src/Application.vala | 1 + src/Core/UpdateManager.vala | 1 + src/MainWindow.vala | 16 +++--- src/Views/AppListUpdateView.vala | 53 +++++++++++-------- .../InstalledPackageRowGrid.vala | 4 +- 5 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index abd65971f..912f4d1cd 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -225,6 +225,7 @@ public class AppCenter.App : Gtk.Application { if (show_updates) { ((MainWindow) active_window).go_to_installed (); + show_updates = false; } active_window.present (); diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 713f5719e..2dd7db5d1 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -227,6 +227,7 @@ public class AppCenterCore.UpdateManager : Object { } public async void update_cache (bool force = false) { + updates_liststore.remove_all (); cancellable.reset (); if (Utils.is_running_in_demo_mode () || Utils.is_running_in_guest_session ()) { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b7b31f46d..2f05e7534 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -145,6 +145,14 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { backend.notify["job-type"].connect (update_overlaybar_label); overlaybar.label = backend.job_type.to_string (); + + if (installed_view == null) { + installed_view = new Views.AppListUpdateView (); + + installed_view.show_app.connect ((package) => { + show_package (package); + }); + } } public override bool close_request () { @@ -192,14 +200,6 @@ public class AppCenter.MainWindow : Gtk.ApplicationWindow { } public void go_to_installed () { - if (installed_view == null) { - installed_view = new Views.AppListUpdateView (); - - installed_view.show_app.connect ((package) => { - show_package (package); - }); - } - if (installed_view.parent != null) { navigation_view.pop_to_page (installed_view); } else { diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index fea6c2bae..03e3c9365 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -33,6 +33,7 @@ namespace AppCenter.Views { private Gtk.Label updated_label; private Gtk.SizeGroup action_button_group; private ListStore installed_liststore; + private Granite.HeaderLabel installed_header; private Widgets.SizeLabel size_label; private bool updating_all_apps = false; private Cancellable? refresh_cancellable = null; @@ -93,7 +94,7 @@ namespace AppCenter.Views { list_box.bind_model (update_manager.updates_liststore, create_row_from_package); list_box.set_placeholder (loading_view); - var installed_header = new Granite.HeaderLabel (_("Up to Date")) { + installed_header = new Granite.HeaderLabel (_("Up to Date")) { margin_top = 12, margin_end = 12, margin_bottom = 12, @@ -131,10 +132,24 @@ namespace AppCenter.Views { ); var refresh_menuitem = new Gtk.Button () { - action_name = "app.refresh", - child = refresh_accellabel + child = refresh_accellabel, + sensitive = false }; refresh_menuitem.add_css_class (Granite.STYLE_CLASS_MENUITEM); + refresh_menuitem.clicked.connect (() => { + activate_action ("app.refresh", null); + }); + + AppCenter.App.refresh_action.activate.connect (() => { + installed_liststore.remove_all (); + list_box.set_placeholder (loading_view); + + refresh_menuitem.sensitive = false; + header_revealer.reveal_child = false; + updated_revealer.reveal_child = false; + installed_header.visible = false; + list_box.vexpand = true; + }); var menu_popover_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); menu_popover_box.append (automatic_updates_button); @@ -178,14 +193,11 @@ namespace AppCenter.Views { /// TRANSLATORS: the name of the Installed Apps view title = C_("view", "Installed"); - on_installed_changed.begin ((obj, res) => { - on_installed_changed.end (res); - installed_header.visible = true; - }); - - update_manager.updates_liststore.items_changed.connect (() => { + update_manager.updates_liststore.items_changed.connect ((position, removed, added) => { Idle.add (() => { - on_updates_changed (); + if (added > 0) { + on_updates_changed (); + } return GLib.Source.REMOVE; }); }); @@ -218,24 +230,18 @@ namespace AppCenter.Views { flatpak_backend.notify ["working"].connect (() => { if (flatpak_backend.working) { + refresh_menuitem.sensitive = false; + header_revealer.reveal_child = false; updated_revealer.reveal_child = false; - - switch (flatpak_backend.job_type) { - case GET_PREPARED_PACKAGES: - case GET_UPDATES: - case REFRESH_CACHE: - case UPDATE_PACKAGE: - list_box.set_placeholder (loading_view); - break; - default: - list_box.set_placeholder (null); - break; - } + list_box.set_placeholder (loading_view); } else { list_box.set_placeholder (null); + refresh_menuitem.sensitive = true; + on_updates_changed (); } }); + automatic_updates_button.notify["active"].connect (() => { if (automatic_updates_button.active) { update_manager.update_cache.begin (true); @@ -295,12 +301,15 @@ namespace AppCenter.Views { unowned var flatpak_backend = AppCenterCore.FlatpakBackend.get_default (); var installed_apps = yield flatpak_backend.get_installed_applications (refresh_cancellable); + installed_header.visible = !installed_apps.is_empty; foreach (var package in installed_apps) { if (package.state != UPDATE_AVAILABLE && package.kind != ADDON && package.kind != FONT) { installed_liststore.insert_sorted (package, compare_installed_func); } } + + list_box.vexpand = installed_liststore.n_items <= 0; } refresh_cancellable = null; diff --git a/src/Widgets/AppContainers/InstalledPackageRowGrid.vala b/src/Widgets/AppContainers/InstalledPackageRowGrid.vala index 7b46442cc..223a8f5ea 100644 --- a/src/Widgets/AppContainers/InstalledPackageRowGrid.vala +++ b/src/Widgets/AppContainers/InstalledPackageRowGrid.vala @@ -122,7 +122,9 @@ public class AppCenter.Widgets.InstalledPackageRowGrid : AbstractPackageRowGrid release_button_revealer.reveal_child = true; } } else { - release_button_revealer.reveal_child = true; + if (newest.get_description () != null) { + release_button_revealer.reveal_child = true; + } } }