Author: danw
Date: 2005-03-23 15:44:04 -0500 (Wed, 23 Mar 2005)
New Revision: 42170

Added:
   trunk/stetic/libstetic/Placeholder.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/CommandDescriptor.cs
   trunk/stetic/libstetic/IStetic.cs
   trunk/stetic/libstetic/IWidgetSite.cs
   trunk/stetic/libstetic/ItemGroup.cs
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/WidgetBox.cs
   trunk/stetic/libstetic/WidgetSite.cs
   trunk/stetic/libstetic/WindowSite.cs
   trunk/stetic/libstetic/wrapper/Bin.cs
   trunk/stetic/libstetic/wrapper/Box.cs
   trunk/stetic/libstetic/wrapper/Button.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Dialog.cs
   trunk/stetic/libstetic/wrapper/Expander.cs
   trunk/stetic/libstetic/wrapper/Frame.cs
   trunk/stetic/libstetic/wrapper/Notebook.cs
   trunk/stetic/libstetic/wrapper/Paned.cs
   trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
   trunk/stetic/libstetic/wrapper/Table.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/libstetic/wrapper/Window.cs
   trunk/stetic/stetic/ContextMenu.cs
   trunk/stetic/stetic/Glade.cs
   trunk/stetic/stetic/Project.cs
   trunk/stetic/stetic/ProjectView.cs
   trunk/stetic/stetic/PropertyGrid.cs
Log:
        Split apart placeholders and WidgetSites. This is an intermediate
        step on the road to killing off WidgetSite, and several wrappers
        are broken in this check-in because it doesn't make much sense to
        fix them twice.

        * libstetic/Placeholder.cs: New subclass of WidgetBox to represent
        a placeholder (which can accept drops, but can't actually hold
        widgets).

        * libstetic/WidgetSite.cs: Mostly remove support for empty
        WidgetSites (though not pseudo-occupied ones).

        * libstetic/WidgetBox.cs: Move some stuff here from WidgetSite
        that both WidgetSite and Placeholder will need. Move out some (but
        not all) stuff that they don't both need.

        * libstetic/WindowSite.cs (FocusChangedHandler, FocusChanged):
        make the focus be a WidgetBox rather than an IWidgetSite

        * libstetic/CommandDescriptor.cs: 
        * libstetic/ItemDescriptor.cs: Update commands to take a Widget
        context rather than an IWidgetSite.

        * libstetic/wrapper/Bin.cs: 
        * libstetic/wrapper/Box.cs: 
        * libstetic/wrapper/Dialog.cs: 
        * libstetic/wrapper/Expander.cs: 
        * libstetic/wrapper/Frame.cs: 
        * libstetic/wrapper/Notebook.cs: 
        * libstetic/wrapper/Paned.cs: 
        * libstetic/wrapper/ScrolledWindow.cs: 
        * libstetic/wrapper/Table.cs: 
        * libstetic/wrapper/Window.cs: update for site/placeholder changes

        * libstetic/wrapper/Widget.cs (CreateWidgetSite): Make this take a
        widget to put in the WidgetSite.
        (CreatePlaceholder): like the old CreateWidgetSite, but creates a
        Placeholder.

        * libstetic/wrapper/Container.cs: update for site/placeholder
        changes
        (ReplaceChild): new virtual method to replace one child widget
        with another
        (SiteEmpty): replace the site with a placeholder
        (PlaceholderDrop): replace the placeholder with a WidgetSite
        containing the dropped widget.

        * libstetic/wrapper/Button.cs: update for site/placeholder changes
        (Wrap): fix this so we don't get blank buttons
        (ConstructChild): fix this to work around a maybe-bug in gtk
        2.4.12 and earlier.

        * stetic/*.cs: Misc updates for WidgetSite/Placeholder changes


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/ChangeLog      2005-03-23 20:44:04 UTC (rev 42170)
@@ -1,3 +1,59 @@
+2005-03-23  Dan Winship  <[EMAIL PROTECTED]>
+
+       Split apart placeholders and WidgetSites. This is an intermediate
+       step on the road to killing off WidgetSite, and several wrappers
+       are broken in this check-in because it doesn't make much sense to
+       fix them twice.
+
+       * libstetic/Placeholder.cs: New subclass of WidgetBox to represent
+       a placeholder (which can accept drops, but can't actually hold
+       widgets).
+
+       * libstetic/WidgetSite.cs: Mostly remove support for empty
+       WidgetSites (though not pseudo-occupied ones).
+
+       * libstetic/WidgetBox.cs: Move some stuff here from WidgetSite
+       that both WidgetSite and Placeholder will need. Move out some (but
+       not all) stuff that they don't both need.
+
+       * libstetic/WindowSite.cs (FocusChangedHandler, FocusChanged):
+       make the focus be a WidgetBox rather than an IWidgetSite
+
+       * libstetic/CommandDescriptor.cs: 
+       * libstetic/ItemDescriptor.cs: Update commands to take a Widget
+       context rather than an IWidgetSite.
+
+       * libstetic/wrapper/Bin.cs: 
+       * libstetic/wrapper/Box.cs: 
+       * libstetic/wrapper/Dialog.cs: 
+       * libstetic/wrapper/Expander.cs: 
+       * libstetic/wrapper/Frame.cs: 
+       * libstetic/wrapper/Notebook.cs: 
+       * libstetic/wrapper/Paned.cs: 
+       * libstetic/wrapper/ScrolledWindow.cs: 
+       * libstetic/wrapper/Table.cs: 
+       * libstetic/wrapper/Window.cs: update for site/placeholder changes
+
+       * libstetic/wrapper/Widget.cs (CreateWidgetSite): Make this take a
+       widget to put in the WidgetSite.
+       (CreatePlaceholder): like the old CreateWidgetSite, but creates a
+       Placeholder.
+
+       * libstetic/wrapper/Container.cs: update for site/placeholder
+       changes
+       (ReplaceChild): new virtual method to replace one child widget
+       with another
+       (SiteEmpty): replace the site with a placeholder
+       (PlaceholderDrop): replace the placeholder with a WidgetSite
+       containing the dropped widget.
+
+       * libstetic/wrapper/Button.cs: update for site/placeholder changes
+       (Wrap): fix this so we don't get blank buttons
+       (ConstructChild): fix this to work around a maybe-bug in gtk
+       2.4.12 and earlier.
+
+       * stetic/*.cs: Misc updates for WidgetSite/Placeholder changes
+
 2005-03-21  Dan Winship  <[EMAIL PROTECTED]>
 
        * libstetic/wrapper/Button.cs: Remove "UseStock" property and just

Modified: trunk/stetic/libstetic/CommandDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/CommandDescriptor.cs 2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/CommandDescriptor.cs 2005-03-23 20:44:04 UTC (rev 
42170)
@@ -17,7 +17,7 @@
 
                        name = commandName;
 
-                       doInfo = wrapperType.GetMethod (commandName, flags, 
null, new Type[] { typeof (Stetic.IWidgetSite) }, null);
+                       doInfo = wrapperType.GetMethod (commandName, flags, 
null, new Type[] { typeof (Gtk.Widget) }, null);
                        if (doInfo != null)
                                needsContext = true;
                        else
@@ -29,7 +29,7 @@
                                label = cattr.Name;
                                description = cattr.Description;
                                if (cattr.Checker != null) {
-                                       checkInfo = wrapperType.GetMethod 
(cattr.Checker, flags, null, needsContext ? new Type[] { typeof 
(Stetic.IWidgetSite) } : new Type[0], null);
+                                       checkInfo = wrapperType.GetMethod 
(cattr.Checker, flags, null, needsContext ? new Type[] { typeof (Gtk.Widget) } 
: new Type[0], null);
                                        if (checkInfo == null)
                                                throw new ArgumentException 
("Invalid checker name " + cattr.Checker + " for command " + wrapperType.Name + 
"." + commandName);
                                }
@@ -69,7 +69,7 @@
                                return (bool)checkInfo.Invoke (wrapper, new 
object[0]);
                }
 
-               public bool Enabled (ObjectWrapper wrapper, IWidgetSite context)
+               public bool Enabled (ObjectWrapper wrapper, Gtk.Widget context)
                {
                        if (checkInfo == null)
                                return EnabledFor (wrapper);
@@ -84,7 +84,7 @@
                        doInfo.Invoke (wrapper, new object[0]);
                }
 
-               public void Run (ObjectWrapper wrapper, IWidgetSite context)
+               public void Run (ObjectWrapper wrapper, Gtk.Widget context)
                {
                        if (needsContext)
                                doInfo.Invoke (wrapper, new object[] { context 
});

Modified: trunk/stetic/libstetic/IStetic.cs
===================================================================
--- trunk/stetic/libstetic/IStetic.cs   2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/libstetic/IStetic.cs   2005-03-23 20:44:04 UTC (rev 42170)
@@ -4,7 +4,8 @@
        public delegate void ISteticDelegate ();
 
        public interface IStetic {
-               WidgetSite CreateWidgetSite ();
+               WidgetSite CreateWidgetSite (Gtk.Widget w);
+               Placeholder CreatePlaceholder ();
 
                Gtk.Widget LookupWidgetById (string id);
 

Modified: trunk/stetic/libstetic/IWidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/IWidgetSite.cs       2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/IWidgetSite.cs       2005-03-23 20:44:04 UTC (rev 
42170)
@@ -7,8 +7,6 @@
                Widget Contents { get; }
                IWidgetSite ParentSite { get; }
 
-               bool Occupied { get; }
-
                bool Internal { get; }
 
                void Select ();

Modified: trunk/stetic/libstetic/ItemGroup.cs
===================================================================
--- trunk/stetic/libstetic/ItemGroup.cs 2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/libstetic/ItemGroup.cs 2005-03-23 20:44:04 UTC (rev 42170)
@@ -19,7 +19,7 @@
                                        Items[i] = new PropertyDescriptor 
(wrapperType, objectType, names[i]);
                                else if (wrapperType.GetMethod (names[i], 
flags, null, new Type[0], null) != null)
                                        Items[i] = new CommandDescriptor 
(wrapperType, names[i]);
-                               else if (wrapperType.GetMethod (names[i], 
flags, null, new Type[] { typeof (Stetic.IWidgetSite) }, null) != null)
+                               else if (wrapperType.GetMethod (names[i], 
flags, null, new Type[] { typeof (Gtk.Widget) }, null) != null)
                                        Items[i] = new CommandDescriptor 
(wrapperType, names[i]);
                                else
                                        throw new ApplicationException ("Bad 
item name " + names[i] + " in " + wrapperType.Name);

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/libstetic/Makefile.am  2005-03-23 20:44:04 UTC (rev 42170)
@@ -16,6 +16,7 @@
        ObjectWrapper.cs                \
        ObjectWrapperAttribute.cs       \
        ParamSpec.cs                    \
+       Placeholder.cs                  \
        PropertyDescriptor.cs           \
        PropertyEditorAttribute.cs      \
        RangeAttribute.cs               \

Added: trunk/stetic/libstetic/Placeholder.cs
===================================================================
--- trunk/stetic/libstetic/Placeholder.cs       2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/Placeholder.cs       2005-03-23 20:44:04 UTC (rev 
42170)
@@ -0,0 +1,87 @@
+using Gtk;
+using System;
+
+namespace Stetic {
+
+       public class Placeholder : WidgetBox {
+
+               public Placeholder ()
+               {
+                       DND.DestSet (this, true);
+                       Internal = true;
+               }
+
+               static private string[] placeholder_xpm = {
+                       "8 8 2 1",
+                       "  c #bbbbbb",
+                       ". c #d6d6d6",
+                       "   ..   ",
+                       "  .  .  ",
+                       " .    . ",
+                       ".      .",
+                       ".      .",
+                       " .    . ",
+                       "  .  .  ",
+                       "   ..   "
+               };
+
+               protected override void OnRealized ()
+               {
+                       WidgetFlags |= WidgetFlags.Realized;
+
+                       GdkWindow = NewWindow (ParentWindow, 
Gdk.WindowClass.InputOutput);
+
+                       Gdk.Pixmap pixmap, mask;
+                       pixmap = Gdk.Pixmap.CreateFromXpmD (GdkWindow, out 
mask, new Gdk.Color (99, 99, 99), placeholder_xpm);
+                       GdkWindow.SetBackPixmap (pixmap, false);
+               }
+
+               protected override bool OnExposeEvent (Gdk.EventExpose evt)
+               {
+                       if (!IsDrawable)
+                               return false;
+
+                       int width, height;
+                       GdkWindow.GetSize (out width, out height);
+
+                       Gdk.GC light, dark;
+                       light = Style.LightGC (StateType.Normal);
+                       dark = Style.DarkGC (StateType.Normal);
+
+                       GdkWindow.DrawLine (light, 0, 0, width - 1, 0);
+                       GdkWindow.DrawLine (light, 0, 0, 0, height - 1);
+                       GdkWindow.DrawLine (dark, 0, height - 1, width - 1, 
height - 1);
+                       GdkWindow.DrawLine (dark, width - 1, 0, width - 1, 
height - 1);
+
+                       return base.OnExposeEvent (evt);
+               }
+
+               public delegate void DropHandler (Placeholder ph, Widget w);
+               public event DropHandler Drop;
+
+               protected override bool OnDragDrop (Gdk.DragContext ctx, int x, 
int y, uint time)
+               {
+                       Widget dragged = DND.Drop (ctx, time);
+                       if (dragged == null)
+                               return false;
+
+                       if (Drop != null)
+                               Drop (this, dragged);
+                       else
+                               dragged.Destroy ();
+                       return true;
+               }
+
+               public override bool HExpandable {
+                       get {
+                               return true;
+                       }
+               }
+
+               public override bool VExpandable {
+                       get {
+                               return true;
+                       }
+               }
+       }
+}

Modified: trunk/stetic/libstetic/WidgetBox.cs
===================================================================
--- trunk/stetic/libstetic/WidgetBox.cs 2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/libstetic/WidgetBox.cs 2005-03-23 20:44:04 UTC (rev 42170)
@@ -5,7 +5,7 @@
 
 namespace Stetic {
 
-       public class WidgetBox : Gtk.Bin {
+       public abstract class WidgetBox : Gtk.Bin {
 
                static Color black, white;
 
@@ -19,31 +19,13 @@
 
                public WidgetBox ()
                {
+                       WidgetFlags |= WidgetFlags.CanFocus;
                        WidgetFlags &= ~WidgetFlags.NoWindow;
-                       ShowPlaceholder = true;
                }
 
-               bool showPlaceholder;
-               protected bool ShowPlaceholder {
-                       get { return showPlaceholder; }
-                       set {
-                               if (value == showPlaceholder)
-                                       return;
-                               showPlaceholder = value;
+               public abstract bool HExpandable { get; }
+               public abstract bool VExpandable { get; }
 
-                               if (IsRealized) {
-                                       bool wasMapped = IsMapped;
-
-                                       if (wasMapped)
-                                               Hide ();
-                                       Unrealize ();
-                                       Realize ();
-                                       if (wasMapped)
-                                               Show ();
-                               }
-                       }
-               }
-
                protected Gdk.Window HandleWindow;
                bool showHandles;
                protected bool ShowHandles {
@@ -89,14 +71,12 @@
                protected override void OnAdded (Widget child)
                {
                        child.ButtonPressEvent += InterceptButtonPress;
-                       ShowPlaceholder = false;
                        base.OnAdded (child);
                }
 
                protected override void OnRemoved (Widget child)
                {
                        child.ButtonPressEvent -= InterceptButtonPress;
-                       ShowPlaceholder = true;
                        ShowHandles = false;
                        base.OnRemoved (child);
                }
@@ -126,11 +106,12 @@
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evt)
                {
-                       if (evt.Button == 3 && evt.Type == 
EventType.ButtonPress) {
+
+                       if (evt.Button == 3 && evt.Type == 
EventType.ButtonPress)
                                EmitPopupContextMenu ();
-                               return true;
-                       }
-                       return false;
+                       else
+                               GrabFocus ();
+                       return true;
                }
 
                protected override bool OnPopupMenu ()
@@ -219,14 +200,8 @@
                        WidgetFlags |= WidgetFlags.Realized;
 
                        GdkWindow = NewWindow (ParentWindow, 
Gdk.WindowClass.InputOutput);
+                       Style.SetBackground (GdkWindow, StateType.Normal);
 
-                       if (ShowPlaceholder) {
-                               Gdk.Pixmap pixmap, mask;
-                               pixmap = Gdk.Pixmap.CreateFromXpmD (GdkWindow, 
out mask, new Gdk.Color (99, 99, 99), placeholder_xpm);
-                               GdkWindow.SetBackPixmap (pixmap, false);
-                       } else
-                               Style.SetBackground (GdkWindow, 
StateType.Normal);
-
                        if (ShowHandles) {
                                HandleWindow = NewWindow (Toplevel.GdkWindow, 
Gdk.WindowClass.InputOutput);
                                HandleWindow.Background = black;
@@ -262,7 +237,7 @@
                        pixmap.DrawRectangle (gc, false, handleSize / 2, 
handleSize / 2,
                                              width - handleSize, height - 
handleSize);
 
-                       if (!ShowPlaceholder && !Internal) {
+                       if (!Internal) {
                                // Draw corner handles
                                pixmap.DrawRectangle (gc, true, 0, 0, 
handleSize, handleSize);
                                pixmap.DrawRectangle (gc, true, 0, height - 
handleSize, handleSize, handleSize);
@@ -297,32 +272,24 @@
                        base.OnUnrealized ();
                }
 
-               protected override bool OnExposeEvent (Gdk.EventExpose evt)
+               protected override void OnSetScrollAdjustments (Gtk.Adjustment 
hadj, Gtk.Adjustment vadj)
                {
-                       if (!IsDrawable)
-                               return false;
+                       if (Child != null)
+                               Child.SetScrollAdjustments (hadj, vadj);
+               }
 
-                       if (ShowPlaceholder) {
-                               int width, height;
-                               GdkWindow.GetSize (out width, out height);
+               public event EventHandler Selected;
 
-                               Gdk.GC light, dark;
-                               light = Style.LightGC (StateType.Normal);
-                               dark = Style.DarkGC (StateType.Normal);
-
-                               GdkWindow.DrawLine (light, 0, 0, width - 1, 0);
-                               GdkWindow.DrawLine (light, 0, 0, 0, height - 1);
-                               GdkWindow.DrawLine (dark, 0, height - 1, width 
- 1, height - 1);
-                               GdkWindow.DrawLine (dark, width - 1, 0, width - 
1, height - 1);
-                       }
-
-                       return base.OnExposeEvent (evt);
+               public void Focus ()
+               {
+                       ShowHandles = true;
+                       if (Selected != null)
+                               Selected (this, EventArgs.Empty);
                }
 
-               protected override void OnSetScrollAdjustments (Gtk.Adjustment 
hadj, Gtk.Adjustment vadj)
+               public void UnFocus ()
                {
-                       if (Child != null)
-                               Child.SetScrollAdjustments (hadj, vadj);
+                       ShowHandles = false;
                }
        }
 }

Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs        2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/WidgetSite.cs        2005-03-23 20:44:04 UTC (rev 
42170)
@@ -9,16 +9,11 @@
 
        public class WidgetSite : WidgetBox, IWidgetSite {
 
-               IStetic stetic;
-
-               public WidgetSite (IStetic stetic)
+               public WidgetSite (Widget child)
                {
-                       WidgetFlags |= WidgetFlags.CanFocus;
                        DND.SourceSet (this, false);
 
-                       this.stetic = stetic;
-                       emptySize.Width = emptySize.Height = 10;
-                       Occupancy = SiteOccupancy.Empty;
+                       Add (child);
                }
 
                public Widget Contents {
@@ -64,23 +59,11 @@
                        if (container != null)
                                container.ContentsChanged -= 
ChildContentsChanged;
 
-                       if (Occupancy == SiteOccupancy.Occupied)
-                               Occupancy = SiteOccupancy.Empty;
                        base.OnRemoved (w);
+                       if (Occupancy == SiteOccupancy.Occupied)
+                               EmitEmpty ();
                }
 
-               Requisition emptySize;
-               public Requisition EmptySize {
-                       get {
-                               return emptySize;
-                       }
-                       set {
-                               emptySize = value;
-                               if (Occupancy == SiteOccupancy.Empty)
-                                       SetSizeRequest (emptySize.Width, 
emptySize.Height);
-                       }
-               }
-
                string internalChildId;
                public string InternalChildId {
                        get {
@@ -98,7 +81,7 @@
                        }
                }
 
-               public enum SiteOccupancy { Empty, Occupied, PseudoOccupied };
+               public enum SiteOccupancy { Occupied, PseudoOccupied };
 
                private SiteOccupancy state;
                private SiteOccupancy Occupancy {
@@ -106,19 +89,12 @@
                        set {
                                state = value;
                                switch (state) {
-                               case SiteOccupancy.Empty:
-                                       SetSizeRequest (emptySize.Width, 
emptySize.Height);
-                                       DND.DestSet (this, true);
-                                       EmitOccupancyChanged ();
-                                       break;
-
                                case SiteOccupancy.Occupied:
                                        SetSizeRequest (-1, -1);
                                        if (faults != null && faults.Count > 0)
                                                DND.DestSet (this, false);
                                        else
                                                DND.DestUnset (this);
-                                       EmitOccupancyChanged ();
                                        break;
 
                                case SiteOccupancy.PseudoOccupied:
@@ -130,25 +106,16 @@
                        }
                }
 
-               public event ChangedHandler OccupancyChanged;
+               public event ChangedHandler Empty;
 
-               void EmitOccupancyChanged ()
+               void EmitEmpty ()
                {
-                       if (OccupancyChanged != null)
-                               OccupancyChanged (this);
-                       if (ShapeChanged != null)
-                               ShapeChanged (this);
+                       if (Empty != null)
+                               Empty (this);
                }
 
-               public bool Occupied {
-                       get { return (Occupancy != SiteOccupancy.Empty); }
-               }
-
-               public bool HExpandable {
+               public override bool HExpandable {
                        get {
-                               if (Occupancy == SiteOccupancy.Empty)
-                                       return true;
-
                                Stetic.Wrapper.Widget child;
                                if (Occupancy == SiteOccupancy.PseudoOccupied)
                                        child = Stetic.Wrapper.Widget.Lookup 
(dragWidget);
@@ -162,11 +129,8 @@
                        }
                }
 
-               public bool VExpandable {
+               public override bool VExpandable {
                        get {
-                               if (Occupancy == SiteOccupancy.Empty)
-                                       return true;
-
                                Stetic.Wrapper.Widget child;
                                if (Occupancy == SiteOccupancy.PseudoOccupied)
                                        child = Stetic.Wrapper.Widget.Lookup 
(dragWidget);
@@ -396,13 +360,6 @@
                        }
                }
 
-               protected override bool OnButtonPressEvent (Gdk.EventButton evt)
-               {
-                       if (!base.OnButtonPressEvent (evt))
-                               GrabFocus ();
-                       return true;
-               }
-
                Widget dragWidget;
 
                protected override bool OnMotionNotifyEvent (Gdk.EventMotion 
evt)
@@ -467,7 +424,7 @@
                                Drop (dragWidget, -1, -1);
                                dragWidget = null;
                        } else if (Child == null)
-                               Occupancy = SiteOccupancy.Empty;
+                               EmitEmpty ();
                }
 
                protected override bool OnKeyReleaseEvent (Gdk.EventKey evt)
@@ -479,20 +436,6 @@
                        return false;
                }
 
-               public event EventHandler Selected;
-
-               public void Focus ()
-               {
-                       ShowHandles = true;
-                       if (Selected != null)
-                               Selected (this, EventArgs.Empty);
-               }
-
-               public void UnFocus ()
-               {
-                       ShowHandles = false;
-               }
-
                public void Select ()
                {
                        GrabFocus ();
@@ -507,7 +450,7 @@
                {
                        if (Child != null) {
                                Child.Destroy ();
-                               EmitOccupancyChanged ();
+                               EmitEmpty ();
                        }
                }
 

Modified: trunk/stetic/libstetic/WindowSite.cs
===================================================================
--- trunk/stetic/libstetic/WindowSite.cs        2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/WindowSite.cs        2005-03-23 20:44:04 UTC (rev 
42170)
@@ -27,7 +27,7 @@
                        windowSites.Remove (contents);
                }
 
-               public delegate void FocusChangedHandler (WindowSite site, 
IWidgetSite focus);
+               public delegate void FocusChangedHandler (WindowSite site, 
WidgetBox focus);
                public event FocusChangedHandler FocusChanged;
 
                [ConnectBefore] // otherwise contents.Focus will be the new 
focus, not the old
@@ -36,14 +36,14 @@
                        Widget w;
 
                        w = contents.Focus;
-                       while (w != null && !(w is WidgetSite))
+                       while (w != null && !(w is WidgetBox))
                                w = w.Parent;
-                       WidgetSite oldf = (WidgetSite)w;
+                       WidgetBox oldf = (WidgetBox)w;
 
                        w = args.Focus;
-                       while (w != null && !(w is WidgetSite))
+                       while (w != null && !(w is WidgetBox))
                                w = w.Parent;
-                       WidgetSite newf = (WidgetSite)w;
+                       WidgetBox newf = (WidgetBox)w;
 
                        if (oldf == newf)
                                return;
@@ -54,7 +54,7 @@
                                newf.Focus ();
 
                        if (FocusChanged != null)
-                               FocusChanged (this, newf != null ? 
(IWidgetSite)newf : (IWidgetSite)this);
+                               FocusChanged (this, newf);
                }
 
                public static IWidgetSite LookupSite (Widget window)
@@ -74,12 +74,6 @@
                        }
                }
 
-               public bool Occupied {
-                       get {
-                               return true;
-                       }
-               }
-
                public bool Internal {
                        get {
                                return false;

Modified: trunk/stetic/libstetic/wrapper/Bin.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Bin.cs       2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Bin.cs       2005-03-23 20:44:04 UTC (rev 
42170)
@@ -6,37 +6,32 @@
 
                public static new Type WrappedType = typeof (Gtk.Bin);
 
-               protected WidgetSite site;
-               protected WidgetSite Site {
-                       get {
-                               if (site == null)
-                                       site = ((Gtk.Bin)Wrapped).Child as 
WidgetSite;
-                               return site;
-                       }
-               }
-               
                public override void Wrap (object obj, bool initialized)
                {
                        base.Wrap (obj, initialized);
+                       if (!initialized && bin.Child == null)
+                               bin.Add (CreatePlaceholder ());
+               }
 
-                       Gtk.Bin bin = (Gtk.Bin)obj;
-                       if (!initialized && bin.Child == null) {
-                               site = CreateWidgetSite ();
-                               bin.Add (site);
+               Gtk.Bin bin {
+                       get {
+                               return (Gtk.Bin)Wrapped;
                        }
                }
 
                public override bool HExpandable {
                        get { 
-                               if (Site != null)
-                                       return Site.HExpandable;
+                               WidgetBox child = bin.Child as WidgetBox;
+                               if (child != null)
+                                       return child.HExpandable;
                                return false;
                        }
                }
                public override bool VExpandable {
                        get {
-                               if (Site != null)
-                                       return Site.VExpandable;
+                               WidgetBox child = bin.Child as WidgetBox;
+                               if (child != null)
+                                       return child.VExpandable;
                                return false;
                        }
                }

Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs       2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Box.cs       2005-03-23 20:44:04 UTC (rev 
42170)
@@ -23,8 +23,8 @@
                {
                        base.Wrap (obj, initialized);
                        if (!initialized) {
-                               box.PackStart (CreateWidgetSite ());
-                               box.PackStart (CreateWidgetSite ());
+                               box.PackStart (CreatePlaceholder ());
+                               box.PackStart (CreatePlaceholder ());
                        }
                        box.SizeAllocated += box_SizeAllocated;
                        box.ParentSet += box_ParentSet;
@@ -82,31 +82,31 @@
                }
 
                [Command ("Insert Before", "Insert an empty row/column before 
the selected one")]
-               void InsertBefore (IWidgetSite context)
+               void InsertBefore (Gtk.Widget context)
                {
-                       Gtk.Box.BoxChild bc = box[(Gtk.Widget)context] as 
Gtk.Box.BoxChild;
-                       WidgetSite site = CreateWidgetSite ();
+                       Gtk.Box.BoxChild bc = box[context] as Gtk.Box.BoxChild;
+                       Placeholder ph = CreatePlaceholder ();
                        if (bc.PackType == Gtk.PackType.Start) {
-                               box.PackStart (site);
-                               box.ReorderChild (site, bc.Position);
+                               box.PackStart (ph);
+                               box.ReorderChild (ph, bc.Position);
                        } else {
-                               box.PackEnd (site);
-                               box.ReorderChild (site, bc.Position + 1);
+                               box.PackEnd (ph);
+                               box.ReorderChild (ph, bc.Position + 1);
                        }
                        EmitContentsChanged ();
                }
 
                [Command ("Insert After", "Insert an empty row/column after the 
selected one")]
-               void InsertAfter (IWidgetSite context)
+               void InsertAfter (Gtk.Widget context)
                {
-                       Gtk.Box.BoxChild bc = box[(Gtk.Widget)context] as 
Gtk.Box.BoxChild;
-                       WidgetSite site = CreateWidgetSite ();
+                       Gtk.Box.BoxChild bc = box[context] as Gtk.Box.BoxChild;
+                       Placeholder ph = CreatePlaceholder ();
                        if (bc.PackType == Gtk.PackType.Start) {
-                               box.PackStart (site);
-                               box.ReorderChild (site, bc.Position + 1);
+                               box.PackStart (ph);
+                               box.ReorderChild (ph, bc.Position + 1);
                        } else {
-                               box.PackEnd (site);
-                               box.ReorderChild (site, bc.Position);
+                               box.PackEnd (ph);
+                               box.ReorderChild (ph, bc.Position);
                        }
                        EmitContentsChanged ();
                }
@@ -119,12 +119,15 @@
                        base.SiteShapeChanged (site);
                }
 
-               protected override void SiteOccupancyChanged (WidgetSite site) {
-                       if (!site.Occupied) {
-                               site.Destroy ();
-                               return;
-                       }
-                       base.SiteOccupancyChanged (site);
+               protected override void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
+               {
+                       if (newChild is Placeholder)
+                               newChild.Destroy ();
+                       else
+                               base.ReplaceChild (oldChild, newChild);
+
+                       if (newChild is WidgetSite)
+                               SiteShapeChanged ((WidgetSite)newChild);
                }
 
                void box_ParentSet (object obj, Gtk.ParentSetArgs args)
@@ -143,9 +146,8 @@
 
                void DropOn (Gtk.Widget w, object faultId)
                {
-                       WidgetSite site = CreateWidgetSite ();
+                       WidgetSite site = CreateWidgetSite (w);
                        box.PackStart (site);
-                       site.Add (w);
                        box.ReorderChild (site, (int)faultId);
                        EmitContentsChanged ();
 

Modified: trunk/stetic/libstetic/wrapper/Button.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Button.cs    2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Button.cs    2005-03-23 20:44:04 UTC (rev 
42170)
@@ -62,14 +62,15 @@
                public override void Wrap (object obj, bool initialized)
                {
                        base.Wrap (obj, initialized);
-                       if (!initialized)
-                               button.Label = button.Name;
 
                        if (button.UseStock)
                                Icon = "stock:" + button.Label;
                        else {
                                Icon = null;
-                               Label = button.Label;
+                               if (initialized)
+                                       Label = button.Label;
+                               else
+                                       Label = button.Name;
                        }
                }
 
@@ -134,8 +135,7 @@
                // true if the button has *anything* in it
                public bool HasContents {
                        get {
-                               WidgetSite site = button.Child as WidgetSite;
-                               return (site == null) || site.Occupied;
+                               return !(button.Child is Placeholder);
                        }
                }
 
@@ -145,11 +145,7 @@
                        if (button.Child != null)
                                button.Remove (button.Child);
 
-                       WidgetSite site = CreateWidgetSite ();
-                       site.OccupancyChanged += delegate (WidgetSite site) {
-                               EmitNotify ("HasContents");
-                       };
-                       button.Add (site);
+                       button.Add (CreatePlaceholder ());
 
                        EmitNotify ("HasContents");
                        EmitNotify ("HasLabel");
@@ -163,6 +159,12 @@
                        EmitNotify ("HasLabel");
                }
 
+               protected override void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
+               {
+                       base.ReplaceChild (oldChild, newChild);
+                       EmitNotify ("HasContents");
+               }
+
                Gtk.Image iconWidget;
                Gtk.Label labelWidget;
                string icon;
@@ -170,6 +172,7 @@
 
                void ConstructChild ()
                {
+                       button.UseStock = false;
                        if (button.Child != null)
                                button.Remove (button.Child);
                        iconWidget = null;

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-23 20:44:04 UTC (rev 
42170)
@@ -53,12 +53,10 @@
                        Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
 
                        if (container.ChildType () == Gtk.Widget.GType) {
-                               WidgetSite site = AddPlaceholder ();
-                               AutoSize[site] = false;
-                               site.Add (child);
-                               child = site;
-                       } else
-                               container.Add (child);
+                               child = CreateWidgetSite (child);
+                               AutoSize[child] = false;
+                       }
+                       container.Add (child);
 
                        GladeUtils.SetPacking (container, child, childprops);
                        return (Widget)wrapper;
@@ -89,9 +87,16 @@
                        }
                }
 
-               public virtual WidgetSite AddPlaceholder ()
+               public virtual Placeholder AddPlaceholder ()
                {
-                       WidgetSite site = CreateWidgetSite ();
+                       Placeholder ph = CreatePlaceholder ();
+                       container.Add (ph);
+                       return ph;
+               }
+
+               public virtual WidgetSite AddWidgetSite (Gtk.Widget child)
+               {
+                       WidgetSite site = CreateWidgetSite (child);
                        container.Add (site);
                        return site;
                }
@@ -163,21 +168,38 @@
 
                protected Set AutoSize = new Set ();
 
-               protected override WidgetSite CreateWidgetSite ()
+               protected override WidgetSite CreateWidgetSite (Gtk.Widget w)
                {
-                       WidgetSite site = base.CreateWidgetSite ();
-                       site.OccupancyChanged += SiteOccupancyChanged;
+                       WidgetSite site = base.CreateWidgetSite (w);
                        site.ShapeChanged += SiteShapeChanged;
-                       AutoSize[site] = true;
+                       site.Empty += SiteEmpty;
                        return site;
                }
 
-               protected virtual void SiteOccupancyChanged (WidgetSite site) {
-                       if (!site.Occupied)
-                               AutoSize[site] = true;
+               protected override Placeholder CreatePlaceholder ()
+               {
+                       Placeholder ph = base.CreatePlaceholder ();
+                       ph.Drop += PlaceholderDrop;
+                       AutoSize[ph] = true;
+                       return ph;
+               }
+
+               void SiteEmpty (WidgetSite site)
+               {
+                       ReplaceChild (site, CreatePlaceholder ());
+                       site.Destroy ();
                        EmitContentsChanged ();
                }
 
+               void PlaceholderDrop (Placeholder ph, Gtk.Widget dropped)
+               {
+                       WidgetSite site = CreateWidgetSite (dropped);
+                       ReplaceChild (ph, site);
+                       ph.Destroy ();
+                       site.Select ();
+                       EmitContentsChanged ();
+               }
+
                protected virtual void SiteShapeChanged (WidgetSite site) {
                        ;
                }
@@ -186,7 +208,7 @@
                {
                        WidgetSite site = args.Widget as WidgetSite;
                        if (site != null) {
-                               site.OccupancyChanged -= SiteOccupancyChanged;
+                               site.Empty -= SiteEmpty;
                                site.ShapeChanged -= SiteShapeChanged;
                                SiteRemoved (site);
                        }
@@ -215,6 +237,30 @@
                        }
                }
 
+               protected virtual void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
+               {
+                       Gtk.Container.ContainerChild cc;
+                       Hashtable props = new Hashtable ();
+
+                       cc = container[oldChild];
+                       foreach (PropertyInfo pinfo in cc.GetType 
().GetProperties ()) {
+                               if (!pinfo.IsDefined (typeof 
(Gtk.ChildPropertyAttribute), true))
+                                       continue;
+                               props[pinfo] = pinfo.GetValue (cc, null);
+                       }
+
+                       container.Remove (oldChild);
+                       AutoSize[oldChild] = false;
+                       AutoSize[newChild] = true;
+                       container.Add (newChild);
+
+                       cc = container[newChild];
+                       foreach (PropertyInfo pinfo in props.Keys)
+                               pinfo.SetValue (cc, props[pinfo], null);
+
+                       Sync ();
+               }
+
                public class ContainerChild : Stetic.ObjectWrapper {
 
                        public static new Type WrappedType = typeof 
(Gtk.Container.ContainerChild);

Modified: trunk/stetic/libstetic/wrapper/Dialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-23 20:44:04 UTC (rev 
42170)
@@ -35,28 +35,26 @@
                        base.Wrap (obj, initialized);
                        dialog.HasSeparator = false;
 
-                       site = CreateWidgetSite ();
+                       dialog.VBox.Unparent ();
+                       site = CreateWidgetSite (dialog.VBox);
                        site.InternalChildId = "vbox";
-                       dialog.VBox.Reparent (site);
                        dialog.Add (site);
                        ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.VBox), dialog.VBox);
                        if (dialog.VBox.Name == "GtkVBox")
                                dialog.VBox.Name = dialog.Name + "_vbox";
 
-                       site = CreateWidgetSite ();
+                       dialog.ActionArea.Unparent ();
+                       site = CreateWidgetSite (dialog.ActionArea);
                        site.InternalChildId = "action_area";
-                       dialog.ActionArea.Reparent (site);
                        dialog.VBox.PackEnd (site, false, true, 0);
                        ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.HButtonBox), dialog.ActionArea);
                        if (dialog.ActionArea.Name == "GtkHButtonBox")
                                dialog.ActionArea.Name = dialog.Name + 
"_action_area";
 
                        if (!initialized) {
-                               site = CreateWidgetSite ();
-                               Gtk.Requisition req;
-                               req.Width = req.Height = 200;
-                               site.EmptySize = req;
-                               dialog.VBox.Add (site);
+                               Placeholder ph = CreatePlaceholder ();
+                               ph.SetSizeRequest (200, 200);
+                               dialog.VBox.Add (ph);
                                Buttons = StandardButtons.Close;
                        }
                }
@@ -152,8 +150,7 @@
                        button.ResponseId = (int)response;
 
                        Stetic.Wrapper.Container actionArea = 
Stetic.Wrapper.Container.Lookup (dialog.ActionArea);
-                       WidgetSite site = actionArea.AddPlaceholder ();
-                       site.Add (widget);
+                       WidgetSite site = actionArea.AddWidgetSite (widget);
 
                        widget.CanDefault = true;
                        button.HasDefault = hasDefault;

Modified: trunk/stetic/libstetic/wrapper/Expander.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Expander.cs  2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Expander.cs  2005-03-23 20:44:04 UTC (rev 
42170)
@@ -35,8 +35,7 @@
                {
                        if (childprops.Count == 1 && 
((string)childprops["type"]) == "label_item") {
                                ObjectWrapper wrapper = 
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
-                               WidgetSite site = CreateWidgetSite ();
-                               site.Add ((Gtk.Widget)wrapper.Wrapped);
+                               WidgetSite site = CreateWidgetSite 
((Gtk.Widget)wrapper.Wrapped);
 
                                expander.LabelWidget = site;
                                return (Widget)wrapper;
@@ -49,16 +48,5 @@
                                return (Gtk.Expander)Wrapped;
                        }
                }
-
-               public override bool HExpandable {
-                       get {
-                               return site.HExpandable;
-                       }
-               }
-               public override bool VExpandable {
-                       get {
-                               return site.VExpandable;
-                       }
-               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Frame.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Frame.cs     2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Frame.cs     2005-03-23 20:44:04 UTC (rev 
42170)
@@ -32,8 +32,7 @@
                {
                        if (childprops.Count == 1 && 
((string)childprops["type"]) == "label_item") {
                                ObjectWrapper wrapper = 
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
-                               WidgetSite site = CreateWidgetSite ();
-                               site.Add ((Gtk.Widget)wrapper.Wrapped);
+                               WidgetSite site = CreateWidgetSite 
((Gtk.Widget)wrapper.Wrapped);
 
                                Gtk.Frame frame = (Gtk.Frame)Wrapped;
                                frame.LabelWidget = site;

Modified: trunk/stetic/libstetic/wrapper/Notebook.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Notebook.cs  2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Notebook.cs  2005-03-23 20:44:04 UTC (rev 
42170)
@@ -46,9 +46,8 @@
                {
                        if (childprops.Count == 1 && 
((string)childprops["type"]) == "tab") {
                                ObjectWrapper wrapper = 
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
-                               WidgetSite site = CreateWidgetSite ();
+                               WidgetSite site = CreateWidgetSite 
((Gtk.Widget)wrapper.Wrapped);
                                site.Selected += LabelSelected;
-                               site.Add ((Gtk.Widget)wrapper.Wrapped);
 
                                notebook.SetTabLabel (notebook.GetNthPage 
(notebook.NPages - 1), site);
                                tabs.Add (site);
@@ -83,16 +82,14 @@
 
                int InsertPage (int position)
                {
-                       WidgetSite labelSite, pageSite;
+                       WidgetSite labelSite;
 
-                       labelSite = CreateWidgetSite ();
-                       labelSite.Selected += LabelSelected;
                        Stetic.Wrapper.Label label = new Stetic.Wrapper.Label 
("page" + (notebook.NPages + 1).ToString ());
-                       labelSite.Add ((Gtk.Widget)label.Wrapped);
+                       labelSite = CreateWidgetSite 
((Gtk.Widget)label.Wrapped);
+                       labelSite.Selected += LabelSelected;
                        tabs.Insert (position, labelSite);
 
-                       pageSite = CreateWidgetSite ();
-                       return notebook.InsertPage (pageSite, labelSite, 
position);
+                       return notebook.InsertPage (CreatePlaceholder (), 
labelSite, position);
                }
 
                [Command ("Go to Previous Page", "Show the previous page", 
"CheckPreviousPage")]

Modified: trunk/stetic/libstetic/wrapper/Paned.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Paned.cs     2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Paned.cs     2005-03-23 20:44:04 UTC (rev 
42170)
@@ -19,11 +19,22 @@
                        base.Wrap (obj, initialized);
                        if (!initialized) {
                                Gtk.Paned paned = (Gtk.Paned)Wrapped;
-                               paned.Pack1 (CreateWidgetSite (), true, false);
-                               paned.Pack2 (CreateWidgetSite (), true, false);
+                               paned.Pack1 (CreatePlaceholder (), true, false);
+                               paned.Pack2 (CreatePlaceholder (), true, false);
                        }
                }
 
+               protected override void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
+               {
+                       Gtk.Paned paned = (Gtk.Paned)Wrapped;
+
+                       paned.Remove (oldChild);
+                       if (oldChild == paned.Child1)
+                               paned.Add1 (newChild);
+                       else if (oldChild == paned.Child2)
+                               paned.Add2 (newChild);
+               }
+
                public class PanedChild : Container.ContainerChild {
 
                        public static new Type WrappedType = typeof 
(Gtk.Paned.PanedChild);

Modified: trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2005-03-23 20:39:18 UTC 
(rev 42169)
+++ trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2005-03-23 20:44:04 UTC 
(rev 42170)
@@ -25,35 +25,22 @@
                                Gtk.ScrolledWindow scrolled = 
(Gtk.ScrolledWindow)Wrapped;
                                scrolled.SetPolicy (Gtk.PolicyType.Always, 
Gtk.PolicyType.Always);
                                if (scrolled.Child == null)
-                                       scrolled.AddWithViewport 
(CreateWidgetSite ());
+                                       scrolled.AddWithViewport 
(CreatePlaceholder ());
                        }
                }
 
                public override bool HExpandable { get { return true; } }
                public override bool VExpandable { get { return true; } }
 
-               protected override void SiteOccupancyChanged (WidgetSite site)
+               protected override void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
                {
                        Gtk.ScrolledWindow scwin = (Gtk.ScrolledWindow)Wrapped;
 
-                       if (scwin.Child == null)
-                               return;
-
-                       if (site.Occupied &&
-                           site.Contents.SetScrollAdjustments (null, null)) {
-                               if (scwin.Child is Gtk.Viewport) {
-                                       ((Gtk.Viewport)scwin.Child).Remove 
(site);
-                                       scwin.Remove (scwin.Child);
-                                       scwin.Add (site);
-                               }
-                       } else {
-                               if (!(scwin.Child is Gtk.Viewport)) {
-                                       scwin.Remove (scwin.Child);
-                                       scwin.AddWithViewport (site);
-                               }
-                       }
-
-                       base.SiteOccupancyChanged (site);
+                       scwin.Remove (scwin.Child);
+                       if (newChild.SetScrollAdjustments (null, null))
+                               scwin.Add (newChild);
+                       else
+                               scwin.AddWithViewport (newChild);
                }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs     2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Table.cs     2005-03-23 20:44:04 UTC (rev 
42170)
@@ -85,18 +85,18 @@
                {
                        uint left, right, top, bottom;
                        uint row, col;
-                       WidgetSite site;
-                       WidgetSite[,] grid;
+                       WidgetBox wbox;
+                       WidgetBox[,] grid;
                        Gtk.Table.TableChild tc;
                        Gtk.Widget[] children;
-                       bool addedSites = false;
+                       bool addedPlaceholders = false;
 
                        if (freeze > 0)
                                return;
                        freeze = 1;
 
                        children = table.Children;
-                       grid = new WidgetSite[NRows,NColumns];
+                       grid = new WidgetBox[NRows,NColumns];
 
                        foreach (Gtk.Widget child in children)
                                child.FreezeChildNotify ();
@@ -105,8 +105,7 @@
                        // placeholders covering more than one grid square, 
remove them.
                        // (New ones will be created below.)
                         foreach (Gtk.Widget child in children) {
-                               site = (WidgetSite) child;
-                               if (site.Occupied)
+                               if (!(child is Placeholder))
                                        continue;
 
                                 tc = table[child] as Gtk.Table.TableChild;
@@ -116,7 +115,7 @@
                                 bottom = tc.BottomAttach;
 
                                if (right == left + 1 && bottom == top + 1)
-                                       grid[top,left] = child as WidgetSite;
+                                       grid[top,left] = (WidgetBox)child;
                                else
                                        table.Remove (child);
                        }
@@ -127,8 +126,7 @@
                        // will probably end up wrong as well. But this 
situation
                        // happens at least temporarily during glade import.)
                         foreach (Gtk.Widget child in children) {
-                               site = (WidgetSite) child;
-                               if (!site.Occupied)
+                               if (child is Placeholder)
                                        continue;
 
                                 tc = table[child] as Gtk.Table.TableChild;
@@ -139,10 +137,10 @@
 
                                 for (row = top; row < bottom; row++) {
                                         for (col = left; col < right; col++) {
-                                               site = grid[row,col];
-                                               if (site != null && 
!site.Occupied)
+                                               wbox = grid[row,col];
+                                               if (wbox is Placeholder)
                                                        table.Remove 
(grid[row,col]);
-                                                grid[row,col] = child as 
WidgetSite;
+                                                grid[row,col] = 
(WidgetBox)child;
                                         }
                                 }
                         }
@@ -159,22 +157,22 @@
                                bool allPlaceholders = true;
 
                                for (col = 0; col < NColumns; col++) {
-                                       site = grid[row,col];
-                                       if (site == null) {
-                                               site = CreateWidgetSite ();
-                                               site.FreezeChildNotify ();
-                                               table.Attach (site, col, col + 
1, row, row + 1);
-                                               grid[row,col] = site;
-                                               addedSites = true;
-                                       } else if (!site.VExpandable || 
!AutoSize[site])
+                                       wbox = grid[row,col];
+                                       if (wbox == null) {
+                                               wbox = CreatePlaceholder ();
+                                               wbox.FreezeChildNotify ();
+                                               table.Attach (wbox, col, col + 
1, row, row + 1);
+                                               grid[row,col] = wbox;
+                                               addedPlaceholders = true;
+                                       } else if (!wbox.VExpandable || 
!AutoSize[wbox])
                                                allPlaceholders = false;
                                }
 
                                for (col = 0; col < NColumns; col++) {
-                                       site = grid[row,col];
-                                       if (!AutoSize[site])
+                                       wbox = grid[row,col];
+                                       if (!AutoSize[wbox])
                                                continue;
-                                       tc = table[site] as 
Gtk.Table.TableChild;
+                                       tc = table[wbox] as 
Gtk.Table.TableChild;
                                        tc.YOptions = allPlaceholders ? 
expandOpts : fillOpts;
                                }
 
@@ -189,18 +187,18 @@
                                bool allPlaceholders = true;
 
                                for (row = 0; row < NRows; row++) {
-                                       site = grid[row,col];
-                                       if (!site.HExpandable || 
!AutoSize[site]) {
+                                       wbox = grid[row,col];
+                                       if (!wbox.HExpandable || 
!AutoSize[wbox]) {
                                                allPlaceholders = false;
                                                break;
                                        }
                                }
 
                                for (row = 0; row < NRows; row++) {
-                                       site = grid[row,col];
-                                       if (!AutoSize[site])
+                                       wbox = grid[row,col];
+                                       if (!AutoSize[wbox])
                                                continue;
-                                       tc = table[site] as 
Gtk.Table.TableChild;
+                                       tc = table[wbox] as 
Gtk.Table.TableChild;
                                        tc.XOptions = allPlaceholders ? 
expandOpts : fillOpts;
                                }
 
@@ -212,7 +210,7 @@
                                child.ThawChildNotify ();
                        freeze = 0;
 
-                       if (addedSites)
+                       if (addedPlaceholders)
                                EmitContentsChanged ();
                }
 
@@ -323,44 +321,44 @@
                }
 
                [Command ("Insert Row Before", "Insert an empty row above the 
selected row")]
-               void InsertRowBefore (IWidgetSite context)
+               void InsertRowBefore (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        AddRow (tc.TopAttach);
                }
 
                [Command ("Insert Row After", "Insert an empty row below the 
selected row")]
-               void InsertRowAfter (IWidgetSite context)
+               void InsertRowAfter (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        AddRow (tc.BottomAttach);
                }
 
                [Command ("Insert Column Before", "Insert an empty column 
before the selected column")]
-               void InsertColumnBefore (IWidgetSite context)
+               void InsertColumnBefore (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        AddColumn (tc.LeftAttach);
                }
 
                [Command ("Insert Column After", "Insert an empty column after 
the selected column")]
-               void InsertColumnAfter (IWidgetSite context)
+               void InsertColumnAfter (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        AddColumn (tc.RightAttach);
                }
 
                [Command ("Delete Row", "Delete the selected row")]
-               void DeleteRow (IWidgetSite context)
+               void DeleteRow (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        DeleteRow (tc.TopAttach);
                }
 
                [Command ("Delete Column", "Delete the selected column")]
-               void DeleteColumn (IWidgetSite context)
+               void DeleteColumn (Gtk.Widget context)
                {
-                       Gtk.Table.TableChild tc = table[(Gtk.Widget)context] as 
Gtk.Table.TableChild;
+                       Gtk.Table.TableChild tc = table[context] as 
Gtk.Table.TableChild;
                        DeleteColumn (tc.LeftAttach);
                }
 
@@ -371,7 +369,7 @@
                protected override void SiteShapeChanged (WidgetSite site)
                {
                        Freeze ();
-                       if (site.Occupied && AutoSize[site]) {
+                       if (AutoSize[site]) {
                                Gtk.Table.TableChild tc = table[site] as 
Gtk.Table.TableChild;
                                tc.XOptions = 0;
                                tc.YOptions = 0;

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-23 20:44:04 UTC (rev 
42170)
@@ -58,13 +58,20 @@
                        return Stetic.ObjectWrapper.Lookup (obj) as 
Stetic.Wrapper.Widget;
                }
 
-               protected virtual WidgetSite CreateWidgetSite ()
+               protected virtual WidgetSite CreateWidgetSite (Gtk.Widget w)
                {
-                       WidgetSite site = stetic.CreateWidgetSite ();
+                       WidgetSite site = stetic.CreateWidgetSite (w);
                        site.Show ();
                        return site;
                }
 
+               protected virtual Placeholder CreatePlaceholder ()
+               {
+                       Placeholder ph = stetic.CreatePlaceholder ();
+                       ph.Show ();
+                       return ph;
+               }
+
                public virtual bool HExpandable { get { return false; } }
                public virtual bool VExpandable { get { return false; } }
 

Modified: trunk/stetic/libstetic/wrapper/Window.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Window.cs    2005-03-23 20:39:18 UTC (rev 
42169)
+++ trunk/stetic/libstetic/wrapper/Window.cs    2005-03-23 20:44:04 UTC (rev 
42170)
@@ -47,11 +47,8 @@
                        if (!initialized) {
                                window.Title = window.Name;
 
-                               if (Site != null) {
-                                       Gtk.Requisition req;
-                                       req.Width = req.Height = 200;
-                                       Site.EmptySize = req;
-                               }
+                               if (window.Child is Placeholder)
+                                       window.Child.SetSizeRequest (200, 200);
                        }
                        window.DeleteEvent += DeleteEvent;
                }

Modified: trunk/stetic/stetic/ContextMenu.cs
===================================================================
--- trunk/stetic/stetic/ContextMenu.cs  2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/stetic/ContextMenu.cs  2005-03-23 20:44:04 UTC (rev 42170)
@@ -9,19 +9,40 @@
 
                IWidgetSite site;
 
-               public ContextMenu (IWidgetSite site) : this (site, site) {}
+               public ContextMenu (Placeholder ph)
+               {
+                       MenuItem item;
 
-               public ContextMenu (IWidgetSite site, IWidgetSite top)
+                       this.site = null;
+
+                       item = LabelItem ("Placeholder");
+                       item.Sensitive = false;
+                       Add (item);
+
+                       item = new MenuItem ("_Select");
+                       item.Sensitive = false;
+                       Add (item);
+
+                       Widget w = ph;
+                       while (w.Parent != null && !(w is WidgetSite))
+                               w = w.Parent;
+                       if (w is WidgetSite)
+                               BuildContextMenu ((WidgetSite)w, false, false, 
ph);
+                       else
+                               BuildContextMenu (WindowSite.LookupSite (w), 
false, false, ph);
+               }
+
+               public ContextMenu (IWidgetSite site) : this (site, site as 
Gtk.Widget) {}
+
+               public ContextMenu (IWidgetSite site, Gtk.Widget context)
                {
                        MenuItem item;
 
                        this.site = site;
 
-                       if (top == site) {
-                               item = LabelItem (site.Occupied ? 
site.Contents.Name : "Placeholder");
-                               item.Sensitive = false;
-                               Add (item);
-                       }
+                       item = LabelItem (site.Contents.Name);
+                       item.Sensitive = false;
+                       Add (item);
 
                        item = new MenuItem ("_Select");
                        item.Activated += DoSelect;
@@ -31,41 +52,46 @@
                        if (wrapper != null) {
                                foreach (CommandDescriptor cmd in 
wrapper.ContextMenuItems.Items) {
                                        item = new MenuItem (cmd.Label);
-                                       if (cmd.Enabled (wrapper, top))
-                                               item.Activated += new 
Stupid69614Workaround (cmd, wrapper, top).Activate;
+                                       if (cmd.Enabled (wrapper, context))
+                                               item.Activated += new 
Stupid69614Workaround (cmd, wrapper, context).Activate;
                                        else
                                                item.Sensitive = false;
                                        Add (item);
                                }
                        }
 
+                       BuildContextMenu (site.ParentSite, true, site.Internal, 
context);
+               }
+
+               void BuildContextMenu (IWidgetSite parentSite, bool occupied, 
bool isInternal, Widget context)
+               {
+                       MenuItem item;
+
                        item = new MenuItem ("Cu_t");
-                       if (!site.Occupied || site.Internal)
+                       if (!occupied || isInternal)
                                item.Sensitive = false;
                        Add (item);
                        item = new MenuItem ("_Copy");
-                       if (!site.Occupied)
+                       if (!occupied)
                                item.Sensitive = false;
                        Add (item);
                        item = new MenuItem ("_Paste");
-                       if (site.Occupied)
+                       if (occupied)
                                item.Sensitive = false;
                        Add (item);
                        item = new MenuItem ("_Delete");
-                       if (site.Occupied && !site.Internal)
+                       if (occupied && !isInternal)
                                item.Activated += DoDelete;
                        else
                                item.Sensitive = false;
                        Add (item);
 
-                       if (site == top) {
-                               for (site = site.ParentSite; site != null; site 
= site.ParentSite) {
-                                       Add (new SeparatorMenuItem ());
+                       for (; parentSite != null; parentSite = 
parentSite.ParentSite) {
+                               Add (new SeparatorMenuItem ());
 
-                                       item = LabelItem (site.Contents.Name);
-                                       item.Submenu = new ContextMenu (site, 
top);
-                                       Add (item);
-                               }
+                               item = LabelItem (parentSite.Contents.Name);
+                               item.Submenu = new ContextMenu (parentSite, 
context);
+                               Add (item);
                        }
 
                        ShowAll ();
@@ -74,17 +100,17 @@
                private class Stupid69614Workaround {
                        CommandDescriptor cmd;
                        ObjectWrapper wrapper;
-                       IWidgetSite top;
+                       Widget context;
 
-                       public Stupid69614Workaround (CommandDescriptor cmd, 
ObjectWrapper wrapper, IWidgetSite top)
+                       public Stupid69614Workaround (CommandDescriptor cmd, 
ObjectWrapper wrapper, Widget context)
                        {
                                this.cmd = cmd;
                                this.wrapper = wrapper;
-                               this.top = top;
+                               this.context = context;
                        }
 
                        public void Activate (object o, EventArgs args) {
-                               cmd.Run (wrapper, top);
+                               cmd.Run (wrapper, context);
                        }
                }
 

Modified: trunk/stetic/stetic/Glade.cs
===================================================================
--- trunk/stetic/stetic/Glade.cs        2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/stetic/Glade.cs        2005-03-23 20:44:04 UTC (rev 42170)
@@ -166,14 +166,14 @@
                                XmlElement child;
 
                                foreach (WidgetSite site in container.Sites) {
+#if FIXME
                                        if (!site.Occupied) {
-#if FIXME
                                                child = doc.CreateElement 
("child");
                                                child.AppendChild 
(doc.CreateElement ("placeholder"));
                                                widget.AppendChild (child);
-#endif
                                                continue;
                                        }
+#endif
 
                                        child = ExportWidget (project, doc, 
container, site.Contents);
                                        if (child != null)

Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs      2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/stetic/Project.cs      2005-03-23 20:44:04 UTC (rev 42170)
@@ -25,7 +25,7 @@
                        AddWidget (site.Contents, null, -1);
 
                        if (select)
-                               WindowFocusChanged (site, site);
+                               WindowFocusChanged (site, null);
                }
 
                void AddWidget (Widget widget, ProjectNode parent)
@@ -58,10 +58,8 @@
                        Stetic.Wrapper.Container container = 
Stetic.Wrapper.Container.Lookup (widget);
                        if (container != null) {
                                container.ContentsChanged += ContentsChanged;
-                               foreach (WidgetSite site in container.Sites) {
-                                       if (site.Occupied)
-                                               AddWidget (site.Contents, 
parent);
-                               }
+                               foreach (WidgetSite site in container.Sites)
+                                       AddWidget (site.Contents, parent);
                        }
                }
 
@@ -156,34 +154,58 @@
                        store = new NodeStore (typeof (ProjectNode));
                }
 
-               public delegate void SelectedHandler (IWidgetSite site, 
ProjectNode node);
+               public delegate void SelectedHandler (WidgetBox box, 
ProjectNode node);
                public event SelectedHandler Selected;
 
-               void WindowFocusChanged (WindowSite site, IWidgetSite focus)
+               void WindowFocusChanged (WindowSite site, WidgetBox focus)
                {
                        if (Selected == null)
                                return;
 
                        if (focus == null)
                                Selected (null, null);
-                       else if (focus.Contents == null)
+                       else if (focus.Child == null)
                                Selected (focus, null);
                        else
-                               Selected (focus, nodes[focus.Contents] as 
ProjectNode);
+                               Selected (focus, nodes[focus.Child] as 
ProjectNode);
                }
 
                // IStetic
 
-               public WidgetSite CreateWidgetSite ()
+               public WidgetSite CreateWidgetSite (Widget w)
                {
-                       WidgetSite site = new WidgetSite (this);
+                       Menu m = null;
+
+                       WidgetSite site = new WidgetSite (w);
                        site.PopupContextMenu += delegate (object obj, 
EventArgs args) {
-                               Menu m = new ContextMenu ((WidgetSite)site);
+                               if (m == null)
+                                       m = new ContextMenu (site);
                                m.Popup ();
                        };
+                       site.Destroyed += delegate (object obj, EventArgs args) 
{
+                               if (m != null)
+                                       m.Destroy ();
+                       };
                        return site;
                }
 
+               public Placeholder CreatePlaceholder ()
+               {
+                       Menu m = null;
+
+                       Placeholder ph = new Placeholder ();
+                       ph.PopupContextMenu += delegate (object obj, EventArgs 
args) {
+                               if (m == null)
+                                       m = new ContextMenu (ph);
+                               m.Popup ();
+                       };
+                       ph.Destroyed += delegate (object obj, EventArgs args) {
+                               if (m != null)
+                                       m.Destroy ();
+                       };
+                       return ph;
+               }
+
                public Gtk.Widget LookupWidgetById (string id)
                {
                        foreach (Gtk.Widget w in nodes.Keys) {

Modified: trunk/stetic/stetic/ProjectView.cs
===================================================================
--- trunk/stetic/stetic/ProjectView.cs  2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/stetic/ProjectView.cs  2005-03-23 20:44:04 UTC (rev 42170)
@@ -60,7 +60,7 @@
                        }
                }
 
-               void WidgetSelected (IWidgetSite site, ProjectNode node)
+               void WidgetSelected (WidgetBox box, ProjectNode node)
                {
                        if (!syncing) {
                                syncing = true;

Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-03-23 20:39:18 UTC (rev 42169)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-03-23 20:44:04 UTC (rev 42170)
@@ -92,10 +92,11 @@
                        }
                }
 
-               void Selected (IWidgetSite site, ProjectNode node)
+               void Selected (WidgetBox box, ProjectNode node)
                {
                        Clear ();
 
+                       WidgetSite site = box as WidgetSite;
                        if (site == null) {
                                AppendLabel ("<i>No selection</i>");
                                return;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to