[gnome-software/881-eos-updater-plugin-allow-other-os-names: 17/18] eos-updater: Read OS name from the system




commit a45dbe71505a4d11811ccc635f6376d0e5747266
Author: Milan Crha <mcrha redhat com>
Date:   Mon Mar 14 11:11:40 2022 +0100

    eos-updater: Read OS name from the system
    
    Read the OS name from the /etc/os-release, thus it can reflect actual
    OS name, instead of hard-coded "Endless OS" name.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/881

 plugins/eos-updater/gs-plugin-eos-updater.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/plugins/eos-updater/gs-plugin-eos-updater.c b/plugins/eos-updater/gs-plugin-eos-updater.c
index 7251f33ff..19581c546 100644
--- a/plugins/eos-updater/gs-plugin-eos-updater.c
+++ b/plugins/eos-updater/gs-plugin-eos-updater.c
@@ -553,8 +553,11 @@ proxy_new_cb (GObject      *source_object,
        g_autoptr(GIcon) ic = NULL;
        g_autofree gchar *background_filename = NULL;
        g_autofree gchar *css = NULL;
+       g_autofree gchar *summary = NULL;
+       g_autoptr(GsOsRelease) os_release = NULL;
        g_autoptr(GMutexLocker) locker = NULL;
        g_autoptr(GError) local_error = NULL;
+       const gchar *os_name;
 
        locker = g_mutex_locker_new (&self->mutex);
 
@@ -596,16 +599,26 @@ proxy_new_cb (GObject      *source_object,
                css = g_strconcat ("background: url('file://", background_filename, "');"
                                   "background-size: 100% 100%;", NULL);
 
+       os_release = gs_os_release_new (&local_error);
+       if (local_error) {
+               g_warning ("Failed to get OS release information: %s", local_error->message);
+               /* Just a fallback, do not localize */
+               os_name = "Endless OS";
+               g_clear_error (&local_error);
+       } else {
+               os_name = gs_os_release_get_name (os_release);
+       }
+
+       /* Translators: The '%s' is replaced with the OS name, like "Endless OS" */
+       summary = g_strdup_printf (_("%s update with new features and fixes."), os_name);
+
        /* create the OS upgrade */
        app = gs_app_new ("com.endlessm.EOS.upgrade");
        gs_app_add_icon (app, ic);
        gs_app_set_scope (app, AS_COMPONENT_SCOPE_SYSTEM);
        gs_app_set_kind (app, AS_COMPONENT_KIND_OPERATING_SYSTEM);
-       /* TRANSLATORS: ‘Endless OS’ is a brand name; https://endlessos.com/ */
-       gs_app_set_name (app, GS_APP_QUALITY_LOWEST, _("Endless OS"));
-       gs_app_set_summary (app, GS_APP_QUALITY_NORMAL,
-                           /* TRANSLATORS: ‘Endless OS’ is a brand name; https://endlessos.com/ */
-                           _("An Endless OS update with new features and fixes."));
+       gs_app_set_name (app, GS_APP_QUALITY_LOWEST, os_name);
+       gs_app_set_summary (app, GS_APP_QUALITY_NORMAL, summary);
        /* ensure that the version doesn't appear as (NULL) in the banner, it
         * should be changed to the right value when it changes in the eos-updater */
        gs_app_set_version (app, "");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]