Author: danw
Date: 2005-05-26 11:32:06 -0400 (Thu, 26 May 2005)
New Revision: 45057

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/GladeUtils.cs
   trunk/stetic/libstetic/IStetic.cs
   trunk/stetic/libstetic/PropertyDescriptor.cs
   trunk/stetic/libstetic/wrapper/Bin.cs
   trunk/stetic/libstetic/wrapper/Button.cs
   trunk/stetic/libstetic/wrapper/ButtonBox.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Image.cs
   trunk/stetic/libstetic/wrapper/OptionMenu.cs
   trunk/stetic/libstetic/wrapper/Scale.cs
   trunk/stetic/libstetic/wrapper/Table.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/stetic/ContextMenu.cs
   trunk/stetic/stetic/Glade.cs
   trunk/stetic/stetic/Makefile.am
   trunk/stetic/stetic/Project.cs
   trunk/stetic/stetic/PropertyGrid.cs
Log:
        * libstetic/GladeUtils.cs (ParseFlags, PropToString): Remove
        special cases for TableChild options (now handled in Table.cs).
        Use PropertyDescriptor.HasDefault.

        * libstetic/IStetic.cs (Selection): Make this a Gtk.Widget, not a
        Stetic.Wrapper.Widget, so we can keep more careful track of
        Placeholder selections.

        * libstetic/PropertyDescriptor.cs (HasDefault): new settable
        property to say whether or not the property has a default value.
        (See Scale.cs below).

        * libstetic/wrapper/Bin.cs (GladeImport): at GladeImportComplete
        time, if the bin is empty, add a Placeholder.

        * libstetic/wrapper/Button.cs (GladeImport, GladeChildren): dtrt
        with buttons that contain placeholders.
        (FixupGladeChildren): set UseUnderline correctly.
        (GladeExport): handle stock buttons correctly

        * libstetic/wrapper/ButtonBox.cs (GladeImportChild): fix the
        "Help" button case.

        * libstetic/wrapper/Container.cs (LookupParent): was
        Widget.ParentWrapper, but now can be used for Placeholders as
        well.
        (Select, UnSelect): update for selection changes

        * libstetic/wrapper/Image.cs (GladeExport): don't export the
        "filename" property when it's a stock image, or the "stock"
        property when it's an image file.
        (UseStock, Stock, Filename): misc other fixes

        * libstetic/wrapper/OptionMenu.cs (GladeImport): juggle the Menu
        at GladeImportComplete time to force a proper size request
        (GladeImportChild): allow the menu to be specified as an internal
        or non-internal child, since different versions of glade
        apparently do different things.

        * libstetic/wrapper/Scale.cs (Register): clear HasDefault on the
        DrawValue and ValuePos properties, since the ParamSpecs are
        registered with the wrong default values.

        * libstetic/wrapper/Table.cs (GladeImportChild, GladeExportChild):
        translate between the "normal" flag value representation
        ("GTK_EXPAND|GTK_FILL") and TableChild's special representation
        ("expand|fill") here rather than in GladeUtils.

        * libstetic/wrapper/Widget.cs (ParentWrapper): use
        Container.LookupParent().
        (WidgetEvent): update for selection changes
        (UnSelect): gone, handled by other things now

        * stetic/ContextMenu.cs: Fix (again) so that only the top level
        menu has submenus. Add icons to the widget labels.

        * stetic/Glade.cs (Export): close the file when we're done.
        (ExportWidget): Remove a no-longer-relevant FIXME about
        Placeholders

        * stetic/Project.cs (Selection, etc): update for IStetic change to
        make Selection a Gtk.Widget. Unselect the previous selection
        always. (Previously Placeholders weren't unselected properly.)

        * stetic/PropertyGrid.cs: Add a "Widget Class" line (with icon)


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/ChangeLog      2005-05-26 15:32:06 UTC (rev 45057)
@@ -1,3 +1,71 @@
+2005-05-26  Dan Winship  <[EMAIL PROTECTED]>
+
+       * libstetic/GladeUtils.cs (ParseFlags, PropToString): Remove
+       special cases for TableChild options (now handled in Table.cs).
+       Use PropertyDescriptor.HasDefault.
+
+       * libstetic/IStetic.cs (Selection): Make this a Gtk.Widget, not a
+       Stetic.Wrapper.Widget, so we can keep more careful track of
+       Placeholder selections.
+
+       * libstetic/PropertyDescriptor.cs (HasDefault): new settable
+       property to say whether or not the property has a default value.
+       (See Scale.cs below).
+
+       * libstetic/wrapper/Bin.cs (GladeImport): at GladeImportComplete
+       time, if the bin is empty, add a Placeholder.
+
+       * libstetic/wrapper/Button.cs (GladeImport, GladeChildren): dtrt
+       with buttons that contain placeholders.
+       (FixupGladeChildren): set UseUnderline correctly.
+       (GladeExport): handle stock buttons correctly
+
+       * libstetic/wrapper/ButtonBox.cs (GladeImportChild): fix the
+       "Help" button case.
+
+       * libstetic/wrapper/Container.cs (LookupParent): was
+       Widget.ParentWrapper, but now can be used for Placeholders as
+       well.
+       (Select, UnSelect): update for selection changes
+
+       * libstetic/wrapper/Image.cs (GladeExport): don't export the
+       "filename" property when it's a stock image, or the "stock"
+       property when it's an image file.
+       (UseStock, Stock, Filename): misc other fixes
+
+       * libstetic/wrapper/OptionMenu.cs (GladeImport): juggle the Menu
+       at GladeImportComplete time to force a proper size request
+       (GladeImportChild): allow the menu to be specified as an internal
+       or non-internal child, since different versions of glade
+       apparently do different things.
+
+       * libstetic/wrapper/Scale.cs (Register): clear HasDefault on the
+       DrawValue and ValuePos properties, since the ParamSpecs are
+       registered with the wrong default values.
+
+       * libstetic/wrapper/Table.cs (GladeImportChild, GladeExportChild):
+       translate between the "normal" flag value representation
+       ("GTK_EXPAND|GTK_FILL") and TableChild's special representation
+       ("expand|fill") here rather than in GladeUtils.
+
+       * libstetic/wrapper/Widget.cs (ParentWrapper): use
+       Container.LookupParent().
+       (WidgetEvent): update for selection changes
+       (UnSelect): gone, handled by other things now
+
+       * stetic/ContextMenu.cs: Fix (again) so that only the top level
+       menu has submenus. Add icons to the widget labels.
+
+       * stetic/Glade.cs (Export): close the file when we're done.
+       (ExportWidget): Remove a no-longer-relevant FIXME about
+       Placeholders
+
+       * stetic/Project.cs (Selection, etc): update for IStetic change to
+       make Selection a Gtk.Widget. Unselect the previous selection
+       always. (Previously Placeholders weren't unselected properly.)
+
+       * stetic/PropertyGrid.cs: Add a "Widget Class" line (with icon)
+
 2005-05-24  Dan Winship  <[EMAIL PROTECTED]>
 
        * libstetic/GladeUtils.cs: Fix up the parsing/unparsing to be

Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs        2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/GladeUtils.cs        2005-05-26 15:32:06 UTC (rev 
45057)
@@ -93,14 +93,11 @@
 
                        try {
                                // The Trim() is needed for Widget.Events.
-                               // The get_value_by_nick() is for 
BoxChild.[XY]Options
                                foreach (string flag in strval.Split ('|')) {
                                        if (flag == "")
                                                continue;
                                        IntPtr flags_value = 
g_flags_get_value_by_name (flags_class, flag.Trim ());
                                        if (flags_value == IntPtr.Zero)
-                                               flags_value = 
g_flags_get_value_by_nick (flags_class, flag);
-                                       if (flags_value == IntPtr.Zero)
                                                throw new GladeException 
("Could not parse");
 
                                        IntPtr bits = Marshal.ReadIntPtr 
(flags_value);
@@ -327,7 +324,7 @@
                                return null;
 
                        // If the property has its default value, we don't need 
to write it
-                       if (prop.ParamSpec != null && value.Equals 
(prop.ParamSpec.Default))
+                       if (prop.HasDefault && value.Equals 
(prop.ParamSpec.Default))
                                return null;
 
                        if (value is Gtk.Adjustment) {
@@ -350,11 +347,11 @@
                                                IntPtr fval = 
Marshal.ReadIntPtr (flags_value);
                                                val &= ~(uint)fval;
 
-                                               IntPtr nick = 
Marshal.ReadIntPtr (flags_value, 2 * Marshal.SizeOf (typeof (IntPtr)));
-                                               if (nick != IntPtr.Zero) {
+                                               IntPtr name = 
Marshal.ReadIntPtr (flags_value, Marshal.SizeOf (typeof (IntPtr)));
+                                               if (name != IntPtr.Zero) {
                                                        if (sb.Length != 0)
                                                                sb.Append ('|');
-                                                       sb.Append 
(GLib.Marshaller.Utf8PtrToString (nick));
+                                                       sb.Append 
(GLib.Marshaller.Utf8PtrToString (name));
                                                }
                                        }
 
@@ -446,9 +443,6 @@
                static extern IntPtr g_enum_get_value (IntPtr enum_class, int 
val);
 
                [DllImport("libgobject-2.0-0.dll")]
-               static extern IntPtr g_flags_get_value_by_nick (IntPtr 
flags_class, string nick);
-
-               [DllImport("libgobject-2.0-0.dll")]
                static extern IntPtr g_flags_get_value_by_name (IntPtr 
flags_class, string nick);
 
                [DllImport("libgobject-2.0-0.dll")]

Modified: trunk/stetic/libstetic/IStetic.cs
===================================================================
--- trunk/stetic/libstetic/IStetic.cs   2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/libstetic/IStetic.cs   2005-05-26 15:32:06 UTC (rev 45057)
@@ -4,7 +4,7 @@
        public delegate void ISteticDelegate ();
 
        public interface IStetic {
-               Stetic.Wrapper.Widget Selection { get; set; }
+               Gtk.Widget Selection { get; set; }
 
                void PopupContextMenu (Stetic.Wrapper.Widget wrapper);
                void PopupContextMenu (Placeholder ph);

Modified: trunk/stetic/libstetic/PropertyDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/PropertyDescriptor.cs        2005-05-26 15:09:02 UTC 
(rev 45056)
+++ trunk/stetic/libstetic/PropertyDescriptor.cs        2005-05-26 15:32:06 UTC 
(rev 45057)
@@ -9,7 +9,7 @@
        public class PropertyDescriptor : ItemDescriptor {
 
                PropertyInfo memberInfo, propertyInfo;
-               bool isWrapperProperty;
+               bool isWrapperProperty, hasDefault;
                ParamSpec pspec;
                Type editorType;
                string label, description;
@@ -53,6 +53,7 @@
                                description = pspec.Blurb;
                                minimum = pspec.Minimum;
                                maximum = pspec.Maximum;
+                               hasDefault = true;
                        } else
                                label = propertyInfo.Name;
 
@@ -187,6 +188,16 @@
                        }
                }
 
+               // Whether or not the property has a default value
+               public bool HasDefault {
+                       get {
+                               return hasDefault;
+                       }
+                       set {
+                               hasDefault = value;
+                       }
+               }
+
                // Gets the value of the property on @wrapper
                public object GetValue (ObjectWrapper wrapper)
                {

Modified: trunk/stetic/libstetic/wrapper/Bin.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Bin.cs       2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Bin.cs       2005-05-26 15:32:06 UTC (rev 
45057)
@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 
 namespace Stetic.Wrapper {
 
@@ -10,9 +11,18 @@
                {
                        base.Wrap (obj, initialized);
                        if (!initialized && bin.Child == null)
-                               bin.Add (CreatePlaceholder ());
+                               AddPlaceholder ();
                }
 
+               protected override void GladeImport (string className, string 
id, Hashtable props)
+               {
+                       base.GladeImport (className, id, props);
+                       stetic.GladeImportComplete += delegate () {
+                               if (bin.Child == null)
+                                       AddPlaceholder ();
+                       };
+               }
+
                Gtk.Bin bin {
                        get {
                                return (Gtk.Bin)Wrapped;

Modified: trunk/stetic/libstetic/wrapper/Button.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Button.cs    2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Button.cs    2005-05-26 15:32:06 UTC (rev 
45057)
@@ -74,6 +74,13 @@
                        }
                }
 
+               protected override void GladeImport (string className, string 
id, Hashtable props)
+               {
+                       base.GladeImport (className, id, props);
+                       if (props["label"] == null && button.Child != null)
+                               button.Remove (button.Child);
+               }
+
                public override Widget GladeImportChild (string className, 
string id,
                                                         Hashtable props, 
Hashtable childprops)
                {
@@ -113,13 +120,18 @@
                        else
                                Icon = "file:" + iwrap.File;
                        Label = label.LabelProp;
+                       UseUnderline = label.UseUnderline;
                        hasLabel = true;
                }
 
                public override void GladeExport (out string className, out 
string id, out Hashtable props)
                {
                        base.GladeExport (out className, out id, out props);
-                       props["use_stock"] = IsStock ? "True" : "False";
+                       if (IsStock) {
+                               props["use_stock"] = "True";
+                               props["label"] = icon.Substring (6);
+                       } else
+                               props["use_stock"] = "False";
                }
 
                public override IEnumerable RealChildren {
@@ -133,7 +145,7 @@
 
                public override IEnumerable GladeChildren {
                        get {
-                               if (Icon == null || IsStock)
+                               if (HasContents && (Icon == null || IsStock))
                                        return new Gtk.Widget[0];
                                else
                                        return base.RealChildren;

Modified: trunk/stetic/libstetic/wrapper/ButtonBox.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ButtonBox.cs 2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/ButtonBox.cs 2005-05-26 15:32:06 UTC (rev 
45057)
@@ -49,7 +49,7 @@
                                button.ResponseId = response;
 
                        if (response == (int)Gtk.ResponseType.Help) {
-                               Gtk.ButtonBox.ButtonBoxChild bbc = 
((Gtk.Container)Wrapped)[((Gtk.Widget)wrapper.Wrapped).Parent] as 
Gtk.ButtonBox.ButtonBoxChild;
+                               Gtk.ButtonBox.ButtonBoxChild bbc = 
((Gtk.Container)Wrapped)[((Gtk.Widget)wrapper.Wrapped)] as 
Gtk.ButtonBox.ButtonBoxChild;
                                bbc.Secondary = true;
                        }
 

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-05-26 15:32:06 UTC (rev 
45057)
@@ -137,6 +137,18 @@
                        return Stetic.ObjectWrapper.Lookup (obj) as 
Stetic.Wrapper.Container;
                }
 
+
+               public static Container LookupParent (Gtk.Widget widget)
+               {
+                       Gtk.Widget parent = widget.Parent;
+                       Container wrapper = null;
+                       while (wrapper == null && parent != null) {
+                               wrapper = Lookup (parent);
+                               parent = parent.Parent;
+                       }
+                       return wrapper;
+               }
+
                public static Stetic.Wrapper.Container.ContainerChild 
ChildWrapper (Stetic.Wrapper.Widget wrapper) {
                        Stetic.Wrapper.Container parentWrapper = 
wrapper.ParentWrapper;
                        if (parentWrapper == null)
@@ -281,25 +293,25 @@
 
                public virtual void Select (Stetic.Wrapper.Widget wrapper)
                {
-                       if (wrapper == null)
+                       if (wrapper == null) {
                                Select (null, false);
-                       else
+                               stetic.Selection = null;
+                       } else {
                                Select (wrapper.Wrapped, 
(wrapper.InternalChildId == null));
-                       stetic.Selection = wrapper;
+                               stetic.Selection = wrapper.Wrapped;
+                       }
                }
 
-               public virtual void UnSelect (Stetic.Wrapper.Widget wrapper)
+               public virtual void UnSelect (Gtk.Widget widget)
                {
-                       if (selection == wrapper.Wrapped) {
+                       if (selection == widget)
                                Select (null, false);
-                               stetic.Selection = null;
-                       }
                }
 
                public virtual void Select (Placeholder ph)
                {
                        Select (ph, false);
-                       stetic.Selection = null;
+                       stetic.Selection = ph;
                }
 
                void Select (Gtk.Widget widget, bool dragHandles)

Modified: trunk/stetic/libstetic/wrapper/Image.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Image.cs     2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Image.cs     2005-05-26 15:32:06 UTC (rev 
45057)
@@ -36,6 +36,17 @@
                                File = filename;
                }
 
+               public override void GladeExport (out string className, out 
string id, out Hashtable props)
+               {
+                       base.GladeExport (out className, out id, out props);
+                       if (useStock)
+                               GladeUtils.ExtractProperty ("filename", props);
+                       else {
+                               GladeUtils.ExtractProperty ("stock", props);
+                               GladeUtils.ExtractProperty ("icon_size", props);
+                       }
+               }
+
                Gtk.Image image {
                        get {
                                return (Gtk.Image)Wrapped;
@@ -71,6 +82,7 @@
                        }
                        set {
                                image.Stock = stock = value;
+                               filename = null;
                        }
                }
 
@@ -85,7 +97,7 @@
                        }
                }
 
-               string filename = "";
+               string filename;
 
                [Editor (typeof (Stetic.Editor.ImageFile))]
                [GladeProperty (Name = "pixbuf")]
@@ -94,9 +106,14 @@
                                return filename;
                        }
                        set {
-                               image.File = filename = value;
-                               if (value == "")
+                               if (value == "" || value == null) {
                                        image.Stock = Gtk.Stock.MissingImage;
+                                       IconSize = Gtk.IconSize.Button;
+                                       filename = stock = null;
+                               } else {
+                                       image.File = filename = value;
+                                       stock = null;
+                               }
                        }
                }
        }

Modified: trunk/stetic/libstetic/wrapper/OptionMenu.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/OptionMenu.cs        2005-05-26 15:09:02 UTC 
(rev 45056)
+++ trunk/stetic/libstetic/wrapper/OptionMenu.cs        2005-05-26 15:32:06 UTC 
(rev 45057)
@@ -35,6 +35,9 @@
                        string history = GladeUtils.ExtractProperty ("history", 
props);
                        base.GladeImport (className, id, props);
                        stetic.GladeImportComplete += delegate () {
+                               Gtk.Widget menu = optionmenu.Menu;
+                               optionmenu.Menu = new Gtk.Menu ();
+                               optionmenu.Menu = menu;
                                if (history != null)
                                        Active = Int32.Parse (history);
                                else
@@ -42,6 +45,8 @@
                        };
                }
 
+               // Some versions of glade call the menu an internal child, some 
don't
+
                public override Widget GladeSetInternalChild (string childId, 
string className, string id, Hashtable props)
                {
                        if (childId != "menu")
@@ -52,6 +57,11 @@
                        return wrapper;
                }
 
+               public override Widget GladeImportChild (string className, 
string id, Hashtable props, Hashtable childprops)
+               {
+                       return GladeSetInternalChild ("menu", className, id, 
props);
+               }
+
                public override IEnumerable GladeChildren {
                        get {
                                return new Gtk.Widget[] { optionmenu.Menu };

Modified: trunk/stetic/libstetic/wrapper/Scale.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Scale.cs     2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Scale.cs     2005-05-26 15:32:06 UTC (rev 
45057)
@@ -18,6 +18,10 @@
                                                        "Inverted");
                        props["Digits"].DependsOn (props["DrawValue"]);
                        props["ValuePos"].DependsOn (props["DrawValue"]);
+
+                       // The default value in the ParamSpec is wrong, so hide 
it
+                       ((PropertyDescriptor)props["DrawValue"]).HasDefault = 
false;
+                       ((PropertyDescriptor)props["ValuePos"]).HasDefault = 
false;
                }
 
                public override void Wrap (object obj, bool initialized)

Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs     2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Table.cs     2005-05-26 15:32:06 UTC (rev 
45057)
@@ -1,5 +1,6 @@
 using System;
 using System.Collections;
+using System.Text.RegularExpressions;
 
 namespace Stetic.Wrapper {
 
@@ -49,14 +50,31 @@
 
                public override Widget GladeImportChild (string className, 
string id, Hashtable props, Hashtable childprops)
                {
-                       if (childprops["x_options"] == null)
-                               childprops["x_options"] = "expand|fill";
-                       if (childprops["y_options"] == null)
-                               childprops["y_options"] = "expand|fill";
+                       string opts = (string)childprops["x_options"];
+                       if (opts == null)
+                               childprops["x_options"] = "GTK_EXPAND|GTK_FILL";
+                       else if (opts != "")
+                               childprops["x_options"] = "GTK_" + 
Regex.Replace (opts.ToUpper (), @"\|", "|GTK_");
+                       opts = (string)childprops["y_options"];
+                       if (opts == null)
+                               childprops["y_options"] = "GTK_EXPAND|GTK_FILL";
+                       else if (opts != "")
+                               childprops["y_options"] = "GTK_" + 
Regex.Replace (opts.ToUpper (), @"\|", "|GTK_");
 
                        return base.GladeImportChild (className, id, props, 
childprops);
                }
 
+               public override void GladeExportChild (Widget wrapper, out 
string className, out string internalId, out string id, out Hashtable props, 
out Hashtable childprops)
+               {
+                       base.GladeExportChild (wrapper, out className, out 
internalId, out id, out props, out childprops);
+                       string opts = (string)childprops["x_options"];
+                       if (opts != null)
+                               childprops["x_options"] = Regex.Replace 
(opts.ToLower (), "gtk_", "");
+                       opts = (string)childprops["y_options"];
+                       if (opts != null)
+                               childprops["y_options"] = Regex.Replace 
(opts.ToLower (), "gtk_", "");
+               }
+
                void PostGladeSync ()
                {
                        Sync ();

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-05-26 15:09:02 UTC (rev 
45056)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-05-26 15:32:06 UTC (rev 
45057)
@@ -66,13 +66,7 @@
 
                public Stetic.Wrapper.Container ParentWrapper {
                        get {
-                               Gtk.Widget parent = Wrapped.Parent;
-                               Container wrapper = null;
-                               while (wrapper == null && parent != null) {
-                                       wrapper = 
Stetic.Wrapper.Container.Lookup (parent);
-                                       parent = parent.Parent;
-                               }
-                               return wrapper;
+                               return Container.LookupParent (Wrapped);
                        }
                }
 
@@ -96,7 +90,7 @@
                        if (wrapper == null)
                                return;
 
-                       if (wrapper != stetic.Selection) {
+                       if (wrapper.Wrapped != stetic.Selection) {
                                wrapper.Select ();
                                args.RetVal = true;
                        }
@@ -148,17 +142,8 @@
                                ((Container)this).Select (this);
                }
 
-               public void UnSelect ()
-               {
-                       if (ParentWrapper != null)
-                               ParentWrapper.UnSelect (this);
-                       else if (this is Stetic.Wrapper.Container)
-                               ((Container)this).UnSelect (this);
-               }
-
                public void Delete ()
                {
-                       UnSelect ();
                        if (ParentWrapper != null)
                                ParentWrapper.Delete (this);
                        else

Modified: trunk/stetic/stetic/ContextMenu.cs
===================================================================
--- trunk/stetic/stetic/ContextMenu.cs  2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/stetic/ContextMenu.cs  2005-05-26 15:32:06 UTC (rev 45057)
@@ -15,7 +15,7 @@
 
                        this.wrapper = null;
 
-                       item = LabelItem ("Placeholder");
+                       item = LabelItem ("Placeholder", null);
                        item.Sensitive = false;
                        Add (item);
 
@@ -23,7 +23,7 @@
                        item.Sensitive = false;
                        Add (item);
 
-                       BuildContextMenu (Stetic.Wrapper.Widget.Lookup 
(ph.Parent), false, false, ph);
+                       BuildContextMenu (Stetic.Wrapper.Container.LookupParent 
(ph), false, false, true, ph);
                }
 
                public ContextMenu (Stetic.Wrapper.Widget wrapper) : this 
(wrapper, wrapper.Wrapped) {}
@@ -35,7 +35,7 @@
                        this.wrapper = wrapper;
 
                        if (context == wrapper.Wrapped) {
-                               item = LabelItem (wrapper.Wrapped.Name);
+                               item = LabelItem (wrapper.Wrapped.Name, 
wrapper.GetType ());
                                item.Sensitive = false;
                                Add (item);
                        }
@@ -53,10 +53,10 @@
                                Add (item);
                        }
 
-                       BuildContextMenu (wrapper.ParentWrapper, true, 
wrapper.InternalChildId != null, context);
+                       BuildContextMenu (wrapper.ParentWrapper, true, 
wrapper.InternalChildId != null, context == wrapper.Wrapped, context);
                }
 
-               void BuildContextMenu (Stetic.Wrapper.Widget parentWrapper, 
bool occupied, bool isInternal, Widget context)
+               void BuildContextMenu (Stetic.Wrapper.Widget parentWrapper, 
bool occupied, bool isInternal, bool top, Widget context)
                {
                        MenuItem item;
 
@@ -79,12 +79,14 @@
                                item.Sensitive = false;
                        Add (item);
 
-                       for (; parentWrapper != null; parentWrapper = 
parentWrapper.ParentWrapper) {
-                               Add (new SeparatorMenuItem ());
+                       if (top) {
+                               for (; parentWrapper != null; parentWrapper = 
parentWrapper.ParentWrapper) {
+                                       Add (new SeparatorMenuItem ());
 
-                               item = LabelItem (parentWrapper.Wrapped.Name);
-                               item.Submenu = new ContextMenu (parentWrapper, 
context);
-                               Add (item);
+                                       item = LabelItem 
(parentWrapper.Wrapped.Name, parentWrapper.GetType ());
+                                       item.Submenu = new ContextMenu 
(parentWrapper, context);
+                                       Add (item);
+                               }
                        }
 
                        ShowAll ();
@@ -122,17 +124,24 @@
                        wrapper.Delete ();
                }
 
-               static MenuItem LabelItem (string labelString)
+               static MenuItem LabelItem (string labelString, Type type)
                {
-                       MenuItem item;
+                       ImageMenuItem item;
                        Label label;
 
                        label = new Label (labelString);
                        label.UseUnderline = false;
                        label.SetAlignment (0.0f, 0.5f);
-                       item = new MenuItem ();
+                       item = new ImageMenuItem ();
                        item.Add (label);
 
+                       if (type != null) {
+                               Gdk.Pixbuf pixbuf = Palette.IconForType (type);
+                               int width, height;
+                               Gtk.Icon.SizeLookup (Gtk.IconSize.Menu, out 
width, out height);
+                               item.Image = new Gtk.Image (pixbuf.ScaleSimple 
(width, height, Gdk.InterpType.Bilinear));
+                       }
+
                        return item;
                }
        }

Modified: trunk/stetic/stetic/Glade.cs
===================================================================
--- trunk/stetic/stetic/Glade.cs        2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/stetic/Glade.cs        2005-05-26 15:32:06 UTC (rev 45057)
@@ -108,6 +108,7 @@
                        XmlTextWriter writer = new XmlTextWriter (filename, 
System.Text.Encoding.ASCII);
                        writer.Formatting = Formatting.Indented;
                        doc.Save (writer);
+                       writer.Close ();
                }
 
                static XmlElement ExportWidget (Project project, XmlDocument 
doc,
@@ -162,15 +163,6 @@
                                XmlElement elt;
 
                                foreach (Gtk.Widget child in 
container.GladeChildren) {
-#if FIXME
-                                       if (!site.Occupied) {
-                                               child = doc.CreateElement 
("child");
-                                               child.AppendChild 
(doc.CreateElement ("placeholder"));
-                                               widget.AppendChild (child);
-                                               continue;
-                                       }
-#endif
-
                                        elt = ExportWidget (project, doc, 
container, child);
                                        if (elt != null)
                                                widget.AppendChild (elt);

Modified: trunk/stetic/stetic/Makefile.am
===================================================================
--- trunk/stetic/stetic/Makefile.am     2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/stetic/Makefile.am     2005-05-26 15:32:06 UTC (rev 45057)
@@ -38,4 +38,4 @@
        LD_LIBRARY_PATH=../glue/.libs:/opt/debug/lib:$$LD_LIBRARY_PATH 
MONO_PATH=../libstetic mdb stetic.exe
 
 gdb:
-       LD_LIBRARY_PATH=../glue/.libs:/opt/debug/lib:$$LD_LIBRARY_PATH 
MONO_PATH=../libstetic gdb $(MONO)
+       LD_LIBRARY_PATH=../glue/.libs:/opt/debug/lib:$$LD_LIBRARY_PATH 
MONO_PATH=../libstetic gdb --args $(MONO) stetic.exe

Modified: trunk/stetic/stetic/Project.cs
===================================================================
--- trunk/stetic/stetic/Project.cs      2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/stetic/Project.cs      2005-05-26 15:32:06 UTC (rev 45057)
@@ -23,7 +23,7 @@
                {
                        AddWidget (window.Wrapped, null, -1);
                        if (select)
-                               Selection = window;
+                               Selection = window.Wrapped;
                }
 
                void AddWidget (Widget widget, ProjectNode parent)
@@ -156,11 +156,11 @@
                public delegate void SelectedHandler (Stetic.Wrapper.Widget 
focus, ProjectNode node);
                public event SelectedHandler Selected;
 
-               Stetic.Wrapper.Widget selection;
+               Gtk.Widget selection;
 
                // IStetic
 
-               public Stetic.Wrapper.Widget Selection
+               public Gtk.Widget Selection
                {
                        get {
                                return selection;
@@ -169,17 +169,22 @@
                                if (selection == value)
                                        return;
 
-                               if (selection != null)
-                                       selection.UnSelect ();
+                               if (selection != null) {
+                                       Stetic.Wrapper.Container parent = 
Stetic.Wrapper.Container.LookupParent (selection);
+                                       if (parent != null)
+                                               parent.UnSelect (selection);
+                               }
+
                                selection = value;
 
                                if (Selected == null)
                                        return;
 
-                               if (selection == null)
+                               Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (selection);
+                               if (wrapper == null)
                                        Selected (null, null);
                                else
-                                       Selected (selection, 
nodes[selection.Wrapped] as ProjectNode);
+                                       Selected (wrapper, nodes[selection] as 
ProjectNode);
                        }
                }
 

Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-05-26 15:09:02 UTC (rev 45056)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-05-26 15:32:06 UTC (rev 45057)
@@ -31,6 +31,17 @@
                        sensitives = new Hashtable ();
                }
 
+               void AppendHeader ()
+               {
+                       AppendProperty (new PropertyDescriptor (typeof 
(Stetic.Wrapper.Widget), typeof (Gtk.Widget), "Name"), selection);
+
+                       Gtk.HBox box = new Gtk.HBox (false, 6);
+                       box.PackStart (new Gtk.Image (Palette.IconForType 
(selection.GetType ())), false, false, 0);
+                       box.PackStart (new Gtk.Label (selection.Wrapped.GetType 
().FullName), false, false, 0);
+                       box.ShowAll ();
+                       AppendPair ("Widget Class", box, null);
+               }
+
                void AppendProperty (PropertyDescriptor prop, ObjectWrapper 
wrapper)
                {
                        if (!prop.VisibleFor (wrapper))
@@ -105,7 +116,7 @@
 
                        selection.Notify += Notified;
 
-                       AppendProperty (new PropertyDescriptor (typeof 
(Stetic.Wrapper.Widget), typeof (Gtk.Widget), "Name"), selection);
+                       AppendHeader ();
                        AppendWrapperGroups (selection);
 
                        packingSelection = 
Stetic.Wrapper.Container.ChildWrapper (selection);

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

Reply via email to