mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: simplify zoom at load
This commit is contained in:
@ -462,6 +462,13 @@ sysprof_capture_view_real_load_async (SysprofCaptureView *self,
|
||||
load_async_free);
|
||||
sysprof_capture_view_monitor_task (self, task);
|
||||
|
||||
/* Zoom after loading state */
|
||||
g_signal_connect_object (task,
|
||||
"notify::completed",
|
||||
G_CALLBACK (sysprof_capture_view_fit_to_width),
|
||||
self,
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
/* Cancel any previously in-flight operations and save a cancellable so
|
||||
* that any supplimental calls will result in the previous being cancelled.
|
||||
*/
|
||||
@ -512,18 +519,11 @@ fit_zoom_cb (GSimpleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofCaptureView *self = user_data;
|
||||
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
|
||||
GtkAllocation alloc;
|
||||
gdouble zoom;
|
||||
gint64 duration;
|
||||
|
||||
g_assert (G_IS_SIMPLE_ACTION (action));
|
||||
g_assert (SYSPROF_IS_CAPTURE_VIEW (self));
|
||||
|
||||
duration = priv->features.end_time - priv->features.begin_time;
|
||||
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
|
||||
zoom = sysprof_zoom_manager_fit_zoom_for_duration (priv->zoom_manager, duration, alloc.width);
|
||||
sysprof_zoom_manager_set_zoom (priv->zoom_manager, zoom);
|
||||
sysprof_capture_view_fit_to_width (self);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -697,6 +697,7 @@ sysprof_capture_view_reset (SysprofCaptureView *self)
|
||||
g_return_if_fail (SYSPROF_IS_CAPTURE_VIEW (self));
|
||||
|
||||
/* TODO: reset */
|
||||
g_warning ("Clear all loaded state");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -716,3 +717,19 @@ sysprof_capture_view_get_zoom_manager (SysprofCaptureView *self)
|
||||
|
||||
return priv->zoom_manager;
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_capture_view_fit_to_width (SysprofCaptureView *self)
|
||||
{
|
||||
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
|
||||
GtkAllocation alloc;
|
||||
gdouble zoom;
|
||||
gint64 duration;
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_CAPTURE_VIEW (self));
|
||||
|
||||
duration = priv->features.end_time - priv->features.begin_time;
|
||||
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
|
||||
zoom = sysprof_zoom_manager_fit_zoom_for_duration (priv->zoom_manager, duration, alloc.width);
|
||||
sysprof_zoom_manager_set_zoom (priv->zoom_manager, zoom);
|
||||
}
|
||||
|
||||
@ -67,5 +67,7 @@ gboolean sysprof_capture_view_load_finish (SysprofCaptureView
|
||||
GError **error);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_capture_view_get_busy (SysprofCaptureView *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_capture_view_fit_to_width (SysprofCaptureView *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -619,7 +619,6 @@ sysprof_visualizer_view_set_reader (SysprofVisualizerView *self,
|
||||
|
||||
if (reader != NULL)
|
||||
{
|
||||
GtkAllocation alloc;
|
||||
gint64 begin_time;
|
||||
gint64 end_time;
|
||||
|
||||
@ -632,18 +631,6 @@ sysprof_visualizer_view_set_reader (SysprofVisualizerView *self,
|
||||
sysprof_visualizer_ticks_set_time_range (priv->ticks, begin_time, end_time);
|
||||
|
||||
sysprof_selection_unselect_all (priv->selection);
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
|
||||
|
||||
if (alloc.width)
|
||||
{
|
||||
gdouble zoom;
|
||||
|
||||
zoom = sysprof_zoom_manager_fit_zoom_for_duration (priv->zoom_manager,
|
||||
end_time - begin_time,
|
||||
alloc.width);
|
||||
sysprof_zoom_manager_set_zoom (priv->zoom_manager, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
sysprof_visualizer_list_set_reader (priv->list, reader);
|
||||
|
||||
Reference in New Issue
Block a user