[gnome-builder/wip/chergert/hover] hover: tweak sizing a bit when webkit is in play



commit 0a795c56450fb1821985fc6c9e9a9465a084721c
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 16 14:11:29 2018 -0700

    hover: tweak sizing a bit when webkit is in play
    
    This helps us avoid giant popovers with empty space caused by weird sizing
    from WebKitWebView.

 src/libide/hover/ide-hover-popover.c             | 21 +++++++++++++++++++++
 src/plugins/devhelp/gbp-devhelp-hover-provider.c |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/hover/ide-hover-popover.c b/src/libide/hover/ide-hover-popover.c
index ab652bc9e..f9e130b8f 100644
--- a/src/libide/hover/ide-hover-popover.c
+++ b/src/libide/hover/ide-hover-popover.c
@@ -144,6 +144,26 @@ ide_hover_popover_query_cb (GObject      *object,
   gtk_widget_show (GTK_WIDGET (self));
 }
 
+static void
+ide_hover_popover_get_preferred_height (GtkWidget *widget,
+                                        gint      *min_height,
+                                        gint      *nat_height)
+{
+  g_assert (IDE_IS_HOVER_POPOVER (widget));
+  g_assert (min_height != NULL);
+  g_assert (nat_height != NULL);
+
+  GTK_WIDGET_CLASS (ide_hover_popover_parent_class)->get_preferred_height (widget, min_height, nat_height);
+
+  /*
+   * If we have embedded webkit views, they can get some bogus size requests
+   * sometimes. So try to detect that and prevent giant popovers.
+   */
+
+  if (*nat_height > 1024)
+    *nat_height = *min_height;
+}
+
 static void
 ide_hover_popover_destroy (GtkWidget *widget)
 {
@@ -185,6 +205,7 @@ ide_hover_popover_class_init (IdeHoverPopoverClass *klass)
   object_class->get_property = ide_hover_popover_get_property;
 
   widget_class->destroy = ide_hover_popover_destroy;
+  widget_class->get_preferred_height = ide_hover_popover_get_preferred_height;
 
   properties [PROP_CONTEXT] =
     g_param_spec_object ("context",
diff --git a/src/plugins/devhelp/gbp-devhelp-hover-provider.c 
b/src/plugins/devhelp/gbp-devhelp-hover-provider.c
index c714b5f0f..c4b923428 100644
--- a/src/plugins/devhelp/gbp-devhelp-hover-provider.c
+++ b/src/plugins/devhelp/gbp-devhelp-hover-provider.c
@@ -107,7 +107,7 @@ find_and_apply_content (Hover *h)
                         "halign", GTK_ALIGN_FILL,
                         "height-request", 200,
                         "hexpand", FALSE,
-                        "valign", GTK_ALIGN_FILL,
+                        "valign", GTK_ALIGN_START,
                         "vexpand", FALSE,
                         "width-request", 400,
                         NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]