[glade3/offscreen] First try to make GladeDesignLayout use a GdkOffscreen to render its child instead of acutally packi



commit c7067041b2f9d87cd9ae3ffe52f535d1b82ed506
Author: Juan Pablo Ugarte <jp synctv com>
Date:   Thu Sep 9 14:33:51 2010 -0300

    First try to make GladeDesignLayout use a GdkOffscreen to render its child instead of acutally packing it

 gladeui/glade-app.c            |   14 +--
 gladeui/glade-command.c        |   12 +-
 gladeui/glade-cursor.c         |    3 +-
 gladeui/glade-design-layout.c  |  329 ++++++++++++++++++++--------------------
 gladeui/glade-design-layout.h  |    7 +-
 gladeui/glade-palette.c        |    7 -
 gladeui/glade-popup.c          |    7 +-
 gladeui/glade-property-class.c |    2 +-
 gladeui/glade-property-class.h |    2 +
 gladeui/glade-widget-adaptor.c |  261 +++++++++++++++++++++++++++++++-
 gladeui/glade-widget-adaptor.h |    2 +
 gladeui/glade-widget.c         |  165 +-------------------
 plugins/gtk+/glade-convert.c   |    7 +-
 plugins/gtk+/glade-gtk.c       |   29 +---
 plugins/gtk+/gtk+.xml.in       |    2 +-
 15 files changed, 457 insertions(+), 392 deletions(-)
---
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index 81259b9..88e4126 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -672,23 +672,12 @@ glade_app_config_save ()
 void
 glade_app_set_transient_parent (GtkWindow *parent)
 {
-	GList     *projects, *objects;
 	GladeApp  *app;
 	
 	g_return_if_fail (GTK_IS_WINDOW (parent));
 
 	app = glade_app_get ();
 	app->priv->transient_parent = parent;
-
-	/* Loop over all projects/widgets and set_transient_for the toplevels.
-	 */
-	for (projects = glade_app_get_projects (); /* projects */
-	     projects; projects = projects->next) 
-		for (objects = (GList *) glade_project_get_objects (GLADE_PROJECT (projects->data));  /* widgets */
-		     objects; objects = objects->next)
-			if (GTK_IS_WINDOW (objects->data))
-				gtk_window_set_transient_for
-					(GTK_WINDOW (objects->data), parent);
 }
 
 GtkWindow *
@@ -1004,7 +993,8 @@ glade_app_add_project (GladeProject *project)
 		{
 			GObject *obj = G_OBJECT (node->data);
 
-			if (GTK_IS_WINDOW (obj))
+			if (GTK_IS_WIDGET (obj) &&
+			    gtk_widget_get_has_window (GTK_WIDGET (obj)))
 			{
 				glade_project_selection_set (project, obj, TRUE);
 				glade_widget_show (glade_widget_get_from_gobject (obj));
diff --git a/gladeui/glade-command.c b/gladeui/glade-command.c
index ab4ef03..5c00b31 100644
--- a/gladeui/glade-command.c
+++ b/gladeui/glade-command.c
@@ -997,7 +997,7 @@ glade_command_add (GList            *widgets,
 	 * fix the bugs as they pop up.
 	 */
 	widget = GLADE_WIDGET (widgets->data);
-	if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE)
+	if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
 		me->project = glade_placeholder_get_project (placeholder);
 	else 
 		me->project = glade_app_get_project();
@@ -1023,9 +1023,9 @@ glade_command_add (GList            *widgets,
 		/* Parent */
 		if (parent == NULL)
 			cdata->parent = glade_widget_get_parent (widget);
-		else if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE)
+		else if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
 			cdata->parent = glade_placeholder_get_parent (placeholder);
-		else if (GTK_IS_WINDOW (widget->object) == FALSE)
+		else if (GWA_IS_TOPLEVEL (widget->adaptor) == FALSE)
 			cdata->parent = parent;
 
 		/* Placeholder */
@@ -1896,9 +1896,9 @@ glade_command_paste(GList *widgets, GladeWidget *parent, GladePlaceholder *place
 	
 	g_return_if_fail (widgets != NULL);
 	
-/* 	if (placeholder && GTK_IS_WINDOW (widget->object) == FALSE) */
+/* 	if (placeholder && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
 /* 		target_project = glade_placeholder_get_project (placeholder); */
-/* 	else if (parent && GTK_IS_WINDOW (widget->object) == FALSE) */
+/* 	else if (parent && GWA_IS_TOPLEVEL (widget->adaptor) == FALSE) */
 /* 		target_project = glade_widget_get_project (parent); */
 /* 	else  */
 /* 		target_project = glade_app_get_project(); */
@@ -2439,7 +2439,7 @@ find_format_rejected_object (GObject *object, gpointer fmtptr)
 	      /* ... and widget is a non GtkWidget object */
 	      !GTK_IS_WIDGET (widget->object) ||
 	      /* ... and its a non-window toplevel */
-	      (!widget->parent && !GTK_IS_WINDOW (widget->object) && !widget->internal))))
+	      (!widget->parent && g_strcmp0 (widget->adaptor->name, "GtkWindow") && !widget->internal))))
 		return 0;
 
 	return -1;
diff --git a/gladeui/glade-cursor.c b/gladeui/glade-cursor.c
index 21587b4..a08c00b 100644
--- a/gladeui/glade-cursor.c
+++ b/gladeui/glade-cursor.c
@@ -75,7 +75,8 @@ set_cursor (GdkCursor *gdk_cursor)
 		{
 			GObject *object = list->data;
 
-			if (GTK_IS_WINDOW (object))
+			if (GTK_IS_WIDGET (object) &&
+			    gtk_widget_get_has_window (GTK_WIDGET (object)))
 			{
 				set_cursor_recurse (GTK_WIDGET (object), gdk_cursor);
 			}
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 2163bbb..53e163d 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -66,8 +66,6 @@ enum
 
 struct _GladeDesignLayoutPrivate
 {
-	GdkWindow *event_window;
-	
 	GdkCursor *cursor_resize_bottom;
 	GdkCursor *cursor_resize_right;
 	GdkCursor *cursor_resize_bottom_right;
@@ -83,7 +81,7 @@ struct _GladeDesignLayoutPrivate
 
 static guint              glade_design_layout_signals[LAST_SIGNAL] = {0};
 
-G_DEFINE_TYPE (GladeDesignLayout, glade_design_layout, GTK_TYPE_BIN)
+G_DEFINE_TYPE (GladeDesignLayout, glade_design_layout, GTK_TYPE_EVENT_BOX)
 
 static PointerRegion
 glade_design_layout_get_pointer_region (GladeDesignLayout *layout, gint x, gint y)
@@ -94,7 +92,7 @@ glade_design_layout_get_pointer_region (GladeDesignLayout *layout, gint x, gint
 
 	priv  = GLADE_DESIGN_LAYOUT_GET_PRIVATE (layout);
 
-	gtk_widget_get_allocation (gtk_bin_get_child (GTK_BIN (layout)), &child_allocation);
+	gtk_widget_get_allocation (layout->child, &child_allocation);
 
 	if ((x >= (child_allocation.x + child_allocation.width)) &&
 	    (x < (child_allocation.x + child_allocation.width + OUTLINE_WIDTH)))
@@ -186,13 +184,13 @@ glade_design_layout_leave_notify_event (GtkWidget *widget, GdkEventCrossing *ev)
 	GtkWidget *child;
 	GladeDesignLayoutPrivate *priv;
 
-	if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+	if ((child = GLADE_DESIGN_LAYOUT (widget)->child) == NULL)
 		return FALSE;
 
 	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
 
 	if (priv->activity == ACTIVITY_NONE)
-		gdk_window_set_cursor (priv->event_window, NULL);
+		gdk_window_set_cursor (widget->window, NULL);
 	
 	return FALSE;
 }
@@ -217,6 +215,7 @@ glade_design_layout_update_child (GladeDesignLayout *layout,
 
 	gtk_widget_size_allocate (child, allocation);
 	gtk_widget_queue_resize (GTK_WIDGET (layout));
+//	gtk_window_resize (GTK_WINDOW (child), allocation->width, allocation->height);
 }
 
 
@@ -341,12 +340,12 @@ glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
 	gint                      x, y;
 	gint                      new_width, new_height;
 
-	if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+	if ((child = GLADE_DESIGN_LAYOUT (widget)->child) == NULL)
 		return FALSE;
 	
 	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
 
-	gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
+	gdk_window_get_pointer (widget->window, &x, &y, NULL);
 	
 	child_glade_widget = glade_widget_get_from_gobject (child);
 	gtk_widget_get_allocation (child, &allocation);
@@ -397,18 +396,18 @@ glade_design_layout_motion_notify_event (GtkWidget *widget, GdkEventMotion *ev)
 		region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
 		
 		if (region == REGION_EAST)
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_right);
 		
 		else if (region == REGION_SOUTH)
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom);
 		
 		else if (region == REGION_SOUTH_EAST ||
 			 region == REGION_WEST_OF_SOUTH_EAST ||
 			 region == REGION_NORTH_OF_SOUTH_EAST)
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
 
 		else if (region == REGION_OUTSIDE)
-			gdk_window_set_cursor (priv->event_window, NULL);
+			gdk_window_set_cursor (widget->window, NULL);
 	}
 	
 	return FALSE;
@@ -423,12 +422,12 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
 	GladeDesignLayoutPrivate *priv;
 	gint                      x, y;
 
-	if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+	if ((child = GLADE_DESIGN_LAYOUT (widget)->child) == NULL)
 		return FALSE;
 
 	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
 
-	gdk_window_get_pointer (priv->event_window, &x, &y, NULL);
+	gdk_window_get_pointer (widget->window, &x, &y, NULL);
 	region = glade_design_layout_get_pointer_region (GLADE_DESIGN_LAYOUT (widget), x, y);
 
 	if (((GdkEventButton *) ev)->button == 1) 
@@ -440,27 +439,27 @@ glade_design_layout_button_press_event (GtkWidget *widget, GdkEventButton *ev)
 		if (region == REGION_EAST) 
 		{
 			priv->activity = ACTIVITY_RESIZE_WIDTH;
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_right);
 		} 
 		if (region == REGION_SOUTH) 
 		{
 			priv->activity = ACTIVITY_RESIZE_HEIGHT;
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom);
 		} 
 		if (region == REGION_SOUTH_EAST) 
 		{
 			priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
 		} 
 		if (region == REGION_WEST_OF_SOUTH_EAST) 
 		{
 			priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
 		} 
 		if (region == REGION_NORTH_OF_SOUTH_EAST) 
 		{
 			priv->activity = ACTIVITY_RESIZE_WIDTH_AND_HEIGHT;
-			gdk_window_set_cursor (priv->event_window, priv->cursor_resize_bottom_right);
+			gdk_window_set_cursor (widget->window, priv->cursor_resize_bottom_right);
 		}
 	}
 		
@@ -473,13 +472,13 @@ glade_design_layout_button_release_event (GtkWidget *widget, GdkEventButton *ev)
 	GladeDesignLayoutPrivate *priv;
 	GtkWidget                *child;
 
-	if ((child = gtk_bin_get_child (GTK_BIN (widget))) == NULL)
+	if ((child = GLADE_DESIGN_LAYOUT (widget)->child) == NULL)
 		return FALSE;
 
 	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
 
 	priv->activity = ACTIVITY_NONE;
-	gdk_window_set_cursor (priv->event_window, NULL);
+	gdk_window_set_cursor (widget->window, NULL);
 
 	return FALSE;
 }
@@ -500,7 +499,7 @@ glade_design_layout_size_request (GtkWidget *widget, GtkRequisition *requisition
 	requisition->width = 0;
 	requisition->height = 0;
 
-	child = gtk_bin_get_child (GTK_BIN (widget));
+	child = GLADE_DESIGN_LAYOUT (widget)->child;
 
 	if (child && gtk_widget_get_visible (child))
 	{
@@ -546,25 +545,14 @@ glade_design_layout_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 	gtk_widget_set_allocation (widget, allocation);
 	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-	if (gtk_widget_get_realized (widget))
-	{
-		if (priv->event_window)
-			gdk_window_move_resize (priv->event_window,
-						allocation->x,
-						allocation->y,
-						allocation->width,
-						allocation->height);
-
-	}
-
-	child = gtk_bin_get_child (GTK_BIN (widget));
-
+	child = GLADE_DESIGN_LAYOUT (widget)->child;
+	
 	if (child && gtk_widget_get_visible (child))
 	{
 		gchild = glade_widget_get_from_gobject (child);
 		g_assert (gchild);
 
-		gtk_widget_get_child_requisition (child, &child_requisition);
+		gtk_widget_get_requisition (child, &child_requisition);
 
 		g_object_get (gchild, 
 			      "toplevel-width", &child_width,
@@ -581,120 +569,116 @@ glade_design_layout_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
 		child_allocation.width = child_width - 2 * border_width;
 		child_allocation.height = child_height - 2 * border_width;
 
+		gdk_window_resize (child->window, child_allocation.width, child_allocation.height);
+		
 		gtk_widget_size_allocate (child, &child_allocation);
 	}
 }
 
 static void
-glade_design_layout_map (GtkWidget *widget)
+offscreen_window_to_parent (GdkWindow     *offscreen_window,
+                            double         offscreen_x,
+                            double         offscreen_y,
+                            double        *parent_x,
+                            double        *parent_y,
+                            gpointer    data)
 {
-	GladeDesignLayoutPrivate *priv;
-
-	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
-	if (priv->event_window)
-		gdk_window_show (priv->event_window);
-
-	GTK_WIDGET_CLASS (glade_design_layout_parent_class)->map (widget);
-
+	*parent_x = offscreen_x;
+	*parent_y = offscreen_y;
 }
 
 static void
-glade_design_layout_unmap (GtkWidget *widget)
+offscreen_window_from_parent (GdkWindow     *window,
+                              double         parent_x,
+                              double         parent_y,
+                              double        *offscreen_x,
+                              double        *offscreen_y,
+                              gpointer    data)
 {
-	GladeDesignLayoutPrivate *priv;	
-
-	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
-
-	GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unmap (widget);
-
-	if (priv->event_window)
-		gdk_window_hide (priv->event_window);
+	*offscreen_x = parent_x;
+	*offscreen_y = parent_y;
 }
 
-static void
-glade_design_layout_realize (GtkWidget *widget)
+static GdkWindow *
+pick_offscreen_child (GdkWindow     *offscreen_window,
+                      double         widget_x,
+                      double         widget_y,
+                      GladeDesignLayout *layout)
 {
-	GladeDesignLayoutPrivate *priv;
-	GtkAllocation allocation;
-	GtkStyle *style;
-	GdkWindow *window;
-	GdkWindowAttr attributes;
-	gint attributes_mask;
-	guint border_width;
-
-	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+	GtkAllocation child_area;
+	double x, y;
 
-	gtk_widget_set_realized (widget, TRUE);
-
-	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+	if (layout->child && gtk_widget_get_visible (layout->child))
+	{
+		x = widget_x;
+		y = widget_y;
+g_message ("pick_offscreen_child");
+		child_area = layout->child->allocation;
+
+		if (x >= 0 && x < child_area.width &&
+		    y >= 0 && y < child_area.height)
+			return layout->child->window;
+	}
 
-	gtk_widget_get_allocation (widget, &allocation);
-	attributes.x = allocation.x;
-	attributes.y = allocation.y;
-	attributes.width = allocation.width;
-	attributes.height = allocation.height;
-
-	attributes.window_type = GDK_WINDOW_CHILD;
-	attributes.wclass = GDK_INPUT_ONLY;
-	attributes.event_mask = 
-		gtk_widget_get_events (widget) |
-		GDK_POINTER_MOTION_MASK        |
-		GDK_POINTER_MOTION_HINT_MASK   |
-		GDK_BUTTON_PRESS_MASK          |
-		GDK_BUTTON_RELEASE_MASK        |
-		GDK_EXPOSURE_MASK              |
-		GDK_ENTER_NOTIFY_MASK          |
-		GDK_LEAVE_NOTIFY_MASK;
-	attributes_mask = GDK_WA_X | GDK_WA_Y;
-
-	window = gtk_widget_get_parent_window (widget);
-	gtk_widget_set_window (widget, g_object_ref (window));
-
-	priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
-					     &attributes, attributes_mask);
-	gdk_window_set_user_data (priv->event_window, widget);
-
-	gtk_widget_style_attach (widget);
-	style = gtk_widget_get_style (widget);
-	gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+	return NULL;
 }
 
 static void
-glade_design_layout_unrealize (GtkWidget *widget)
+child_realize (GtkWidget *widget, GtkWidget *parent)
 {
-	GladeDesignLayoutPrivate *priv;
+	GdkWindow *window, *new_window;
+	GdkWindowAttr attributes;
 
-	priv = GLADE_DESIGN_LAYOUT_GET_PRIVATE (widget);
+	window = gtk_widget_get_window (widget);
 
-	if (priv->event_window)
-	{
-		gdk_window_set_user_data (priv->event_window, NULL);
-		gdk_window_destroy (priv->event_window);
-		priv->event_window = NULL;
-	}
+	gdk_drawable_get_size (GDK_DRAWABLE (window),
+	                       &attributes.width,
+	                       &attributes.height);
+
+	attributes.window_type = GDK_WINDOW_OFFSCREEN;
+	attributes.wclass = GDK_INPUT_OUTPUT;
+	attributes.event_mask = gdk_window_get_events (window);
+	attributes.visual = gtk_widget_get_visual (widget);
+	attributes.colormap = gtk_widget_get_colormap (widget);
+	
+	new_window = gdk_window_new (NULL, &attributes, GDK_WA_VISUAL | GDK_WA_COLORMAP);
+	gtk_widget_set_window (widget, new_window);
 
-	GTK_WIDGET_CLASS (glade_design_layout_parent_class)->unrealize (widget);
+	gdk_window_set_user_data (new_window, parent);
 
+	 g_signal_connect (parent->window, "pick-embedded-child",
+	                   G_CALLBACK (pick_offscreen_child), GLADE_DESIGN_LAYOUT (parent));
+	
+	gdk_offscreen_window_set_embedder (widget->window, parent->window);
+	g_signal_connect (widget->window, "to-embedder",
+	                  G_CALLBACK (offscreen_window_to_parent), NULL);
+	g_signal_connect (widget->window, "from-embedder",
+	                  G_CALLBACK (offscreen_window_from_parent), NULL);
+
+	gtk_style_set_background (widget->style, new_window, GTK_STATE_NORMAL);
+	gdk_window_show (new_window);
 }
 
 static void
 glade_design_layout_add (GtkContainer *container, GtkWidget *widget)
 {
 	GladeDesignLayout *layout;
+	GtkWidget *parent;
 
 	layout = GLADE_DESIGN_LAYOUT (container);
+	parent = GTK_WIDGET (container);
 
 	layout->priv->current_size_request->width = 0;
 	layout->priv->current_size_request->height = 0;
-
+	
 	g_signal_connect (G_OBJECT (widget), "size-request", 
 			  G_CALLBACK (child_size_request_handler),
-			  container);
+	                  container);
+	g_signal_connect_after (G_OBJECT (widget), "realize", 
+			  G_CALLBACK (child_realize),
+	                  GTK_WIDGET (container));
 
-	GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->add (container, widget);
-
-	gdk_window_lower (layout->priv->event_window);
+//	GTK_CONTAINER_CLASS (glade_design_layout_parent_class)->add (container, widget);
 }
 
 static void
@@ -771,61 +755,68 @@ draw_frame (GtkWidget *widget,
 static gboolean
 glade_design_layout_expose_event (GtkWidget *widget, GdkEventExpose *ev)
 {
-	GladeDesignLayout *layout;
-	GtkStyle *style;
-	GtkAllocation allocation, child_allocation;
-	GtkWidget *child;
-	GdkWindow *window;
-	gint x, y, w, h;
-	gint border_width;
-	cairo_t *cr;
+	GladeDesignLayout *layout = GLADE_DESIGN_LAYOUT (widget);
 
-	layout = GLADE_DESIGN_LAYOUT (widget);
+	if (ev->window == widget->window)
+	{
+		GtkStyle *style;
+		GtkAllocation allocation;
+		GtkWidget *child;
+		GdkWindow *window;
+		gint x, y, w, h;
+		gint border_width;
+		cairo_t *cr;
 
-	border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+		border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-	window = gtk_widget_get_window (widget);
-	style = gtk_widget_get_style (widget);
-	gtk_widget_get_allocation (widget, &allocation);
+		window = gtk_widget_get_window (widget);
+		style = gtk_widget_get_style (widget);
+		gtk_widget_get_allocation (widget, &allocation);
 
-	child = gtk_bin_get_child (GTK_BIN (widget));
+		child = layout->child;
 
-	cr = gdk_cairo_create (window);
+		cr = gdk_cairo_create (window);
 
-	/* draw a white widget background */
-	glade_utils_cairo_draw_rectangle (cr,
-					  &style->base [gtk_widget_get_state (widget)],
-					  TRUE,
-					  allocation.x + border_width,
-					  allocation.y + border_width,
-					  allocation.width - 2 * border_width,
-					  allocation.height - 2 * border_width);
+		/* draw a white widget background */
+		glade_utils_cairo_draw_rectangle (cr,
+		                                  &style->base [gtk_widget_get_state (widget)],
+		                                  TRUE,
+		                                  allocation.x + border_width,
+		                                  allocation.y + border_width,
+		                                  allocation.width - 2 * border_width,
+		                                  allocation.height - 2 * border_width);
+
+		if (child && gtk_widget_get_visible (child))
+		{
+			GdkPixmap *child_pixmap = gdk_offscreen_window_get_pixmap (child->window);
 
-	if (child && gtk_widget_get_visible (child))
-	{
-		/* draw frame */
-		gtk_widget_get_allocation (child, &child_allocation);
-		x = child_allocation.x - OUTLINE_WIDTH / 2;
-		y = child_allocation.y - OUTLINE_WIDTH / 2;
-		w = child_allocation.width + OUTLINE_WIDTH;
-		h = child_allocation.height + OUTLINE_WIDTH;
-		
-		draw_frame (widget, cr, x, y, w, h);
+			gdk_drawable_get_size (GDK_DRAWABLE (child_pixmap), &w, &h);
 
-		/* draw a filled rectangle in case child does not draw 
-		 * it's own background (a GTK_WIDGET_NO_WINDOW child). */
-		glade_utils_cairo_draw_rectangle (cr,
-						  &style->bg[GTK_STATE_NORMAL],
-						  TRUE,
-						  x + OUTLINE_WIDTH / 2, y + OUTLINE_WIDTH / 2,
-						  w - OUTLINE_WIDTH, h - OUTLINE_WIDTH);
+			x = allocation.x + border_width;
+			y = allocation.y + border_width;
 
-		GTK_WIDGET_CLASS (glade_design_layout_parent_class)->expose_event (widget, ev);
-	}	
+			g_message ("aaaa %d %d %d %d ", x, y, w, h);
 
-	cairo_destroy (cr);
+			gdk_cairo_set_source_pixmap (cr, child_pixmap, 0, 0);
+			cairo_rectangle (cr, x + OUTLINE_WIDTH/2, y + OUTLINE_WIDTH/2, w, h);
+			cairo_paint (cr);
 
-	return TRUE;
+			w += border_width + OUTLINE_WIDTH;
+			h += border_width + OUTLINE_WIDTH;
+
+			/* draw frame */
+			draw_frame (widget, cr, x, y, w, h);
+		}
+
+		cairo_destroy (cr);
+		return TRUE;
+	}
+	else if (ev->window == layout->child->window)
+	{
+		g_message ("ev->window == layout->child->window");
+	}
+
+	return FALSE;
 }
 
 /**
@@ -852,10 +843,10 @@ glade_design_layout_widget_event (GladeDesignLayout *layout,
 	
 	gtk_widget_get_pointer (GTK_WIDGET (layout), &x, &y);
 	gwidget = glade_design_layout_deepest_gwidget_at_position
-		(GTK_CONTAINER (layout), GTK_CONTAINER (layout), x, y);
+		(GTK_CONTAINER (layout->child), GTK_CONTAINER (layout->child), x, y);
 
 	child = glade_design_layout_deepest_widget_at_position 
-		(GTK_CONTAINER (layout), GTK_CONTAINER (layout), x, y);
+		(GTK_CONTAINER (layout->child), GTK_CONTAINER (layout->child), x, y);
 
 	/* First try a placeholder */
 	if (GLADE_IS_PLACEHOLDER (child) && event->type != GDK_EXPOSE)
@@ -901,7 +892,6 @@ glade_design_layout_init (GladeDesignLayout *layout)
 
 	gtk_widget_set_has_window (GTK_WIDGET (layout), FALSE);
 
-	priv->event_window = NULL;
 	priv->activity = ACTIVITY_NONE;
 
 	priv->current_size_request = g_slice_new0 (GtkRequisition);
@@ -914,6 +904,15 @@ glade_design_layout_init (GladeDesignLayout *layout)
 	priv->new_height = -1;
 }
 
+static gboolean
+glade_design_layout_damage (GtkWidget *widget, GdkEventExpose *event)
+{
+
+	gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+
+	return TRUE;
+}
+
 static void
 glade_design_layout_class_init (GladeDesignLayoutClass *klass)
 {
@@ -935,16 +934,18 @@ glade_design_layout_class_init (GladeDesignLayoutClass *klass)
 	widget_class->leave_notify_event    = glade_design_layout_leave_notify_event;
 	widget_class->button_press_event    = glade_design_layout_button_press_event;
 	widget_class->button_release_event  = glade_design_layout_button_release_event;
-	widget_class->realize               = glade_design_layout_realize;
-	widget_class->unrealize             = glade_design_layout_unrealize;
-	widget_class->map                   = glade_design_layout_map;
-	widget_class->unmap                 = glade_design_layout_unmap;
 	widget_class->expose_event          = glade_design_layout_expose_event;
 	widget_class->size_request          = glade_design_layout_size_request;
 	widget_class->size_allocate         = glade_design_layout_size_allocate;
 
 	klass->widget_event          = glade_design_layout_widget_event_impl;
 
+
+	g_signal_override_class_closure (g_signal_lookup ("damage-event", GTK_TYPE_WIDGET),
+	                                 GLADE_TYPE_DESIGN_LAYOUT,
+	                                 g_cclosure_new (G_CALLBACK (glade_design_layout_damage),
+	                                                 NULL, NULL));
+	
 	/**
 	 * GladeDesignLayout::widget-event:
 	 * @glade_design_layout: the #GladeDesignLayout containing the #GladeWidget.
diff --git a/gladeui/glade-design-layout.h b/gladeui/glade-design-layout.h
index 8f3e71b..d2aa783 100644
--- a/gladeui/glade-design-layout.h
+++ b/gladeui/glade-design-layout.h
@@ -48,14 +48,15 @@ enum
 
 struct _GladeDesignLayout
 {
-	GtkBin parent_instance;
-
+	GtkEventBox parent_instance;
+	GtkWidget *child;
+	
 	GladeDesignLayoutPrivate *priv;
 };
 
 struct _GladeDesignLayoutClass
 {
-	GtkBinClass parent_class;
+	GtkEventBoxClass parent_class;
 	gboolean      (*widget_event)        (GladeProject *project,
 					      GladeWidget *gwidget,
 					      GdkEvent *event);
diff --git a/gladeui/glade-palette.c b/gladeui/glade-palette.c
index 805f9ce..d9fcc5c 100644
--- a/gladeui/glade-palette.c
+++ b/gladeui/glade-palette.c
@@ -324,13 +324,6 @@ glade_palette_toggled (GladePalette *palette)
 		 * disabled so no chance of creating a non-window toplevel here
 		 */
 		widget = glade_palette_create_root_widget (palette, adaptor);
-		
-		/* if this is a top level widget set the accel group */
-		if (widget && glade_app_get_accel_group () && GTK_IS_WINDOW (widget->object))
-		{
-			gtk_window_add_accel_group (GTK_WINDOW (widget->object),
-						    glade_app_get_accel_group ());
-		}
 	}
 }
 
diff --git a/gladeui/glade-popup.c b/gladeui/glade-popup.c
index 5c8679f..f6c33ab 100644
--- a/gladeui/glade-popup.c
+++ b/gladeui/glade-popup.c
@@ -498,9 +498,14 @@ glade_popup_create_menu (GladeWidget      *widget,
 	/* paste is placholder specific when the popup is on a placeholder */
 	sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
 	non_window = FALSE;
+
 	for (list = glade_app_get_clipboard ()->selection; list; list = list->next)
-		if (!GTK_IS_WINDOW (GLADE_WIDGET (list->data)->object))
+	{
+		GladeWidget *gwidget = GLADE_WIDGET (list->data);
+		if (!GTK_IS_WIDGET (gwidget->object) ||
+		    !gtk_widget_get_has_window (GTK_WIDGET (gwidget->object)))
 			non_window = TRUE;
+	}
 
 	if (placeholder)
 		glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
diff --git a/gladeui/glade-property-class.c b/gladeui/glade-property-class.c
index 87bf8c9..80cef70 100644
--- a/gladeui/glade-property-class.c
+++ b/gladeui/glade-property-class.c
@@ -200,7 +200,7 @@ glade_property_class_free (GladePropertyClass *property_class)
 }
 
 
-static GValue *
+GValue *
 glade_property_class_get_default_from_spec (GParamSpec *spec)
 {
 	GValue *value;
diff --git a/gladeui/glade-property-class.h b/gladeui/glade-property-class.h
index b2ec3ef..cedeceb 100644
--- a/gladeui/glade-property-class.h
+++ b/gladeui/glade-property-class.h
@@ -278,6 +278,8 @@ gint                glade_property_class_compare                 (GladePropertyC
 								  const GValue       *value2,
 								  GladeProjectFormat  fmt);
 
+GValue             *glade_property_class_get_default_from_spec   (GParamSpec *spec);
+
 G_END_DECLS
 
 #endif /* __GLADE_PROPERTY_CLASS_H__ */
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 70308fc..3458a17 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -346,14 +346,14 @@ gwa_add_signals (GladeWidgetAdaptor *adaptor, GList **signals, GType type)
 }
 
 static GList * 
-gwa_list_signals (GladeWidgetAdaptor *adaptor) 
+gwa_list_signals (GladeWidgetAdaptor *adaptor, GType real_type) 
 {
 	GList *signals = NULL;
 	GType type, parent, *i, *p;
 
-	g_return_val_if_fail (adaptor->type != 0, NULL);
+	g_return_val_if_fail (real_type != 0, NULL);
 
-	for (type = adaptor->type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
+	for (type = real_type; g_type_is_a (type, G_TYPE_OBJECT); type = parent)
 	{
 		parent = g_type_parent (type);
 		
@@ -593,7 +593,7 @@ glade_widget_adaptor_constructor (GType                  type,
 	if ((object_class = g_type_class_ref (adaptor->type)))
 	{
 		/* Build signals & properties */
-		adaptor->signals = gwa_list_signals (adaptor);
+		adaptor->signals = gwa_list_signals (adaptor, adaptor->type);
 
 		gwa_inherit_signals (adaptor);
 		gwa_setup_properties (adaptor, object_class, FALSE);
@@ -744,6 +744,7 @@ glade_widget_adaptor_real_set_property (GObject         *object,
 	case PROP_NAME:
 		/* assume once (construct-only) */
 		adaptor->name = g_value_dup_string (value);
+		adaptor->real_type = g_type_from_name (adaptor->name);
 		break;
 	case PROP_ICON_NAME:
 		/* assume once (construct-only) */
@@ -1855,6 +1856,188 @@ gwa_update_properties_from_node (GladeWidgetAdaptor  *adaptor,
 	}
 }
 
+static GParamSpec *
+pspec_dup (GParamSpec *spec)
+{
+	const gchar *name, *nick, *blurb;
+	GType  spec_type, value_type;
+	GParamSpec *pspec = NULL;
+
+	spec_type = G_PARAM_SPEC_TYPE (spec);
+	value_type = spec->value_type;
+
+	name = g_param_spec_get_name (spec);	
+	nick = g_param_spec_get_nick (spec);
+	blurb = g_param_spec_get_blurb (spec);
+
+	if (spec_type == G_TYPE_PARAM_ENUM   ||
+	    spec_type == G_TYPE_PARAM_FLAGS  ||
+	    spec_type == G_TYPE_PARAM_BOXED  ||
+	    spec_type == G_TYPE_PARAM_OBJECT ||
+	    spec_type == GLADE_TYPE_PARAM_OBJECTS)
+	{
+
+		if (spec_type == G_TYPE_PARAM_ENUM)
+		{
+			GParamSpecEnum *p = (GParamSpecEnum *)spec;
+			pspec = g_param_spec_enum (name, nick, blurb, value_type, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_FLAGS)
+		{
+			GParamSpecFlags *p = (GParamSpecFlags *)spec;
+			pspec = g_param_spec_flags (name, nick, blurb, value_type, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_OBJECT)
+			pspec = g_param_spec_object (name, nick, blurb, value_type, 0);
+		else if (spec_type == GLADE_TYPE_PARAM_OBJECTS)
+			pspec = glade_param_spec_objects (name, nick, blurb, value_type, 0);
+		else
+			pspec = g_param_spec_boxed (name, nick, blurb, value_type, 0);
+	}
+	else if (spec_type == G_TYPE_PARAM_STRING)
+	{
+		GParamSpecString *p = (GParamSpecString *)spec;
+		pspec = g_param_spec_string (name, nick, blurb, p->default_value, 0);
+	}
+	else if (spec_type == G_TYPE_PARAM_BOOLEAN)
+	{
+		GParamSpecBoolean *p = (GParamSpecBoolean *)spec;
+		pspec = g_param_spec_boolean (name, nick, blurb, p->default_value, 0);
+	}
+	else
+	{
+		if (spec_type == G_TYPE_PARAM_CHAR)
+		{
+			GParamSpecChar *p = (GParamSpecChar *)spec;
+			pspec = g_param_spec_char (name, nick, blurb,
+			                           p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_UCHAR)
+		{
+			GParamSpecUChar *p = (GParamSpecUChar *)spec;
+			pspec = g_param_spec_uchar (name, nick, blurb,
+			                            p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_INT)
+		{
+			GParamSpecInt *p = (GParamSpecInt *)spec;
+			pspec = g_param_spec_int (name, nick, blurb,
+			                          p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_UINT)
+		{
+			GParamSpecUInt *p = (GParamSpecUInt *)spec;
+			pspec = g_param_spec_uint (name, nick, blurb,
+			                           p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_LONG)
+		{
+			GParamSpecLong *p = (GParamSpecLong *)spec;
+			pspec = g_param_spec_long (name, nick, blurb,
+			                           p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_ULONG)
+		{
+			GParamSpecULong *p = (GParamSpecULong *)spec;
+			pspec = g_param_spec_ulong (name, nick, blurb,
+			                            p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_INT64)
+		{
+			GParamSpecInt64 *p = (GParamSpecInt64 *)spec;
+			pspec = g_param_spec_int64 (name, nick, blurb,
+			                            p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_UINT64)
+		{
+			GParamSpecUInt64 *p = (GParamSpecUInt64 *)spec;
+			pspec = g_param_spec_uint64 (name, nick, blurb,
+			                             p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_FLOAT)
+		{
+			GParamSpecFloat *p = (GParamSpecFloat *)spec;
+			pspec = g_param_spec_float (name, nick, blurb,
+			                            p->minimum, p->maximum, p->default_value, 0);
+		}
+		else if (spec_type == G_TYPE_PARAM_DOUBLE)
+		{
+			GParamSpecDouble *p = (GParamSpecDouble *)spec;
+			pspec = g_param_spec_float (name, nick, blurb,
+			                            p->minimum, p->maximum, p->default_value, 0);
+		}
+	}
+	return pspec;
+}
+
+static void
+gwa_update_properties_from_type (GladeWidgetAdaptor  *adaptor,
+				 GType                type,
+                                 GList              **properties,
+				 gboolean             is_packing)
+{
+	gpointer object_class = g_type_class_ref (type);
+	GParamSpec **specs = NULL, *spec;
+	guint i, n_specs = 0;
+
+	/* only GtkContainer child propeties can be introspected */
+	if (is_packing && !g_type_is_a (adaptor->type, GTK_TYPE_CONTAINER))
+		return;
+
+	if (is_packing)
+		specs = gtk_container_class_list_child_properties (object_class, &n_specs);
+	else
+		specs = g_object_class_list_properties (object_class, &n_specs);
+
+	for (i = 0; i < n_specs; i++)
+	{
+		GladePropertyClass *property_class;
+		GList *list;
+		
+		/* find the property in our list, if not found append a new property */
+		for (list = *properties; list && list->data; list = list->next)
+		{
+			property_class = GLADE_PROPERTY_CLASS (list->data);
+			if (property_class->id != NULL &&
+			    g_ascii_strcasecmp (specs[i]->name, property_class->id) == 0)
+				break;
+		}
+
+		if (list == NULL && (spec = pspec_dup (specs[i])))
+		{
+			property_class = glade_property_class_new (adaptor);
+			property_class->id = g_strdup (spec->name);
+			
+			property_class->pspec = spec;
+
+			/* Make sure we can tell properties apart by there 
+			 * owning class.
+			 */
+			property_class->pspec->owner_type = adaptor->type;
+
+			/* Disable properties by default since the does not really implement them */
+			property_class->virt = TRUE;
+			property_class->ignore = TRUE;
+
+			property_class->tooltip = g_strdup (g_param_spec_get_blurb (spec));
+			property_class->name = g_strdup (g_param_spec_get_nick (spec));
+			
+			if (property_class->pspec->flags & G_PARAM_CONSTRUCT_ONLY)
+				property_class->construct_only = TRUE;
+
+			property_class->orig_def = glade_property_class_get_default_from_spec (spec);
+
+			property_class->def = glade_property_class_get_default_from_spec (spec);			
+
+			property_class->packing = is_packing;
+
+			*properties = g_list_append (*properties, property_class);
+		}
+	}
+
+	g_free (specs);
+}			 
+
 static void
 gwa_action_update_from_node (GladeWidgetAdaptor *adaptor,
 			     gboolean is_packing,
@@ -2052,9 +2235,10 @@ static GType
 generate_type (const char *name, 
 	       const char *parent_name)
 {
-	GType parent_type;
+	GType parent_type, retval;
 	GTypeQuery query;
 	GTypeInfo *type_info;
+	char *new_name;
 	
 	g_return_val_if_fail (name != NULL, 0);
 	g_return_val_if_fail (parent_name != NULL, 0);
@@ -2064,12 +2248,29 @@ generate_type (const char *name,
 	
 	g_type_query (parent_type, &query);
 	g_return_val_if_fail (query.type != 0, 0);
-	
+
+	/*
+	 * If the type already exist it means we want to use the parent type
+	 * instead of the real one at runtime.
+	 * This is currently used to instantiate GtkWindow as a GtkEventBox
+	 * at runtime.	 
+	 */
+	if (g_type_from_name (name))
+		new_name = g_strdup_printf ("GladeFake%s", name);
+	else
+		new_name = NULL;
+
 	type_info = g_new0 (GTypeInfo, 1);
 	type_info->class_size = query.class_size;
 	type_info->instance_size = query.instance_size;
+		
+	retval = g_type_register_static (parent_type,
+	                                 (new_name) ? new_name : name,
+	                                 type_info, 0);
+
+	g_free (new_name);
 	
-	return g_type_register_static (parent_type, name, type_info, 0);
+	return retval;
 }
 
 
@@ -2130,7 +2331,24 @@ glade_widget_adaptor_from_catalog (GladeCatalog         *catalog,
 	else if ((func_name = glade_xml_get_property_string (class_node, GLADE_TAG_GET_TYPE_FUNCTION)) != NULL)
 		object_type = glade_util_get_type_from_name (func_name, TRUE);
 	else
+	{
+		GType type_iter;
+		
 		object_type = glade_util_get_type_from_name (name, FALSE);
+		
+		for (type_iter = g_type_parent (object_type);
+		     type_iter;
+		     type_iter = g_type_parent (type_iter))
+		{
+			GladeWidgetAdaptor *a = glade_widget_adaptor_get_by_name (g_type_name (type_iter));
+
+			if (a && a->real_type != a->type)
+			{
+				object_type = generate_type (name, g_type_name (a->type));
+				break;
+			}
+		}
+	}
 	
 	if (object_type == 0)
 	{
@@ -2246,6 +2464,22 @@ glade_widget_adaptor_from_catalog (GladeCatalog         *catalog,
 			   name, GLADE_TAG_GENERIC_NAME);
 	}
 
+	/* if adaptor->type (the runtime used by glade) differs from adaptor->name
+	 * (the name specified in the catalog) means we are using the type specified in the
+	 * the parent tag as the runtime and the class already exist.
+	 * So we need to add the properties and signals from the real class
+	 * even though they wont be aplied at runtime.
+	 *//*
+	if (adaptor->type != adaptor->real_type)
+	{
+		adaptor->signals = gwa_list_signals (adaptor, adaptor->real_type);
+		
+		gwa_update_properties_from_type (adaptor, adaptor->real_type,
+		                                 &adaptor->properties, FALSE);
+		gwa_update_properties_from_type (adaptor, adaptor->real_type,
+		                                 &adaptor->packing_props, TRUE);
+	}*/
+	
 	/* Perform a stoopid fallback just incase */
 	if (adaptor->generic_name == NULL)
 		adaptor->generic_name = g_strdup ("widget");
@@ -2647,6 +2881,19 @@ glade_widget_adaptor_construct_object (GladeWidgetAdaptor *adaptor,
 {
 	g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
 
+/*
+	if (g_type_is_a (adaptor->type, GTK_TYPE_WINDOW))
+	{
+		GParameter type = {0, };
+
+		type.name = "type";
+		g_value_init (&type.value, GTK_TYPE_WINDOW_TYPE);
+		g_value_set_enum (&type.value, GTK_WINDOW_OFFSCREEN);
+
+		n_parameters = 1;
+		parameters = &type;
+	}*/
+
 	return GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->construct_object (adaptor, n_parameters, parameters);
 }
 
diff --git a/gladeui/glade-widget-adaptor.h b/gladeui/glade-widget-adaptor.h
index 4d59160..fb3149d 100644
--- a/gladeui/glade-widget-adaptor.h
+++ b/gladeui/glade-widget-adaptor.h
@@ -625,6 +625,8 @@ struct _GladeWidgetAdaptor
 
 	GType        type;         /* GType of the widget */
 
+	GType        real_type;
+	
 	gchar       *name;         /* Name of the widget, for example GtkButton */
 
 
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 15efdbd..b946c95 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -63,8 +63,6 @@ static void         glade_widget_set_adaptor           (GladeWidget           *w
 							GladeWidgetAdaptor    *adaptor);
 static void         glade_widget_set_properties        (GladeWidget           *widget,
 							GList                 *properties);
-static gboolean     glade_window_is_embedded           (GtkWindow *window);
-static gboolean     glade_widget_embed                 (GladeWidget *widget);
 
 enum
 {
@@ -1522,20 +1520,11 @@ glade_widget_dup_internal (GladeWidget *main_target,
 	for (l = gwidget->properties; l; l = l->next)
 		glade_property_load (GLADE_PROPERTY (l->data));
 
-	/* Special case GtkWindow here and ensure the pasted window
-	 * has the same size as the 'Cut' one.
-	 */
-	if (GTK_IS_WINDOW (gwidget->object))
-	{
-		gint width, height;
-		g_assert (GTK_IS_WINDOW (template_widget->object));
-
-		gtk_window_get_size (GTK_WINDOW (template_widget->object), 
-				     &width, &height);
-		gtk_window_resize (GTK_WINDOW (gwidget->object),
-				   width, height);
-	}
-
+	if (GWA_IS_TOPLEVEL (gwidget->adaptor) && GTK_IS_WIDGET (gwidget->object))
+		g_object_set (gwidget, 
+		              "toplevel-width", template_widget->width,
+		              "toplevel-height", template_widget->height,
+		              NULL);
 	return gwidget;
 }
 
@@ -1947,7 +1936,7 @@ glade_widget_add_to_layout (GladeWidget *widget, GtkWidget *layout)
 		gtk_container_remove (GTK_CONTAINER (layout), gtk_bin_get_child (GTK_BIN (layout)));
 
 	gtk_container_add (GTK_CONTAINER (layout), GTK_WIDGET (widget->object));
-
+	GLADE_DESIGN_LAYOUT (layout)->child = GTK_WIDGET (widget->object);
 	gtk_widget_show_all (GTK_WIDGET (widget->object));
 }
 
@@ -1969,12 +1958,6 @@ glade_widget_show (GladeWidget *widget)
 	/* Position window at saved coordinates or in the center */
 	if (GTK_IS_WIDGET (widget->object) && !widget->parent)
 	{
-		if (GTK_IS_WINDOW (widget->object) && !glade_widget_embed (widget))
-		{
-			g_warning ("Unable to embed %s\n", widget->name);
-			return;
-		}
-
 		/* Maybe a property references this widget internally, show that widget instead */
 		if ((property = glade_widget_get_parentless_widget_ref (widget)) != NULL)
 		{
@@ -4231,142 +4214,6 @@ glade_widget_remove_pack_action (GladeWidget *widget, const gchar *action_path)
 	glade_widget_action_lookup (&widget->packing_actions, action_path, TRUE);
 }
 
-/*******************************************************************************
- *                           Toplevel GladeWidget Embedding                    *
- ******************************************************************************
- *
- * Overrides realize() and size_allocate() by signal connection on GtkWindows.
- *
- * This is high crack code and should be replaced by a more robust implementation
- * in GTK+ proper. 
- *
- */
-
-static GQuark
-embedded_window_get_quark ()
-{
-	static GQuark embedded_window_quark = 0;
-
-	if (embedded_window_quark == 0)
-		embedded_window_quark = g_quark_from_string ("GladeEmbedWindow");
-	
-	return embedded_window_quark;
-}
-
-static gboolean
-glade_window_is_embedded (GtkWindow *window)
-{
-	return GPOINTER_TO_INT (g_object_get_qdata ((GObject *) window, embedded_window_get_quark ()));	 
-}
-
-static void
-embedded_window_realize_handler (GtkWidget *widget)
-{
-	GtkAllocation allocation;
-	GtkStyle *style;
-	GdkWindow *window;
-	GdkWindowAttr attributes;
-	gint attributes_mask;
-
-	gtk_widget_set_realized (widget, TRUE);
-
-	attributes.window_type = GDK_WINDOW_CHILD;
-	attributes.wclass = GDK_INPUT_OUTPUT;
-	attributes.visual = gtk_widget_get_visual (widget);
-	attributes.colormap = gtk_widget_get_colormap (widget);
-
-	gtk_widget_get_allocation (widget, &allocation);
-	attributes.x = allocation.x;
-	attributes.y = allocation.y;
-	attributes.width = allocation.width;
-	attributes.height = allocation.height;
-
-	attributes.event_mask = gtk_widget_get_events (widget) |
-				GDK_EXPOSURE_MASK              |
-                                GDK_FOCUS_CHANGE_MASK          |
-			        GDK_KEY_PRESS_MASK             |
-			        GDK_KEY_RELEASE_MASK           |
-			        GDK_ENTER_NOTIFY_MASK          |
-			        GDK_LEAVE_NOTIFY_MASK          |
-				GDK_STRUCTURE_MASK;
-
-	attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
-	/* destroy the previously created window */
-	window = gtk_widget_get_window (widget);
-	if (GDK_IS_WINDOW (window))
-	{
-		gdk_window_hide (window);
-	}
-
-	window = gdk_window_new (gtk_widget_get_parent_window (widget),
-				 &attributes, attributes_mask);
-	gtk_widget_set_window (widget, window);
-
-	gdk_window_enable_synchronized_configure (window);
-
-	gdk_window_set_user_data (window, GTK_WINDOW (widget));
-
-	gtk_widget_style_attach (widget);
-	style = gtk_widget_get_style (widget);
-	gtk_style_set_background (style, window, GTK_STATE_NORMAL);
-}
-
-static void
-embedded_window_size_allocate_handler (GtkWidget *widget)
-{
-	GtkAllocation allocation;
-
-	if (gtk_widget_get_realized (widget))
-	{
-		gtk_widget_get_allocation (widget, &allocation);
-		gdk_window_move_resize (gtk_widget_get_window (widget),
-					allocation.x,
-					allocation.y,
-					allocation.width,
-					allocation.height);
-	}
-}
-
-/**
- * glade_widget_embed:
- * @window: a #GtkWindow
- *
- * Embeds a window by signal connection method
- */
-static gboolean
-glade_widget_embed (GladeWidget *gwidget)
-{
-	GtkWindow *window;
-	GtkWidget *widget;
-	
-	g_return_val_if_fail (GLADE_IS_WIDGET (gwidget), FALSE);
-	g_return_val_if_fail (GTK_IS_WINDOW (gwidget->object), FALSE);
-	
-	window = GTK_WINDOW (gwidget->object);
-	widget = GTK_WIDGET (window);
-	
-	if (glade_window_is_embedded (window)) return TRUE;
-	
-	if (gtk_widget_get_realized (widget)) gtk_widget_unrealize (widget);
-
-	GTK_WIDGET_UNSET_FLAGS (widget, GTK_TOPLEVEL);
-	gtk_container_set_resize_mode (GTK_CONTAINER (window), GTK_RESIZE_PARENT);
-
-	g_signal_connect (window, "realize",
-			  G_CALLBACK (embedded_window_realize_handler), NULL);
-	g_signal_connect (window, "size-allocate",
-			  G_CALLBACK (embedded_window_size_allocate_handler), NULL);
-
-	/* mark window as embedded */
-	g_object_set_qdata (G_OBJECT (window), embedded_window_get_quark (),
-			    GINT_TO_POINTER (TRUE));
-	
-	return TRUE;
-}
-
-
-
 /**
  * glade_widget_create_editor_property:
  * @widget: A #GladeWidget
diff --git a/plugins/gtk+/glade-convert.c b/plugins/gtk+/glade-convert.c
index 6874462..c2c465c 100644
--- a/plugins/gtk+/glade-convert.c
+++ b/plugins/gtk+/glade-convert.c
@@ -796,14 +796,13 @@ convert_menus_finished (GladeProject  *project,
 		if (accel_group == NULL)
 		{
 			GladeWidget *toplevel = glade_widget_get_toplevel (widget);
-
+			GladeProperty *groups_prop;
+			
 			accel_group = glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_ACCEL_GROUP),
 							    NULL, NULL, project);
 
-
-			if (GTK_IS_WINDOW (toplevel->object))
+			if ((groups_prop = glade_widget_get_property (toplevel, "accel-groups")))
 			{
-				GladeProperty *groups_prop = glade_widget_get_property (toplevel, "accel-groups");
 				GList *list = g_list_append (NULL, accel_group->object);
 				glade_command_set_property (groups_prop, list);
 				g_list_free (list);
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 3342e3d..a43c1d8 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -952,7 +952,7 @@ glade_gtk_widget_deep_post_create (GladeWidgetAdaptor *adaptor,
 	
 	glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
 
-	if (GTK_IS_WINDOW (widget) || gwidget->internal)
+	if (GWA_IS_TOPLEVEL (adaptor) || gwidget->internal)
 		glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);
 
 
@@ -5000,29 +5000,6 @@ glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor  *adaptor,
 }
 
 /* ----------------------------- GtkWindow ------------------------------ */
-static gint
-glade_gtk_widget_show_on_delete (GtkWidget *widget,
-				 gpointer   user_data)
-{
-	gtk_widget_show (widget);
-	return TRUE;
-}
-
-void
-glade_gtk_window_deep_post_create (GladeWidgetAdaptor *adaptor,
-				   GObject            *object,
-				   GladeCreateReason   reason)
-{
-	GtkWindow *window = GTK_WINDOW (object);
-
-	g_return_if_fail (GTK_IS_WINDOW (window));
-
-	/* Chain her up first */
-	GWA_GET_CLASS (GTK_TYPE_CONTAINER)->deep_post_create (adaptor, object, reason);
-
-	g_signal_connect (object, "delete-event", G_CALLBACK (glade_gtk_widget_show_on_delete), NULL);
-}
-
 static void
 glade_gtk_window_read_accel_groups (GladeWidget  *widget,
 				    GladeXmlNode *node)
@@ -5601,8 +5578,8 @@ glade_gtk_message_dialog_image_determine_action (GtkMessageDialog *dialog,
 			g_warning ("Setting property to an object outside the project");
 			return MD_IMAGE_ACTION_INVALID;
 		}
-		
-		if (glade_widget_get_parent (*gimage) || GTK_IS_WINDOW (*image))
+
+		if (glade_widget_get_parent (*gimage) || GWA_IS_TOPLEVEL ((*gimage)->adaptor))
 			return MD_IMAGE_ACTION_INVALID;
 
 		return MD_IMAGE_ACTION_SET;
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 4db98cf..5d71b51 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -336,7 +336,6 @@ embedded in another object</_tooltip>
     </glade-widget-class>
     
     <glade-widget-class name="GtkWindow" generic-name="window" _title="Window" toplevel="True" default-width="440" default-height="250">
-      <deep-post-create-function>glade_gtk_window_deep_post_create</deep-post-create-function>
       <read-widget-function>glade_gtk_window_read_widget</read-widget-function>
       <write-widget-function>glade_gtk_window_write_widget</write-widget-function>
 
@@ -393,6 +392,7 @@ embedded in another object</_tooltip>
 	  <displayable-values>
 	    <value id="GTK_WINDOW_TOPLEVEL" _name="Top Level"/>
 	    <value id="GTK_WINDOW_POPUP" _name="Popup"/>
+	    <value id="GTK_WINDOW_OFFSCREEN" _name="Offscreen"/>
 	  </displayable-values>
 	</property>
 	<property id="allow-shrink" disabled="True" />



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]