[gnome-control-center] Switch to g_get_os_info to read os_release



commit 4383f020e7ce819aa977344e9709333ae059d731
Author: Eric <eric daigle zaclys net>
Date:   Sat Jun 5 11:35:22 2021 -0400

    Switch to g_get_os_info to read os_release
    
    As described in #1346, GLib 2.64 includes a g_get_os_info() function,
    providing access to keys from /etc/os-release. This commit replaces calls to
    gnome-control-center's custom parser (in panels/common/cc-os-release.c)
    with calls to this new function, and deletes the custom parser code.
    
    Closes #1346

 meson.build                                   |  2 +-
 panels/common/cc-os-release.c                 | 84 ---------------------------
 panels/common/cc-os-release.h                 | 30 ----------
 panels/common/meson.build                     |  1 -
 panels/diagnostics/cc-diagnostics-panel.c     |  7 ++-
 panels/info-overview/cc-info-overview-panel.c | 22 +++----
 6 files changed, 14 insertions(+), 132 deletions(-)
---
diff --git a/meson.build b/meson.build
index 10f49d38e..5346d4999 100644
--- a/meson.build
+++ b/meson.build
@@ -121,7 +121,7 @@ accounts_dep = dependency('accountsservice', version: '>= 0.6.39')
 colord_dep = dependency('colord', version: '>= 0.1.34')
 gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.23.0')
 gio_dep = dependency('gio-2.0')
-glib_dep = dependency('glib-2.0', version: '>= 2.56.0')
+glib_dep = dependency('glib-2.0', version: '>= 2.64.0')
 gnome_desktop_dep = dependency('gnome-desktop-3.0', version: '>= 3.33.4')
 gnome_settings_dep = dependency('gnome-settings-daemon', version: '>= 3.27.90')
 goa_dep = dependency('goa-1.0', version: goa_req_version)
diff --git a/panels/common/meson.build b/panels/common/meson.build
index bf22b1539..7be1f8207 100644
--- a/panels/common/meson.build
+++ b/panels/common/meson.build
@@ -27,7 +27,6 @@ common_sources += gnome.mkenums(
 sources = files(
   'cc-hostname-entry.c',
   'cc-time-entry.c',
-  'cc-os-release.c',
   'hostname-helper.c',
   'list-box-helper.c',
 )
diff --git a/panels/diagnostics/cc-diagnostics-panel.c b/panels/diagnostics/cc-diagnostics-panel.c
index 7f1b5e2f0..0ea554ee9 100644
--- a/panels/diagnostics/cc-diagnostics-panel.c
+++ b/panels/diagnostics/cc-diagnostics-panel.c
@@ -21,7 +21,6 @@
 #include "list-box-helper.h"
 #include "cc-diagnostics-panel.h"
 #include "cc-diagnostics-resources.h"
-#include "cc-os-release.h"
 #include "cc-util.h"
 #include "shell/cc-application.h"
 
@@ -135,8 +134,10 @@ cc_diagnostics_panel_init (CcDiagnosticsPanel *self)
                    self->abrt_switch, "active",
                    G_SETTINGS_BIND_DEFAULT);
 
-  os_name = cc_os_release_get_value ("NAME");
-  url = cc_os_release_get_value ("PRIVACY_POLICY_URL");
+  os_name = g_get_os_info (G_OS_INFO_KEY_NAME);
+  if (!os_name)
+    os_name = g_strdup ("GNOME");
+  url = g_get_os_info (G_OS_INFO_KEY_PRIVACY_POLICY_URL);
   if (!url)
     url = g_strdup ("http://www.gnome.org/privacy-policy";);
   /* translators: Text used in link to privacy policy */
diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c
index fbb34a33d..d9d2fa60f 100644
--- a/panels/info-overview/cc-info-overview-panel.c
+++ b/panels/info-overview/cc-info-overview-panel.c
@@ -23,7 +23,6 @@
 #include <config.h>
 
 #include "cc-hostname-entry.h"
-#include "cc-os-release.h"
 
 #include "cc-info-overview-resources.h"
 #include "info-cleanup.h"
@@ -418,20 +417,17 @@ get_graphics_hardware_string (void)
 static char *
 get_os_name (void)
 {
-  g_autoptr(GHashTable) os_info = NULL;
-  const gchar *name, *version_id, *pretty_name, *build_id;
-  gchar *result = NULL;
+  g_autofree gchar *name = NULL;
+  g_autofree gchar *version_id = NULL;
+  g_autofree gchar *pretty_name = NULL;
+  g_autofree gchar *build_id = NULL;
   g_autofree gchar *name_version = NULL;
+  gchar *result = NULL;
 
-  os_info = cc_os_release_get_values ();
-
-  if (!os_info)
-    return g_strdup (_("Unknown"));
-
-  name = g_hash_table_lookup (os_info, "NAME");
-  version_id = g_hash_table_lookup (os_info, "VERSION_ID");
-  pretty_name = g_hash_table_lookup (os_info, "PRETTY_NAME");
-  build_id = g_hash_table_lookup (os_info, "BUILD_ID");
+  name = g_get_os_info (G_OS_INFO_KEY_NAME);
+  version_id = g_get_os_info (G_OS_INFO_KEY_VERSION_ID);
+  pretty_name = g_get_os_info (G_OS_INFO_KEY_PRETTY_NAME);
+  build_id = g_get_os_info ("BUILD_ID");
 
   if (pretty_name)
     name_version = g_strdup (pretty_name);


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