[glade] GtkBox, GtkGrid: support adding widgets even if there is no placeholder



commit 3b94aec9d8733ab991d22cf447850c2cf6339fdd
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Sep 16 18:54:08 2020 -0300

    GtkBox, GtkGrid: support adding widgets even if there is no placeholder
    
    To make things easier you can always add a widget to a box or grid even if
    there is no more placeholders.
    Adding a widget will automatically increase the box size number or
    the grid column count.
    
    Fix issue #470 "Widgets of type need placeholders to add children"

 plugins/gtk+/glade-gtk-grid.c | 10 ++++++++--
 plugins/gtk+/gtk+.xml         |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/plugins/gtk+/glade-gtk-grid.c b/plugins/gtk+/glade-gtk-grid.c
index 27f069d9..c2094a11 100644
--- a/plugins/gtk+/glade-gtk-grid.c
+++ b/plugins/gtk+/glade-gtk-grid.c
@@ -151,7 +151,7 @@ glade_gtk_grid_refresh_placeholders (GtkGrid *grid,
 }
 
 static void
-glade_gtk_grid_parse_finished (GladeProject *project, GObject *container)
+glade_gtk_grid_refresh_size (GObject *container)
 {
   GladeWidget *gwidget = glade_widget_get_from_gobject (container);
   gint initial_rows = 0, initial_columns = 0;
@@ -193,6 +193,12 @@ glade_gtk_grid_parse_finished (GladeProject *project, GObject *container)
   glade_gtk_grid_refresh_placeholders (GTK_GRID (container), TRUE);
 }
 
+static void
+glade_gtk_grid_parse_finished (GladeProject *project, GObject *container)
+{
+  glade_gtk_grid_refresh_size (container);
+}
+
 void
 glade_gtk_grid_post_create (GladeWidgetAdaptor *adaptor,
                             GObject            *container,
@@ -289,7 +295,7 @@ glade_gtk_grid_add_child (GladeWidgetAdaptor *adaptor,
 
   gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
 
-  glade_gtk_grid_refresh_placeholders (GTK_GRID (object), FALSE);
+  glade_gtk_grid_refresh_size (object);
 }
 
 void
diff --git a/plugins/gtk+/gtk+.xml b/plugins/gtk+/gtk+.xml
index 3c18dbd7..05c9b69b 100644
--- a/plugins/gtk+/gtk+.xml
+++ b/plugins/gtk+/gtk+.xml
@@ -617,6 +617,7 @@
       <get-property-function>glade_gtk_box_get_property</get-property-function>
       <verify-function>glade_gtk_box_verify_property</verify-function>
       <add-child-function>glade_gtk_box_add_child</add-child-function>
+      <add-child-verify-function>gtk_true</add-child-verify-function>
       <remove-child-function>glade_gtk_box_remove_child</remove-child-function>
       <replace-child-function>glade_gtk_box_replace_child</replace-child-function>
       <child-set-property-function>glade_gtk_box_set_child_property</child-set-property-function>
@@ -2240,6 +2241,7 @@
       <child-verify-function>glade_gtk_grid_child_verify_property</child-verify-function>
       <get-children-function>glade_gtk_grid_get_children</get-children-function>
       <add-child-function>glade_gtk_grid_add_child</add-child-function>
+      <add-child-verify-function>gtk_true</add-child-verify-function>
       <remove-child-function>glade_gtk_grid_remove_child</remove-child-function>
       <replace-child-function>glade_gtk_grid_replace_child</replace-child-function>
       <set-property-function>glade_gtk_grid_set_property</set-property-function>


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