Skip to content

Commit

Permalink
Various fixes in AppListUpdateView (#2237)
Browse files Browse the repository at this point in the history
* 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 <italo@glitchypixel.com.co>
  • Loading branch information
edwood-grant and italo-capasso authored Dec 27, 2024
1 parent efb5ad2 commit d086f65
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down
1 change: 1 addition & 0 deletions src/Core/UpdateManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()) {
Expand Down
16 changes: 8 additions & 8 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 {
Expand Down
53 changes: 31 additions & 22 deletions src/Views/AppListUpdateView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
});
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/Widgets/AppContainers/InstalledPackageRowGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit d086f65

Please sign in to comment.