Author: danw
Date: 2005-03-23 17:26:01 -0500 (Wed, 23 Mar 2005)
New Revision: 42176

Removed:
   trunk/stetic/libstetic/IWidgetSite.cs
   trunk/stetic/libstetic/WindowSite.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/WidgetBox.cs
   trunk/stetic/libstetic/WidgetSite.cs
   trunk/stetic/libstetic/wrapper/Button.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Dialog.cs
   trunk/stetic/libstetic/wrapper/RadioButton.cs
   trunk/stetic/libstetic/wrapper/ToggleButton.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
   trunk/stetic/stetic/WidgetFactory.cs
Log:
        Move IWidgetSite and WindowSite interfaces to
        Stetic.Wrapper.Widget and Stetic.Wrapper.Window.

        * libstetic/wrapper/Widget.cs (Wrapped): override to return a
        Gtk.Widget, to get rid of lots of typecasting
        (ParentWrapper): replacement for WidgetSite.ParentSite; returns
        the wrapper for the wrapped widget's parent
        (InternalChildId, Select): Moved here from WidgetSite.

        * libstetic/wrapper/Window.cs (FocusChanged): moved here from
        WindowSite.
        (Select): override

        * libstetic/WidgetSite.cs (ParentSite): gone; replaced by
        Wrapper.Widget.ParentWrapper.
        (Internal): replaces InternalChildId.
        (Drop): call Select on the wrapper, not the site.
        (Select, UnSelect, Delete): gone

        * libstetic/IWidgetSite.cs: 
        * libstetic/WindowSite.cs: gone

        * libstetic/wrapper/Button.cs (HasResponseId): use ParentWrapper
        rather than ParentSite.

        * libstetic/wrapper/Container.cs (GladeExportChild,
        FindInternalChild): update for InternalChildId move from
        WidgetSite to Wrapper.Widget.
        (ChildWrapper): take a Wrapper.Widget instead of an IWidgetSite.
        (PlaceholderDrop): call Select on the wrapper, not the site.

        * libstetic/wrapper/Dialog.cs (Wrap): set InternalChildId on the
        wrapper, not the site.

        * stetic/ContextMenu.cs: Change all IWidgetSites to
        Stetic.Wrapper.Widgets

        * stetic/Project.cs (AddWindow): take a Stetic.Wrapper.Window
        rather than a WindowSite.
        (ProjectNode): add a "Wrapper" field

        * stetic/ProjectView.cs (RowSelected, WidgetSelected): update to
        use wrappers intead of sites.

        * stetic/Glade.cs (Import): 
        * stetic/WidgetFactory.cs (WindowFactory.OnButtonPressEvent):
        don't need to create a WindowSite for top-level windows any more.
        Just pass the wrapper to Project.AddWindow instead.


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/ChangeLog      2005-03-23 22:26:01 UTC (rev 42176)
@@ -1,5 +1,56 @@
 2005-03-23  Dan Winship  <[EMAIL PROTECTED]>
 
+       Move IWidgetSite and WindowSite interfaces to
+       Stetic.Wrapper.Widget and Stetic.Wrapper.Window.
+
+       * libstetic/wrapper/Widget.cs (Wrapped): override to return a
+       Gtk.Widget, to get rid of lots of typecasting
+       (ParentWrapper): replacement for WidgetSite.ParentSite; returns
+       the wrapper for the wrapped widget's parent
+       (InternalChildId, Select): Moved here from WidgetSite.
+
+       * libstetic/wrapper/Window.cs (FocusChanged): moved here from
+       WindowSite.
+       (Select): override
+
+       * libstetic/WidgetSite.cs (ParentSite): gone; replaced by
+       Wrapper.Widget.ParentWrapper.
+       (Internal): replaces InternalChildId.
+       (Drop): call Select on the wrapper, not the site.
+       (Select, UnSelect, Delete): gone
+
+       * libstetic/IWidgetSite.cs: 
+       * libstetic/WindowSite.cs: gone
+
+       * libstetic/wrapper/Button.cs (HasResponseId): use ParentWrapper
+       rather than ParentSite.
+
+       * libstetic/wrapper/Container.cs (GladeExportChild,
+       FindInternalChild): update for InternalChildId move from
+       WidgetSite to Wrapper.Widget.
+       (ChildWrapper): take a Wrapper.Widget instead of an IWidgetSite.
+       (PlaceholderDrop): call Select on the wrapper, not the site.
+
+       * libstetic/wrapper/Dialog.cs (Wrap): set InternalChildId on the
+       wrapper, not the site.
+
+       * stetic/ContextMenu.cs: Change all IWidgetSites to
+       Stetic.Wrapper.Widgets
+
+       * stetic/Project.cs (AddWindow): take a Stetic.Wrapper.Window
+       rather than a WindowSite.
+       (ProjectNode): add a "Wrapper" field
+
+       * stetic/ProjectView.cs (RowSelected, WidgetSelected): update to
+       use wrappers intead of sites.
+
+       * stetic/Glade.cs (Import): 
+       * stetic/WidgetFactory.cs (WindowFactory.OnButtonPressEvent):
+       don't need to create a WindowSite for top-level windows any more.
+       Just pass the wrapper to Project.AddWindow instead.
+
+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

Deleted: trunk/stetic/libstetic/IWidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/IWidgetSite.cs       2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/IWidgetSite.cs       2005-03-23 22:26:01 UTC (rev 
42176)
@@ -1,18 +0,0 @@
-using Gtk;
-using System;
-
-namespace Stetic {
-
-       public interface IWidgetSite {
-               Widget Contents { get; }
-               IWidgetSite ParentSite { get; }
-
-               bool Internal { get; }
-
-               void Select ();
-               void UnSelect ();
-
-               void Delete ();
-       }
-
-}

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/libstetic/Makefile.am  2005-03-23 22:26:01 UTC (rev 42176)
@@ -12,7 +12,6 @@
        ItemDescriptor.cs               \
        ItemGroup.cs                    \
        IStetic.cs                      \
-       IWidgetSite.cs                  \
        ObjectWrapper.cs                \
        ObjectWrapperAttribute.cs       \
        ParamSpec.cs                    \
@@ -24,7 +23,6 @@
        TranslatableAttribute.cs        \
        WidgetBox.cs                    \
        WidgetSite.cs                   \
-       WindowSite.cs                   \
        editor/Boolean.cs               \
        editor/Char.cs                  \
        editor/Color.cs                 \

Modified: trunk/stetic/libstetic/WidgetBox.cs
===================================================================
--- trunk/stetic/libstetic/WidgetBox.cs 2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/libstetic/WidgetBox.cs 2005-03-23 22:26:01 UTC (rev 42176)
@@ -54,7 +54,7 @@
                }
 
                bool isInternal;
-               protected bool Internal {
+               public virtual bool Internal {
                        get { return isInternal; }
                        set {
                                if (value == isInternal)

Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs        2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/WidgetSite.cs        2005-03-23 22:26:01 UTC (rev 
42176)
@@ -7,7 +7,7 @@
 
        public delegate void ChangedHandler (WidgetSite site);
 
-       public class WidgetSite : WidgetBox, IWidgetSite {
+       public class WidgetSite : WidgetBox {
 
                public WidgetSite (Widget child)
                {
@@ -22,19 +22,6 @@
                        }
                }
 
-               public IWidgetSite ParentSite {
-                       get {
-                               for (Widget w = Parent; ; w = w.Parent) {
-                                       if (w == null)
-                                               return null;
-                                       if (w is IWidgetSite)
-                                               return w as IWidgetSite;
-                                       if (w.Parent == null)
-                                               return WindowSite.LookupSite 
(w);
-                               }
-                       }
-               }
-
                public event ChangedHandler ShapeChanged;
 
                private void ChildContentsChanged (Stetic.Wrapper.Container 
container)
@@ -64,20 +51,16 @@
                                EmitEmpty ();
                }
 
-               string internalChildId;
-               public string InternalChildId {
+               public override bool Internal {
                        get {
-                               return internalChildId;
+                               return base.Internal;
                        }
                        set {
-                               if (internalChildId == null && value != null) {
+                               if (!base.Internal && value)
                                        DND.SourceUnset (this);
-                                       Internal = true;
-                               } else if (internalChildId != null && value == 
null) {
+                               else if (base.Internal && !value)
                                        DND.SourceSet (this, false);
-                                       Internal = false;
-                               }
-                               internalChildId = value;
+                               base.Internal = value;
                        }
                }
 
@@ -390,12 +373,12 @@
                                Gdk.Window win;
                                FindFault (x, y, out faultId, out win);
                                DropOn (w, faultId);
-                               if (w.Parent is WidgetSite)
-                                       ((WidgetSite)w.Parent).Select ();
-                       } else {
+                       } else
                                Add (w);
-                               Select ();
-                       }
+
+                       Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (w);
+                       if (wrapper != null)
+                               wrapper.Select ();
                }
 
                protected override bool OnDragDrop (DragContext ctx, int x, int 
y, uint time)
@@ -430,30 +413,15 @@
                protected override bool OnKeyReleaseEvent (Gdk.EventKey evt)
                {
                        if (evt.Key == Gdk.Key.Delete) {
-                               Delete ();
+                               if (Child != null) {
+                                       Child.Destroy ();
+                                       EmitEmpty ();
+                               }
                                return true;
                        }
                        return false;
                }
 
-               public void Select ()
-               {
-                       GrabFocus ();
-               }
-
-               public void UnSelect ()
-               {
-                       UnFocus ();
-               }
-
-               public void Delete ()
-               {
-                       if (Child != null) {
-                               Child.Destroy ();
-                               EmitEmpty ();
-                       }
-               }
-
                public override string ToString ()
                {
                        if (Child == null)

Deleted: trunk/stetic/libstetic/WindowSite.cs
===================================================================
--- trunk/stetic/libstetic/WindowSite.cs        2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/WindowSite.cs        2005-03-23 22:26:01 UTC (rev 
42176)
@@ -1,99 +0,0 @@
-using Gtk;
-using GLib;
-using System;
-using System.Collections;
-
-namespace Stetic {
-
-       public class WindowSite : IWidgetSite {
-               Gtk.Window contents;
-
-               static Hashtable windowSites = new Hashtable ();
-
-               public WindowSite (Gtk.Window contents)
-               {
-                       this.contents = contents;
-                       windowSites[contents] = this;
-                       contents.DeleteEvent += ContentsDeleted;
-                       contents.SetFocus += ContentsSetFocus;
-               }
-
-               void ContentsDeleted (object obj, EventArgs args)
-               {
-                       if (FocusChanged != null) {
-                               FocusChanged (this, null);
-                               FocusChanged = null;
-                       }
-                       windowSites.Remove (contents);
-               }
-
-               public delegate void FocusChangedHandler (WindowSite site, 
WidgetBox focus);
-               public event FocusChangedHandler FocusChanged;
-
-               [ConnectBefore] // otherwise contents.Focus will be the new 
focus, not the old
-               void ContentsSetFocus (object obj, SetFocusArgs args)
-               {
-                       Widget w;
-
-                       w = contents.Focus;
-                       while (w != null && !(w is WidgetBox))
-                               w = w.Parent;
-                       WidgetBox oldf = (WidgetBox)w;
-
-                       w = args.Focus;
-                       while (w != null && !(w is WidgetBox))
-                               w = w.Parent;
-                       WidgetBox newf = (WidgetBox)w;
-
-                       if (oldf == newf)
-                               return;
-
-                       if (oldf != null)
-                               oldf.UnFocus ();
-                       if (newf != null)
-                               newf.Focus ();
-
-                       if (FocusChanged != null)
-                               FocusChanged (this, newf);
-               }
-
-               public static IWidgetSite LookupSite (Widget window)
-               {
-                       return windowSites[window] as IWidgetSite;
-               }
-
-               public Widget Contents {
-                       get {
-                               return contents;
-                       }
-               }
-
-               public IWidgetSite ParentSite {
-                       get {
-                               return null;
-                       }
-               }
-
-               public bool Internal {
-                       get {
-                               return false;
-                       }
-               }
-
-               public void Delete ()
-               {
-                       contents.Destroy ();
-               }
-
-               public void Select ()
-               {
-                       contents.Show ();
-                       contents.Focus = null;
-               }
-
-               public void UnSelect ()
-               {
-                       ;
-               }
-       }
-}

Modified: trunk/stetic/libstetic/wrapper/Button.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Button.cs    2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/wrapper/Button.cs    2005-03-23 22:26:01 UTC (rev 
42176)
@@ -252,13 +252,13 @@
 
                public bool HasResponseId {
                        get {
-                               WidgetSite site = button.Parent as WidgetSite;
-                               if (site == null)
+                               Stetic.Wrapper.Widget pwrap = ParentWrapper;
+                               if (pwrap == null)
                                        return false;
-                               site = site.ParentSite as WidgetSite;
-                               if (site == null)
+                               pwrap = pwrap.ParentWrapper;
+                               if (pwrap == null)
                                        return false;
-                               return site.InternalChildId == "action_area";
+                               return pwrap.InternalChildId == "action_area";
                        }
                }
 

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-23 22:26:01 UTC (rev 
42176)
@@ -75,15 +75,12 @@
                        while (child != null && !(child is WidgetSite))
                                child = child.Parent;
 
-                       WidgetSite site = child as WidgetSite;
-                       if (site != null) {
-                               if (site.InternalChildId != null)
-                                       internalId = site.InternalChildId;
-                               else {
-                                       ObjectWrapper childwrapper = 
ChildWrapper (site);
-                                       if (childwrapper != null)
-                                               GladeUtils.GetProps 
(childwrapper, out childprops);
-                               }
+                       if (InternalChildId != null)
+                               internalId = InternalChildId;
+                       else {
+                               ObjectWrapper childwrapper = ChildWrapper 
(wrapper);
+                               if (childwrapper != null)
+                                       GladeUtils.GetProps (childwrapper, out 
childprops);
                        }
                }
 
@@ -105,11 +102,12 @@
                {
                        Container ancestor = this;
                        while (ancestor != null) {
-                               foreach (WidgetSite site in ancestor.Sites) {
-                                       if (site.InternalChildId == childId)
-                                               return site.Contents;
+                               foreach (Gtk.Widget w in 
ancestor.container.Children) {
+                                       Widget wrapper = Lookup (w);
+                                       if (wrapper != null && 
wrapper.InternalChildId == childId)
+                                               return w;
                                }
-                               ancestor = Lookup (ancestor.container.Parent);
+                               ancestor = ParentWrapper;
                        }
                        return null;
                }
@@ -131,21 +129,23 @@
                        return Stetic.ObjectWrapper.Lookup (obj) as 
Stetic.Wrapper.Container;
                }
 
-               public static Stetic.Wrapper.Container.ContainerChild 
ChildWrapper (Stetic.IWidgetSite site) {
-                       Gtk.Widget sitew = site as Gtk.Widget;
-                       if (sitew == null || site.ParentSite == null)
+               public static Stetic.Wrapper.Container.ContainerChild 
ChildWrapper (Stetic.Wrapper.Widget wrapper) {
+                       Stetic.Wrapper.Container parentWrapper = 
wrapper.ParentWrapper;
+                       if (parentWrapper == null)
                                return null;
 
-                       Gtk.Container parent = site.ParentSite.Contents as 
Gtk.Container;
+                       Gtk.Container parent = parentWrapper.Wrapped as 
Gtk.Container;
                        if (parent == null)
                                return null;
 
-                       Stetic.Wrapper.Container pwrap = 
Stetic.Wrapper.Container.Lookup (parent);
-                       if (pwrap == null)
+                       Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
+                       while (child != null && child.Parent != parent)
+                               child = child.Parent;
+                       if (child == null)
                                return null;
 
                        Type ct = null;
-                       for (Type t = pwrap.GetType (); t != null; t = 
t.BaseType) {
+                       for (Type t = parentWrapper.GetType (); t != null; t = 
t.BaseType) {
                                ct = childTypes[t] as Type;
                                if (ct != null)
                                        break;
@@ -153,8 +153,8 @@
                        if (ct == null)
                                return null;
 
-                       Gtk.Container.ContainerChild cc = parent[sitew];
-                       return Stetic.ObjectWrapper.Create (pwrap.stetic, ct, 
cc) as ContainerChild;
+                       Gtk.Container.ContainerChild cc = parent[child];
+                       return Stetic.ObjectWrapper.Create 
(parentWrapper.stetic, ct, cc) as ContainerChild;
                }
 
                public delegate void ContentsChangedHandler (Container 
container);
@@ -196,7 +196,9 @@
                        WidgetSite site = CreateWidgetSite (dropped);
                        ReplaceChild (ph, site);
                        ph.Destroy ();
-                       site.Select ();
+                       Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (dropped);
+                       if (wrapper != null)
+                               wrapper.Select ();
                        EmitContentsChanged ();
                }
 

Modified: trunk/stetic/libstetic/wrapper/Dialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-23 22:26:01 UTC (rev 
42176)
@@ -31,23 +31,24 @@
                public override void Wrap (object obj, bool initialized)
                {
                        WidgetSite site;
+                       Stetic.Wrapper.Widget wrapper;
 
                        base.Wrap (obj, initialized);
                        dialog.HasSeparator = false;
 
                        dialog.VBox.Unparent ();
                        site = CreateWidgetSite (dialog.VBox);
-                       site.InternalChildId = "vbox";
                        dialog.Add (site);
-                       ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.VBox), dialog.VBox);
+                       wrapper = ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.VBox), dialog.VBox) as Stetic.Wrapper.Widget;
+                       wrapper.InternalChildId = "vbox";
                        if (dialog.VBox.Name == "GtkVBox")
                                dialog.VBox.Name = dialog.Name + "_vbox";
 
                        dialog.ActionArea.Unparent ();
                        site = CreateWidgetSite (dialog.ActionArea);
-                       site.InternalChildId = "action_area";
                        dialog.VBox.PackEnd (site, false, true, 0);
-                       ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.HButtonBox), dialog.ActionArea);
+                       wrapper = ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.HButtonBox), dialog.ActionArea) as Stetic.Wrapper.Widget;
+                       wrapper.InternalChildId = "action_area";
                        if (dialog.ActionArea.Name == "GtkHButtonBox")
                                dialog.ActionArea.Name = dialog.Name + 
"_action_area";
 

Modified: trunk/stetic/libstetic/wrapper/RadioButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/RadioButton.cs       2005-03-23 22:24:08 UTC 
(rev 42175)
+++ trunk/stetic/libstetic/wrapper/RadioButton.cs       2005-03-23 22:26:01 UTC 
(rev 42176)
@@ -48,7 +48,7 @@
                        if (group != null)
                                stetic.GladeImportComplete += SetGroup;
                        else {
-                               GroupList.Add (((Gtk.Widget)Wrapped).Name);
+                               GroupList.Add (Wrapped.Name);
                                GroupLeaders.Add (Wrapped);
                        }
                }

Modified: trunk/stetic/libstetic/wrapper/ToggleButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ToggleButton.cs      2005-03-23 22:24:08 UTC 
(rev 42175)
+++ trunk/stetic/libstetic/wrapper/ToggleButton.cs      2005-03-23 22:26:01 UTC 
(rev 42176)
@@ -43,7 +43,7 @@
                        base.Wrap (obj, initialized);
                        if (!initialized) {
                                Icon = null;
-                               Label = ((Gtk.Widget)Wrapped).Name;
+                               Label = Wrapped.Name;
                        }
                }
        }

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-23 22:26:01 UTC (rev 
42176)
@@ -29,19 +29,24 @@
                {
                        base.Wrap (obj, initialized);
 
-                       Gtk.Widget widget = (Gtk.Widget)Wrapped;
-                       if (!(widget is Gtk.Window))
-                               widget.ShowAll ();
+                       if (!(Wrapped is Gtk.Window))
+                               Wrapped.ShowAll ();
 
                        Type type = GetType ();
                        if (!counters.Contains (type))
                                counters[type] = 1;
 
                        if (!initialized)
-                               widget.Name = type.Name.ToLower () + 
((int)counters[type]).ToString ();
+                               Wrapped.Name = type.Name.ToLower () + 
((int)counters[type]).ToString ();
                        counters[type] = (int)counters[type] + 1;
                }
 
+               public new Gtk.Widget Wrapped {
+                       get {
+                               return (Gtk.Widget)base.Wrapped;
+                       }
+               }
+
                protected virtual void GladeImport (string className, string 
id, Hashtable props)
                {
                        GladeUtils.ImportWidget (stetic, this, className, id, 
props);
@@ -72,6 +77,39 @@
                        return ph;
                }
 
+               public Stetic.Wrapper.Container ParentWrapper {
+                       get {
+                               Gtk.Widget p = Wrapped.Parent;
+                               while (p != null && (p is WidgetSite))
+                                       p = p.Parent;
+                               return Stetic.Wrapper.Container.Lookup (p);
+                       }
+               }
+
+               string internalChildId;
+               public string InternalChildId {
+                       get {
+                               return internalChildId;
+                       }
+                       set {
+                               internalChildId = value;
+
+                               if (Wrapped != null) {
+                                       WidgetSite site = Wrapped.Parent as 
WidgetSite;
+                                       if (site != null)
+                                               site.Internal = (value != null);
+                               }
+                       }
+               }
+
+               public virtual void Select ()
+               {
+                       Gtk.Widget w = Wrapped;
+                       if (!w.CanFocus && w.Parent is WidgetSite)
+                               w = w.Parent;
+                       w.GrabFocus ();
+               }
+
                public virtual bool HExpandable { get { return false; } }
                public virtual bool VExpandable { get { return false; } }
 
@@ -82,13 +120,13 @@
                                if (Wrapped is Gtk.Window)
                                        return window_visible;
                                else
-                                       return ((Gtk.Widget)Wrapped).Visible;
+                                       return Wrapped.Visible;
                        }
                        set {
                                if (Wrapped is Gtk.Window)
                                        window_visible = value;
                                else
-                                       ((Gtk.Widget)Wrapped).Visible = value;
+                                       Wrapped.Visible = value;
                        }
                }
 
@@ -101,21 +139,18 @@
                        set {
                                hasDefault = value;
 
-                               Gtk.Widget widget = (Gtk.Widget)Wrapped;
-                               if (widget.Toplevel != null)
-                                       widget.HasDefault = hasDefault;
+                               if (Wrapped.Toplevel != null)
+                                       Wrapped.HasDefault = hasDefault;
                                else
-                                       widget.HierarchyChanged += 
HierarchyChanged;
+                                       Wrapped.HierarchyChanged += 
HierarchyChanged;
                        }
                }
 
                void HierarchyChanged (object obj, Gtk.HierarchyChangedArgs 
args)
                {
-                       Gtk.Widget widget = (Gtk.Widget)Wrapped;
-
-                       if (widget.Toplevel != null) {
-                               widget.HasDefault = hasDefault;
-                               widget.HierarchyChanged -= HierarchyChanged;
+                       if (Wrapped.Toplevel != null) {
+                               Wrapped.HasDefault = hasDefault;
+                               Wrapped.HierarchyChanged -= HierarchyChanged;
                        }
                }
        }

Modified: trunk/stetic/libstetic/wrapper/Window.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Window.cs    2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/libstetic/wrapper/Window.cs    2005-03-23 22:26:01 UTC (rev 
42176)
@@ -50,14 +50,55 @@
                                if (window.Child is Placeholder)
                                        window.Child.SetSizeRequest (200, 200);
                        }
+
                        window.DeleteEvent += DeleteEvent;
+                       window.SetFocus += SetFocus;
                }
 
+               public delegate void FocusChangedHandler (Stetic.Wrapper.Window 
wrapper, WidgetBox focus);
+               public event FocusChangedHandler FocusChanged;
+
+               [ConnectBefore] // otherwise contents.Focus will be the new 
focus, not the old
+               void SetFocus (object obj, Gtk.SetFocusArgs args)
+               {
+                       Gtk.Widget w;
+
+                       w = ((Gtk.Window)Wrapped).Focus;
+                       while (w != null && !(w is WidgetBox))
+                               w = w.Parent;
+                       WidgetBox oldf = (WidgetBox)w;
+
+                       w = args.Focus;
+                       while (w != null && !(w is WidgetBox))
+                               w = w.Parent;
+                       WidgetBox newf = (WidgetBox)w;
+
+                       if (oldf == newf)
+                               return;
+
+                       if (oldf != null)
+                               oldf.UnFocus ();
+                       if (newf != null)
+                               newf.Focus ();
+
+                       if (FocusChanged != null)
+                               FocusChanged (this, newf);
+               }
+
+               public override void Select ()
+               {
+                       Wrapped.Show ();
+                       ((Gtk.Window)Wrapped).Focus = null;
+               }
+
                [ConnectBefore]
                void DeleteEvent (object obj, Gtk.DeleteEventArgs args)
                {
-                       ((Gtk.Widget)Wrapped).Hide ();
+                       Wrapped.Hide ();
                        args.RetVal = true;
+
+                       if (FocusChanged != null)
+                               FocusChanged (this, null);
                }
 
                public override bool HExpandable { get { return true; } }

Modified: trunk/stetic/stetic/ContextMenu.cs
===================================================================
--- trunk/stetic/stetic/ContextMenu.cs  2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/stetic/ContextMenu.cs  2005-03-23 22:26:01 UTC (rev 42176)
@@ -7,13 +7,13 @@
 
        public class ContextMenu : Gtk.Menu {
 
-               IWidgetSite site;
+               Stetic.Wrapper.Widget wrapper;
 
                public ContextMenu (Placeholder ph)
                {
                        MenuItem item;
 
-                       this.site = null;
+                       this.wrapper = null;
 
                        item = LabelItem ("Placeholder");
                        item.Sensitive = false;
@@ -23,24 +23,18 @@
                        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);
+                       BuildContextMenu (Stetic.Wrapper.Widget.Lookup 
(ph.Parent), false, false, ph);
                }
 
-               public ContextMenu (IWidgetSite site) : this (site, site as 
Gtk.Widget) {}
+               public ContextMenu (Stetic.Wrapper.Widget wrapper) : this 
(wrapper, wrapper.Wrapped.Parent) {}
 
-               public ContextMenu (IWidgetSite site, Gtk.Widget context)
+               public ContextMenu (Stetic.Wrapper.Widget wrapper, Gtk.Widget 
context)
                {
                        MenuItem item;
 
-                       this.site = site;
+                       this.wrapper = wrapper;
 
-                       item = LabelItem (site.Contents.Name);
+                       item = LabelItem (wrapper.Wrapped.Name);
                        item.Sensitive = false;
                        Add (item);
 
@@ -48,22 +42,19 @@
                        item.Activated += DoSelect;
                        Add (item);
 
-                       Stetic.Wrapper.Object wrapper = 
Stetic.Wrapper.Object.Lookup (site.Contents);
-                       if (wrapper != null) {
-                               foreach (CommandDescriptor cmd in 
wrapper.ContextMenuItems.Items) {
-                                       item = new MenuItem (cmd.Label);
-                                       if (cmd.Enabled (wrapper, context))
-                                               item.Activated += new 
Stupid69614Workaround (cmd, wrapper, context).Activate;
-                                       else
-                                               item.Sensitive = false;
-                                       Add (item);
-                               }
+                       foreach (CommandDescriptor cmd in 
wrapper.ContextMenuItems.Items) {
+                               item = new MenuItem (cmd.Label);
+                               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);
+                       BuildContextMenu (wrapper.ParentWrapper, true, 
wrapper.InternalChildId != null, context);
                }
 
-               void BuildContextMenu (IWidgetSite parentSite, bool occupied, 
bool isInternal, Widget context)
+               void BuildContextMenu (Stetic.Wrapper.Widget parentWrapper, 
bool occupied, bool isInternal, Widget context)
                {
                        MenuItem item;
 
@@ -86,11 +77,11 @@
                                item.Sensitive = false;
                        Add (item);
 
-                       for (; parentSite != null; parentSite = 
parentSite.ParentSite) {
+                       for (; parentWrapper != null; parentWrapper = 
parentWrapper.ParentWrapper) {
                                Add (new SeparatorMenuItem ());
 
-                               item = LabelItem (parentSite.Contents.Name);
-                               item.Submenu = new ContextMenu (parentSite, 
context);
+                               item = LabelItem (parentWrapper.Wrapped.Name);
+                               item.Submenu = new ContextMenu (parentWrapper, 
context);
                                Add (item);
                        }
 
@@ -116,12 +107,12 @@
 
                void DoSelect (object obj, EventArgs args)
                {
-                       site.Select ();
+                       wrapper.Select ();
                }
 
                void DoDelete (object obj, EventArgs args)
                {
-                       site.Delete ();
+                       wrapper.Wrapped.Destroy ();
                }
 
                static MenuItem LabelItem (string labelString)

Modified: trunk/stetic/stetic/Glade.cs
===================================================================
--- trunk/stetic/stetic/Glade.cs        2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/stetic/Glade.cs        2005-03-23 22:26:01 UTC (rev 42176)
@@ -32,11 +32,10 @@
 
                        project.BeginGladeImport ();
                        foreach (XmlNode toplevel in node.SelectNodes 
("widget")) {
-                               Widget w = ImportWidget (project, null, null, 
toplevel);
-                               if (w == null)
-                                       continue;
-                               WindowSite site = new WindowSite 
((Gtk.Window)w);
-                               project.AddWindow (site);
+                               Stetic.Wrapper.Window window =
+                                       ImportWidget (project, null, null, 
toplevel) as Stetic.Wrapper.Window;
+                               if (window != null)
+                                       project.AddWindow (window);
                        }
                        project.EndGladeImport ();
                }
@@ -44,7 +43,7 @@
                [DllImport("libsteticglue")]
                static extern bool stetic_g_value_init_for_child_property (ref 
GLib.Value value, string className, string propertyName);
 
-               static Widget ImportWidget (Project project, 
Stetic.Wrapper.Container parent, XmlNode thischild, XmlNode widget)
+               static Stetic.Wrapper.Widget ImportWidget (Project project, 
Stetic.Wrapper.Container parent, XmlNode thischild, XmlNode widget)
                {
                        string className = widget.Attributes["class"].Value;
                        string id = widget.Attributes["id"].Value;
@@ -81,7 +80,7 @@
                                }
                        }
 
-                       return (Gtk.Widget)wrapper.Wrapped;
+                       return (Stetic.Wrapper.Widget)wrapper;
                }
 
                static void ExtractProperties (XmlNodeList nodes, out Hashtable 
props)

Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs      2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/stetic/Project.cs      2005-03-23 22:26:01 UTC (rev 42176)
@@ -14,18 +14,18 @@
                        store = new NodeStore (typeof (ProjectNode));
                }
 
-               public void AddWindow (WindowSite site)
+               public void AddWindow (Stetic.Wrapper.Window window)
                {
-                       AddWindow (site, false);
+                       AddWindow (window, false);
                }
 
-               public void AddWindow (WindowSite site, bool select)
+               public void AddWindow (Stetic.Wrapper.Window window, bool 
select)
                {
-                       site.FocusChanged += WindowFocusChanged;
-                       AddWidget (site.Contents, null, -1);
+                       window.FocusChanged += WindowFocusChanged;
+                       AddWidget (window.Wrapped, null, -1);
 
                        if (select)
-                               WindowFocusChanged (site, null);
+                               WindowFocusChanged (window, null);
                }
 
                void AddWidget (Widget widget, ProjectNode parent)
@@ -35,10 +35,11 @@
 
                void AddWidget (Widget widget, ProjectNode parent, int position)
                {
-                       if (Stetic.Wrapper.Widget.Lookup (widget) == null)
+                       Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (widget);
+                       if (wrapper == null)
                                return;
 
-                       ProjectNode node = new ProjectNode (widget);
+                       ProjectNode node = new ProjectNode (wrapper);
                        nodes[widget] = node;
                        if (parent == null) {
                                if (position == -1)
@@ -157,7 +158,7 @@
                public delegate void SelectedHandler (WidgetBox box, 
ProjectNode node);
                public event SelectedHandler Selected;
 
-               void WindowFocusChanged (WindowSite site, WidgetBox focus)
+               void WindowFocusChanged (Stetic.Wrapper.Window window, 
WidgetBox focus)
                {
                        if (Selected == null)
                                return;
@@ -179,7 +180,7 @@
                        WidgetSite site = new WidgetSite (w);
                        site.PopupContextMenu += delegate (object obj, 
EventArgs args) {
                                if (m == null)
-                                       m = new ContextMenu (site);
+                                       m = new ContextMenu 
(Stetic.Wrapper.Widget.Lookup (site.Contents));
                                m.Popup ();
                        };
                        site.Destroyed += delegate (object obj, EventArgs args) 
{
@@ -231,19 +232,24 @@
 
        [TreeNode (ColumnCount=2)]
        public class ProjectNode : TreeNode {
-               Widget widget;
+               Stetic.Wrapper.Widget wrapper;
                Gdk.Pixbuf icon;
 
-               public ProjectNode (Widget widget)
+               public ProjectNode (Stetic.Wrapper.Widget wrapper)
                {
-                       this.widget = widget;
-                       Stetic.Wrapper.Object wrapper = 
Stetic.Wrapper.Object.Lookup (widget);
+                       this.wrapper = wrapper;
                        icon = Stetic.Palette.IconForType (wrapper.GetType ());
                }
 
+               public Stetic.Wrapper.Widget Wrapper {
+                       get {
+                               return wrapper;
+                       }
+               }
+
                public Widget Widget {
                        get {
-                               return widget;
+                               return (Gtk.Widget)wrapper.Wrapped;
                        }
                }
 
@@ -257,13 +263,13 @@
                [TreeNodeValue (Column=1)]
                public string Name {
                        get {
-                               return widget.Name;
+                               return Widget.Name;
                        }
                }
 
                public override string ToString ()
                {
-                       return "[ProjectNode " + GetHashCode().ToString() + " " 
+ widget.GetType().FullName + " '" + Name + "']";
+                       return "[ProjectNode " + GetHashCode().ToString() + " " 
+ Widget.GetType().FullName + " '" + Name + "']";
                }
        }
 

Modified: trunk/stetic/stetic/ProjectView.cs
===================================================================
--- trunk/stetic/stetic/ProjectView.cs  2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/stetic/ProjectView.cs  2005-03-23 22:26:01 UTC (rev 42176)
@@ -27,7 +27,7 @@
                        project.Selected += WidgetSelected;
                }
 
-               IWidgetSite SelectedSite {
+               Stetic.Wrapper.Widget SelectedWrapper {
                        get {
                                ITreeNode[] nodes = NodeSelection.SelectedNodes;
 
@@ -35,15 +35,7 @@
                                        return null;
 
                                ProjectNode node = (ProjectNode)nodes[0];
-
-                               Widget w = node.Widget.Parent;
-                               while (w != null && !(w is IWidgetSite))
-                                       w = w.Parent;
-
-                               if (w == null)
-                                       return WindowSite.LookupSite 
(node.Widget);
-                               else
-                                       return (IWidgetSite)w;
+                               return node.Wrapper;
                        }
                }
 
@@ -53,7 +45,7 @@
                {
                        if (!syncing) {
                                syncing = true;
-                               IWidgetSite selection = SelectedSite;
+                               Stetic.Wrapper.Widget selection = 
SelectedWrapper;
                                if (selection != null)
                                        selection.Select ();
                                syncing = false;
@@ -81,7 +73,7 @@
 
                protected override bool OnPopupMenu ()
                {
-                       IWidgetSite selection = SelectedSite;
+                       Stetic.Wrapper.Widget selection = SelectedWrapper;
 
                        if (selection != null) {
                                Menu m = new ContextMenu (selection);

Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-03-23 22:24:08 UTC (rev 42175)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-03-23 22:26:01 UTC (rev 42176)
@@ -11,7 +11,8 @@
                Hashtable editors;
                Hashtable sensitives;
 
-               ObjectWrapper selection, packingSelection;
+               Stetic.Wrapper.Widget selection;
+               Stetic.Wrapper.Container.ContainerChild packingSelection;
 
                public PropertyGrid (Project project)
                {
@@ -102,16 +103,15 @@
                                return;
                        }
 
-                       selection = Stetic.ObjectWrapper.Lookup (site.Contents);
+                       selection = Stetic.Wrapper.Widget.Lookup 
(site.Contents);
                        if (selection == null)
                                return;
                        selection.Notify += Notified;
 
-                       if (selection is Stetic.Wrapper.Widget)
-                               AppendProperty (new PropertyDescriptor (typeof 
(Stetic.Wrapper.Widget), typeof (Gtk.Widget), "Name"), selection);
+                       AppendProperty (new PropertyDescriptor (typeof 
(Stetic.Wrapper.Widget), typeof (Gtk.Widget), "Name"), selection);
                        AppendWrapperGroups (selection);
 
-                       packingSelection = 
Stetic.Wrapper.Container.ChildWrapper (site);
+                       packingSelection = 
Stetic.Wrapper.Container.ChildWrapper (selection);
                        if (packingSelection != null && 
packingSelection.ItemGroups.Count > 0) {
                                AppendWrapperGroups (packingSelection);
                                packingSelection.Notify += Notified;

Modified: trunk/stetic/stetic/WidgetFactory.cs
===================================================================
--- trunk/stetic/stetic/WidgetFactory.cs        2005-03-23 22:24:08 UTC (rev 
42175)
+++ trunk/stetic/stetic/WidgetFactory.cs        2005-03-23 22:26:01 UTC (rev 
42176)
@@ -46,13 +46,12 @@
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evt)
                {
-                       Stetic.Wrapper.Widget wrapper = 
Stetic.ObjectWrapper.Create (project, wrapperType) as Stetic.Wrapper.Widget;
+                       Stetic.Wrapper.Window wrapper = 
Stetic.ObjectWrapper.Create (project, wrapperType) as Stetic.Wrapper.Window;
 
                        Gtk.Window win = wrapper.Wrapped as Gtk.Window;
                        win.Present ();
 
-                       WindowSite site = new WindowSite (win);
-                       project.AddWindow (site, true);
+                       project.AddWindow (wrapper, true);
 
                        return true;
                }

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

Reply via email to