Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes in AppListUpdateView #2237

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
Loading