[gtk+/wip/csoriano/pathbar-prototype] experiment with scrolled window



commit 2e22ff9529ba3b583daa79d2e0984053a9563653
Author: Carlos Soriano <csoriano gnome org>
Date:   Fri May 13 18:02:19 2016 +0200

    experiment with scrolled window

 gtk/gtkhidingbox.c |   69 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 51 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index 08ea752..fa4f114 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -30,6 +30,8 @@
 #include "gtksizerequest.h"
 #include "gtkbuildable.h"
 #include "gtkrevealer.h"
+#include "gtkadjustment.h"
+#include "gtkscrolledwindow.h"
 
 #include "glib.h"
 
@@ -53,6 +55,10 @@ struct _GtkHidingBoxPrivate
   gint current_width;
   gint current_height;
   guint needs_update :1;
+
+  GtkWidget *scrolled_window;
+  GtkWidget *box;
+  GtkAdjustment *adjustment;
 };
 
 static void
@@ -151,11 +157,16 @@ gtk_hiding_box_add (GtkContainer *container,
   GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
 
   revealer = gtk_revealer_new ();
+  gtk_revealer_set_transition_type (GTK_REVEALER (revealer),
+                                    GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
   gtk_container_add (GTK_CONTAINER (revealer), widget);
-  gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), FALSE);
-  priv->children = g_list_append (priv->children, revealer);
+  g_print ("box fine? %s \n", G_OBJECT_TYPE_NAME (priv->box));
+  gtk_container_add (GTK_CONTAINER (priv->box), revealer);
+  priv->children = g_list_append (priv->children, widget);
   gtk_widget_show (revealer);
-  gtk_widget_set_parent (revealer, GTK_WIDGET (box));
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
+
   g_print ("add\n");
 }
 
@@ -207,16 +218,8 @@ gtk_hiding_box_forall (GtkContainer *container,
 {
   GtkHidingBox *box = GTK_HIDING_BOX (container);
   GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
-  GtkWidget *child;
-  GList *children;
 
-  children = priv->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-      (* callback) (child, callback_data);
-    }
+  (* callback) (priv->scrolled_window, callback_data);
 }
 
 static void
@@ -418,19 +421,19 @@ idle_update_revealers (GtkHidingBox *box)
   for (l = priv->widgets_to_show; l != NULL; l = l->next)
     {
           g_print ("widget to show %p\n", l->data);
-      gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), TRUE);
+      gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_widget_get_parent (l->data)), TRUE);
     }
 
   for (l = priv->widgets_to_hide; l != NULL; l = l->next)
     {
           g_print ("widget to hide %p\n", l->data);
-      gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), FALSE);
+      gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_widget_get_parent (l->data)), FALSE);
     }
 
   for (l = priv->widgets_to_remove; l != NULL; l = l->next)
     {
           g_print ("widget to remove %p\n", l->data);
-      gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), FALSE);
+      gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_widget_get_parent (l->data)), FALSE);
     }
 }
 
@@ -452,8 +455,27 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
   gint n_visible_children = 0;
   gint n_visible_children_expanding = 0;
   gint children_size = 0;
+  gint minimum_height;
+  gint natural_height;
+
+  gint window_min_width;
+  gint window_nat_width;
+  gint window_min_height;
+  gint window_nat_height;
 
   gtk_widget_set_allocation (widget, allocation);
+
+  update_children_visibility (box, allocation, sizes, FALSE, &children_size,
+                                  &n_visible_children_expanding);
+
+  idle_update_revealers (box);
+
+  child_allocation.x = allocation->x;
+  child_allocation.y = allocation->y;
+  child_allocation.width = allocation->width;
+  child_allocation.height = allocation->height;
+  gtk_widget_size_allocate (priv->scrolled_window, &child_allocation);
+#if 0
   sizes = g_newa (GtkRequestedSize, g_list_length (priv->children));
 
   /*
@@ -511,7 +533,8 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
       else
         child_allocation.width = sizes[i].minimum_size;
 
-      child_allocation.height = allocation->height;
+      gtk_widget_get_preferred_height (child_widget, &minimum_height, &natural_height);
+      child_allocation.height = CLAMP (natural_height, minimum_height, allocation->height);
       if (direction == GTK_TEXT_DIR_RTL)
         child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - 
child_allocation.width;
 
@@ -520,6 +543,7 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
       x += child_allocation.width + spacing;
       ++i;
     }
+#endif
 
   _gtk_widget_set_simple_clip (widget, NULL);
 }
@@ -606,6 +630,15 @@ gtk_hiding_box_init (GtkHidingBox *box)
   GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
 
   gtk_widget_set_has_window (GTK_WIDGET (box), FALSE);
+  priv->adjustment = gtk_adjustment_new (0, 0, 0, 1, 1, 1);
+  priv->scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (priv->scrolled_window,
+                                  GTK_POLICY_ALWAYS,
+                                  GTK_POLICY_NEVER);
+  priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_container_add (GTK_CONTAINER (priv->scrolled_window), priv->box);
+  gtk_widget_set_parent (priv->scrolled_window, GTK_WIDGET (box));
+
   priv->spacing = 0;
   priv->inverted = FALSE;
   priv->widgets_to_hide = NULL;
@@ -613,8 +646,8 @@ gtk_hiding_box_init (GtkHidingBox *box)
   priv->widgets_to_remove = NULL;
   priv->widgets_shown = NULL;
   priv->animation_phase = ANIMATION_PHASE_NONE;
-  priv->current_width = 0;
-  priv->current_height = 0;
+
+  gtk_widget_show_all (priv->scrolled_window);
 }
 
 static void


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