[sysprof/wip/chergert/sysprof-3] libsysprof-ui: try to use default-width before visible
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof-ui: try to use default-width before visible
- Date: Mon, 20 May 2019 22:30:07 +0000 (UTC)
commit a936b92a55af39d59879f94763d32d4e21cf1735
Author: Christian Hergert <chergert redhat com>
Date: Mon May 20 15:29:52 2019 -0700
libsysprof-ui: try to use default-width before visible
This increases the chance that "sysprof foo.syscap" has the right size
when displayed to the user for the first time.
src/libsysprof-ui/sysprof-capture-view.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c
index c70b499..e99f901 100644
--- a/src/libsysprof-ui/sysprof-capture-view.c
+++ b/src/libsysprof-ui/sysprof-capture-view.c
@@ -919,6 +919,7 @@ void
sysprof_capture_view_fit_to_width (SysprofCaptureView *self)
{
SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self);
+ GtkWidget *toplevel;
GtkAllocation alloc;
gdouble zoom;
gint64 duration;
@@ -936,8 +937,20 @@ sysprof_capture_view_fit_to_width (SysprofCaptureView *self)
priv->needs_fit = FALSE;
- /* Trim a bit off the width to avoid drawing past edges */
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
+
+ /* If we got here before we got any sort of backing allocations
+ * created, then we will just try to guess the right size based
+ * on the window's default sizes.
+ */
+ if ((toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self))) &&
+ GTK_IS_WINDOW (toplevel) &&
+ alloc.width <= 1)
+ g_object_get (toplevel,
+ "default-width", &alloc.width,
+ NULL);
+
+ /* Trim a bit off the width to avoid drawing past edges */
width = MAX (100, alloc.width - 25);
zoom = sysprof_zoom_manager_fit_zoom_for_duration (priv->zoom_manager, duration, width);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]