libsysprof-ui: wire up display for re-recording

This commit is contained in:
Christian Hergert
2019-05-23 17:20:45 -07:00
parent 974cbf5130
commit 7c41a99b99
2 changed files with 33 additions and 2 deletions

View File

@ -165,7 +165,7 @@ sysprof_display_start_recording_cb (SysprofDisplay *self,
g_assert (SYSPROF_IS_DISPLAY (self));
g_assert (SYSPROF_IS_PROFILER (profiler));
g_assert (SYSPROF_IS_PROFILER_ASSISTANT (assistant));
g_assert (!assistant || SYSPROF_IS_PROFILER_ASSISTANT (assistant));
g_assert (sysprof_display_is_empty (self));
if (g_set_object (&priv->profiler, profiler))
@ -619,10 +619,37 @@ sysprof_display_get_can_replay (SysprofDisplay *self)
sysprof_capture_view_get_can_replay (priv->capture_view);
}
/**
* sysprof_display_replay:
* @self: a #SysprofDisplay
*
* Gets a new display that will re-run the previous recording that is being
* viewed. This requires a capture file which contains enough information to
* replay the operation.
*
* Returns: (nullable) (transfer full): a #SysprofDisplay or %NULL
*
* Since: 3.34
*/
SysprofDisplay *
sysprof_display_replay (SysprofDisplay *self)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
g_autoptr(SysprofProfiler) profiler = NULL;
SysprofCaptureReader *reader;
SysprofDisplay *copy;
g_return_val_if_fail (SYSPROF_IS_DISPLAY (self), NULL);
return NULL;
reader = sysprof_capture_view_get_reader (priv->capture_view);
g_return_val_if_fail (reader != NULL, NULL);
profiler = sysprof_local_profiler_new_replay (reader);
g_return_val_if_fail (profiler != NULL, NULL);
g_return_val_if_fail (SYSPROF_IS_LOCAL_PROFILER (profiler), NULL);
copy = g_object_new (SYSPROF_TYPE_DISPLAY, NULL);
sysprof_display_start_recording_cb (copy, profiler, NULL);
return g_steal_pointer (&copy);
}

View File

@ -344,6 +344,7 @@ sysprof_notebook_replay (SysprofNotebook *self)
{
SysprofDisplay *display;
SysprofDisplay *replay;
gint page;
g_return_if_fail (SYSPROF_IS_NOTEBOOK (self));
@ -354,5 +355,8 @@ sysprof_notebook_replay (SysprofNotebook *self)
g_return_if_fail (SYSPROF_IS_DISPLAY (replay));
gtk_widget_show (GTK_WIDGET (replay));
gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (replay));
page = gtk_notebook_page_num (GTK_NOTEBOOK (self), GTK_WIDGET (replay));
gtk_notebook_set_current_page (GTK_NOTEBOOK (self), page);
}