[sysprof/wip/chergert/sysprof-3] libsysprof-ui: fix child properties for tab labels
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof-ui: fix child properties for tab labels
- Date: Fri, 17 May 2019 18:30:59 +0000 (UTC)
commit 5355013dc4642d27fe2c58231a92bfb81dc99db5
Author: Christian Hergert <chergert redhat com>
Date: Fri May 17 11:31:23 2019 -0700
libsysprof-ui: fix child properties for tab labels
src/libsysprof-ui/sysprof-display.c | 39 ++++++++++++++++++++++++++++++++++---
src/libsysprof-ui/sysprof-display.h | 2 ++
2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index ff263af..9bdff77 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -71,7 +71,7 @@ sysprof_display_new (void)
return g_object_new (SYSPROF_TYPE_DISPLAY, NULL);
}
-static gchar *
+gchar *
sysprof_display_dup_title (SysprofDisplay *self)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
@@ -91,7 +91,38 @@ sysprof_display_dup_title (SysprofDisplay *self)
}
- return g_strdup (_("Unsaved Session"));
+ return g_strdup (_("New Recording"));
+}
+
+static void
+update_title_child_property (SysprofDisplay *self)
+{
+ GtkWidget *parent;
+
+ g_assert (SYSPROF_IS_DISPLAY (self));
+
+ if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) && GTK_IS_NOTEBOOK (parent))
+ {
+ g_autofree gchar *title = sysprof_display_dup_title (self);
+
+ gtk_container_child_set (GTK_CONTAINER (parent), GTK_WIDGET (self),
+ "menu-label", title,
+ NULL);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
+}
+
+static void
+sysprof_display_parent_set (GtkWidget *widget,
+ GtkWidget *old_parent)
+{
+ g_assert (SYSPROF_IS_DISPLAY (widget));
+
+ if (GTK_WIDGET_CLASS (sysprof_display_parent_class)->parent_set)
+ GTK_WIDGET_CLASS (sysprof_display_parent_class)->parent_set (widget, old_parent);
+
+ update_title_child_property (SYSPROF_DISPLAY (widget));
}
static void
@@ -147,6 +178,8 @@ sysprof_display_class_init (SysprofDisplayClass *klass)
object_class->get_property = sysprof_display_get_property;
object_class->set_property = sysprof_display_set_property;
+ widget_class->parent_set = sysprof_display_parent_set;
+
properties [PROP_TITLE] =
g_param_spec_string ("title",
"Title",
@@ -281,5 +314,5 @@ sysprof_display_open (SysprofDisplay *self,
g_task_set_task_data (task, g_file_dup (file), g_object_unref);
g_task_run_in_thread (task, sysprof_display_open_worker);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
+ update_title_child_property (self);
}
diff --git a/src/libsysprof-ui/sysprof-display.h b/src/libsysprof-ui/sysprof-display.h
index 6d7f194..5826ab8 100644
--- a/src/libsysprof-ui/sysprof-display.h
+++ b/src/libsysprof-ui/sysprof-display.h
@@ -43,6 +43,8 @@ struct _SysprofDisplayClass
SYSPROF_AVAILABLE_IN_ALL
GtkWidget *sysprof_display_new (void);
SYSPROF_AVAILABLE_IN_ALL
+gchar *sysprof_display_dup_title (SysprofDisplay *self);
+SYSPROF_AVAILABLE_IN_ALL
SysprofProfiler *sysprof_display_get_profiler (SysprofDisplay *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_display_is_empty (SysprofDisplay *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]