[gnome-control-center/info-overview-add-kernel-row: 2/2] info-overview: Add "Kernel Version" row
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/info-overview-add-kernel-row: 2/2] info-overview: Add "Kernel Version" row
- Date: Thu, 13 Oct 2022 14:17:59 +0000 (UTC)
commit 921235a274e53c0026693699716fda8c781e4b61
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Oct 13 11:16:03 2022 +0200
info-overview: Add "Kernel Version" row
Fixes #1112
panels/info-overview/cc-info-overview-panel.c | 24 ++++++++++++++++++++++++
panels/info-overview/cc-info-overview-panel.ui | 9 +++++++++
2 files changed, 33 insertions(+)
---
diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c
index a0ebf4526..8444d730e 100644
--- a/panels/info-overview/cc-info-overview-panel.c
+++ b/panels/info-overview/cc-info-overview-panel.c
@@ -66,6 +66,7 @@ struct _CcInfoOverviewPanel
GtkDialog *hostname_editor;
CcHostnameEntry *hostname_entry;
CcListRow *hostname_row;
+ CcListRow *kernel_row;
CcListRow *memory_row;
GtkPicture *os_logo;
CcListRow *os_name_row;
@@ -437,6 +438,23 @@ get_hardware_model_string ()
return g_strdup_printf ("%s %s", vendor_string, model_string);
}
+static char *
+get_kernel_version_string ()
+{
+ g_autofree char *kernel_name = NULL;
+ g_autofree char *kernel_release = NULL;
+
+ kernel_name = get_hostnamed_property ("KernelName");
+ if (!kernel_name || g_strcmp0 (kernel_name, "") == 0)
+ return NULL;
+
+ kernel_release = get_hostnamed_property ("KernelRelease");
+ if (!kernel_release || g_strcmp0 (kernel_release, "") == 0)
+ return NULL;
+
+ return g_strdup_printf ("%s %s", kernel_name, kernel_release);
+}
+
static char *
get_cpu_info (const glibtop_sysinfo *info)
{
@@ -695,6 +713,7 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
g_autofree char *os_name_text = NULL;
g_autofree char *os_build_text = NULL;
g_autofree char *hardware_model_text = NULL;
+ g_autofree char *kernel_version_text = NULL;
g_autofree gchar *graphics_hardware_string = NULL;
cc_object_storage_create_dbus_proxy (G_BUS_TYPE_SESSION,
@@ -738,6 +757,10 @@ info_overview_panel_setup_overview (CcInfoOverviewPanel *self)
cc_list_row_set_secondary_label (self->os_type_row, os_type_text);
cc_list_row_set_secondary_label (self->windowing_system_row, get_windowing_system ());
+
+ kernel_version_text = get_kernel_version_string ();
+ cc_list_row_set_secondary_label (self->kernel_row, kernel_version_text);
+ gtk_widget_set_visible (GTK_WIDGET (self->kernel_row), kernel_version_text != NULL);
}
static gboolean
@@ -945,6 +968,7 @@ cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hostname_editor);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hostname_entry);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, hostname_row);
+ gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, kernel_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, memory_row);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, os_logo);
gtk_widget_class_bind_template_child (widget_class, CcInfoOverviewPanel, os_name_row);
diff --git a/panels/info-overview/cc-info-overview-panel.ui b/panels/info-overview/cc-info-overview-panel.ui
index ec2ed2706..2b1fa5d58 100644
--- a/panels/info-overview/cc-info-overview-panel.ui
+++ b/panels/info-overview/cc-info-overview-panel.ui
@@ -143,6 +143,15 @@
</object>
</child>
+ <!-- Kernel version -->
+ <child>
+ <object class="CcListRow" id="kernel_row">
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Kernel Version</property>
+ <property name="activatable">False</property>
+ </object>
+ </child>
+
<!-- Software Updates -->
<child>
<object class="AdwActionRow" id="software_updates_row">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]