o Reverting the simplification of gtkbox, the regression was that the box

* src/glade-gtk.c, widgets/gtk+.xml.in:
	  o Reverting the simplification of gtkbox, the regression was that the box
	    placeholders were not adjusting properly on undo/redo of create/delete/cut/paste
	    commands.
	  o Fixing GtkFixed/GtkLayout to not call glade_gtk_container_add/remove_child for
	    its children.

	* src/glade-command.c: Slight simplifications made.
This commit is contained in:
Tristan Van Berkom 2006-06-07 18:00:32 +00:00
parent 897c5a14f8
commit 66b079666d
4 changed files with 104 additions and 11 deletions

View File

@ -1,3 +1,14 @@
2006-06-07 Tristan Van Berkom <tvb@gnome.org>
* src/glade-gtk.c, widgets/gtk+.xml.in:
o Reverting the simplification of gtkbox, the regression was that the box
placeholders were not adjusting properly on undo/redo of create/delete/cut/paste
commands.
o Fixing GtkFixed/GtkLayout to not call glade_gtk_container_add/remove_child for
its children.
* src/glade-command.c: Slight simplifications made.
2006-06-06 Tristan Van Berkom <tvb@gnome.org>
* src/glade-command.c: fixed double free in glade_command_add_signal_finalize()

View File

@ -854,14 +854,12 @@ glade_command_create_execute (GladeCommandCreateDelete *me)
}
else
{
glade_widget_set_parent (cdata->widget, cdata->parent);
glade_widget_class_container_add
(cdata->parent->widget_class,
cdata->parent->object,
cdata->widget->object);
glade_widget_set_packing_properties (cdata->widget, cdata->parent);
glade_widget_set_parent (cdata->widget, cdata->parent);
}
/* Now that we've added, apply any packing props if nescisary. */
@ -1251,10 +1249,6 @@ glade_command_paste_execute (GladeCommandCutCopyPaste *me)
(cdata->parent,
G_OBJECT (cdata->placeholder),
cdata->widget->object);
/* Hmmm XXX should we record initial paste
* packing props here ?
*/
}
else if (cdata->parent->manager != NULL)
/* Paste at mouse position only once */
@ -1262,15 +1256,18 @@ glade_command_paste_execute (GladeCommandCutCopyPaste *me)
cdata->props_recorded == FALSE);
else
{
glade_widget_set_parent (cdata->widget,
cdata->parent);
/* glade_widget_set_parent (cdata->widget, */
/* cdata->parent); */
glade_widget_class_container_add
(cdata->parent->widget_class,
cdata->parent->object,
cdata->widget->object);
glade_widget_set_packing_properties (cdata->widget, cdata->parent);
glade_widget_set_parent (cdata->widget,
cdata->parent);
/* glade_widget_set_packing_properties (cdata->widget, cdata->parent); */
}
/* Now that we've added, apply any packing props if nescisary. */
@ -1358,7 +1355,7 @@ glade_command_cut_execute (GladeCommandCutCopyPaste *me)
(cdata->parent,
cdata->widget->object,
G_OBJECT (cdata->placeholder));
else if (cdata->parent->manager != NULL)
else if (cdata->parent->manager != NULL)
glade_fixed_manager_remove_child
(cdata->parent->manager, cdata->widget);
else

View File

@ -198,6 +198,38 @@ glade_gtk_spin_button_set_adjustment (GObject *object, GValue *value)
/* GtkBox */
void GLADEGTK_API
glade_gtk_box_set_child_property (GObject *container,
GObject *child,
const gchar *property_name,
GValue *value)
{
GladeWidget *gbox;
g_return_if_fail (GTK_IS_BOX (container));
g_return_if_fail (GTK_IS_WIDGET (child));
gbox = glade_widget_get_from_gobject (container);
g_return_if_fail (GLADE_IS_WIDGET (gbox));
g_return_if_fail (property_name != NULL || value != NULL);
/* Chain Up */
gtk_container_child_set_property (GTK_CONTAINER (container),
GTK_WIDGET (child),
property_name,
value);
if (strcmp (property_name, "position") == 0)
{
gint position, size;
position = g_value_get_int (value) + 1;
glade_widget_property_get (gbox, "size", &size);
if (size < position)
glade_widget_property_set (gbox, "size", position);
}
}
void GLADEGTK_API
glade_gtk_box_get_size (GObject *object, GValue *value)
{
@ -317,6 +349,25 @@ glade_gtk_box_add_child (GObject *object, GObject *child)
gbox = glade_widget_get_from_gobject (object);
project = glade_widget_get_project (gbox);
/*
Try to remove the last placeholder if any, this way GtkBox`s size
will not be changed.
*/
if (!GLADE_IS_PLACEHOLDER (child))
{
GList *l;
GtkBox *box = GTK_BOX (object);
for (l = g_list_last (box->children); l; l = g_list_previous (l))
{
GtkWidget *child_widget = ((GtkBoxChild *) (l->data))->widget;
if (GLADE_IS_PLACEHOLDER (child_widget))
{
gtk_container_remove (GTK_CONTAINER (box), child_widget);
break;
}
}
}
gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
@ -360,6 +411,22 @@ glade_gtk_box_get_internal_child (GObject *object,
g_list_free (children);
}
void GLADEGTK_API
glade_gtk_box_remove_child (GObject *object, GObject *child)
{
GladeWidget *gbox;
gint size;
g_return_if_fail (GTK_IS_BOX (object));
g_return_if_fail (GTK_IS_WIDGET (child));
gbox = glade_widget_get_from_gobject (object);
gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
glade_widget_property_get (gbox, "size", &size);
glade_widget_property_set (gbox, "size", size);
}
/* GtkToolBar */
void GLADEGTK_API

View File

@ -111,6 +111,8 @@
<child>
<type>GtkWidget</type>
<add-child-function>glade_gtk_box_add_child</add-child-function>
<remove-child-function>glade_gtk_box_remove_child</remove-child-function>
<child-set-property-function>glade_gtk_box_set_child_property</child-set-property-function>
<properties>
<property id="pack-type">
<displayable-values>
@ -987,10 +989,26 @@
<property id="hadjustment" disabled="True"/>
<property id="vadjustment" disabled="True"/>
</properties>
<children>
<!-- This will unset any custom handler defined in the plugin for _add() -->
<child>
<type>GtkWidget</type>
<add-child-function>gtk_container_add</add-child-function>
<remove-child-function>gtk_container_remove</remove-child-function>
</child>
</children>
</glade-widget-class>
<glade-widget-class name="GtkFixed" generic-name="fixed" _title="Fixed">
<post-create-function>glade_gtk_fixed_layout_post_create</post-create-function>
<children>
<!-- This will unset any custom handler defined in the plugin for _add() -->
<child>
<type>GtkWidget</type>
<add-child-function>gtk_container_add</add-child-function>
<remove-child-function>gtk_container_remove</remove-child-function>
</child>
</children>
</glade-widget-class>
<glade-widget-class name="GtkDrawingArea" generic-name="drawingarea" _title="Drawing Area"/>