From 5919c9e4e2a26870a2a5b2225516e2899f7dae54 Mon Sep 17 00:00:00 2001 From: Nathaniel Russell Date: Sun, 30 Jun 2024 01:24:54 +0000 Subject: [PATCH] Revert GNOME Version to show the correct version of Gnome Shell and not just the major version number. --- .../system/about/cc-system-details-window.c | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/panels/system/about/cc-system-details-window.c b/panels/system/about/cc-system-details-window.c index 0fc21f7d31..dbbb506c2c 100644 --- a/panels/system/about/cc-system-details-window.c +++ b/panels/system/about/cc-system-details-window.c @@ -639,6 +639,47 @@ get_ram_size_dmi (void) return ram_total; } +static char * +get_gnome_version () +{ + GDBusProxy *shell_proxy; + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) variant = NULL; + const char *gnome_version = NULL; + + shell_proxy = cc_object_storage_create_dbus_proxy_sync ( + G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS | + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + "org.gnome.Shell", + "/org/gnome/Shell", + "org.gnome.Shell", + NULL, + &error); + + + if (!shell_proxy) + { + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + return g_strdup (_("Not Available")); + g_warning ("Failed to contact gnome-shell: %s", error->message); + } + + variant = g_dbus_proxy_get_cached_property (shell_proxy, "ShellVersion"); + if (!variant) + return g_strdup (_("Not Available")); + + gnome_version = g_variant_get_string (variant, NULL); + if (!gnome_version || *gnome_version == '\0') + { + /* translators: this is the placeholder string when the GNOME Shell + * version couldn't be loaded, eg. “GNOME Version: Not Available” */ + return g_strdup (_("Not Available")); + } + else + return g_strdup (gnome_version); +} + static void system_details_window_title_print_padding (const gchar *title, GString *dst_string, gsize maxlen) { @@ -671,6 +712,7 @@ on_copy_button_clicked_cb (GtkWidget *widget, g_autofree char *os_type_text = NULL; g_autofree char *os_name_text = NULL; g_autofree char *os_build_text = NULL; + g_autofree char *gnome_version_text = NULL; g_autofree char *hardware_model_text = NULL; g_autofree char *firmware_version_text = NULL; g_autofree char *windowing_system_text = NULL; @@ -767,7 +809,7 @@ on_copy_button_clicked_cb (GtkWidget *widget, g_string_append (result_str, "- "); system_details_window_title_print_padding ("**GNOME Version:**", result_str, 0); - g_string_append_printf (result_str, "%s\n", MAJOR_VERSION); + g_string_append_printf (result_str, "%s\n", gnome_version_text); g_string_append (result_str, "- "); system_details_window_title_print_padding (_("**Windowing System:**"), result_str, 0); @@ -798,6 +840,7 @@ system_details_window_setup_overview (CcSystemDetailsWindow *self) g_autofree char *os_type_text = NULL; g_autofree char *os_name_text = NULL; g_autofree char *os_build_text = NULL; + g_autofree char *gnome_version_text = NULL; g_autofree char *hardware_model_text = NULL; g_autofree char *firmware_version_text = NULL; g_autofree char *kernel_version_text = NULL; @@ -839,7 +882,8 @@ system_details_window_setup_overview (CcSystemDetailsWindow *self) os_type_text = get_os_type (); cc_info_entry_set_value (self->os_type_row, os_type_text); - cc_info_entry_set_value (self->gnome_version_row, MAJOR_VERSION); + gnome_version_text = get_gnome_version (); + cc_info_entry_set_value (self->gnome_version_row, gnome_version_text); cc_info_entry_set_value (self->windowing_system_row, get_windowing_system ()); -- GitLab