[sysprof] libsysprof-ui: wire up more recording state
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: wire up more recording state
- Date: Wed, 29 May 2019 22:36:09 +0000 (UTC)
commit b740652e1059d6ded861884444e80fa31fdc40d4
Author: Christian Hergert <chergert redhat com>
Date: Sat May 18 20:50:29 2019 -0700
libsysprof-ui: wire up more recording state
src/libsysprof-ui/sysprof-display.c | 27 ++++++++++++++++++++++++++-
src/libsysprof-ui/sysprof-tab.c | 7 ++++---
src/libsysprof-ui/ui/sysprof-tab.ui | 19 +++++++++++++++++--
3 files changed, 47 insertions(+), 6 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index d3fa872..57ed97b 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -52,6 +52,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (SysprofDisplay, sysprof_display, GTK_TYPE_BIN)
enum {
PROP_0,
+ PROP_RECORDING,
PROP_TITLE,
N_PROPS
};
@@ -92,6 +93,7 @@ sysprof_display_profiler_failed_cb (SysprofDisplay *self,
gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->failed_view));
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RECORDING]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
@@ -106,6 +108,7 @@ sysprof_display_profiler_stopped_cb (SysprofDisplay *self,
gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->capture_view));
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RECORDING]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
@@ -141,6 +144,7 @@ sysprof_display_start_recording_cb (SysprofDisplay *self,
sysprof_profiler_start (priv->profiler);
}
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RECORDING]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
@@ -158,7 +162,7 @@ sysprof_display_dup_title (SysprofDisplay *self)
if (priv->profiler != NULL)
{
if (sysprof_profiler_get_is_running (priv->profiler))
- return g_strdup (_("⏺ Recording…"));
+ return g_strdup (_("Recording…"));
}
if (priv->file != NULL)
@@ -194,6 +198,16 @@ update_title_child_property (SysprofDisplay *self)
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
+static gboolean
+sysprof_display_get_is_recording (SysprofDisplay *self)
+{
+ SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
+
+ g_assert (SYSPROF_IS_DISPLAY (self));
+
+ return GTK_WIDGET (priv->recording_view) == gtk_stack_get_visible_child (priv->stack);
+}
+
static void
sysprof_display_parent_set (GtkWidget *widget,
GtkWidget *old_parent)
@@ -229,6 +243,10 @@ sysprof_display_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_RECORDING:
+ g_value_set_boolean (value, sysprof_display_get_is_recording (self));
+ break;
+
case PROP_TITLE:
g_value_take_string (value, sysprof_display_dup_title (self));
break;
@@ -263,6 +281,13 @@ sysprof_display_class_init (SysprofDisplayClass *klass)
widget_class->parent_set = sysprof_display_parent_set;
+ properties [PROP_RECORDING] =
+ g_param_spec_boolean ("recording",
+ "Recording",
+ "If the display is in recording state",
+ FALSE,
+ (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
properties [PROP_TITLE] =
g_param_spec_string ("title",
"Title",
diff --git a/src/libsysprof-ui/sysprof-tab.c b/src/libsysprof-ui/sysprof-tab.c
index 5c3e7b5..864aba2 100644
--- a/src/libsysprof-ui/sysprof-tab.c
+++ b/src/libsysprof-ui/sysprof-tab.c
@@ -32,6 +32,7 @@ struct _SysprofTab
GtkButton *close_button;
GtkLabel *title;
+ GtkImage *recording;
SysprofDisplay *display;
};
@@ -106,9 +107,8 @@ sysprof_tab_set_property (GObject *object,
{
case PROP_DISPLAY:
g_set_weak_pointer (&self->display, g_value_get_object (value));
- g_object_bind_property (self->display, "title",
- self->title, "label",
- G_BINDING_SYNC_CREATE);
+ g_object_bind_property (self->display, "title", self->title, "label", G_BINDING_SYNC_CREATE);
+ g_object_bind_property (self->display, "recording", self->recording, "visible", G_BINDING_SYNC_CREATE);
break;
default:
@@ -128,6 +128,7 @@ sysprof_tab_class_init (SysprofTabClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-tab.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofTab, close_button);
+ gtk_widget_class_bind_template_child (widget_class, SysprofTab, recording);
gtk_widget_class_bind_template_child (widget_class, SysprofTab, title);
properties [PROP_DISPLAY] =
diff --git a/src/libsysprof-ui/ui/sysprof-tab.ui b/src/libsysprof-ui/ui/sysprof-tab.ui
index 1bf77db..883cd25 100644
--- a/src/libsysprof-ui/ui/sysprof-tab.ui
+++ b/src/libsysprof-ui/ui/sysprof-tab.ui
@@ -7,13 +7,27 @@
<property name="hexpand">True</property>
<property name="spacing">6</property>
<child>
+ <object class="GtkImage" id="recording">
+ <property name="visible">false</property>
+ <property name="icon-name">media-record-symbolic</property>
+ <property name="pixel-size">16</property>
+ <property name="hexpand">true</property>
+ <property name="halign">end</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ <property name="pack-type">start</property>
+ </packing>
+ </child>
+ <child type="center">
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
@@ -36,6 +50,7 @@
</style>
</object>
<packing>
+ <property name="pack-type">end</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]