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



commit 719c7b26b051ce538234db21a4959706ff3bd297
Author: Carlos Soriano <csoriano gnome org>
Date:   Wed May 11 17:19:52 2016 +0200

    experiment with revealers

 gtk/Makefile.am                               |    2 +-
 gtk/gtk.h                                     |    1 +
 gtk/gtkbox.c                                  |    5 +
 gtk/gtkgrid.c                                 |    8 ++
 gtk/gtkhidingbox.c                            |  158 +++++++++++++++++++------
 gtk/{gtkhidingboxprivate.h => gtkhidingbox.h} |    6 +-
 gtk/gtkpathbar.c                              |    2 +-
 gtk/gtkpathbarcontainer.c                     |    2 +-
 gtk/gtkrevealer.c                             |    1 +
 tests/Makefile.am                             |    5 +
 tests/testhidingbox.c                         |   66 +++++++++--
 11 files changed, 202 insertions(+), 54 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index d91fbbd..e230d1c 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -489,7 +489,7 @@ gtk_private_h_sources =             \
        gtkgestureswipeprivate.h        \
        gtkgesturezoomprivate.h \
        gtkheaderbarprivate.h   \
-       gtkhidingboxprivate.h   \
+       gtkhidingbox.h  \
        gtkhslaprivate.h        \
        gtkiconcache.h          \
        gtkiconhelperprivate.h  \
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 5e336e7..3fb9c67 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -121,6 +121,7 @@
 #include <gtk/gtkglarea.h>
 #include <gtk/gtkgrid.h>
 #include <gtk/gtkheaderbar.h>
+#include <gtk/gtkhidingbox.h>
 #include <gtk/gtkicontheme.h>
 #include <gtk/gtkiconview.h>
 #include <gtk/gtkimage.h>
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 93206cf..bcf8220 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -479,7 +479,12 @@ count_expand_children (GtkBox *box,
        {
          *visible_children += 1;
          if (child->expand || gtk_widget_compute_expand (child->widget, private->orientation))
+            {
+
+              if (GTK_IS_REVEALER (child->widget))
+                g_print ("########################## IT IS\n");
            *expand_children += 1;
+            }
        }
     }
 }
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index 5fed33f..a7e2c50 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -29,6 +29,7 @@
 #include "gtkcontainerprivate.h"
 #include "gtkcsscustomgadgetprivate.h"
 #include "gtkprivate.h"
+#include "gtkrevealer.h"
 #include "gtkintl.h"
 
 
@@ -1000,7 +1001,12 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
       line = &lines->lines[attach->pos - lines->min];
       line->empty = FALSE;
       if (gtk_widget_compute_expand (child->widget, orientation))
+        {
+
+              if (GTK_IS_REVEALER (child->widget))
+                g_print ("########################## IT IS\n");
         line->expand = TRUE;
+        }
     }
 
   for (list = priv->children; list; list = list->next)
@@ -1030,6 +1036,8 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
 
       if (!has_expand && gtk_widget_compute_expand (child->widget, orientation))
         {
+              if (GTK_IS_REVEALER (child->widget))
+                g_print ("########################## IT IS\n");
           for (i = 0; i < attach->span; i++)
             {
              if (attach->pos + i >= max || attach->pos + 1 < min)
diff --git a/gtk/gtkhidingbox.c b/gtk/gtkhidingbox.c
index ac45efd..12e10d6 100644
--- a/gtk/gtkhidingbox.c
+++ b/gtk/gtkhidingbox.c
@@ -24,12 +24,15 @@
 
 #include "config.h"
 
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
 #include "gtkwidgetprivate.h"
 #include "gtkintl.h"
 #include "gtksizerequest.h"
 #include "gtkbuildable.h"
 #include "gtkrevealer.h"
+#include "gtkadjustment.h"
+#include "gtkscrolledwindow.h"
+#include "gtkbox.h"
 
 #include "glib.h"
 
@@ -53,15 +56,27 @@ struct _GtkHidingBoxPrivate
   gint current_width;
   gint current_height;
   guint needs_update :1;
+
+  GtkWidget *scrolled_window;
+  GtkWidget *box;
+  GtkAdjustment *adjustment;
 };
 
 static void
+gtk_hiding_box_buildable_init (GtkBuildableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_CONTAINER,
+                         G_ADD_PRIVATE (GtkHidingBox)
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_hiding_box_buildable_init))
+
+
+static void
 gtk_hiding_box_buildable_add_child (GtkBuildable *buildable,
                                     GtkBuilder   *builder,
                                     GObject      *child,
                                     const gchar  *type)
 {
-  GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+  GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (buildable);
 
   if (!type)
     {
@@ -80,10 +95,6 @@ gtk_hiding_box_buildable_init (GtkBuildableIface *iface)
   iface->add_child = gtk_hiding_box_buildable_add_child;
 }
 
-G_DEFINE_TYPE_WITH_CODE (GtkHidingBox, gtk_hiding_box, GTK_TYPE_CONTAINER,
-                         G_ADD_PRIVATE (GtkHidingBox)
-                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_hiding_box_buildable_init))
-
 enum {
   PROP_0,
   PROP_SPACING,
@@ -147,37 +158,49 @@ 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);
-  gtk_widget_set_parent (revealer, GTK_WIDGET (box));
+  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_revealer_set_reveal_child (GTK_REVEALER (revealer), TRUE);
+
+  g_print ("add\n");
 }
 
 static void
-really_remove_child (GtkContainer *container,
-                     GtkWidget    *widget)
+really_remove_child (GObject    *widget,
+                     GParamSpec *pspec,
+                     gpointer    user_data)
 {
   GList *child;
-  GtkHidingBox *box = GTK_HIDING_BOX (container);
+  GtkHidingBox *box = GTK_HIDING_BOX (user_data);
   GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
 
+  g_print ("really remove child %p %s\n", widget, G_OBJECT_TYPE_NAME (widget));
   for (child = priv->children; child != NULL; child = child->next)
     {
-      if (child->data == widget)
+      GtkWidget *revealer;
+
+      revealer = gtk_widget_get_parent (child->data);
+      if (revealer == widget && !gtk_revealer_get_reveal_child (GTK_REVEALER (revealer)))
         {
+          g_print ("############################## INSIDE\n");
           gboolean was_visible = gtk_widget_get_visible (widget) &&
                                  gtk_widget_get_child_visible (widget);
 
-          gtk_widget_unparent (widget);
-          priv->children = g_list_delete_link (priv->children, child);
+          priv->widgets_to_remove = g_list_remove (priv->widgets_to_remove, child->data);
+          gtk_container_remove (priv->box, widget);
 
           if (was_visible)
-            gtk_widget_queue_resize (GTK_WIDGET (container));
+            gtk_widget_queue_resize (GTK_WIDGET (box));
 
           break;
         }
     }
-
 }
 
 static void
@@ -187,8 +210,16 @@ gtk_hiding_box_remove (GtkContainer *container,
   GList *child;
   GtkHidingBox *box = GTK_HIDING_BOX (container);
   GtkHidingBoxPrivate *priv = gtk_hiding_box_get_instance_private (box);
+  GtkWidget *to_remove;
 
-  priv->widgets_to_remove = g_list_append (priv->widgets_to_remove, gtk_widget_get_parent (widget));
+  g_print ("remove %p %s\n", widget, G_OBJECT_TYPE_NAME (widget));
+  if (GTK_IS_REVEALER (widget) && gtk_widget_get_parent (widget) == priv->box)
+    to_remove = gtk_bin_get_child (widget);
+  else
+    to_remove = widget;
+
+  priv->widgets_to_remove = g_list_append (priv->widgets_to_remove, to_remove);
+  priv->children = g_list_remove (priv->children, to_remove);
   priv->needs_update = TRUE;
   gtk_widget_queue_resize (GTK_WIDGET (container));
 }
@@ -201,16 +232,18 @@ 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;
+  GList *child;
 
-  children = priv->children;
-  while (children)
-    {
-      child = children->data;
-      children = children->next;
-      (* callback) (child, callback_data);
-    }
+  for (child = priv->children; child != NULL; child = child->next)
+    (* callback) (child->data, callback_data);
+
+  if (include_internals)
+  {
+    (* callback) (priv->scrolled_window, callback_data);
+
+    for (child = priv->widgets_to_remove; child != NULL; child = child->next)
+      (* callback) (child->data, callback_data);
+  }
 }
 
 static void
@@ -294,7 +327,9 @@ update_children_visibility (GtkHidingBox     *box,
       if (gtk_widget_get_hexpand (child_widget))
         (n_visible_children_expanding)++;
       (n_visible_children)++;
-      priv->widgets_to_show = g_list_append (priv->widgets_to_show, child_widget);
+
+      if (!g_list_find (priv->widgets_to_remove, child_widget))
+        priv->widgets_to_show = g_list_append (priv->widgets_to_show, child_widget);
     }
 
   for (i = 0; i < n_visible_children; i++)
@@ -408,17 +443,31 @@ idle_update_revealers (GtkHidingBox *box)
 
   for (l = priv->widgets_to_show; l != NULL; l = l->next)
     {
-      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)
     {
-      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)
     {
-      gtk_revealer_set_reveal_child (GTK_REVEALER (l->data), FALSE);
+      GtkRevealer *revealer;
+
+      revealer = GTK_REVEALER (gtk_widget_get_parent (l->data));
+      if (gtk_revealer_get_child_revealed (revealer))
+        {
+          g_print ("widget to remove revealed %p\n", l->data);
+          g_signal_connect (revealer, "notify::child-revealed", (GCallback) really_remove_child, box);
+
+          gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_widget_get_parent (l->data)), FALSE);
+        }
+      else
+        {
+          g_print ("widget to remove NOT revealed %p\n", l->data);
+          really_remove_child (l->data, NULL, box);
+        }
     }
 }
 
@@ -440,9 +489,28 @@ 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);
+
   sizes = g_newa (GtkRequestedSize, g_list_length (priv->children));
+  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
 
   /*
   if (needs_update (box, allocation))
@@ -470,9 +538,6 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
 
 
   /* If there is no visible child, simply return. */
-  if (n_visible_children == 0)
-    return;
-
   direction = gtk_widget_get_direction (widget);
 
   /* Bring children up to allocation width first */
@@ -480,8 +545,7 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
   extra_space = gtk_distribute_natural_allocation (MAX (0, extra_space), n_visible_children, sizes);
 
   /* Distribute extra space on the expanding children */
-  if (n_visible_children > 1)
-    extra_space = extra_space / MAX (1, n_visible_children_expanding);
+  extra_space = extra_space / MAX (1, n_visible_children_expanding);
 
   x = allocation->x;
   for (i = 0, child = priv->children; child != NULL; child = child->next)
@@ -503,7 +567,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;
 
@@ -512,6 +577,7 @@ gtk_hiding_box_size_allocate (GtkWidget     *widget,
       x += child_allocation.width + spacing;
       ++i;
     }
+#endif
 
   _gtk_widget_set_simple_clip (widget, NULL);
 }
@@ -593,11 +659,25 @@ gtk_hiding_box_get_request_mode (GtkWidget *self)
 }
 
 static void
+on_what (gpointer  data,
+         GObject  *where_the_object_was)
+{
+  G_BREAKPOINT ();
+}
+
+static void
 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);
+  priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  g_object_weak_ref (G_OBJECT (priv->box), on_what, NULL);
+  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;
@@ -605,8 +685,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
diff --git a/gtk/gtkhidingboxprivate.h b/gtk/gtkhidingbox.h
similarity index 96%
rename from gtk/gtkhidingboxprivate.h
rename to gtk/gtkhidingbox.h
index b44dc55..e125495 100644
--- a/gtk/gtkhidingboxprivate.h
+++ b/gtk/gtkhidingbox.h
@@ -18,8 +18,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifndef __GTK_HIDING_BOX_PRIVATE_H__
-#define __GTK_HIDING_BOX_PRIVATE_H__
+#ifndef __GTK_HIDING_BOX_H__
+#define __GTK_HIDING_BOX_H__
 
 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
 #error "Only <gtk/gtk.h> can be included directly."
@@ -74,4 +74,4 @@ GDK_AVAILABLE_IN_3_20
 GList             *gtk_hiding_box_get_overflow_children  (GtkHidingBox      *box);
 G_END_DECLS
 
-#endif /* GTK_HIDING_BOX_PRIVATE_H_ */
+#endif /* GTK_HIDING_BOX_H_ */
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index b507c63..a983f10 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -37,7 +37,7 @@
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtktypebuiltins.h"
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
 
 /**
  * SECTION:gtkpathbar
diff --git a/gtk/gtkpathbarcontainer.c b/gtk/gtkpathbarcontainer.c
index 876bfbc..f68d9dc 100644
--- a/gtk/gtkpathbarcontainer.c
+++ b/gtk/gtkpathbarcontainer.c
@@ -25,7 +25,7 @@
 #include "gtkwidget.h"
 #include "gtkmenubutton.h"
 #include "gtksizerequest.h"
-#include "gtkhidingboxprivate.h"
+#include "gtkhidingbox.h"
 #include "gtkwidgetprivate.h"
 #include "glib-object.h"
 
diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c
index b23f66a..45a0bed 100644
--- a/gtk/gtkrevealer.c
+++ b/gtk/gtkrevealer.c
@@ -456,6 +456,7 @@ gtk_revealer_real_size_allocate (GtkWidget     *widget,
 
   g_return_if_fail (allocation != NULL);
 
+  g_print ("revealer allocation %d %d %d %d\n", allocation->height, allocation->width, allocation->x, 
allocation->y);
   gtk_widget_set_allocation (widget, allocation);
   gtk_revealer_get_child_allocation (revealer, allocation, &child_allocation);
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d9308f..3352d9a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -86,6 +86,7 @@ noinst_PROGRAMS =  $(TEST_PROGS)      \
        testgtk                         \
        testheaderbar                   \
        testheightforwidth              \
+       testhidingbox                   \
        testiconview                    \
        testiconview-keynav             \
        testicontheme                   \
@@ -293,6 +294,7 @@ testpixbuf_save_DEPENDENCIES = $(TEST_DEPS)
 testpixbuf_color_DEPENDENCIES = $(TEST_DEPS)
 testpixbuf_scale_DEPENDENCIES = $(TEST_DEPS)
 testpathbar_DEPENDENCIES = $(TEST_DEPS)
+testhidingbox_DEPENDENCIES = $(TEST_DEPS)
 testgmenu_DEPENDENCIES = $(TEST_DEPS)
 testlogout_DEPENDENCIES = $(TEST_DEPS)
 teststack_DEPENDENCIES = $(TEST_DEPS)
@@ -396,6 +398,9 @@ testmenubutton_SOURCES =    \
 testpathbar_SOURCES =          \
        testpathbar.c
 
+testhidingbox_SOURCES =        \
+       testhidingbox.c
+
 testprint_SOURCES =            \
        testprint.c             \
        testprintfileoperation.h \
diff --git a/tests/testhidingbox.c b/tests/testhidingbox.c
index 7093f53..6c99a44 100644
--- a/tests/testhidingbox.c
+++ b/tests/testhidingbox.c
@@ -1,7 +1,8 @@
 #include "config.h"
 #include "glib.h"
 #include <gtk/gtk.h>
-#include <gtk/gtkhidingboxprivate.h>
+
+#define N_BUTTONS 10
 
 static GtkWidget *hiding_box;
 
@@ -17,6 +18,7 @@ static void
 on_button_clicked (GtkWidget *button,
                    gpointer   user_data)
 {
+  g_print ("button clicked\n");
   gtk_container_remove (GTK_CONTAINER (user_data), button);
 }
 
@@ -25,14 +27,45 @@ on_reset_button_clicked (GtkButton *reset_button)
 {
   GtkWidget *button;
 
-  gtk_container_foreach (GTK_CONTAINER (hiding_box), gtk_widget_destroy);
+  gtk_container_foreach (GTK_CONTAINER (hiding_box), gtk_widget_destroy, NULL);
+
+  g_print ("clicked\n");
+  for (int i = 0; i < N_BUTTONS; i++)
+    {
+      g_autofree gchar *label;
+
+      label = g_strdup_printf ("test%d", i, NULL);
+      button = gtk_button_new_with_label (label);
+      g_signal_connect (button, "clicked", (GCallback) on_button_clicked, hiding_box);
+      gtk_container_add (GTK_CONTAINER (hiding_box), button);
+
+    }
+
+  gtk_widget_show_all (hiding_box);
+}
+
+static void
+on_add_button (gint line)
+{
+  g_autofree gchar *label;
+  GtkWidget *button;
+
+  button = gtk_button_new_with_label ("added button");
+  gtk_widget_show (button);
+  g_signal_connect (button, "clicked", (GCallback) on_button_clicked, hiding_box);
+  gtk_container_add (GTK_CONTAINER (hiding_box), button);
+}
+
+static void
+on_remove_button (gint line)
+{
+  GList *children;
+  GList *last;
 
-  button = gtk_button_new_with_label ("test1");
-  g_signal_connect (button, "clicked", on_button_clicked, hiding_box);
-  gtk_container_add (GTK_CONTAINER (hiding_box), );
-  gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test2"));
-  gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test3"));
-  gtk_container_add (GTK_CONTAINER (hiding_box), gtk_button_new_with_label ("test4"));
+  children = gtk_container_get_children (hiding_box);
+  last = g_list_last (children);
+  if (last)
+    gtk_container_remove (hiding_box, GTK_WIDGET (last->data));
 }
 
 int
@@ -41,6 +74,8 @@ main (int argc, char *argv[])
   GtkWidget *window;
   GtkWidget *grid;
   GtkWidget *reset_button;
+  GtkWidget *add_button;
+  GtkWidget *remove_button;
   GtkWidget *label;
   GFile *file = NULL;
   GIcon *icon;
@@ -63,8 +98,21 @@ main (int argc, char *argv[])
   gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 2, 1);
 
   /* ----------------------------------------------------------------------- */
-  hiding_box = gtk_hiding_box ();
+  hiding_box = gtk_hiding_box_new ();
+  gtk_grid_attach (GTK_GRID (grid), hiding_box, 0, 1, 1, 1);
+  gtk_widget_show_all (hiding_box);
+  /* Add/Remove buttons */
   gtk_grid_attach (GTK_GRID (grid), hiding_box, 0, 1, 1, 1);
+  add_button = gtk_button_new_with_label ("Add");
+  gtk_widget_set_halign (add_button, GTK_ALIGN_END);
+  remove_button = gtk_button_new_with_label ("Remove");
+  gtk_widget_set_halign (remove_button, GTK_ALIGN_END);
+  gtk_grid_attach_next_to (GTK_GRID (grid), add_button, hiding_box, GTK_POS_RIGHT, 1, 1);
+  g_signal_connect_swapped (add_button, "clicked", (GCallback) on_add_button, GINT_TO_POINTER (0));
+  gtk_grid_attach_next_to (GTK_GRID (grid), remove_button, add_button, GTK_POS_RIGHT, 1, 1);
+  g_signal_connect_swapped (remove_button, "clicked", (GCallback) on_remove_button, GINT_TO_POINTER (0));
+  gtk_widget_show (add_button);
+  gtk_widget_show (remove_button);
 
   /* Reset button */
   reset_button = gtk_button_new_with_label ("Reset State");


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