Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glade3/ChangeLog,v
retrieving revision 1.322.2.3
diff -u -p -r1.322.2.3 ChangeLog
--- ChangeLog	18 Nov 2004 06:25:34 -0000	1.322.2.3
+++ ChangeLog	19 Nov 2004 15:32:54 -0000
@@ -1,3 +1,48 @@
+2004-11-19  Tristan Van Berkom  <tristan.van.berkom@gmail.com>
+
+	* src/glade-catalog.c: pallet_name is no longer "required" in the catalog,
+	  if it is present, then the widget goes in the pallet, if there is a generic
+	  name, it will be used in the case of non-widgets.
+
+	* src/glade-command.c: glade_command_create no longer nescesitates a placeholder
+	  and now has a "parent" argument for the case of (!toplevel && non-widget)
+	  (surrounding code adjusted to work with non-widgets, glade_command_delete stuff
+	  included).
+	
+	* src/glade-editor.c: 
+	    - Widget page is now called General page
+	    - Name field not appended to non-widgets
+
+	* src/glade-gtk.c: GtkFixed code fixed to not needlessly create placeholders
+	  at child create time (go directly to glade_command_create() without passing
+	  go or collecting 200 dollars).
+
+	* src/glade-placeholder.c: Use new glade_command_create ()
+
+	* src/glade-popup.c: 
+	    - Added code needed for addition of non-widgets.
+	    - Added "add_children" arg to glade_popup_widget_pop ()
+	
+	* src/glade-project-view.c:
+	    - fixed bug 145299.
+	    - Added popup code to treeview.
+
+	* src/glade-project-window.c: Fixed some error messages, used new 
+	  glade_command_create()
+
+	* src/glade-property.c: Fixed a bug in rebuilding of widgets
+	  (project list needs to be searched to find out if the widget is
+	  actualy in the project).
+
+	* src/glade-utils.c: glade_utils_draw_nodes_idle(), dont try to draw nodes
+	  on non-widgets.
+
+	* src/glade-widget-class.[ch]: Added glade_widget_class_get_by_type ()
+
+	* src/glade-widget.c: Added glade_widget_sync_packing_props () and
+	  glade_widget_set_parent ().
+	 
+	
 2004-11-16  Tristan Van Berkom  <tristan.van.berkom@gmail.com>
 
 	* Replaced `GtkWidget *' with `GObject *' throughout the code
Index: src/glade-catalog.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-catalog.c,v
retrieving revision 1.22.2.1
diff -u -p -r1.22.2.1 glade-catalog.c
--- src/glade-catalog.c	18 Nov 2004 06:19:21 -0000	1.22.2.1
+++ src/glade-catalog.c	19 Nov 2004 15:32:54 -0000
@@ -124,11 +124,8 @@ glade_catalog_load (const char *base_cat
 
 		/* get the specific library to the widget class, if any */
 		base_widget_class_library = glade_xml_get_property_string (widget_node, "library");
-
 		generic_name = glade_xml_get_property_string (widget_node, "generic_name");
-		palette_name = NULL;
-		if (generic_name != NULL)
-			palette_name = glade_xml_get_property_string_required (widget_node, "palette_name", name);
+		palette_name = glade_xml_get_property_string (widget_node, "palette_name");
 		
 		base_filename = glade_xml_get_property_string (widget_node, "filename");
 
Index: src/glade-command.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-command.c,v
retrieving revision 1.34.2.1
diff -u -p -r1.34.2.1 glade-command.c
--- src/glade-command.c	18 Nov 2004 06:25:34 -0000	1.34.2.1
+++ src/glade-command.c	19 Nov 2004 15:32:54 -0000
@@ -547,11 +547,11 @@ glade_command_set_name (GladeWidget *wid
 typedef struct {
 	GladeCommand parent;
 
-	GladeWidget *widget;
+	GladeWidget      *parent_widget;
+	GladeWidget      *widget;
 	GladePlaceholder *placeholder;
-	gboolean create;
-
-	gulong  handler_id;
+	
+	gboolean          create;
 } GladeCommandCreateDelete;
 
 GLADE_MAKE_COMMAND (GladeCommandCreateDelete, glade_command_create_delete);
@@ -571,13 +571,23 @@ static gboolean
 glade_command_create_execute (GladeCommandCreateDelete *me)
 {
 	GladeWidget      *widget      = me->widget;
+	GladeWidget      *parent      = me->parent_widget;
 	GladePlaceholder *placeholder = me->placeholder;
 
-	if (!GTK_WIDGET_TOPLEVEL (widget->object))
-		glade_widget_replace
-			(glade_placeholder_get_parent (placeholder),
-			 G_OBJECT (placeholder), widget->object);
-
+	if (parent)
+	{
+		if (placeholder)
+			glade_widget_replace
+				(parent, G_OBJECT (placeholder), widget->object);
+		else
+		{
+			glade_widget_class_container_add (parent->widget_class,
+							  parent->object,
+							  widget->object);
+			glade_widget_set_parent (widget, parent);
+		}
+	}
+	
 	glade_project_add_object    (widget->project, widget->object);
 	glade_project_selection_set (widget->project, widget->object, TRUE);
 
@@ -591,22 +601,20 @@ static gboolean
 glade_command_delete_execute (GladeCommandCreateDelete *me)
 {
 	GladeWidget *widget = me->widget;
-	GladeWidget *parent;
+	GladeWidget *parent = me->parent_widget;
 
 	g_return_val_if_fail (widget != NULL, TRUE);
 
 	parent = glade_widget_get_parent (widget);
 	if (parent)
 	{
-		if (me->placeholder == NULL)
-		{
-			me->placeholder = GLADE_PLACEHOLDER (glade_placeholder_new ());
-			g_object_ref (G_OBJECT (me->placeholder));
-		}
-
-		glade_widget_replace
-			(glade_widget_get_parent (widget),
-			 widget->object, G_OBJECT (me->placeholder));
+		if (me->placeholder)
+			glade_widget_replace
+				(parent, widget->object, G_OBJECT (me->placeholder));
+		else
+			glade_widget_class_container_remove (parent->widget_class,
+							     parent->object,
+							     widget->object);
 	}
 
 	if (GTK_IS_WIDGET (widget->object))
@@ -670,9 +678,10 @@ glade_command_create_delete_collapse (Gl
  * Placeholder arg may be NULL for toplevel widgets
  */
 static void
-glade_command_create_delete_common (GladeWidget *widget,
+glade_command_create_delete_common (GladeWidget      *widget,
+				    GladeWidget      *parent,
 				    GladePlaceholder *placeholder,
-				    gboolean create)
+				    gboolean          create)
 {
 	GladeCommandCreateDelete *me;
 	GladeCommand *cmd;
@@ -680,10 +689,11 @@ glade_command_create_delete_common (Glad
  	me = g_object_new (GLADE_COMMAND_CREATE_DELETE_TYPE, NULL);
  	cmd = GLADE_COMMAND (me);
 
- 	me->widget       = g_object_ref(widget);
- 	me->create       = create;
-	me->placeholder  = placeholder;
-	cmd->description =
+ 	me->widget        = g_object_ref(widget);
+ 	me->create        = create;
+	me->placeholder   = placeholder;
+	me->parent_widget = parent;
+	cmd->description  =
 		g_strdup_printf (_("%s %s"), create ?
 				 "Create" : "Delete", widget->name);
 	
@@ -709,7 +719,8 @@ glade_command_delete (GladeWidget *widge
 	if (widget->internal)
 		return;
 
-	glade_command_create_delete_common (widget, NULL, FALSE);
+	glade_command_create_delete_common (widget, glade_widget_get_parent (widget),
+					    NULL, FALSE);
 }
 
 /**
@@ -728,28 +739,30 @@ glade_command_delete (GladeWidget *widge
  */
 void
 glade_command_create (GladeWidgetClass *class,
+		      GladeWidget      *parent,
 		      GladePlaceholder *placeholder,
-		      GladeProject *project)
+		      GladeProject     *project)
 {
-	GladeProjectWindow *gpw;
-	GladeWidget *widget;
-	GladeWidget *parent = NULL;
+	GladeProjectWindow *gpw = glade_project_window_get ();
+	GladeWidget        *widget;
 
 	g_return_if_fail (GLADE_IS_WIDGET_CLASS (class));
-	g_return_if_fail (placeholder != NULL || GLADE_IS_PROJECT (project));
 
-	gpw = glade_project_window_get ();
+	/* Need either a parent or a placeholder or a project
+	 */
+	g_return_if_fail (parent      != NULL ||
+			  placeholder != NULL ||
+			  GLADE_IS_PROJECT (project));
+	g_assert         (gpw != NULL);
 	g_return_if_fail (GLADE_IS_PALETTE (gpw->palette));
 
-	/* AFAIK Only GtkWindow and derivaitves can be toplevels. */
-	if (g_type_is_a (class->type, GTK_TYPE_WINDOW) == FALSE)
+	if (g_type_is_a (class->type, GTK_TYPE_WINDOW) == FALSE && !parent)
 	{
-		parent = glade_placeholder_get_parent (placeholder);
-		g_return_if_fail (parent != NULL);
+		g_return_if_fail (placeholder != NULL);
+		g_return_if_fail ((parent = glade_placeholder_get_parent (placeholder)));
+		if (!project) project = parent->project;
 	}
-	
-	if (!project)
-		project = parent->project;
+	g_return_if_fail (project != NULL);
 
 	widget = glade_widget_new (class, project);
 
@@ -757,7 +770,7 @@ glade_command_create (GladeWidgetClass *
 	if (widget == NULL)
 		return;
 
-	glade_command_create_delete_common (widget, placeholder, TRUE);
+	glade_command_create_delete_common (widget, parent, placeholder, TRUE);
 
 	/* reset the palette */
 	glade_palette_unselect_widget (gpw->palette);
Index: src/glade-command.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-command.h,v
retrieving revision 1.11
diff -u -p -r1.11 glade-command.h
--- src/glade-command.h	5 Nov 2004 19:44:21 -0000	1.11
+++ src/glade-command.h	19 Nov 2004 15:32:54 -0000
@@ -48,7 +48,10 @@ void glade_command_set_property		(GladeP
 void glade_command_set_name		(GladeWidget *glade_widget, const gchar *name);
 
 void glade_command_delete		(GladeWidget *glade_widget);
-void glade_command_create		(GladeWidgetClass *widget_class, GladePlaceholder *placeholder, GladeProject *project);
+void glade_command_create		(GladeWidgetClass *widget_class,
+					 GladeWidget      *parent,
+					 GladePlaceholder *placeholder,
+					 GladeProject     *project);
 
 void glade_command_cut			(GladeWidget *glade_widget);
 void glade_command_copy			(GladeWidget *glade_widget);
Index: src/glade-editor.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-editor.c,v
retrieving revision 1.61.2.1
diff -u -p -r1.61.2.1 glade-editor.c
--- src/glade-editor.c	18 Nov 2004 06:25:34 -0000	1.61.2.1
+++ src/glade-editor.c	19 Nov 2004 15:32:54 -0000
@@ -161,12 +161,16 @@ glade_editor_init (GladeEditor *editor)
 {
 	editor->tooltips = gtk_tooltips_new ();
 
-	editor->vbox_widget  = glade_editor_notebook_page (_("Widget"), GTK_WIDGET (editor));
+	editor->vbox_widget  = glade_editor_notebook_page (_("General"), GTK_WIDGET (editor));
 	editor->vbox_packing = glade_editor_notebook_page (_("Packing"), GTK_WIDGET (editor));
 	editor->vbox_common  = glade_editor_notebook_page (_("Common"), GTK_WIDGET (editor));
 	editor->vbox_signals = glade_editor_notebook_page (_("Signals"), GTK_WIDGET (editor));
 	editor->widget_tables = NULL;
 	editor->loading = FALSE;
+
+	/* Common page is removed for non-widgets.
+	 */
+	g_object_ref (G_OBJECT (editor->vbox_common));
 }
 
 /**
@@ -937,7 +941,7 @@ glade_editor_table_append_item (GladeEdi
 }
 
 static void
-glade_editor_table_append_standard_fields (GladeEditorTable *table)
+glade_editor_table_append_name_field (GladeEditorTable *table)
 {
 	GtkWidget *gtk_table;
 	GtkWidget *label;
@@ -957,6 +961,16 @@ glade_editor_table_append_standard_field
 	glade_editor_table_attach (gtk_table, label, 0, table->rows);
 	glade_editor_table_attach (gtk_table, entry, 1, table->rows);
 	table->rows++;
+}
+
+static void
+glade_editor_table_append_class_field (GladeEditorTable *table)
+{
+	GtkWidget *gtk_table;
+	GtkWidget *label;
+	GtkWidget *entry;
+
+	gtk_table = table->table_widget;
 	
 	/* Class */
 	label = gtk_label_new (_("Class :"));
@@ -995,7 +1009,9 @@ glade_editor_table_append_items (GladeEd
 			continue;
 		else if (type == TABLE_TYPE_COMMON && property_class->common == FALSE)
 			continue;
-
+		else if (type == TABLE_TYPE_GENERAL && property_class->common == TRUE)
+			continue;
+		
 		property = glade_editor_table_append_item (table, property_class);
 		if (property != NULL)
 			new_list = g_list_prepend (new_list, property);
@@ -1060,8 +1076,15 @@ glade_editor_table_create (GladeEditor *
 	table->editor = editor;
 	table->glade_widget_class = class;
 	table->type = type;
+
 	if (type == TABLE_TYPE_GENERAL)
-		glade_editor_table_append_standard_fields (table);
+	{
+		if (g_type_is_a (class->type, GTK_TYPE_WIDGET))
+			glade_editor_table_append_name_field (table);
+		
+		glade_editor_table_append_class_field (table);
+	}
+
 	if (!glade_editor_table_append_items (table, class,
 					      &table->properties, type))
 		return NULL;
@@ -1576,8 +1599,9 @@ glade_editor_load_widget (GladeEditor *e
 	editor->loading = TRUE;
 
 	/* Load each GladeEditorProperty */
-	table = glade_editor_get_table_from_class (editor, class, FALSE);
-	gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name);
+	table = glade_editor_get_table_from_class (editor, class, TABLE_TYPE_GENERAL);
+	if (table->name_entry)
+		gtk_entry_set_text (GTK_ENTRY (table->name_entry), widget->name);
 
 	for (list = table->properties; list; list = list->next)
 	{
@@ -1586,7 +1610,7 @@ glade_editor_load_widget (GladeEditor *e
 	}
 
 	/* Load each GladeEditorProperty for the common tab */
-	table = glade_editor_get_table_from_class (editor, class, TRUE);
+	table = glade_editor_get_table_from_class (editor, class, TABLE_TYPE_COMMON);
 	for (list = table->properties; list; list = list->next)
 	{
 		property = list->data;
Index: src/glade-editor.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-editor.h,v
retrieving revision 1.17.2.1
diff -u -p -r1.17.2.1 glade-editor.h
--- src/glade-editor.h	18 Nov 2004 06:25:34 -0000	1.17.2.1
+++ src/glade-editor.h	19 Nov 2004 15:32:54 -0000
@@ -22,7 +22,6 @@ typedef struct _GladeEditorTable     Gla
 typedef struct _GladeEditorProperty  GladeEditorProperty;
 typedef enum   _GladeEditorTableType GladeEditorTableType;
 
-
 enum _GladeEditorTableType
 {
 	TABLE_TYPE_GENERAL,
Index: src/glade-gtk.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-gtk.c,v
retrieving revision 1.60.2.1
diff -u -p -r1.60.2.1 glade-gtk.c
--- src/glade-gtk.c	18 Nov 2004 06:25:34 -0000	1.60.2.1
+++ src/glade-gtk.c	19 Nov 2004 15:32:55 -0000
@@ -79,7 +79,7 @@ glade_gtk_stock_get_type (void)
 			{ 4,   "Close",  "gtk-close"  },
 			{ 0, NULL, NULL }
 		};
-		etype = g_enum_register_static ("GtkTtScrollType", values);
+		etype = g_enum_register_static ("GladeGtkStockType", values);
 	}
 	return etype;
 }
@@ -1047,23 +1047,16 @@ glade_gtk_fixed_button_press (GtkWidget 
 		gpw = glade_project_window_get ();
 		if (gpw->add_class != NULL)
 		{
-			GtkWidget     *placeholder = glade_placeholder_new ();
 			GtkWidget     *new_widget;
 			GladeWidget   *new_gwidget;
+			GladeWidget   *fixed_gwidget;
 			GladeProperty *property;
 			GList         *selection;
 			GValue         value = { 0, };
 
-			/* A widget type is selected in the palette.
-			 * Create a placeholder at the mouse position and
-			 * add a new widget of that type with a default
-			 * size request.
-			 */
-			gtk_fixed_put(GTK_FIXED(widget), placeholder,
-				      (gint)event->x, (gint)event->y);
-
-			glade_command_create (gpw->add_class,
-					      GLADE_PLACEHOLDER(placeholder), NULL);
+			fixed_gwidget = glade_widget_get_from_gobject (widget);
+			
+			glade_command_create (gpw->add_class, fixed_gwidget, NULL, NULL);
 
 			selection = glade_project_selection_get
 				(glade_project_window_get_active_project(gpw));
@@ -1073,6 +1066,16 @@ glade_gtk_fixed_button_press (GtkWidget 
 			
 			g_value_init (&value, G_TYPE_INT);
 
+			property = glade_widget_get_property (new_gwidget, "x");
+			property->enabled = TRUE;
+			g_value_set_int (&value, event->x);
+			glade_property_set (property, &value);
+
+			property = glade_widget_get_property (new_gwidget, "y");
+			property->enabled = TRUE;
+			g_value_set_int (&value, event->y);
+			glade_property_set (property, &value);
+			
 			property = glade_widget_get_property (new_gwidget, "width-request");
 			property->enabled = TRUE;
 			g_value_set_int (&value, FIXED_DEFAULT_CHILD_WIDTH);
@@ -1086,7 +1089,8 @@ glade_gtk_fixed_button_press (GtkWidget 
 			/* We need to resync the editor so that width-request/height-request
 			 * are actualy enabled in the editor
 			 */
-			glade_editor_load_widget (gpw->editor, gpw->editor->loaded_widget);
+			glade_editor_load_widget (gpw->editor, NULL);
+			glade_editor_load_widget (gpw->editor, new_gwidget);
 			
 		}
 		return TRUE;
Index: src/glade-placeholder.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-placeholder.c,v
retrieving revision 1.56.2.1
diff -u -p -r1.56.2.1 glade-placeholder.c
--- src/glade-placeholder.c	18 Nov 2004 06:25:34 -0000	1.56.2.1
+++ src/glade-placeholder.c	19 Nov 2004 15:32:55 -0000
@@ -312,7 +312,7 @@ glade_placeholder_button_press (GtkWidge
 			/* A widget type is selected in the palette.
 			 * Add a new widget of that type.
 			 */
-			glade_command_create (gpw->add_class, placeholder, NULL);
+			glade_command_create (gpw->add_class, NULL, placeholder, NULL);
 		}
 		else
 		{
Index: src/glade-popup.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-popup.c,v
retrieving revision 1.17.2.1
diff -u -p -r1.17.2.1 glade-popup.c
--- src/glade-popup.c	18 Nov 2004 06:25:34 -0000	1.17.2.1
+++ src/glade-popup.c	19 Nov 2004 15:32:55 -0000
@@ -77,10 +77,18 @@ static void
 glade_popup_add_item_cb (GtkMenuItem *item,
 			 GladeWidget *widget)
 {
-	GladeSupportedChild *support =
-		g_object_get_data (G_OBJECT (item), "support");
+	GladeWidgetClass    *class;
+	GladeSupportedChild *support;
 
-	/* XXX finish me !!! */
+	if ((support =
+	     g_object_get_data (G_OBJECT (item), "support")) != NULL)
+	{
+		if ((class =
+		     glade_widget_class_get_by_type (support->type)) != NULL)
+		{
+			glade_command_create (class, widget, NULL, NULL);
+		}
+	}
 }
 
 /*
@@ -225,11 +233,12 @@ glade_popup_create_placeholder_menu (Gla
  * glade_popup_widget_pop:
  * @widget:
  * @event:
+ * @add_children:
  *
  * TODO: write me
  */
 void
-glade_popup_widget_pop (GladeWidget *widget, GdkEventButton *event)
+glade_popup_widget_pop (GladeWidget *widget, GdkEventButton *event, gboolean add_children)
 {
 	GtkWidget *popup_menu;
 	gint button;
@@ -237,7 +246,7 @@ glade_popup_widget_pop (GladeWidget *wid
 
 	g_return_if_fail (GLADE_IS_WIDGET (widget));
 
-	popup_menu = glade_popup_create_menu (widget, TRUE);
+	popup_menu = glade_popup_create_menu (widget, add_children);
 
 	if (event)
 	{
Index: src/glade-popup.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-popup.h,v
retrieving revision 1.3
diff -u -p -r1.3 glade-popup.h
--- src/glade-popup.h	23 Jan 2004 12:05:26 -0000	1.3
+++ src/glade-popup.h	19 Nov 2004 15:32:55 -0000
@@ -4,7 +4,7 @@
 
 G_BEGIN_DECLS
 
-void glade_popup_widget_pop (GladeWidget *widget, GdkEventButton *event);
+void glade_popup_widget_pop (GladeWidget *widget, GdkEventButton *event, gboolean add_children);
 void glade_popup_placeholder_pop (GladePlaceholder *placeholder, GdkEventButton *event);
 
 G_END_DECLS
Index: src/glade-project-view.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project-view.c,v
retrieving revision 1.40.2.1
diff -u -p -r1.40.2.1 glade-project-view.c
--- src/glade-project-view.c	18 Nov 2004 06:25:34 -0000	1.40.2.1
+++ src/glade-project-view.c	19 Nov 2004 15:32:55 -0000
@@ -25,6 +25,7 @@
 #include "glade-project.h"
 #include "glade-widget-class.h"
 #include "glade-project-view.h"
+#include "glade-popup.h"
 
 enum
 {
@@ -129,22 +130,44 @@ glade_project_view_find_iter_by_widget (
 					GladeWidget *findme)
 {
 	GtkTreeIter iter;
-	GtkTreeIter *retval;
 
 	if (!gtk_tree_model_get_iter_root (model, &iter))
 	{
-		g_warning ("Could not find first widget.");
 		return NULL;
 	}
+	return glade_project_view_find_iter (model, &iter, findme);
+}
 
-	retval = glade_project_view_find_iter (model, &iter, findme);
-
-	if (!retval)
-		g_warning ("Could not find iterator for %s\n", findme->name);
+static GList *
+glade_project_view_list_child_iters (GtkTreeStore *model,
+				     GladeWidget  *parent)
+{
+	GList *children, *l, *child_iters = NULL;
 
-	return retval;
+	if ((children = glade_widget_class_container_get_all_children
+	     (parent->widget_class, parent->object)) != NULL)
+	{
+		for (l = children; l && l->data; l = l->next)
+		{
+			GObject     *object = l->data;
+			GladeWidget *gwidget;
+			if ((gwidget = glade_widget_get_from_gobject (object)) != NULL)
+			{
+				GtkTreeIter *iter;
+
+				if ((iter = glade_project_view_find_iter_by_widget
+				     (GTK_TREE_MODEL (model), gwidget)) != NULL)
+				{
+					child_iters = g_list_prepend (child_iters, iter);
+				}
+			}
+		}
+		g_list_free (children);
+	}
+	return g_list_reverse (child_iters);
 }
 
+
 static void
 glade_project_view_widget_name_changed (GladeProjectView *view,
 					GladeWidget *findme)
@@ -178,8 +201,8 @@ glade_project_view_populate_model_real (
 					GtkTreeIter *parent_iter,
 					gboolean add_childs)
 {
-	GList *list;
-	GtkTreeIter iter;
+	GList *children, *list;
+	GtkTreeIter       iter;
 
 	list = g_list_copy (widgets);
 	list = g_list_reverse (list);
@@ -187,28 +210,26 @@ glade_project_view_populate_model_real (
 	{
 		GladeWidget *widget;
 
-		widget = glade_widget_get_from_gobject (list->data);
-		if (widget)
+		if ((widget = glade_widget_get_from_gobject (list->data)) != NULL)
 		{
 			gtk_tree_store_append (model, &iter, parent_iter);
-			gtk_tree_store_set (model, &iter,
-					    WIDGET_COLUMN, widget,
-					    -1);
-		}
+			gtk_tree_store_set (model, &iter, WIDGET_COLUMN, widget, -1);
 
-		if (add_childs && GTK_IS_CONTAINER (list->data))
-		{
-			GList *children;
-			GtkTreeIter *copy = NULL;
+			if (add_childs &&
+			    (children = glade_widget_class_container_get_all_children
+			     (widget->widget_class, widget->object)) != NULL)
+			{
+				GtkTreeIter *copy = NULL;
+
+				copy = gtk_tree_iter_copy (&iter);
+				glade_project_view_populate_model_real
+					(model, children, copy, TRUE);
+				gtk_tree_iter_free (copy);
 
-			copy = gtk_tree_iter_copy (&iter);
-			children = gtk_container_get_children (GTK_CONTAINER (list->data));
-			glade_project_view_populate_model_real (model, children, copy, TRUE);
-			gtk_tree_iter_free (copy);
-			g_list_free (children);
+				g_list_free (children);
+			}
 		}
 	}
-
 	g_list_free (list);
 }
 
@@ -227,7 +248,7 @@ glade_project_view_populate_model (Glade
 	for (list = project->objects; list; list = list->next)
 	{
 		GObject *object = G_OBJECT (list->data);
-		if (GTK_WIDGET_TOPLEVEL (object))
+		if (GTK_IS_WIDGET (object) && GTK_WIDGET_TOPLEVEL (object))
 			toplevels = g_list_append (toplevels, object);
 	}
 
@@ -243,11 +264,12 @@ glade_project_view_add_item (GladeProjec
 			     GladeWidget *widget)
 {
 	GladeWidgetClass *class;
-	GladeWidget *parent;
+	GladeWidget  *parent;
 	GtkTreeStore *model;
-	GtkTreeIter iter;
-	GtkTreeIter *parent_iter = NULL;
-
+	GtkTreeIter   iter;
+	GtkTreeIter  *parent_iter = NULL, *child_iter;
+	GList        *child_iters, *children, *l;
+	
 	g_return_if_fail (widget != NULL);
 
 	class = glade_widget_get_class (widget);
@@ -265,11 +287,25 @@ glade_project_view_add_item (GladeProjec
 	gtk_tree_store_append (model, &iter, parent_iter);
 	gtk_tree_store_set (model, &iter, WIDGET_COLUMN, widget, -1);
 
-	
-	/*
-	  XXX Add find any children and shuffle them around in the tree view.
-	*/
+	/* Remove all children */
+	if ((child_iters = 
+	     glade_project_view_list_child_iters (model, widget)) != NULL)
+	{
+		for (l = child_iters; l && l->data; l = l->next)
+		{
+			child_iter = l->data;
+			gtk_tree_store_remove (model, child_iter);
+		}
+	}
 
+	/* Repopulate these children properly.
+	 */
+	if ((children = glade_widget_class_container_get_all_children
+	     (widget->widget_class, widget->object)) != NULL)
+	{
+		glade_project_view_populate_model_real (model, children, &iter, TRUE);
+		g_list_free (children);
+	}
 	
 	view->updating_selection = TRUE;
 	glade_project_selection_set (widget->project,
@@ -292,8 +328,8 @@ glade_project_view_remove_item (GladePro
 	
 	model = GTK_TREE_MODEL (view->model);
 
-	iter = glade_project_view_find_iter_by_widget (model, widget);
-	gtk_tree_store_remove (view->model, iter);
+	if ((iter = glade_project_view_find_iter_by_widget (model, widget)) != NULL)
+		gtk_tree_store_remove (view->model, iter);
 }      
 
 /**
@@ -430,6 +466,42 @@ glade_project_view_item_activated_cb (Gt
 	}
 }
 
+static gint
+glade_project_view_button_press_cb (GtkWidget        *widget,
+				    GdkEventButton   *event,
+				    GladeProjectView *view)
+{
+	GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+	GtkTreePath *path = NULL;
+
+	if (event->button == 3 &&
+	    event->window == gtk_tree_view_get_bin_window (tree_view))
+	{
+		if (gtk_tree_view_get_path_at_pos
+		    (tree_view, event->x, event->y,
+		     &path, NULL, NULL, NULL) && path != NULL)
+		{
+			GtkTreeIter  iter;
+			GladeWidget *widget = NULL;
+			if (gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model),
+						     &iter, path))
+			{
+				/* Alright, now we can obtain the widget from the iter.
+				 */
+				gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter,
+						    WIDGET_COLUMN, &widget, -1);
+				if (widget != NULL)
+				{
+					glade_popup_widget_pop (widget, event, FALSE);
+				}
+			}
+			gtk_tree_path_free (path);
+		}
+		return TRUE;
+	}
+	return FALSE;
+}
+
 static void
 glade_project_view_cell_function (GtkTreeViewColumn *tree_column,
 				  GtkCellRenderer *cell,
@@ -517,6 +589,9 @@ glade_project_view_init (GladeProjectVie
 			       G_CALLBACK (glade_project_view_selection_changed_cb),
 			       view, NULL, 0);
 
+	g_signal_connect (G_OBJECT (view->tree_view), "button-press-event",
+			  G_CALLBACK (glade_project_view_button_press_cb), view);
+	
 	view->updating_selection = FALSE;
 }
 
Index: src/glade-project-window.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-project-window.c,v
retrieving revision 1.86.2.2
diff -u -p -r1.86.2.2 glade-project-window.c
--- src/glade-project-window.c	18 Nov 2004 06:25:34 -0000	1.86.2.2
+++ src/glade-project-window.c	19 Nov 2004 15:32:55 -0000
@@ -331,7 +331,7 @@ do_close (GladeProjectWindow *gpw, Glade
 	for (list = project->objects; list; list = list->next)
 	{
 		GObject *object = list->data;
-		if (GTK_WIDGET_TOPLEVEL (object))
+		if (GTK_IS_WIDGET (object) && GTK_WIDGET_TOPLEVEL (object))
 			gtk_widget_destroy (GTK_WIDGET(object));
 	}
 
@@ -542,7 +542,7 @@ gpw_palette_button_clicked (GladePalette
 	/* class may be NULL if the selector was pressed */
 	if (class && g_type_is_a (class->type, GTK_TYPE_WINDOW))
 	{
-		glade_command_create (class, NULL, gpw->active_project);
+		glade_command_create (class, NULL, NULL, gpw->active_project);
 		gpw->add_class = NULL;
 	}
 	else
@@ -1317,9 +1317,9 @@ gpw_project_selection_changed_cb (GladeP
 		list = glade_project_selection_get (project);
 		num = g_list_length (list);
 		if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
-			glade_editor_load_widget (gpw->editor,
-						  glade_widget_get_from_gobject
-						  (GTK_WIDGET (list->data)));
+			glade_editor_load_widget
+				(gpw->editor,
+				 glade_widget_get_from_gobject (list->data));
 		else
 			glade_editor_load_widget (gpw->editor, NULL);
 	}
Index: src/glade-property.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-property.c,v
retrieving revision 1.54.2.2
diff -u -p -r1.54.2.2 glade-property.c
--- src/glade-property.c	18 Nov 2004 06:25:34 -0000	1.54.2.2
+++ src/glade-property.c	19 Nov 2004 15:32:55 -0000
@@ -216,8 +216,15 @@ glade_property_sync (GladeProperty *prop
 		 * updating the selection if the widget was selected.
 		 */
 		GList    *selection;
-		gboolean  reselect = FALSE;
-		if (property->widget->project)
+		gboolean  reselect  = FALSE;
+		gboolean  inproject =
+			property->widget->project ?
+			(glade_project_get_widget_by_name
+			 (property->widget->project,
+			  property->widget->name) ? TRUE : FALSE) : FALSE;
+
+		
+		if (inproject)
 		{
 			if ((selection =
 			     glade_project_selection_get (property->widget->project)) != NULL &&
@@ -235,7 +242,7 @@ glade_property_sync (GladeProperty *prop
 
 		glade_widget_rebuild (property->widget);
 
-		if (property->widget->project)
+		if (inproject)
 		{
 			glade_project_add_object (property->widget->project,
 						  glade_widget_get_object (property->widget));
Index: src/glade-utils.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-utils.c,v
retrieving revision 1.35.2.1
diff -u -p -r1.35.2.1 glade-utils.c
--- src/glade-utils.c	18 Nov 2004 06:25:34 -0000	1.35.2.1
+++ src/glade-utils.c	19 Nov 2004 15:32:55 -0000
@@ -712,13 +712,19 @@ glade_util_draw_nodes_idle (GdkWindow *e
 
 	/* Step through all the selected widgets in the project. */
 	for (elem = expose_gwidget->project->selection; elem; elem = elem->next) {
+
 		GtkWidget *sel_widget;
 		GdkWindow *sel_win, *sel_toplevel;
 		gint sel_x, sel_y, x, y, w, h;
 
 		sel_widget = elem->data;
-		sel_win = glade_util_get_window_positioned_in (sel_widget);
 
+		if (!GTK_IS_WIDGET (sel_widget))
+			continue;
+		
+		if ((sel_win = glade_util_get_window_positioned_in (sel_widget)) == NULL)
+			continue;
+		
 		/* Calculate the offset of the selected widget's window
 		   within its toplevel. */
 		glade_util_calculate_window_offset (sel_win, &sel_x, &sel_y,
@@ -776,7 +782,7 @@ glade_util_queue_draw_nodes (GdkWindow *
 
 
 /**
- * glade_util_add_nodes:
+ * glade_util_add_selection:
  * @widget: a #GtkWidget
  *
  * TODO: write me
@@ -791,7 +797,7 @@ glade_util_add_selection (GObject *objec
 }
 
 /**
- * glade_util_remove_nodes:
+ * glade_util_remove_selection:
  * @widget: a #GtkWidget
  *
  * TODO: write me
@@ -810,7 +816,7 @@ glade_util_remove_selection (GObject *ob
 }
 
 /**
- * glade_util_has_nodes:
+ * glade_util_has_selectoin:
  * @widget: a #GtkWidget
  *
  * Returns: %TRUE if @widget has nodes, %FALSE otherwise
Index: src/glade-widget-class.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-widget-class.c,v
retrieving revision 1.65.2.2
diff -u -p -r1.65.2.2 glade-widget-class.c
--- src/glade-widget-class.c	18 Nov 2004 06:25:34 -0000	1.65.2.2
+++ src/glade-widget-class.c	19 Nov 2004 15:32:55 -0000
@@ -244,7 +244,7 @@ glade_widget_class_list_signals (GladeWi
 	g_return_val_if_fail (class->type != 0, NULL);
 
 	type = class->type;
-	while (g_type_is_a (type, GTK_TYPE_OBJECT))
+	while (g_type_is_a (type, G_TYPE_OBJECT))
 	{
 		if (G_TYPE_IS_INSTANTIATABLE (type) || G_TYPE_IS_INTERFACE (type))
 		{
@@ -537,6 +537,34 @@ glade_widget_class_get_by_name (const ch
 		return NULL;
 }
 
+typedef struct
+{
+	GType              type;
+	GladeWidgetClass **class;
+} GladeClassSearchPair;
+
+static void
+search_class_by_type (gchar                *name,
+		      GladeWidgetClass     *class,
+		      GladeClassSearchPair *pair)
+{
+	if (class->type == pair->type)
+		*pair->class = class;
+}
+
+GladeWidgetClass *
+glade_widget_class_get_by_type (GType type)
+{
+	GladeWidgetClass     *class = NULL;
+	GladeClassSearchPair  pair = { type, &class };
+	
+	if (widget_classes != NULL)
+	{
+		g_hash_table_foreach (widget_classes, (GHFunc)search_class_by_type, &pair);
+	}
+	return class;
+}
+
 /**
  * glade_widget_class_merge_properties:
  * @widget_properties: Pointer to the list of properties in the widget.
@@ -832,7 +860,7 @@ glade_widget_class_new (const char *name
 	widget_class->generic_name = generic_name ? g_strdup (generic_name) : NULL;
 	widget_class->palette_name = palette_name ? g_strdup (palette_name) : NULL;
 	widget_class->name = g_strdup (name);
-	widget_class->in_palette = generic_name ? TRUE : FALSE;
+	widget_class->in_palette = palette_name ? TRUE : FALSE;
 
 	widget_class->type = glade_util_get_type_from_name (widget_class->name);
 	if (widget_class->type == 0)
Index: src/glade-widget-class.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-widget-class.h,v
retrieving revision 1.35.2.1
diff -u -p -r1.35.2.1 glade-widget-class.h
--- src/glade-widget-class.h	18 Nov 2004 06:25:34 -0000	1.35.2.1
+++ src/glade-widget-class.h	19 Nov 2004 15:32:55 -0000
@@ -148,6 +148,7 @@ GladeWidgetClass    *glade_widget_class_
 GladeWidgetClass    *glade_widget_class_new_from_node      (GladeXmlNode     *node);
 void                 glade_widget_class_free               (GladeWidgetClass *widget_class);
 GladeWidgetClass    *glade_widget_class_get_by_name        (const char       *name);
+GladeWidgetClass    *glade_widget_class_get_by_type        (GType             type);
 GType 	             glade_widget_class_get_type           (GladeWidgetClass *class);
 void                 glade_widget_class_dump_param_specs   (GladeWidgetClass *class);
 GladePropertyClass  *glade_widget_class_get_property_class (GladeWidgetClass *class,
Index: src/glade-widget.c
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-widget.c,v
retrieving revision 1.122.2.2
diff -u -p -r1.122.2.2 glade-widget.c
--- src/glade-widget.c	18 Nov 2004 06:25:34 -0000	1.122.2.2
+++ src/glade-widget.c	19 Nov 2004 15:32:55 -0000
@@ -346,6 +346,16 @@ glade_widget_sync_custom_props (GladeWid
 }
 
 static void
+glade_widget_sync_packing_props (GladeWidget *widget)
+{
+	GList *l;
+	for (l = widget->packing_properties; l && l->data; l = l->next) {
+		GladeProperty *prop  = GLADE_PROPERTY(l->data);
+		glade_property_sync (prop);
+	}
+}
+
+static void
 glade_widget_copy_props (GladeWidget *widget,
 			 GladeWidget *template)
 {
@@ -1106,7 +1116,7 @@ glade_widget_popup_menu (GtkWidget *widg
 	g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
 	glade_widget = glade_widget_get_from_gobject (widget);
-	glade_popup_widget_pop (glade_widget, NULL);
+	glade_popup_widget_pop (glade_widget, NULL, TRUE);
 
 	return TRUE;
 }
@@ -1212,7 +1222,9 @@ glade_widget_button_press (GtkWidget *wi
 	{
 		/* if it's already selected don't stop default handlers, e.g. toggle button */
 		if (glade_util_has_selection (G_OBJECT(widget)))
+		{
 			return FALSE;
+		}
 
 		glade_project_selection_set (glade_widget->project, G_OBJECT(widget), TRUE);
 
@@ -1553,6 +1565,20 @@ glade_widget_get_parent (GladeWidget *wi
 {
 	g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
 	return widget->parent;
+}
+
+void
+glade_widget_set_parent (GladeWidget *widget,
+			 GladeWidget *parent)
+{
+	GladeWidget *old_parent = widget->parent;
+	widget->parent = parent;
+
+	if (old_parent == NULL ||
+	    old_parent->widget_class->type != parent->widget_class->type)
+		glade_widget_set_packing_properties (widget, parent);
+	else
+		glade_widget_sync_packing_props (widget);
 }
 
 /**
Index: src/glade-widget.h
===================================================================
RCS file: /cvs/gnome/glade3/src/glade-widget.h,v
retrieving revision 1.37.2.2
diff -u -p -r1.37.2.2 glade-widget.h
--- src/glade-widget.h	18 Nov 2004 06:25:34 -0000	1.37.2.2
+++ src/glade-widget.h	19 Nov 2004 15:32:55 -0000
@@ -134,6 +134,8 @@ GladeWidget            *glade_widget_rea
     g_object_get_data (G_OBJECT (w), "GladeWidgetDataTag")
 
 GladeWidget            *glade_widget_get_parent             (GladeWidget      *widget);
+void                    glade_widget_set_parent             (GladeWidget      *widget,
+							     GladeWidget      *parent);
 
 
 G_END_DECLS
