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

Remove OS updates #2111

Merged
merged 8 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Core/Client.vala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class AppCenterCore.Client : Object {
var application = Application.get_default ();
if (was_empty && updates_number != 0U) {
string title = ngettext ("Update Available", "Updates Available", updates_number);
string body = ngettext ("%u update is available for your system", "%u updates are available for your system", updates_number).printf (updates_number);
string body = ngettext ("%u app update is available", "%u app updates are available", updates_number).printf (updates_number);

var notification = new Notification (title);
notification.set_body (body);
Expand Down
15 changes: 4 additions & 11 deletions src/Core/Package.vala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class AppCenterCore.Package : Object {
X11
}

public const string OS_UPDATES_ID = "xxx-os-updates";
public const string RUNTIME_UPDATES_ID = "xxx-runtime-updates";
public const string LOCAL_ID_SUFFIX = ".appcenter-local";
public const string DEFAULT_PRICE_DOLLARS = "1";
Expand All @@ -127,7 +126,7 @@ public class AppCenterCore.Package : Object {
private bool _installed = false;
public bool installed {
get {
if (is_os_updates || is_runtime_updates) {
if (is_runtime_updates) {
return true;
}

Expand Down Expand Up @@ -207,12 +206,6 @@ public class AppCenterCore.Package : Object {
}
}

public bool is_os_updates {
get {
return component.id == OS_UPDATES_ID;
}
}

public bool is_runtime_updates {
get {
return component.id == RUNTIME_UPDATES_ID;
Expand All @@ -233,7 +226,7 @@ public class AppCenterCore.Package : Object {

public bool is_shareable {
get {
return is_native && component.get_kind () != AppStream.ComponentKind.DRIVER && !is_os_updates && !is_runtime_updates;
return is_native && component.get_kind () != AppStream.ComponentKind.DRIVER && !is_runtime_updates;
}
}

Expand Down Expand Up @@ -874,7 +867,7 @@ public class AppCenterCore.Package : Object {
}

private string convert_version (string version) {
if (is_os_updates || is_runtime_updates) {
if (is_runtime_updates) {
return version;
}

Expand Down Expand Up @@ -965,7 +958,7 @@ public class AppCenterCore.Package : Object {
}

private void populate_backend_details_sync () {
if (is_os_updates || is_runtime_updates || is_local) {
if (is_runtime_updates || is_local) {
backend_details = new PackageDetails ();
return;
}
Expand Down
72 changes: 0 additions & 72 deletions src/Core/UpdateManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public class AppCenterCore.UpdateManager : Object {
public bool restart_required { public get; private set; default = false; }
public Package os_updates { public get; private set; }
public Package runtime_updates { public get; private set; }
public int unpaid_apps_number { get; private set; default = 0; }
public uint64 updates_size { get; private set; default = 0ULL; }
Expand All @@ -32,18 +31,6 @@ public class AppCenterCore.UpdateManager : Object {
construct {
restart_file = File.new_for_path (RESTART_REQUIRED_FILE);

var os_icon = new AppStream.Icon ();
os_icon.set_name ("distributor-logo");
os_icon.set_kind (AppStream.IconKind.STOCK);

var os_updates_component = new AppStream.Component ();
os_updates_component.id = AppCenterCore.Package.OS_UPDATES_ID;
os_updates_component.name = _("Operating System Updates");
os_updates_component.summary = _("Updates to system components");
os_updates_component.add_icon (os_icon);

os_updates = new AppCenterCore.Package (BackendAggregator.get_default (), os_updates_component);

var runtime_icon = new AppStream.Icon ();
runtime_icon.set_name ("application-vnd.flatpak");
runtime_icon.set_kind (AppStream.IconKind.STOCK);
Expand Down Expand Up @@ -71,10 +58,6 @@ public class AppCenterCore.UpdateManager : Object {
installed_package.update_state ();
}


uint os_count = 0;
string os_desc = "";

#if PACKAGEKIT_BACKEND
danirabbit marked this conversation as resolved.
Show resolved Hide resolved
Pk.Results pk_updates;
unowned PackageKitBackend client = PackageKitBackend.get_default ();
Expand All @@ -84,28 +67,8 @@ public class AppCenterCore.UpdateManager : Object {
warning ("Unable to get updates from PackageKit backend: %s", e.message);
return 0;
}

var package_array = pk_updates.get_package_array ();
debug ("PackageKit backend reports %d updates", package_array.length);

package_array.foreach ((pk_package) => {
var pkg_name = pk_package.get_name ();
debug ("Added %s to OS updates", pkg_name);
os_count++;
unowned string pkg_summary = pk_package.get_summary ();
unowned string pkg_version = pk_package.get_version ();
os_desc += Markup.printf_escaped (
" • %s\n\t%s\n\t%s\n",
pkg_name,
pkg_summary,
_("Version: %s").printf (pkg_version)
);
});
#endif

os_updates.component.set_pkgnames ({});
os_updates.change_information.clear_update_info ();

uint runtime_count = 0;
string runtime_desc = "";

Expand Down Expand Up @@ -171,18 +134,6 @@ public class AppCenterCore.UpdateManager : Object {
}
}

if (os_count == 0) {
debug ("No OS updates found");
var latest_version = _("No components with updates");
os_updates.latest_version = latest_version;
os_updates.description = GLib.Markup.printf_escaped ("%s\n", latest_version);
} else {
debug ("%u OS updates found", os_count);
var latest_version = ngettext ("%u component with updates", "%u components with updates", os_count).printf (os_count);
os_updates.latest_version = latest_version;
os_updates.description = "%s\n%s\n".printf (GLib.Markup.printf_escaped (_("%s:"), latest_version), os_desc);
}

if (runtime_count == 0) {
debug ("No runtime updates found");
var latest_version = _("No runtimes with updates");
Expand All @@ -196,34 +147,11 @@ public class AppCenterCore.UpdateManager : Object {
}

debug ("%u app updates found", count);
if (os_count > 0) {
count += 1;
}

if (runtime_count > 0) {
count += 1;
}

#if PACKAGEKIT_BACKEND
pk_updates.get_details_array ().foreach ((pk_detail) => {
var pk_package = new Pk.Package ();
try {
pk_package.set_id (pk_detail.get_package_id ());
var pkg_name = pk_package.get_name ();

var pkgnames = os_updates.component.pkgnames;
pkgnames += pkg_name;
os_updates.component.pkgnames = pkgnames;

os_updates.change_information.updatable_packages.@set (client, pk_package.get_id ());
os_updates.change_information.size += pk_detail.size;
} catch (Error e) {
critical (e.message);
}
});
#endif

os_updates.update_state ();
runtime_updates.update_state ();
return count;
}
Expand Down
4 changes: 2 additions & 2 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ public class AppCenter.MainWindow : Hdy.ApplicationWindow {
child = search_entry
};

var automatic_updates_button = new Granite.SwitchModelButton (_("Automatic App Updates")) {
description = _("System updates and unpaid apps will not update automatically")
var automatic_updates_button = new Granite.SwitchModelButton (_("Automatically Update Free & Purchased Apps")) {
description = _("Apps being tried for free will not update automatically")
};

var refresh_accellabel = new Granite.AccelLabel.from_action_name (
Expand Down
8 changes: 4 additions & 4 deletions src/Views/AppInfoView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer {
} else {
app_icon.gicon = package.get_icon (app_icon.pixel_size, scale_factor);

if (package.is_os_updates || package.is_runtime_updates) {
if (package.is_runtime_updates) {
badge_image.icon_name = "system-software-update";
app_icon_overlay.add_overlay (badge_image);
}
Expand Down Expand Up @@ -298,7 +298,7 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer {
maximum_size = MAX_WIDTH
};

if (!package.is_os_updates && !package.is_runtime_updates) {
if (!package.is_runtime_updates) {
#if CURATED
if (!package.is_native) {
var uncurated = new ContentType (
Expand Down Expand Up @@ -852,10 +852,10 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer {
uninstall_button_revealer.reveal_child = false;
break;
case AppCenterCore.Package.State.INSTALLED:
uninstall_button_revealer.reveal_child = !package.is_os_updates && !package.is_runtime_updates && !package.is_compulsory;
uninstall_button_revealer.reveal_child = !package.is_runtime_updates && !package.is_compulsory;
break;
case AppCenterCore.Package.State.UPDATE_AVAILABLE:
uninstall_button_revealer.reveal_child = !package.is_os_updates && !package.is_runtime_updates && !package.is_compulsory;
uninstall_button_revealer.reveal_child = !package.is_runtime_updates && !package.is_compulsory;
break;
default:
break;
Expand Down
8 changes: 0 additions & 8 deletions src/Views/AppListUpdateView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,6 @@ namespace AppCenter.Views {
if (!refresh_cancellable.is_cancelled ()) {
clear ();

var os_updates = AppCenterCore.UpdateManager.get_default ().os_updates;
var os_updates_size = yield os_updates.get_download_size_including_deps ();
if (os_updates_size > 0) {
updates_liststore.insert_sorted (os_updates, compare_package_func);
}

var runtime_updates = AppCenterCore.UpdateManager.get_default ().runtime_updates;
var runtime_updates_size = yield runtime_updates.get_download_size_including_deps ();
if (runtime_updates_size > 0) {
Expand Down Expand Up @@ -316,7 +310,6 @@ namespace AppCenter.Views {
string a_package_name = "";
if (package1 != null) {
a_is_driver = package1.kind == AppStream.ComponentKind.DRIVER;
a_is_os = package1.is_os_updates;
a_is_runtime = package1.is_runtime_updates;
a_is_updating = package1.is_updating;
a_package_name = package1.get_name ();
Expand All @@ -329,7 +322,6 @@ namespace AppCenter.Views {
string b_package_name = "";
if (package2 != null) {
b_is_driver = package2.kind == AppStream.ComponentKind.DRIVER;
b_is_os = package2.is_os_updates;
b_is_runtime = package2.is_runtime_updates;
b_is_updating = package2.is_updating;
b_package_name = package2.get_name ();
Expand Down
8 changes: 2 additions & 6 deletions src/Widgets/AppContainers/AbstractAppContainer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public abstract class AppCenter.AbstractAppContainer : Gtk.Box {
}

protected void update_action () {
if (package == null || package.component == null || !package.is_native || package.is_os_updates || package.is_runtime_updates) {
if (package == null || package.component == null || !package.is_native || package.is_runtime_updates) {
action_button.can_purchase = false;
} else {
var can_purchase = package.get_payments_key () != null;
Expand Down Expand Up @@ -191,7 +191,7 @@ public abstract class AppCenter.AbstractAppContainer : Gtk.Box {
action_button.amount = 0;
}

action_button_revealer.reveal_child = !(package.is_os_updates || package.is_runtime_updates);
action_button_revealer.reveal_child = !package.is_runtime_updates;
open_button_revealer.reveal_child = false;

break;
Expand All @@ -204,10 +204,6 @@ public abstract class AppCenter.AbstractAppContainer : Gtk.Box {
case AppCenterCore.Package.State.UPDATE_AVAILABLE:
action_button.free_string = _("Update");

if (package.is_os_updates) {
action_button.free_string = _("Download");
}

if (!package.should_pay) {
action_button.amount = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/AppContainers/AbstractPackageRowGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public abstract class AppCenter.Widgets.AbstractPackageRowGrid : AbstractAppCont
} else {
app_icon.gicon = package.get_icon (app_icon.pixel_size, scale_factor);

if (package.is_os_updates || package.is_runtime_updates) {
if (package.is_runtime_updates) {
badge_image.icon_name = "system-software-update";
app_icon_overlay.add_overlay (badge_image);
}
Expand Down