libsysprof-ui: wire up more recording state

This commit is contained in:
Christian Hergert
2019-05-18 20:50:29 -07:00
parent 386057bdee
commit b740652e10
3 changed files with 49 additions and 8 deletions

View File

@ -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",

View File

@ -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] =

View File

@ -7,15 +7,29 @@
<property name="hexpand">True</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<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>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -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>