summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tvb@src.gnome.org>2007-07-23 20:29:15 +0000
committerTristan Van Berkom <tvb@src.gnome.org>2007-07-23 20:29:15 +0000
commit4d4131334fec993fc993c66f9e45d44a56455464 (patch)
tree61b322a0f16bc3080f5e1352fd5b61ee66addab7
parent79910092a23a2ce37ccf1739c4be0cf6a37bdebc (diff)
downloadglade-4d4131334fec993fc993c66f9e45d44a56455464.tar.gz
- Fixed order in which we setup packing actions when adding/replacing
* gladeui/glade-widget.[ch]: - Fixed order in which we setup packing actions when adding/replacing widgets in * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: - Added a "Remove Slot" packing action to delete placeholders from GtkBox (bug 387963) svn path=/trunk/; revision=1504
-rw-r--r--ChangeLog17
-rw-r--r--gladeui/glade-widget.c32
-rw-r--r--plugins/gtk+/glade-gtk.c80
-rw-r--r--plugins/gtk+/gtk+.xml.in2
4 files changed, 98 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ea8b380..6e2aaf56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,19 @@
2006-07-23 Tristan Van Berkom <tvb@gnome.org>
- * gladeui/glade-widget.[ch]: Adding convenience funcs that help with
- debugging property values in plugins: glade_widget_property_string(),
- glade_widget_pack_property_string().
+ * gladeui/glade-widget.[ch]:
+ - Adding convenience funcs that help with debugging property values in plugins:
+ glade_widget_property_string(), glade_widget_pack_property_string().
+ - Fixed order in which we setup packing actions when adding/replacing widgets in
+ containers and also commented about how packing properties are different in this
+ regard (this change allowed me to glade_widget_remove_pack_action() from the
+ backend's replace_child/add_child handlers).
* gladeui/glade-popup.c: Added parent options in placeholder context menus.
- * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: Reset label/markup/use-underline
- properties at realize time, this fixes load time glitches with markup
- and mnemonics (bug 396446).
+ * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in:
+ - Reset label/markup/use-underline properties at realize time, this
+ fixes load time glitches with markup and mnemonics (bug 396446).
+ - Added a "Remove Slot" packing action to delete placeholders from GtkBox (bug 387963)
2007-07-20 Vincent Geddes <vgeddes@gnome.org>
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index b7ed8cd1..1433d9f3 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -136,11 +136,28 @@ glade_widget_add_child_impl (GladeWidget *widget,
*/
glade_widget_set_parent (child, widget);
+ /* Set packing actions first so we have access from the plugin
+ */
+ glade_widget_set_packing_actions (child, widget);
+
glade_widget_adaptor_add
(widget->adaptor, widget->object, child->object);
+ /* XXX FIXME:
+ * We have a fundamental flaw here, we set packing props
+ * after parenting the widget so that we can introspect the
+ * values setup by the runtime widget, in which case the plugin
+ * cannot access its packing properties and set them sensitive
+ * or connect to thier signals etc. maybe its not so important
+ * but its a flaw worthy of note, some kind of double pass api
+ * would be needed to accomadate this.
+ */
+
+
+ /* Setup packing properties here so we can introspect the new
+ * values from the backend.
+ */
glade_widget_set_packing_properties (child, widget);
- glade_widget_set_packing_actions (child, widget);
}
static void
@@ -159,7 +176,15 @@ glade_widget_replace_child_impl (GladeWidget *widget,
GladeWidget *gnew_widget = glade_widget_get_from_gobject (new_object);
GladeWidget *gold_widget = glade_widget_get_from_gobject (old_object);
- if (gnew_widget) gnew_widget->parent = widget;
+ if (gnew_widget)
+ {
+ gnew_widget->parent = widget;
+
+ /* Set packing actions first so we have access from the plugin
+ */
+ glade_widget_set_packing_actions (gnew_widget, widget);
+ }
+
if (gold_widget && gold_widget != gnew_widget)
gold_widget->parent = NULL;
@@ -171,10 +196,7 @@ glade_widget_replace_child_impl (GladeWidget *widget,
* values from the backend.
*/
if (gnew_widget)
- {
glade_widget_set_packing_properties (gnew_widget, widget);
- glade_widget_set_packing_actions (gnew_widget, widget);
- }
}
static void
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index aa139e07..99a3278d 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1137,12 +1137,63 @@ glade_gtk_box_add_child (GladeWidgetAdaptor *adaptor,
glade_widget_property_set (gbox, "size", num_children);
gchild = glade_widget_get_from_gobject (child);
+
+ /* The "Remove Slot" operation only makes sence on placeholders,
+ * otherwise its a "Delete" operation on the child widget.
+ */
+ if (gchild)
+ glade_widget_remove_pack_action (gchild, "remove_slot");
/* Packing props arent around when parenting during a glade_widget_dup() */
if (gchild && gchild->packing_properties)
glade_widget_pack_property_set (gchild, "position", num_children - 1);
}
+void
+glade_gtk_box_remove_child (GladeWidgetAdaptor *adaptor,
+ 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));
+
+ if (glade_widget_superuser () == FALSE)
+ {
+ glade_widget_property_get (gbox, "size", &size);
+ glade_widget_property_set (gbox, "size", size);
+ }
+}
+
+
+void
+glade_gtk_box_replace_child (GladeWidgetAdaptor *adaptor,
+ GObject *container,
+ GObject *current,
+ GObject *new_widget)
+{
+ GladeWidget *gchild;
+
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor,
+ container,
+ current,
+ new_widget);
+
+ if ((gchild = glade_widget_get_from_gobject (new_widget)) != NULL)
+ /* The "Remove Slot" operation only makes sence on placeholders,
+ * otherwise its a "Delete" operation on the child widget.
+ */
+ glade_widget_remove_pack_action (gchild, "remove_slot");
+
+}
+
+
GObject *
glade_gtk_box_get_internal_child (GladeWidgetAdaptor *adaptor,
GObject *object,
@@ -1172,28 +1223,6 @@ glade_gtk_box_get_internal_child (GladeWidgetAdaptor *adaptor,
return child;
}
-void
-glade_gtk_box_remove_child (GladeWidgetAdaptor *adaptor,
- 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));
-
- if (glade_widget_superuser () == FALSE)
- {
- glade_widget_property_get (gbox, "size", &size);
- glade_widget_property_set (gbox, "size", size);
- }
-}
-
static void
glade_gtk_box_notebook_child_insert_remove_action (GladeWidgetAdaptor *adaptor,
GObject *container,
@@ -1223,6 +1252,13 @@ glade_gtk_box_child_action_activate (GladeWidgetAdaptor *adaptor,
_("Insert placeholder to %s"),
FALSE, FALSE);
}
+ else if (strcmp (action_path, "remove_slot") == 0)
+ {
+ glade_gtk_box_notebook_child_insert_remove_action (adaptor, container,
+ object, "size",
+ _("Remove placeholder from %s"),
+ TRUE, FALSE);
+ }
else
GWA_GET_CLASS (GTK_TYPE_CONTAINER)->child_action_activate (adaptor,
container,
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 55a5d7e6..784146db 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -217,12 +217,14 @@ embedded in another object</_tooltip>
<verify-function>glade_gtk_box_verify_property</verify-function>
<add-child-function>glade_gtk_box_add_child</add-child-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>
<child-action-activate-function>glade_gtk_box_child_action_activate</child-action-activate-function>
<packing-actions>
<action id="insert_before" _name="Insert Before" stock="gtk-add"/>
<action id="insert_after" _name="Insert After" stock="gtk-add"/>
+ <action id="remove_slot" _name="Remove Slot" stock="gtk-remove"/>
</packing-actions>
<properties>