[gnome-builder] stack: add workarounds for GtkStack changes



commit 9abd5ecc6863a8e1f9b07ecf114c3a7c68fb8308
Author: Christian Hergert <christian hergert me>
Date:   Fri May 29 14:57:24 2015 -0700

    stack: add workarounds for GtkStack changes
    
    Once upstream fixes the GtkStack related issues, we can remove this
    workaround.
    
    In particular, we were getting very large size requests all the way up
    into the GtkStack. This forces our "minimum height" requisition to take
    place since we will just fill the area anyway.

 src/editor/gb-editor-view.c  |   26 ++++++++++++++++++++++++++
 src/workbench/gb-workspace.c |   31 +++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index 6f60d95..9897cb1 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -606,6 +606,30 @@ gb_editor_view_invalidate_symbol_filter (GbEditorView *self,
   gtk_list_box_invalidate_filter (self->symbols_listbox);
 }
 
+static GtkSizeRequestMode
+gb_editor_view_get_request_mode (GtkWidget *widget)
+{
+  return GTK_SIZE_REQUEST_CONSTANT_SIZE;
+}
+
+static void
+gb_editor_view_get_preferred_height (GtkWidget *widget,
+                                     gint      *min_height,
+                                     gint      *nat_height)
+{
+  /*
+   * FIXME: Workaround GtkStack changes.
+   *
+   * This can probably be removed once upstream changes land.
+   *
+   * This ignores our potential giant size requests since we don't actually
+   * care about keeping our size requests between animated transitions in
+   * the stack.
+   */
+  GTK_WIDGET_CLASS (gb_editor_view_parent_class)->get_preferred_height (widget, min_height, nat_height);
+  *nat_height = *min_height;
+}
+
 static void
 gb_editor_view_finalize (GObject *object)
 {
@@ -674,6 +698,8 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
   object_class->set_property = gb_editor_view_set_property;
 
   widget_class->grab_focus = gb_editor_view_grab_focus;
+  widget_class->get_request_mode = gb_editor_view_get_request_mode;
+  widget_class->get_preferred_height = gb_editor_view_get_preferred_height;
 
   view_class->create_split = gb_editor_view_create_split;
   view_class->get_document = gb_editor_view_get_document;
diff --git a/src/workbench/gb-workspace.c b/src/workbench/gb-workspace.c
index b1b18fe..16d7acd 100644
--- a/src/workbench/gb-workspace.c
+++ b/src/workbench/gb-workspace.c
@@ -89,6 +89,30 @@ gb_workspace_set_title (GbWorkspace *self,
     }
 }
 
+static GtkSizeRequestMode
+gb_workspace_get_request_mode (GtkWidget *widget)
+{
+  return GTK_SIZE_REQUEST_CONSTANT_SIZE;
+}
+
+static void
+gb_workspace_get_preferred_height (GtkWidget *widget,
+                                   gint      *min_height,
+                                   gint      *nat_height)
+{
+  /*
+   * FIXME: Workaround for GtkStack changes
+   *
+   * Various changes in Gtk+ is causing the stack to allocate a very large size
+   * based on the child requisitions. So we force our natural size to the
+   * minimum size so we just fill things in.
+   *
+   * This can probably be removed as soon as upstream fixes land.
+   */
+  GTK_WIDGET_CLASS (gb_workspace_parent_class)->get_preferred_height (widget, min_height, nat_height);
+  *nat_height = *min_height;
+}
+
 static void
 gb_workspace_finalize (GObject *object)
 {
@@ -150,13 +174,16 @@ gb_workspace_set_property (GObject      *object,
 static void
 gb_workspace_class_init (GbWorkspaceClass *klass)
 {
-  GObjectClass *object_class;
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class = G_OBJECT_CLASS (klass);
   object_class->finalize = gb_workspace_finalize;
   object_class->get_property = gb_workspace_get_property;
   object_class->set_property = gb_workspace_set_property;
 
+  widget_class->get_preferred_height = gb_workspace_get_preferred_height;
+  widget_class->get_request_mode = gb_workspace_get_request_mode;
+
   gParamSpecs[PROP_TITLE] =
     g_param_spec_string ("title",
                          _("Title"),


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