[Glade-devel] [patch, glade3] consolidate reparenting
- From: pborelli katamail com (paolo borelli)
- Subject: [Glade-devel] [patch, glade3] consolidate reparenting
- Date: 01 Jun 2003 21:35:17 +0200
--=-ISsgmxIQ40CJ3k8pcPms
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hi!
Thanks to Joaquin for reviwing and applying my previous patches.
The attached patch consolidates in one place widget reparenting:
each time we called project_add_widget we also added the widget to the
list of children of the parent (if present), so it makes sense move the
reparenting into the project_add_widget function.
ciao
paolo
--=-ISsgmxIQ40CJ3k8pcPms
Content-Disposition: attachment; filename=reparent.patch
Content-Type: text/x-patch; name=reparent.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
diff -upr gnome2/glade3/ChangeLog glade3/ChangeLog
--- gnome2/glade3/ChangeLog 2003-06-01 11:15:02.000000000 +0200
+++ glade3/ChangeLog 2003-06-01 21:21:43.000000000 +0200
@@ -1,3 +1,10 @@
+2003-06-01 Paolo Borelli <pborelli katamail com>
+
+ * src/glade-project.[ch]: do reparenting at project_add time.
+ * src/glade-clipboard: update for the above.
+ * src/glade-command.c: ditto.
+ * src/glade-widget.c: ditto.
+
2003-05-31 Joaquin Cuenca Abela <e98cuenc yahoo com>
* src/glade-widget.c: free the resources allocated by a GladeWidget
diff -upr gnome2/glade3/src/glade-clipboard.c glade3/src/glade-clipboard.c
--- gnome2/glade3/src/glade-clipboard.c 2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-clipboard.c 2003-06-01 21:15:26.000000000 +0200
@@ -216,10 +216,7 @@ glade_clipboard_paste (GladeClipboard *c
widget->name = glade_widget_new_name (project, widget->class);
widget->parent = parent;
glade_packing_add_properties (widget);
- glade_project_add_widget (project, widget);
-
- if (parent)
- parent->children = g_list_prepend (parent->children, widget);
+ glade_project_add_widget (project, widget, parent);
glade_widget_set_contents (widget);
glade_widget_connect_signals (widget);
diff -upr gnome2/glade3/src/glade-command.c glade3/src/glade-command.c
--- gnome2/glade3/src/glade-command.c 2003-06-01 11:15:03.000000000 +0200
+++ glade3/src/glade-command.c 2003-06-01 21:08:45.000000000 +0200
@@ -617,11 +618,8 @@ glade_command_create_execute (GladeComma
me->placeholder = NULL;
}
- if (widget->parent)
- widget->parent->children = g_list_prepend (widget->parent->children, widget);
-
glade_project_selection_clear (widget->project, FALSE);
- glade_project_add_widget (widget->project, widget);
+ glade_project_add_widget (widget->project, widget, widget->parent);
if (GTK_IS_WIDGET (widget->widget)) {
glade_project_selection_add (widget, TRUE);
diff -upr gnome2/glade3/src/glade-project.c glade3/src/glade-project.c
--- gnome2/glade3/src/glade-project.c 2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-project.c 2003-06-01 21:03:59.000000000 +0200
@@ -154,35 +154,49 @@ static void
glade_project_add_widget_real (GladeProject *project,
GladeWidget *widget)
{
- GladeWidget *child;
- GList *list;
-
widget->project = project;
- /*
- * Add all the children as well.
- */
- list = widget->children;
- for (; list; list = list->next) {
- child = list->data;
- glade_project_add_widget_real (project, child);
- child->project = project;
- }
-
project->widgets = g_list_prepend (project->widgets, widget);
gtk_signal_emit (GTK_OBJECT (project),
glade_project_signals [ADD_WIDGET], widget);
}
+/**
+ * glade_project_add_widget:
+ * @project: the project the widget is added to
+ * @widget: the GladeWidget to add
+ * @parent: the GladeWidget @widget is reparented to
+ *
+ * Adds a widget to the project. Parent should be NULL for toplevels.
+ **/
void
glade_project_add_widget (GladeProject *project,
- GladeWidget *widget)
+ GladeWidget *widget,
+ GladeWidget *parent)
{
+ GladeWidget *child;
+ GList *list;
+
g_return_if_fail (GLADE_IS_PROJECT (project));
- g_return_if_fail (GTK_IS_OBJECT (project));
+ g_return_if_fail (GLADE_IS_WIDGET (widget));
glade_project_add_widget_real (project, widget);
+
+ /* Add all the children as well */
+ for (list = widget->children; list; list = list->next) {
+ child = list->data;
+ glade_project_add_widget_real (project, child);
+ }
+
+ /* reparent */
+ if (parent) {
+ g_return_if_fail (GLADE_IS_WIDGET (parent));
+
+ widget->parent = parent;
+ parent->children = g_list_prepend (parent->children, widget);
+ }
+
project->changed = TRUE;
}
diff -upr gnome2/glade3/src/glade-project.h glade3/src/glade-project.h
--- gnome2/glade3/src/glade-project.h 2003-05-24 17:41:46.000000000 +0200
+++ glade3/src/glade-project.h 2003-06-01 21:06:11.000000000 +0200
@@ -67,7 +67,8 @@ gboolean glade_project_save (GladeProjec
/* Widget related stuff */
void glade_project_remove_widget (GladeWidget *widget);
void glade_project_add_widget (GladeProject *project,
- GladeWidget *glade_widget);
+ GladeWidget *widget,
+ GladeWidget *parent);
GladeWidget *glade_project_get_widget_by_name (GladeProject *project, const char *name);
char *glade_project_new_widget_name (GladeProject *project, const char *base_name);
diff -upr gnome2/glade3/src/glade-widget.c glade3/src/glade-widget.c
--- gnome2/glade3/src/glade-widget.c 2003-06-01 11:15:04.000000000 +0200
+++ glade3/src/glade-widget.c 2003-06-01 21:14:19.000000000 +0200
@@ -802,13 +802,7 @@ glade_widget_new_full (GladeWidgetClass
glade_packing_add_properties (widget);
glade_widget_create_gtk_widget (widget);
- /*
- glade_project_add_widget (project, widget);
- if (parent)
- parent->children = g_list_prepend (parent->children, widget);
- */
-
glade_widget_set_contents (widget);
glade_widget_connect_signals (widget);
--=-ISsgmxIQ40CJ3k8pcPms--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]