From acb212af6527b3b6e8c3f164ec0cc1a8ab957122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 6 Feb 2024 15:56:36 -0800 Subject: [PATCH 1/6] Remove OS updates --- src/Core/Package.vala | 15 ++-- src/Core/UpdateManager.vala | 72 ------------------- src/Views/AppInfoView.vala | 8 +-- src/Views/AppListUpdateView.vala | 8 --- .../AppContainers/AbstractAppContainer.vala | 8 +-- .../AppContainers/AbstractPackageRowGrid.vala | 2 +- 6 files changed, 11 insertions(+), 102 deletions(-) diff --git a/src/Core/Package.vala b/src/Core/Package.vala index ed1412926..de051201d 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -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"; @@ -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; } @@ -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; @@ -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; } } @@ -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; } @@ -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; } diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 348d916be..79eb02d66 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -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; } @@ -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); @@ -71,10 +58,6 @@ public class AppCenterCore.UpdateManager : Object { installed_package.update_state (); } - - uint os_count = 0; - string os_desc = ""; - #if PACKAGEKIT_BACKEND Pk.Results pk_updates; unowned PackageKitBackend client = PackageKitBackend.get_default (); @@ -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 = ""; @@ -177,18 +140,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"); @@ -202,34 +153,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; } diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index bef37f0ec..e35b67a3b 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -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); } @@ -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 ( @@ -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; diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 2aa618c7b..86621831c 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -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) { @@ -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 (); @@ -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 (); diff --git a/src/Widgets/AppContainers/AbstractAppContainer.vala b/src/Widgets/AppContainers/AbstractAppContainer.vala index 6dd833e7f..5c12d926f 100644 --- a/src/Widgets/AppContainers/AbstractAppContainer.vala +++ b/src/Widgets/AppContainers/AbstractAppContainer.vala @@ -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; @@ -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; @@ -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; } diff --git a/src/Widgets/AppContainers/AbstractPackageRowGrid.vala b/src/Widgets/AppContainers/AbstractPackageRowGrid.vala index fc8eb633e..dfedbe546 100644 --- a/src/Widgets/AppContainers/AbstractPackageRowGrid.vala +++ b/src/Widgets/AppContainers/AbstractPackageRowGrid.vala @@ -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); } From 1863941d021b2c8b14499eca3f2000e8e1dc9a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 6 Feb 2024 16:00:58 -0800 Subject: [PATCH 2/6] Update notification text --- src/Core/Client.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Client.vala b/src/Core/Client.vala index 7aca55477..3708ce193 100644 --- a/src/Core/Client.vala +++ b/src/Core/Client.vala @@ -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); From 922d95c875b5af526ce1180a12550390a9d9e062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 10:22:43 -0800 Subject: [PATCH 3/6] Update menubutton text --- src/MainWindow.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 0349ee96b..bb9c33ef1 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -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 ( From 1a99d161d222f2c04b81eaec60235ee2193aaad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 12:34:46 -0800 Subject: [PATCH 4/6] Remove restart stuff --- src/Core/PackageKitBackend.vala | 2 -- src/Core/UpdateManager.vala | 32 -------------------------------- src/Views/AppListUpdateView.vala | 15 ++++++--------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/src/Core/PackageKitBackend.vala b/src/Core/PackageKitBackend.vala index a108831ef..d694d6f33 100644 --- a/src/Core/PackageKitBackend.vala +++ b/src/Core/PackageKitBackend.vala @@ -233,8 +233,6 @@ public class AppCenterCore.PackageKitBackend : Backend, Object { private void updates_changed_callback () { if (!working) { - UpdateManager.get_default ().update_restart_state (); - var time_since_last_action = (new DateTime.now_local ()).difference (last_action) / GLib.TimeSpan.MILLISECOND; if (time_since_last_action >= PACKAGEKIT_ACTIVITY_TIMEOUT_MS) { info ("packages possibly changed by external program, refreshing cache"); diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 86b9e1cca..8dbf9d539 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -18,19 +18,12 @@ */ public class AppCenterCore.UpdateManager : Object { - public bool restart_required { public get; private set; default = false; } 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; } public bool has_flatpak_updates { get; private set; default = false; } - private const string RESTART_REQUIRED_FILE = "/var/run/reboot-required"; - - private File restart_file; - construct { - restart_file = File.new_for_path (RESTART_REQUIRED_FILE); - var runtime_icon = new AppStream.Icon (); runtime_icon.set_name ("application-vnd.flatpak"); runtime_icon.set_kind (AppStream.IconKind.STOCK); @@ -156,31 +149,6 @@ public class AppCenterCore.UpdateManager : Object { return count; } - public void update_restart_state () { -#if PACKAGEKIT_BACKEND - var should_restart = restart_file.query_exists () || PackageKitBackend.get_default ().is_restart_required (); -#else - var should_restart = restart_file.query_exists (); -#endif - - if (should_restart) { - if (!restart_required) { - string title = _("Restart Required"); - string body = _("Please restart your system to finalize updates"); - var notification = new Notification (title); - notification.set_body (body); - notification.set_icon (new ThemedIcon ("system-reboot")); - notification.set_priority (NotificationPriority.URGENT); - notification.set_default_action ("app.open-application"); - Application.get_default ().send_notification ("restart", notification); - } - - restart_required = true; - } else if (restart_required) { - restart_required = false; - } - } - private static GLib.Once instance; public static unowned UpdateManager get_default () { return instance.once (() => { return new UpdateManager (); }); diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 86621831c..1bca77899 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -250,15 +250,12 @@ namespace AppCenter.Views { size_label.update (update_manager.updates_size, update_manager.has_flatpak_updates); } else { header_revealer.reveal_child = false; - - if (!update_manager.restart_required) { - updated_revealer.reveal_child = true; - updated_label.label = _("Everything is up to date. Last checked %s.").printf ( - Granite.DateTime.get_relative_datetime ( - new DateTime.from_unix_local (AppCenter.App.settings.get_int64 ("last-refresh-time")) - ) - ); - } + updated_revealer.reveal_child = true; + updated_label.label = _("Everything is up to date. Last checked %s.").printf ( + Granite.DateTime.get_relative_datetime ( + new DateTime.from_unix_local (AppCenter.App.settings.get_int64 ("last-refresh-time")) + ) + ); } var installed_apps = yield client.get_installed_applications (refresh_cancellable); From bc7e9ef2bcd34c0e4ee65791e6af3bd6c5ffbf54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 12:35:29 -0800 Subject: [PATCH 5/6] Remove PK check from updates completely --- src/Core/UpdateManager.vala | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 8dbf9d539..88d52f746 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -51,17 +51,6 @@ public class AppCenterCore.UpdateManager : Object { installed_package.update_state (); } -#if PACKAGEKIT_BACKEND - Pk.Results pk_updates; - unowned PackageKitBackend client = PackageKitBackend.get_default (); - try { - pk_updates = yield client.get_updates (cancellable); - } catch (Error e) { - warning ("Unable to get updates from PackageKit backend: %s", e.message); - return 0; - } -#endif - uint runtime_count = 0; string runtime_desc = ""; From f68659c8f4bea43974fd5cde4403c8bb6e39cb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 7 Feb 2024 12:40:30 -0800 Subject: [PATCH 6/6] Simplify size_label, has_flatpak_updates --- src/Core/UpdateManager.vala | 4 ---- src/Views/AppInfoView.vala | 2 +- src/Views/AppListUpdateView.vala | 2 +- src/Widgets/SizeLabel.vala | 21 +++++---------------- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 88d52f746..853913800 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -21,7 +21,6 @@ public class AppCenterCore.UpdateManager : Object { 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; } - public bool has_flatpak_updates { get; private set; default = false; } construct { var runtime_icon = new AppStream.Icon (); @@ -40,7 +39,6 @@ public class AppCenterCore.UpdateManager : Object { public async uint get_updates (Cancellable? cancellable = null) { var apps_with_updates = new Gee.TreeSet (); uint count = 0; - has_flatpak_updates = false; unpaid_apps_number = 0; updates_size = 0ULL; @@ -70,7 +68,6 @@ public class AppCenterCore.UpdateManager : Object { count++; updates_size += appcenter_package.change_information.size; - has_flatpak_updates = true; appcenter_package.change_information.updatable_packages.@set (fp_client, flatpak_update); appcenter_package.update_state (); @@ -95,7 +92,6 @@ public class AppCenterCore.UpdateManager : Object { } runtime_count++; - has_flatpak_updates = true; runtime_desc += Markup.printf_escaped ( " • %s\n\t%s\n", diff --git a/src/Views/AppInfoView.vala b/src/Views/AppInfoView.vala index e35b67a3b..93f35f44e 100644 --- a/src/Views/AppInfoView.vala +++ b/src/Views/AppInfoView.vala @@ -884,7 +884,7 @@ public class AppCenter.Views.AppInfoView : AppCenter.AbstractAppContainer { } var size = yield package.get_download_size_including_deps (); - size_label.update (size, package.is_flatpak); + size_label.update (size); ContentType? runtime_warning = null; switch (package.runtime_status) { diff --git a/src/Views/AppListUpdateView.vala b/src/Views/AppListUpdateView.vala index 1bca77899..8201ea2b4 100644 --- a/src/Views/AppListUpdateView.vala +++ b/src/Views/AppListUpdateView.vala @@ -247,7 +247,7 @@ namespace AppCenter.Views { client.updates_number ).printf (client.updates_number); - size_label.update (update_manager.updates_size, update_manager.has_flatpak_updates); + size_label.update (update_manager.updates_size); } else { header_revealer.reveal_child = false; updated_revealer.reveal_child = true; diff --git a/src/Widgets/SizeLabel.vala b/src/Widgets/SizeLabel.vala index d2677f057..e54b83c44 100644 --- a/src/Widgets/SizeLabel.vala +++ b/src/Widgets/SizeLabel.vala @@ -17,18 +17,14 @@ */ public class AppCenter.Widgets.SizeLabel : Gtk.Box { - public bool using_flatpak { get; construct; } public uint64 size { get; construct; } private Gtk.Label size_label; private Gtk.Image icon; private Gtk.Revealer revealer; - public SizeLabel (uint64 _size = 0, bool _using_flatpak = false) { - Object ( - size: _size, - using_flatpak: _using_flatpak - ); + public SizeLabel (uint64 _size = 0) { + Object (size: _size); } construct { @@ -55,20 +51,13 @@ public class AppCenter.Widgets.SizeLabel : Gtk.Box { add (revealer); show_all (); - update (size, using_flatpak); + update (size); } - public void update (uint64 size = 0, bool using_flatpak = false) { - has_tooltip = using_flatpak; - icon.visible = using_flatpak; - + public void update (uint64 size = 0) { string human_size = GLib.format_size (size); - if (using_flatpak) { - size_label.label = _("Up to %s").printf (human_size); - } else { - size_label.label = "%s".printf (human_size); - } + size_label.label = _("Up to %s").printf (human_size); revealer.reveal_child = size > 0; }