From fb85c2078ec1aa4668b770167cbce2f455d4bba4 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 10 Jul 2023 14:59:09 -0700 Subject: [PATCH] sysprof: start on icons for sections --- .../scalable/actions/system-log-symbolic.svg | 23 +++++++++++ src/sysprof/sysprof-section.c | 38 +++++++++++++++++++ src/sysprof/sysprof-section.h | 21 +++++----- src/sysprof/sysprof-sidebar.c | 23 +++++++++-- src/sysprof/sysprof-window.ui | 5 +++ src/sysprof/sysprof.gresource.xml | 1 + 6 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 src/sysprof/icons/scalable/actions/system-log-symbolic.svg diff --git a/src/sysprof/icons/scalable/actions/system-log-symbolic.svg b/src/sysprof/icons/scalable/actions/system-log-symbolic.svg new file mode 100644 index 00000000..df132b2a --- /dev/null +++ b/src/sysprof/icons/scalable/actions/system-log-symbolic.svg @@ -0,0 +1,23 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + diff --git a/src/sysprof/sysprof-section.c b/src/sysprof/sysprof-section.c index 52e93fc2..581edded 100644 --- a/src/sysprof/sysprof-section.c +++ b/src/sysprof/sysprof-section.c @@ -26,6 +26,7 @@ typedef struct { char *category; + char *icon_name; char *title; SysprofSession *session; } SysprofSectionPrivate; @@ -36,6 +37,7 @@ enum { PROP_0, PROP_SESSION, PROP_CATEGORY, + PROP_ICON_NAME, PROP_TITLE, N_PROPS }; @@ -55,6 +57,7 @@ sysprof_section_dispose (GObject *object) g_clear_object (&priv->session); g_clear_pointer (&priv->title, g_free); g_clear_pointer (&priv->category, g_free); + g_clear_pointer (&priv->icon_name, g_free); G_OBJECT_CLASS (sysprof_section_parent_class)->dispose (object); } @@ -77,6 +80,10 @@ sysprof_section_get_property (GObject *object, g_value_set_string (value, sysprof_section_get_category (self)); break; + case PROP_ICON_NAME: + g_value_set_string (value, sysprof_section_get_icon_name (self)); + break; + case PROP_TITLE: g_value_set_string (value, sysprof_section_get_title (self)); break; @@ -104,6 +111,10 @@ sysprof_section_set_property (GObject *object, sysprof_section_set_category (self, g_value_get_string (value)); break; + case PROP_ICON_NAME: + sysprof_section_set_icon_name (self, g_value_get_string (value)); + break; + case PROP_TITLE: sysprof_section_set_title (self, g_value_get_string (value)); break; @@ -138,6 +149,11 @@ sysprof_section_class_init (SysprofSectionClass *klass) NULL, (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + properties[PROP_ICON_NAME] = + g_param_spec_string ("icon-name", NULL, NULL, + NULL, + (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties (object_class, N_PROPS, properties); gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT); @@ -214,3 +230,25 @@ sysprof_section_set_category (SysprofSection *self, if (g_set_str (&priv->category, category)) g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CATEGORY]); } + +const char * +sysprof_section_get_icon_name (SysprofSection *self) +{ + SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self); + + g_return_val_if_fail (SYSPROF_IS_SECTION (self), NULL); + + return priv->icon_name; +} + +void +sysprof_section_set_icon_name (SysprofSection *self, + const char *icon_name) +{ + SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self); + + g_return_if_fail (SYSPROF_IS_SECTION (self)); + + if (g_set_str (&priv->icon_name, icon_name)) + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]); +} diff --git a/src/sysprof/sysprof-section.h b/src/sysprof/sysprof-section.h index 3d7a23fc..edc9e464 100644 --- a/src/sysprof/sysprof-section.h +++ b/src/sysprof/sysprof-section.h @@ -35,14 +35,17 @@ struct _SysprofSectionClass GtkWidgetClass parent_class; }; -SysprofSession *sysprof_section_get_session (SysprofSection *self); -void sysprof_section_set_session (SysprofSection *self, - SysprofSession *session); -const char *sysprof_section_get_category (SysprofSection *self); -void sysprof_section_set_category (SysprofSection *self, - const char *category); -const char *sysprof_section_get_title (SysprofSection *self); -void sysprof_section_set_title (SysprofSection *self, - const char *title); +SysprofSession *sysprof_section_get_session (SysprofSection *self); +void sysprof_section_set_session (SysprofSection *self, + SysprofSession *session); +const char *sysprof_section_get_category (SysprofSection *self); +void sysprof_section_set_category (SysprofSection *self, + const char *category); +const char *sysprof_section_get_icon_name (SysprofSection *self); +void sysprof_section_set_icon_name (SysprofSection *self, + const char *icon_name); +const char *sysprof_section_get_title (SysprofSection *self); +void sysprof_section_set_title (SysprofSection *self, + const char *title); G_END_DECLS diff --git a/src/sysprof/sysprof-sidebar.c b/src/sysprof/sysprof-sidebar.c index cc40b744..3b79fe53 100644 --- a/src/sysprof/sysprof-sidebar.c +++ b/src/sysprof/sysprof-sidebar.c @@ -48,16 +48,31 @@ sysprof_sidebar_create_row (gpointer item, SysprofSidebar *sidebar = user_data; SysprofSection *section; GtkListBoxRow *row; + GtkImage *image; + GtkLabel *label; + GtkBox *box; g_assert (GTK_IS_STACK_PAGE (page)); g_assert (SYSPROF_IS_SIDEBAR (sidebar)); section = SYSPROF_SECTION (gtk_stack_page_get_child (page)); + + box = g_object_new (GTK_TYPE_BOX, + "orientation", GTK_ORIENTATION_HORIZONTAL, + "spacing", 6, + NULL); + label = g_object_new (GTK_TYPE_LABEL, + "xalign", .0f, + "label", sysprof_section_get_title (section), + NULL); + image = g_object_new (GTK_TYPE_IMAGE, + "icon-name", sysprof_section_get_icon_name (section), + NULL); + gtk_box_append (box, GTK_WIDGET (image)); + gtk_box_append (box, GTK_WIDGET (label)); + row = g_object_new (GTK_TYPE_LIST_BOX_ROW, - "child", g_object_new (GTK_TYPE_LABEL, - "xalign", .0f, - "label", sysprof_section_get_title (section), - NULL), + "child", box, NULL); g_object_set_data_full (G_OBJECT (row), "SECTION", g_object_ref (section), g_object_unref); diff --git a/src/sysprof/sysprof-window.ui b/src/sysprof/sysprof-window.ui index c2d8d9b0..15e72680 100644 --- a/src/sysprof/sysprof-window.ui +++ b/src/sysprof/sysprof-window.ui @@ -100,6 +100,7 @@ callgraph + org.gnome.Sysprof-symbolic SysprofWindow @@ -116,6 +117,7 @@ processes + system-log-symbolic SysprofWindow @@ -124,6 +126,7 @@ processes + mark-chart-symbolic SysprofWindow @@ -132,6 +135,7 @@ processes + application-x-executable-symbolic SysprofWindow @@ -140,6 +144,7 @@ auxiliary + folder-symbolic SysprofWindow diff --git a/src/sysprof/sysprof.gresource.xml b/src/sysprof/sysprof.gresource.xml index 15d06dfb..cfc481c6 100644 --- a/src/sysprof/sysprof.gresource.xml +++ b/src/sysprof/sysprof.gresource.xml @@ -16,5 +16,6 @@ sysprof-window.ui icons/scalable/actions/mark-chart-symbolic.svg icons/scalable/actions/mark-table-symbolic.svg + icons/scalable/actions/system-log-symbolic.svg