summaryrefslogtreecommitdiff
path: root/gladeui
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-09-17 21:08:28 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-09-18 21:38:15 -0300
commita72c4fca91a5183723bc1558abbc8eed6eef4889 (patch)
treec78bf613f25a1bf75ac7a191ed5a607c0892efb7 /gladeui
parent5781798ea5ad41d79a364fc14dc5974138241679 (diff)
downloadglade-a72c4fca91a5183723bc1558abbc8eed6eef4889.tar.gz
GladePopup: special case add to box/grid
Increase size of grid/box if there is no space to add a widget in the container Fix issue #470 "Widgets of type need placeholders to add children"
Diffstat (limited to 'gladeui')
-rw-r--r--gladeui/glade-popup.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 28621634..6e437793 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -66,12 +66,41 @@ typedef struct {
static void
glade_popup_widget_add_cb (GtkMenuItem *item, RootAddData *data)
{
+ gboolean use_group = FALSE;
+ GObject *parent;
+
g_return_if_fail (data->adaptor != NULL);
- if (glade_command_create (data->adaptor, data->parent,
- data->placeholder, data->project))
+ parent = glade_widget_get_object (data->parent);
+
+ if ((GTK_IS_BOX (parent) || GTK_IS_GRID (parent)) &&
+ glade_util_count_placeholders (data->parent) == 0)
+ {
+ GladeProperty *prop;
+ gint value;
+
+ glade_command_push_group (_("Create %s"),
+ glade_widget_adaptor_get_name (data->adaptor));
+
+ if (GTK_IS_BOX (parent))
+ prop = glade_widget_get_property (data->parent, "size");
+ else
+ prop = glade_widget_get_property (data->parent, "n-columns");
+
+ glade_property_get (prop, &value);
+ glade_command_set_property (prop, ++value);
+ use_group = TRUE;
+ }
+
+ if (glade_command_create (data->adaptor,
+ data->parent,
+ data->placeholder,
+ data->project))
glade_project_set_add_item (data->project, NULL);
+
+ if (use_group)
+ glade_command_pop_group();
}
static void