libsysprof-ui: wire up can-save propagation

This commit is contained in:
Christian Hergert
2019-05-19 11:26:07 -07:00
parent a7b18281e6
commit 688b6a2189
3 changed files with 73 additions and 0 deletions

View File

@ -52,6 +52,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (SysprofDisplay, sysprof_display, GTK_TYPE_BIN)
enum {
PROP_0,
PROP_CAN_SAVE,
PROP_RECORDING,
PROP_TITLE,
N_PROPS
@ -124,6 +125,7 @@ sysprof_display_profiler_stopped_cb (SysprofDisplay *self,
}
notify:
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_CAN_SAVE]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_RECORDING]);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TITLE]);
}
@ -274,6 +276,10 @@ sysprof_display_get_property (GObject *object,
switch (prop_id)
{
case PROP_CAN_SAVE:
g_value_set_boolean (value, sysprof_display_get_can_save (self));
break;
case PROP_RECORDING:
g_value_set_boolean (value, sysprof_display_get_is_recording (self));
break;
@ -312,6 +318,13 @@ sysprof_display_class_init (SysprofDisplayClass *klass)
widget_class->parent_set = sysprof_display_parent_set;
properties [PROP_CAN_SAVE] =
g_param_spec_boolean ("can-save",
"Can Save",
"If the display can save a recording",
FALSE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_RECORDING] =
g_param_spec_boolean ("recording",
"Recording",
@ -536,3 +549,13 @@ sysprof_display_save (SysprofDisplay *self)
gtk_native_dialog_destroy (GTK_NATIVE_DIALOG (native));
}
gboolean
sysprof_display_get_can_save (SysprofDisplay *self)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
g_return_val_if_fail (SYSPROF_IS_DISPLAY (self), FALSE);
return sysprof_capture_view_get_reader (priv->capture_view) != NULL;
}

View File

@ -53,5 +53,7 @@ void sysprof_display_open (SysprofDisplay *self,
GFile *file);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_display_save (SysprofDisplay *self);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_display_get_can_save (SysprofDisplay *self);
G_END_DECLS