Author: danw
Date: 2005-03-14 16:46:09 -0500 (Mon, 14 Mar 2005)
New Revision: 41806

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/WidgetSite.cs
   trunk/stetic/libstetic/wrapper/Box.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Expander.cs
   trunk/stetic/libstetic/wrapper/Table.cs
   trunk/stetic/stetic/Glade.cs
   trunk/stetic/stetic/Project.cs
   trunk/stetic/stetic/ProjectView.cs
   trunk/stetic/stetic/PropertyGrid.cs
   trunk/stetic/stetic/Stetic.cs
   trunk/stetic/stetic/WidgetFactory.cs
Log:
        * libstetic/WidgetSite.cs: Make OccupancyChanged mean only
        "Occupancy changed", and add a new ShapeChanged event for when
        something else happens that may affect AutoSizing in its parent.
        (ToString): override this for debug purposes

        * libstetic/wrapper/Container.cs (CreateWidgetSite, SiteRemoved):
        connect to/disconnect from ShapeChanged
        (SiteShapeChanged): new virtual method
        (SiteRemoved): call EmitContentsChanged()

        * libstetic/wrapper/Box.cs (InsertBefore, InsertAfter, DropOn):
        call EmitContentsChanged()
        (SiteShapeChanged): connect to this, not OccupancyChanged

        * libstetic/wrapper/Expander.cs: don't EmitContentsChanged when
        toggling the expander, make HExpandable/VExpandable not depend on
        whether or not the expander is expanded.

        * libstetic/wrapper/Table.cs (Sync): EmitContentsChanged() iff we
        added sites.
        (SiteShapeChanged): connect to this, not OccupancyChanged

        * stetic/Project.cs (AddWindow): take a WindowSite rather than a
        Window, and connect to its FocusChanged event
        (AddWidget): connect to the widget's Destroyed event
        (WidgetDestroyed): remove the widget from the tree
        (ContentsChanged): simplify using new gtk# api
        (Selected): new event, emitted from the WindowSite.FocusChanged
        handler

        * stetic/ProjectView.cs (ProjectView): connect to the project's
        "Selected" event.
        (RowSelected): if not already syncing, grab the selection on the
        widget corresponding to the row.
        (WidgetSelected): if not already syncing, move the table selection
        to the selected widget.

        * stetic/Stetic.cs: pass Project to the PropertyGrid.
        (Select, NoSelection): gone; the PropertyGrid snoops the Project
        directly now.

        * stetic/Glade.cs (Import):
        * stetic/WidgetFactory.cs (WindowFactory): remove focus-handling
        code; Project.AddWindow will deal with it now

        * stetic/PropertyGrid.cs (PropertyGrid): take a Project and
        connect to its Selected event and set the selection directly from
        that.


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/ChangeLog      2005-03-14 21:46:09 UTC (rev 41806)
@@ -1,3 +1,54 @@
+2005-03-14  Dan Winship  <[EMAIL PROTECTED]>
+
+       * libstetic/WidgetSite.cs: Make OccupancyChanged mean only
+       "Occupancy changed", and add a new ShapeChanged event for when
+       something else happens that may affect AutoSizing in its parent.
+       (ToString): override this for debug purposes
+
+       * libstetic/wrapper/Container.cs (CreateWidgetSite, SiteRemoved):
+       connect to/disconnect from ShapeChanged
+       (SiteShapeChanged): new virtual method
+       (SiteRemoved): call EmitContentsChanged()
+
+       * libstetic/wrapper/Box.cs (InsertBefore, InsertAfter, DropOn):
+       call EmitContentsChanged()
+       (SiteShapeChanged): connect to this, not OccupancyChanged
+
+       * libstetic/wrapper/Expander.cs: don't EmitContentsChanged when
+       toggling the expander, make HExpandable/VExpandable not depend on
+       whether or not the expander is expanded.
+
+       * libstetic/wrapper/Table.cs (Sync): EmitContentsChanged() iff we
+       added sites.
+       (SiteShapeChanged): connect to this, not OccupancyChanged
+
+       * stetic/Project.cs (AddWindow): take a WindowSite rather than a
+       Window, and connect to its FocusChanged event
+       (AddWidget): connect to the widget's Destroyed event
+       (WidgetDestroyed): remove the widget from the tree
+       (ContentsChanged): simplify using new gtk# api
+       (Selected): new event, emitted from the WindowSite.FocusChanged
+       handler
+
+       * stetic/ProjectView.cs (ProjectView): connect to the project's
+       "Selected" event.
+       (RowSelected): if not already syncing, grab the selection on the
+       widget corresponding to the row.
+       (WidgetSelected): if not already syncing, move the table selection
+       to the selected widget.
+
+       * stetic/Stetic.cs: pass Project to the PropertyGrid.
+       (Select, NoSelection): gone; the PropertyGrid snoops the Project
+       directly now.
+
+       * stetic/Glade.cs (Import):
+       * stetic/WidgetFactory.cs (WindowFactory): remove focus-handling
+       code; Project.AddWindow will deal with it now
+
+       * stetic/PropertyGrid.cs (PropertyGrid): take a Project and
+       connect to its Selected event and set the selection directly from
+       that.
+
 2005-03-11  Dan Winship  <[EMAIL PROTECTED]>
 
        First draft of Glade export.

Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs        2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/libstetic/WidgetSite.cs        2005-03-14 21:46:09 UTC (rev 
41806)
@@ -5,7 +5,7 @@
 
 namespace Stetic {
 
-       public delegate void OccupancyChangedHandler (WidgetSite site);
+       public delegate void ChangedHandler (WidgetSite site);
 
        public class WidgetSite : WidgetBox, IWidgetSite {
 
@@ -40,10 +40,12 @@
                        }
                }
 
+               public event ChangedHandler ShapeChanged;
+
                private void ChildContentsChanged (Stetic.Wrapper.Container 
container)
                {
-                       if (OccupancyChanged != null)
-                               OccupancyChanged (this);
+                       if (ShapeChanged != null)
+                               ShapeChanged (this);
                }
 
                protected override void OnAdded (Widget child)
@@ -100,8 +102,7 @@
                                case SiteOccupancy.Empty:
                                        SetSizeRequest (emptySize.Width, 
emptySize.Height);
                                        DND.DestSet (this, true);
-                                       if (OccupancyChanged != null)
-                                               OccupancyChanged (this);
+                                       EmitOccupancyChanged ();
                                        break;
 
                                case SiteOccupancy.Occupied:
@@ -110,8 +111,7 @@
                                                DND.DestSet (this, false);
                                        else
                                                DND.DestUnset (this);
-                                       if (OccupancyChanged != null)
-                                               OccupancyChanged (this);
+                                       EmitOccupancyChanged ();
                                        break;
 
                                case SiteOccupancy.PseudoOccupied:
@@ -123,8 +123,16 @@
                        }
                }
 
-               public event OccupancyChangedHandler OccupancyChanged;
+               public event ChangedHandler OccupancyChanged;
 
+               void EmitOccupancyChanged ()
+               {
+                       if (OccupancyChanged != null)
+                               OccupancyChanged (this);
+                       if (ShapeChanged != null)
+                               ShapeChanged (this);
+               }
+
                public bool Occupied {
                        get { return (Occupancy != SiteOccupancy.Empty); }
                }
@@ -399,11 +407,19 @@
                public void Delete ()
                {
                        if (Child != null) {
-                               Remove (Child);
-                               if (OccupancyChanged != null)
-                                       OccupancyChanged (this);
+                               Child.Destroy ();
+                               EmitOccupancyChanged ();
                        }
                }
 
+               public override string ToString ()
+               {
+                       if (Child == null)
+                               return "[Empty WidgetSite " + 
GetHashCode().ToString() + "]";
+                       else if (Child.Name == null)
+                               return "[WidgetSite " + 
GetHashCode().ToString() + ": " + Child.ToString() + " " + 
Child.GetHashCode().ToString() + "]";
+                       else
+                               return "[WidgetSite " + 
GetHashCode().ToString() + ": " + Child.ToString() + " '" + Child.Name + "' " + 
Child.GetHashCode().ToString() + "]";
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs       2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/libstetic/wrapper/Box.cs       2005-03-14 21:46:09 UTC (rev 
41806)
@@ -98,6 +98,7 @@
                                box.PackEnd (site);
                                box.ReorderChild (site, bc.Position + 1);
                        }
+                       EmitContentsChanged ();
                }
 
                [Command ("Insert After", "Insert an empty row/column after the 
selected one")]
@@ -112,14 +113,15 @@
                                box.PackEnd (site);
                                box.ReorderChild (site, bc.Position);
                        }
+                       EmitContentsChanged ();
                }
 
-               protected override void SiteOccupancyChanged (WidgetSite site) {
+               protected override void SiteShapeChanged (WidgetSite site) {
                        if (AutoSize[site]) {
                                Gtk.Box.BoxChild bc = ((Gtk.Box)Wrapped)[site] 
as Gtk.Box.BoxChild;
                                bc.Expand = bc.Fill = (this is HBox) ? 
site.HExpandable : site.VExpandable;
                        }
-                       base.SiteOccupancyChanged (site);
+                       base.SiteShapeChanged (site);
                }
 
                void box_ParentSet (object obj, Gtk.ParentSetArgs args)
@@ -142,6 +144,7 @@
                        box.PackStart (site);
                        site.Add (w);
                        box.ReorderChild (site, (int)faultId);
+                       EmitContentsChanged ();
 
                        Sync ();
                }

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-14 21:46:09 UTC (rev 
41806)
@@ -167,6 +167,7 @@
                {
                        WidgetSite site = base.CreateWidgetSite ();
                        site.OccupancyChanged += SiteOccupancyChanged;
+                       site.ShapeChanged += SiteShapeChanged;
                        AutoSize[site] = true;
                        return site;
                }
@@ -177,16 +178,24 @@
                        EmitContentsChanged ();
                }
 
+               protected virtual void SiteShapeChanged (WidgetSite site) {
+                       ;
+               }
+
                void SiteRemoved (object obj, Gtk.RemovedArgs args)
                {
                        WidgetSite site = args.Widget as WidgetSite;
-                       if (site != null)
+                       if (site != null) {
                                site.OccupancyChanged -= SiteOccupancyChanged;
+                               site.ShapeChanged -= SiteShapeChanged;
+                               SiteRemoved (site);
+                       }
                }
 
                protected virtual void SiteRemoved (WidgetSite site)
                {
                        AutoSize[site] = false;
+                       EmitContentsChanged ();
                }
 
                class SiteEnumerator {

Modified: trunk/stetic/libstetic/wrapper/Expander.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Expander.cs  2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/libstetic/wrapper/Expander.cs  2005-03-14 21:46:09 UTC (rev 
41806)
@@ -27,13 +27,8 @@
                public override void Wrap (object obj, bool initialized)
                {
                        base.Wrap (obj, initialized);
-
                        if (!initialized)
                                expander.Label = expander.Name;
-
-                       expander.Activated += delegate (object obj, EventArgs 
args) {
-                               EmitContentsChanged ();
-                       };
                }
 
                public override Widget GladeImportChild (string className, 
string id, Hashtable props, Hashtable childprops)
@@ -57,12 +52,12 @@
 
                public override bool HExpandable {
                        get {
-                               return expander.Expanded && site.HExpandable;
+                               return site.HExpandable;
                        }
                }
                public override bool VExpandable {
                        get {
-                               return expander.Expanded && site.VExpandable;
+                               return site.VExpandable;
                        }
                }
        }

Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs     2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/libstetic/wrapper/Table.cs     2005-03-14 21:46:09 UTC (rev 
41806)
@@ -89,6 +89,7 @@
                        WidgetSite[,] grid;
                        Gtk.Table.TableChild tc;
                        Gtk.Widget[] children;
+                       bool addedSites = false;
 
                        if (freeze > 0)
                                return;
@@ -164,6 +165,7 @@
                                                site.FreezeChildNotify ();
                                                table.Attach (site, col, col + 
1, row, row + 1);
                                                grid[row,col] = site;
+                                               addedSites = true;
                                        } else if (!site.VExpandable || 
!AutoSize[site])
                                                allPlaceholders = false;
                                }
@@ -210,7 +212,8 @@
                                child.ThawChildNotify ();
                        freeze = 0;
 
-                       EmitContentsChanged ();
+                       if (addedSites)
+                               EmitContentsChanged ();
                }
 
                public uint NRows {
@@ -365,7 +368,7 @@
                public override bool HExpandable { get { return hexpandable; } }
                public override bool VExpandable { get { return vexpandable; } }
 
-               protected override void SiteOccupancyChanged (WidgetSite site)
+               protected override void SiteShapeChanged (WidgetSite site)
                {
                        Freeze ();
                        if (site.Occupied && AutoSize[site]) {
@@ -374,7 +377,7 @@
                                tc.YOptions = 0;
                        }
                        Thaw ();
-                       base.SiteOccupancyChanged (site);
+                       base.SiteShapeChanged (site);
                }
 
 #if NOT

Modified: trunk/stetic/stetic/Glade.cs
===================================================================
--- trunk/stetic/stetic/Glade.cs        2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/stetic/Glade.cs        2005-03-14 21:46:09 UTC (rev 41806)
@@ -35,14 +35,8 @@
                                Widget w = ImportWidget (project, null, null, 
toplevel);
                                if (w == null)
                                        continue;
-                               project.AddWindow (w);
                                WindowSite site = new WindowSite 
((Gtk.Window)w);
-                               site.FocusChanged += delegate (WindowSite site, 
IWidgetSite focus) {
-                                       if (focus == null)
-                                               SteticMain.NoSelection ();
-                                       else
-                                               SteticMain.Select (focus);
-                               };
+                               project.AddWindow (site);
                        }
                        project.EndGladeImport ();
                }

Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs      2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/stetic/Project.cs      2005-03-14 21:46:09 UTC (rev 41806)
@@ -5,34 +5,53 @@
 namespace Stetic {
 
        public class Project : IStetic {
-               Hashtable nodes, widgets;
+               Hashtable nodes;
                NodeStore store;
 
                public Project ()
                {
                        nodes = new Hashtable ();
-                       widgets = new Hashtable ();
                        store = new NodeStore (typeof (ProjectNode));
                }
 
-               public void AddWindow (Widget window)
+               public void AddWindow (WindowSite site)
                {
-                       AddWidget (window, null);
+                       AddWindow (site, false);
                }
 
+               public void AddWindow (WindowSite site, bool select)
+               {
+                       site.FocusChanged += WindowFocusChanged;
+                       AddWidget (site.Contents, null, -1);
+
+                       if (select)
+                               WindowFocusChanged (site, site);
+               }
+
                void AddWidget (Widget widget, ProjectNode parent)
                {
+                       AddWidget (widget, parent, -1);
+               }
+
+               void AddWidget (Widget widget, ProjectNode parent, int position)
+               {
                        if (Stetic.Wrapper.Widget.Lookup (widget) == null)
                                return;
 
-                       widgets[widget.Name] = widget;
-
                        ProjectNode node = new ProjectNode (widget);
                        nodes[widget] = node;
-                       if (parent == null)
-                               store.AddNode (node);
-                       else
-                               parent.AddChild (node);
+                       if (parent == null) {
+                               if (position == -1)
+                                       store.AddNode (node);
+                               else
+                                       store.AddNode (node, position);
+                       } else {
+                               if (position == -1)
+                                       parent.AddChild (node);
+                               else
+                                       parent.AddChild (node, position);
+                       }
+                       widget.Destroyed += WidgetDestroyed;
 
                        parent = node;
 
@@ -46,51 +65,79 @@
                        }
                }
 
-               public IEnumerable Toplevels {
-                       get {
-                               ArrayList list = new ArrayList ();
-                               foreach (Widget w in nodes.Keys) {
-                                       if (w is Gtk.Window)
-                                               list.Add (w);
-                               }
-                               return list;
-                       }
+               void UnhashNodeRecursive (ProjectNode node)
+               {
+                       nodes.Remove (node.Widget);
+                       for (int i = 0; i < node.ChildCount; i++)
+                               UnhashNodeRecursive (node[i] as ProjectNode);
                }
 
+               void RemoveNode (ProjectNode node)
+               {
+                       UnhashNodeRecursive (node);
+
+                       ProjectNode parent = node.Parent as ProjectNode;
+                       if (parent == null)
+                               store.RemoveNode (node);
+                       else
+                               parent.RemoveChild (node);
+               }
+
+               void WidgetDestroyed (object obj, EventArgs args)
+               {
+                       ProjectNode node = nodes[obj] as ProjectNode;
+                       if (node != null)
+                               RemoveNode (node);
+               }
+
                void ContentsChanged (Stetic.Wrapper.Container cwrap)
                {
                        Container container = cwrap.Wrapped as Container;
-                       ProjectNode node = nodes[container] as ProjectNode, 
child;
+                       ProjectNode node = nodes[container] as ProjectNode;
+                       if (node == null)
+                               return;
 
-                       // Since TreeNode doesn't have an InsertChild method, 
the
-                       // easiest way to do this is to copy all of the child 
nodes
-                       // out, and then add them (and any new ones) back in in
-                       // the right order.
-
-                       Hashtable childNodes = new Hashtable ();
-                       while (node.ChildCount != 0) {
-                               child = node[0] as ProjectNode;
-                               childNodes[child.Widget] = child;
-                               node.RemoveChild (child);
+                       ArrayList children = new ArrayList ();
+                       foreach (WidgetSite site in cwrap.Sites) {
+                               if (site.Occupied)
+                                       children.Add (site.Contents);
                        }
 
-                       foreach (WidgetSite site in cwrap.Sites) {
-                               if (!site.Occupied)
-                                       continue;
+                       int i = 0;
+                       while (i < node.ChildCount && i < children.Count) {
+                               Widget widget = children[i] as Widget;
+                               ITreeNode child = nodes[widget] as ITreeNode;
 
-                               Widget w = site.Contents;
-                               child = childNodes[w] as ProjectNode;
-                               if (child != null) {
-                                       childNodes.Remove (w);
-                                       node.AddChild (child);
-                               } else
-                                       AddWidget (w, node);
+                               if (child == null)
+                                       AddWidget (widget, node, i);
+                               else if (child != node[i]) {
+                                       int index = node.IndexOf (child);
+                                       while (index > i) {
+                                               RemoveNode (node[i] as 
ProjectNode);
+                                               index--;
+                                       }
+                               }
+                               i++;
                        }
 
-                       foreach (ProjectNode dead in childNodes.Values)
-                               nodes.Remove (dead.Widget);
+                       while (i < node.ChildCount)
+                               RemoveNode (node[i] as ProjectNode);
+
+                       while (i < children.Count)
+                               AddWidget (children[i++] as Widget, node);
                }
 
+               public IEnumerable Toplevels {
+                       get {
+                               ArrayList list = new ArrayList ();
+                               foreach (Widget w in nodes.Keys) {
+                                       if (w is Gtk.Window)
+                                               list.Add (w);
+                               }
+                               return list;
+                       }
+               }
+
                public void DeleteWindow (Widget window)
                {
                        store.RemoveNode (nodes[window] as ProjectNode);
@@ -109,6 +156,20 @@
                        store = new NodeStore (typeof (ProjectNode));
                }
 
+               public delegate void SelectedHandler (IWidgetSite site, 
ProjectNode node);
+               public event SelectedHandler Selected;
+
+               void WindowFocusChanged (WindowSite site, IWidgetSite focus)
+               {
+                       if (Selected == null)
+                               return;
+
+                       if (focus == null)
+                               Selected (null, null);
+                       else
+                               Selected (focus, nodes[focus.Contents] as 
ProjectNode);
+               }
+
                // IStetic
 
                public WidgetSite CreateWidgetSite ()
@@ -123,7 +184,11 @@
 
                public Gtk.Widget LookupWidgetById (string id)
                {
-                       return widgets[id] as Gtk.Widget;
+                       foreach (Gtk.Widget w in nodes.Keys) {
+                               if (w.Name == id)
+                                       return w;
+                       }
+                       return null;
                }
 
                public event ISteticDelegate GladeImportComplete;
@@ -171,6 +236,11 @@
                                return widget.Name;
                        }
                }
+
+               public override string ToString ()
+               {
+                       return "[ProjectNode " + GetHashCode().ToString() + " " 
+ widget.GetType().FullName + " '" + Name + "']";
+               }
        }
 
 

Modified: trunk/stetic/stetic/ProjectView.cs
===================================================================
--- trunk/stetic/stetic/ProjectView.cs  2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/stetic/ProjectView.cs  2005-03-14 21:46:09 UTC (rev 41806)
@@ -23,7 +23,8 @@
                        AppendColumn (col);
 
                        NodeSelection.Mode = SelectionMode.Single;
-                       NodeSelection.Changed += Selection_Changed;
+                       NodeSelection.Changed += RowSelected;
+                       project.Selected += WidgetSelected;
                }
 
                IWidgetSite SelectedSite {
@@ -46,12 +47,29 @@
                        }
                }
 
-               void Selection_Changed (object obj, EventArgs args)
+               bool syncing = false;
+
+               void RowSelected (object obj, EventArgs args)
                {
-                       IWidgetSite selection = SelectedSite;
+                       if (!syncing) {
+                               syncing = true;
+                               IWidgetSite selection = SelectedSite;
+                               if (selection != null)
+                                       selection.Select ();
+                               syncing = false;
+                       }
+               }
 
-                       if (selection != null)
-                               selection.Select ();
+               void WidgetSelected (IWidgetSite site, ProjectNode node)
+               {
+                       if (!syncing) {
+                               syncing = true;
+                               if (node != null)
+                                       NodeSelection.SelectNode (node);
+                               else
+                                       NodeSelection.UnselectAll ();
+                               syncing = false;
+                       }
                }
 
                protected override bool OnButtonPressEvent (Gdk.EventButton evt)

Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-03-14 21:46:09 UTC (rev 41806)
@@ -13,12 +13,13 @@
 
                ObjectWrapper selection, packingSelection;
 
-               public PropertyGrid ()
+               public PropertyGrid (Project project)
                {
-                       NoSelection ();
+                       project.Selected += Selected;
+                       Selected (null, null);
                }
 
-               protected new void Clear ()
+               new void Clear ()
                {
                        base.Clear ();
                        if (selection != null) {
@@ -29,7 +30,7 @@
                        sensitives = new Hashtable ();
                }
 
-               protected void AppendProperty (PropertyDescriptor prop, 
ObjectWrapper wrapper)
+               void AppendProperty (PropertyDescriptor prop, ObjectWrapper 
wrapper)
                {
                        PropertyEditor rep = PropertyEditor.MakeEditor (prop, 
wrapper);
                        editors[prop.Name] = rep;
@@ -58,7 +59,7 @@
                        }
                }
 
-               protected void AppendCommand (CommandDescriptor cmd, 
ObjectWrapper wrapper)
+               void AppendCommand (CommandDescriptor cmd, ObjectWrapper 
wrapper)
                {
                        Gtk.Button button = new Gtk.Button (cmd.Label);
                        button.Clicked += new Stupid69614Workaround (cmd, 
wrapper).Activate;
@@ -79,7 +80,7 @@
                        UpdateSensitivity ();
                }
 
-               protected void UpdateSensitivity ()
+               void UpdateSensitivity ()
                {
                        foreach (ItemDescriptor item in sensitives.Keys) {
                                Widget w = editors[item.Name] as Widget;
@@ -88,10 +89,15 @@
                        }
                }
 
-               public void Select (IWidgetSite site)
+               void Selected (IWidgetSite site, ProjectNode node)
                {
                        Clear ();
 
+                       if (site == null) {
+                               AppendLabel ("<i>No selection</i>");
+                               return;
+                       }
+
                        selection = Stetic.ObjectWrapper.Lookup (site.Contents);
                        if (selection == null)
                                return;
@@ -110,8 +116,7 @@
                        UpdateSensitivity ();
                }
 
-               void
-               AppendWrapperGroups (ObjectWrapper wrapper)
+               void AppendWrapperGroups (ObjectWrapper wrapper)
                {
                        bool first = true;
                        foreach (ItemGroup igroup in wrapper.ItemGroups) {
@@ -125,11 +130,5 @@
                                first = false;
                        }
                }
-
-               public void NoSelection ()
-               {
-                       Clear ();
-                       AppendLabel ("<i>No selection</i>");
-               }
        }
 }

Modified: trunk/stetic/stetic/Stetic.cs
===================================================================
--- trunk/stetic/stetic/Stetic.cs       2005-03-14 21:38:27 UTC (rev 41805)
+++ trunk/stetic/stetic/Stetic.cs       2005-03-14 21:46:09 UTC (rev 41806)
@@ -9,6 +9,10 @@
 
                static Gnome.Program program;
 
+               static Stetic.Project Project;
+               static Stetic.ProjectView ProjectView;
+               static Stetic.PropertyGrid Properties;
+
                public static int Main (string[] args) {
                        Gtk.Window win;
                        Gtk.Box vbox, hbox;
@@ -58,7 +62,7 @@
 
                        scwin = new Gtk.ScrolledWindow ();
                        scwin.SetPolicy (Gtk.PolicyType.Never, 
Gtk.PolicyType.Automatic);
-                       Properties = new Stetic.PropertyGrid ();
+                       Properties = new Stetic.PropertyGrid (Project);
                        Properties.Show ();
                        scwin.AddWithViewport (Properties);
                        Gtk.Viewport vp = (Gtk.Viewport)scwin.Child;
@@ -101,21 +105,5 @@
                        program.Quit ();
                        args.RetVal = true;
                }
-
-               public static Stetic.Project Project;
-               static Stetic.ProjectView ProjectView;
-
-               static Stetic.PropertyGrid Properties;
-
-               public static void NoSelection ()
-               {
-                       Properties.NoSelection ();
-               }
-
-               public static void Select (IWidgetSite site)
-               {
-                       Properties.Select (site);
-               }
-
        }
 }

Modified: trunk/stetic/stetic/WidgetFactory.cs
===================================================================
--- trunk/stetic/stetic/WidgetFactory.cs        2005-03-14 21:38:27 UTC (rev 
41805)
+++ trunk/stetic/stetic/WidgetFactory.cs        2005-03-14 21:46:09 UTC (rev 
41806)
@@ -51,16 +51,9 @@
                        Gtk.Window win = wrapper.Wrapped as Gtk.Window;
                        win.Present ();
 
-                       SteticMain.Project.AddWindow (win);
-
                        WindowSite site = new WindowSite (win);
-                       SteticMain.Select (site);
-                       site.FocusChanged += delegate (WindowSite site, 
IWidgetSite focus) {
-                               if (focus == null)
-                                       SteticMain.NoSelection ();
-                               else
-                                       SteticMain.Select (focus);
-                       };
+                       project.AddWindow (site, true);
+
                        return true;
                }
 

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

Reply via email to