Author: danw
Date: 2005-03-17 14:53:27 -0500 (Thu, 17 Mar 2005)
New Revision: 41960

Added:
   trunk/stetic/libstetic/editor/ResponseId.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/TODO
   trunk/stetic/libstetic/DND.cs
   trunk/stetic/libstetic/IWidgetSite.cs
   trunk/stetic/libstetic/ItemDescriptor.cs
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/WidgetBox.cs
   trunk/stetic/libstetic/WidgetSite.cs
   trunk/stetic/libstetic/WindowSite.cs
   trunk/stetic/libstetic/wrapper/Box.cs
   trunk/stetic/libstetic/wrapper/Button.cs
   trunk/stetic/libstetic/wrapper/Dialog.cs
   trunk/stetic/libstetic/wrapper/MessageDialog.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/stetic/ContextMenu.cs
   trunk/stetic/stetic/PropertyGrid.cs
Log:
        * libstetic/WidgetBox.cs (Internal): new property saying that the
        box represents an internal object.
        (ShapeHandles): if the box is Internal, don't add corner handles.

        * libstetic/WidgetSite.cs (InternalChildId): set the "Internal"
        property according to whether or not the child id is null, and
        call DND.SourceUnset if marking something internal, so it can't be
        dragged anywhere.

        * libstetic/DND.cs (SourceUnset): new.
        (SourceButtonPress, CanDrag): make sure that CanDrag always
        returns false if the widget isn't a source.

        * stetic/ContextMenu.cs (ContextMenu): disable Cut and Delete on
        "Internal" widgetsites.

        * libstetic/ItemDescriptor.cs (VisibleIf, InvisibleIf): mark a
        property visible if/unless another property is set
        (VisibleFor): Check if the property should be visible on a given
        object.

        * stetic/PropertyGrid.cs (AppendProperty): skip properties that
        shouldn't be visible on this wrapper. 

        * libstetic/wrapper/Button.cs (Register): add a "ResponseId"
        property, and a "HasResponseId" property saying whether or not it
        should be visible.
        (HasResponseId): Check if the button's site's parentsite has an
        InternalChildId of "action_area"

        * libstetic/editor/ResponseId.cs: ComboBoxEntry for dialog button
        Response IDs.

        * libstetic/wrapper/Dialog.cs (Register): add Buttons and
        HelpButton properties.
        (Wrap): set HasSeparator false. Give the internal children sane
        names. Create a button by default.
        (Buttons): Allow the user to pick default buttons via a menu
        (HelpButton): Toggle a "Help" button on/off.

        * libstetic/wrapper/Box.cs: Fix some minor autoexpand problems,
        make it work right with buttonboxes.

        * libstetic/wrapper/Widget.cs (HasDefault): instead of marking
        this "LateImport", if it's set when the widget doesn't have a
        Toplevel, connect to "HierarchyChanged". (That way things other
        than glade import can set it at inappropriate times as well.)


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/ChangeLog      2005-03-17 19:53:27 UTC (rev 41960)
@@ -1,3 +1,53 @@
+2005-03-17  Dan Winship  <[EMAIL PROTECTED]>
+
+       * libstetic/WidgetBox.cs (Internal): new property saying that the
+       box represents an internal object.
+       (ShapeHandles): if the box is Internal, don't add corner handles.
+
+       * libstetic/WidgetSite.cs (InternalChildId): set the "Internal"
+       property according to whether or not the child id is null, and
+       call DND.SourceUnset if marking something internal, so it can't be
+       dragged anywhere.
+
+       * libstetic/DND.cs (SourceUnset): new.
+       (SourceButtonPress, CanDrag): make sure that CanDrag always
+       returns false if the widget isn't a source.
+
+       * stetic/ContextMenu.cs (ContextMenu): disable Cut and Delete on
+       "Internal" widgetsites.
+
+       * libstetic/ItemDescriptor.cs (VisibleIf, InvisibleIf): mark a
+       property visible if/unless another property is set
+       (VisibleFor): Check if the property should be visible on a given
+       object.
+
+       * stetic/PropertyGrid.cs (AppendProperty): skip properties that
+       shouldn't be visible on this wrapper. 
+
+       * libstetic/wrapper/Button.cs (Register): add a "ResponseId"
+       property, and a "HasResponseId" property saying whether or not it
+       should be visible.
+       (HasResponseId): Check if the button's site's parentsite has an
+       InternalChildId of "action_area"
+
+       * libstetic/editor/ResponseId.cs: ComboBoxEntry for dialog button
+       Response IDs.
+
+       * libstetic/wrapper/Dialog.cs (Register): add Buttons and
+       HelpButton properties.
+       (Wrap): set HasSeparator false. Give the internal children sane
+       names. Create a button by default.
+       (Buttons): Allow the user to pick default buttons via a menu
+       (HelpButton): Toggle a "Help" button on/off.
+
+       * libstetic/wrapper/Box.cs: Fix some minor autoexpand problems,
+       make it work right with buttonboxes.
+
+       * libstetic/wrapper/Widget.cs (HasDefault): instead of marking
+       this "LateImport", if it's set when the widget doesn't have a
+       Toplevel, connect to "HierarchyChanged". (That way things other
+       than glade import can set it at inappropriate times as well.)
+
 2005-03-15  Dan Winship  <[EMAIL PROTECTED]>
 
        * libstetic/editor/StockItem.cs: fix sorting again. (ignore "_")

Modified: trunk/stetic/TODO
===================================================================
--- trunk/stetic/TODO   2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/TODO   2005-03-17 19:53:27 UTC (rev 41960)
@@ -24,6 +24,9 @@
           does, and needs to implement insert/remove commands
 
        - Dialog
+               - "Buttons" should automatically switch to "Custom" if
+                 you add/remove them.
+               - "Buttons" menu labels need to be better
 
        - Notebook has a bunch of problems:
                - tab labels start out with WidgetSites, but lose them

Modified: trunk/stetic/libstetic/DND.cs
===================================================================
--- trunk/stetic/libstetic/DND.cs       2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/libstetic/DND.cs       2005-03-17 19:53:27 UTC (rev 41960)
@@ -27,6 +27,12 @@
                                source.ButtonPressEvent += SourceButtonPress;
                }
 
+               public static void SourceUnset (Gtk.Widget source)
+               {
+                       Gtk.Drag.SourceUnset (source);
+                       source.ButtonPressEvent -= SourceButtonPress;
+               }
+
                public static void DestSet (Gtk.Widget dest, bool automatic)
                {
                        Gtk.Drag.DestSet (dest, automatic ? 
Gtk.DestDefaults.All : 0,
@@ -38,23 +44,28 @@
                        Gtk.Drag.DestUnset (dest);
                }
 
+               static Gtk.Widget clickWidget;
                static int clickX, clickY;
 
+               [GLib.ConnectBefore]
                static void SourceButtonPress (object obj, 
Gtk.ButtonPressEventArgs args)
                {
                        Gdk.EventButton evt = args.Event;
                        if (evt.Button == 1 && evt.Type == 
Gdk.EventType.ButtonPress) {
+                               clickWidget = obj as Gtk.Widget;
                                clickX = (int)evt.XRoot;
                                clickY = (int)evt.YRoot;
                        }
                }
 
-               // Non-automaticl drag sources should call this on any 
MotionEvent
+               // Non-automatic drag sources should call this on any 
MotionEvent
                // to see if that motion can start a drag
                public static bool CanDrag (Gtk.Widget source, Gdk.EventMotion 
evt)
                {
                        if ((evt.State & Gdk.ModifierType.Button1Mask) == 0)
                                return false;
+                       if (source != clickWidget)
+                               return false;
                        return Gtk.Drag.CheckThreshold (source, clickX, clickY, 
(int)evt.XRoot, (int)evt.YRoot);
                }
 

Modified: trunk/stetic/libstetic/IWidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/IWidgetSite.cs       2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/IWidgetSite.cs       2005-03-17 19:53:27 UTC (rev 
41960)
@@ -9,6 +9,8 @@
 
                bool Occupied { get; }
 
+               bool Internal { get; }
+
                void Select ();
                void UnSelect ();
 

Modified: trunk/stetic/libstetic/ItemDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/ItemDescriptor.cs    2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/ItemDescriptor.cs    2005-03-17 19:53:27 UTC (rev 
41960)
@@ -5,7 +5,7 @@
 
        public abstract class ItemDescriptor {
 
-               ArrayList dependencies = new ArrayList (), inverseDependencies 
= new ArrayList ();
+               Hashtable deps, visdeps;
 
                // The property's display name
                public abstract string Name { get; }
@@ -15,7 +15,9 @@
                // sensitive in the PropertyGrid when master is true.
                public void DependsOn (ItemDescriptor master)
                {
-                       dependencies.Add (master);
+                       if (deps == null)
+                               deps = new Hashtable ();
+                       deps[master] = true;
                }
 
                // Marks the property as depending inversely on master
@@ -23,24 +25,51 @@
                // sensitive in the PropertyGrid when master is false.
                public void DependsInverselyOn (ItemDescriptor master)
                {
-                       inverseDependencies.Add (master);
+                       if (deps == null)
+                               deps = new Hashtable ();
+                       deps[master] = false;
                }
 
                public bool HasDependencies {
                        get {
-                               return dependencies.Count > 0 || 
inverseDependencies.Count > 0;
+                               return deps != null;
                        }
                }
 
                public bool EnabledFor (ObjectWrapper wrapper)
                {
-                       foreach (PropertyDescriptor dep in dependencies) {
-                               if (!(bool)dep.GetValue (wrapper))
-                                       return false;
+                       if (deps != null) {
+                               foreach (PropertyDescriptor dep in deps.Keys) {
+                                       if ((bool)dep.GetValue (wrapper) != 
(bool)deps[dep])
+                                               return false;
+                               }
                        }
-                       foreach (PropertyDescriptor dep in inverseDependencies) 
{
-                               if ((bool)dep.GetValue (wrapper))
-                                       return false;
+                       return true;
+               }
+
+               // As above, but the property will not even be visible if the
+               // master property is false.
+               public void VisibleIf (ItemDescriptor master)
+               {
+                       if (visdeps == null)
+                               visdeps = new Hashtable ();
+                       visdeps[master] = true;
+               }
+
+               public void InvisibleIf (ItemDescriptor master)
+               {
+                       if (visdeps == null)
+                               visdeps = new Hashtable ();
+                       visdeps[master] = false;
+               }
+
+               public bool VisibleFor (ObjectWrapper wrapper)
+               {
+                       if (visdeps != null) {
+                               foreach (PropertyDescriptor dep in 
visdeps.Keys) {
+                                       if ((bool)dep.GetValue (wrapper) != 
(bool)visdeps[dep])
+                                               return false;
+                               }
                        }
                        return true;
                }

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/libstetic/Makefile.am  2005-03-17 19:53:27 UTC (rev 41960)
@@ -34,6 +34,7 @@
        editor/FloatRange.cs            \
        editor/IntRange.cs              \
        editor/OptIntRange.cs           \
+       editor/ResponseId.cs            \
        editor/StockItem.cs             \
        editor/String.cs                \
        editor/Text.cs                  \

Modified: trunk/stetic/libstetic/WidgetBox.cs
===================================================================
--- trunk/stetic/libstetic/WidgetBox.cs 2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/libstetic/WidgetBox.cs 2005-03-17 19:53:27 UTC (rev 41960)
@@ -71,6 +71,21 @@
                        }
                }
 
+               bool isInternal;
+               protected bool Internal {
+                       get { return isInternal; }
+                       set {
+                               if (value == isInternal)
+                                       return;
+                               isInternal = value;
+
+                               if (ShowHandles) {
+                                       ShowHandles = false;
+                                       ShowHandles = true;
+                               }
+                       }
+               }
+
                protected override void OnAdded (Widget child)
                {
                        child.ButtonPressEvent += InterceptButtonPress;
@@ -247,7 +262,7 @@
                        pixmap.DrawRectangle (gc, false, handleSize / 2, 
handleSize / 2,
                                              width - handleSize, height - 
handleSize);
 
-                       if (!ShowPlaceholder) {
+                       if (!ShowPlaceholder && !Internal) {
                                // Draw corner handles
                                pixmap.DrawRectangle (gc, true, 0, 0, 
handleSize, handleSize);
                                pixmap.DrawRectangle (gc, true, 0, height - 
handleSize, handleSize, handleSize);

Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs        2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/WidgetSite.cs        2005-03-17 19:53:27 UTC (rev 
41960)
@@ -87,6 +87,13 @@
                                return internalChildId;
                        }
                        set {
+                               if (internalChildId == null && value != null) {
+                                       DND.SourceUnset (this);
+                                       Internal = true;
+                               } else if (internalChildId != null && value == 
null) {
+                                       DND.SourceSet (this, false);
+                                       Internal = false;
+                               }
                                internalChildId = value;
                        }
                }

Modified: trunk/stetic/libstetic/WindowSite.cs
===================================================================
--- trunk/stetic/libstetic/WindowSite.cs        2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/WindowSite.cs        2005-03-17 19:53:27 UTC (rev 
41960)
@@ -80,6 +80,12 @@
                        }
                }
 
+               public bool Internal {
+                       get {
+                               return false;
+                       }
+               }
+
                public void Delete ()
                {
                        contents.Destroy ();

Added: trunk/stetic/libstetic/editor/ResponseId.cs
===================================================================
--- trunk/stetic/libstetic/editor/ResponseId.cs 2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/editor/ResponseId.cs 2005-03-17 19:53:27 UTC (rev 
41960)
@@ -0,0 +1,66 @@
+using System;
+using System.Collections;
+using System.Reflection;
+
+namespace Stetic.Editor {
+
+       public class ResponseId : Gtk.HBox {
+
+               Gtk.ComboBoxEntry combo;
+               Gtk.Entry entry;
+               ArrayList values;
+
+               public ResponseId ()
+               {
+                       combo = Gtk.ComboBoxEntry.NewText ();
+                       combo.Changed += combo_Changed;
+                       combo.Show ();
+                       PackStart (combo, true, true, 0);
+
+                       entry = combo.Child as Gtk.Entry;
+                       entry.Changed += entry_Changed;
+
+                       values = new ArrayList ();
+                       foreach (int i in Enum.GetValues (typeof 
(Gtk.ResponseType))) {
+                               Enum value = (Enum)Enum.ToObject (typeof 
(Gtk.ResponseType), i);
+                               string name = Enum.GetName (typeof 
(Gtk.ResponseType), value);
+
+                               combo.AppendText (name);
+                               values.Add (i);
+                       }
+               }
+
+               public int Value {
+                       get {
+                               if (combo.Active != -1)
+                                       return (int)values[combo.Active];
+                               else {
+                                       try {
+                                               return Int32.Parse (entry.Text);
+                                       } catch {
+                                               return 0;
+                                       }
+                               }
+                       }
+                       set {
+                               combo.Active = values.IndexOf (value);
+                               if (combo.Active == -1)
+                                       entry.Text = value.ToString ();
+                       }
+               }
+
+               public event EventHandler ValueChanged;
+
+               void combo_Changed (object o, EventArgs args)
+               {
+                       if (ValueChanged != null)
+                               ValueChanged (this, EventArgs.Empty);
+               }
+
+               void entry_Changed (object o, EventArgs args)
+               {
+                       if (combo.Active == -1 && ValueChanged != null)
+                               ValueChanged (this, EventArgs.Empty);
+               }
+       }
+}

Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs       2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/wrapper/Box.cs       2005-03-17 19:53:27 UTC (rev 
41960)
@@ -53,13 +53,13 @@
 
                        foreach (Gtk.Widget child in children) {
                                WidgetSite childsite = child as WidgetSite;
-                               if (childsite == null || !childsite.Occupied)
+                               if (childsite == null || childsite.Child == 
null)
                                        continue;
                                Gtk.Box.BoxChild bc = box[child] as 
Gtk.Box.BoxChild;
                                sorted[bc.Position] = childsite;
                        }
 
-                       if (this is HBox) {
+                       if (this is HBox || this is HButtonBox) {
                                if (sorted[0] != null)
                                        site.AddVFault (0, null, sorted[0]);
                                if (sorted[sorted.Length - 1] != null)
@@ -73,7 +73,7 @@
 
                        for (int i = 1; i < sorted.Length; i++) {
                                if (sorted[i - 1] != null && sorted[i] != null) 
{
-                                       if (this is HBox)
+                                       if (this is HBox || this is HButtonBox)
                                                site.AddVFault (i, sorted[i - 
1], sorted[i]);
                                        else
                                                site.AddHFault (i, sorted[i - 
1], sorted[i]);

Modified: trunk/stetic/libstetic/wrapper/Button.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Button.cs    2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/wrapper/Button.cs    2005-03-17 19:53:27 UTC (rev 
41960)
@@ -15,6 +15,7 @@
                                                                "UseStock",
                                                                "StockId",
                                                                "Label",
+                                                               "ResponseId",
                                                                
"RemoveContents",
                                                                "RestoreLabel");
 
@@ -35,6 +36,12 @@
                                props["RestoreLabel"].DependsInverselyOn 
(hasLabel);
                                props["RemoveContents"].DependsOn (hasContents);
 
+                               PropertyDescriptor hasResponseId =
+                                       new PropertyDescriptor (typeof 
(Stetic.Wrapper.Button),
+                                                               typeof 
(Gtk.Button),
+                                                               
"HasResponseId");
+                               props["ResponseId"].VisibleIf (hasResponseId);
+
                                props = AddContextMenuItems (type,
                                                             "RemoveContents",
                                                             "RestoreLabel");
@@ -166,5 +173,31 @@
                                        button.Label = value;
                        }
                }
+
+               public bool HasResponseId {
+                       get {
+                               WidgetSite site = button.Parent as WidgetSite;
+                               if (site == null)
+                                       return false;
+                               site = site.ParentSite as WidgetSite;
+                               if (site == null)
+                                       return false;
+                               return site.InternalChildId == "action_area";
+                       }
+               }
+
+               int responseId;
+
+               [GladeProperty (Name = "response_id")]
+               [Editor (typeof (Stetic.Editor.ResponseId))]
+               [Description ("Response Id", "The response ID to emit when this 
button is clicked.")]
+               public int ResponseId {
+                       get {
+                               return responseId;
+                       }
+                       set {
+                               responseId = value;
+                       }
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Dialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/wrapper/Dialog.cs    2005-03-17 19:53:27 UTC (rev 
41960)
@@ -5,13 +5,14 @@
        [ObjectWrapper ("Dialog Box", "dialog.png", ObjectWrapperType.Window)]
        public class Dialog : Window {
 
-
                public static new Type WrappedType = typeof (Gtk.Dialog);
 
                static new void Register (Type type)
                {
                        AddItemGroup (type, "Dialog Properties",
                                      "Title",
+                                     "Buttons",
+                                     "HelpButton",
                                      "Icon",
                                      "WindowPosition",
                                      "Modal",
@@ -32,17 +33,23 @@
                        WidgetSite site;
 
                        base.Wrap (obj, initialized);
-                       Gtk.Dialog dialog = (Gtk.Dialog)Wrapped;
+                       dialog.HasSeparator = false;
 
                        site = CreateWidgetSite ();
                        site.InternalChildId = "vbox";
                        dialog.VBox.Reparent (site);
                        dialog.Add (site);
+                       ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.VBox), dialog.VBox);
+                       if (dialog.VBox.Name == "GtkVBox")
+                               dialog.VBox.Name = dialog.Name + "_vbox";
 
                        site = CreateWidgetSite ();
                        site.InternalChildId = "action_area";
                        dialog.ActionArea.Reparent (site);
                        dialog.VBox.PackEnd (site, false, true, 0);
+                       ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.HButtonBox), dialog.ActionArea);
+                       if (dialog.ActionArea.Name == "GtkHButtonBox")
+                               dialog.ActionArea.Name = dialog.Name + 
"_action_area";
 
                        if (!initialized) {
                                site = CreateWidgetSite ();
@@ -50,7 +57,112 @@
                                req.Width = req.Height = 200;
                                site.EmptySize = req;
                                dialog.VBox.Add (site);
+                               Buttons = StandardButtons.Close;
                        }
                }
+
+               Gtk.Dialog dialog {
+                       get {
+                               return (Gtk.Dialog)Wrapped;
+                       }
+               }
+
+               public enum StandardButtons {
+                       Custom,
+                       Close,
+                       Ok,
+                       CancelOk,
+               }
+
+               StandardButtons buttons;
+
+//             [Editor (typeof (Stetic.Editor.DialogButtons))]
+               [Description ("Buttons", "The buttons to display")]
+               public StandardButtons Buttons {
+                       get {
+                               return buttons;
+                       }
+                       set {
+                               if (buttons == value)
+                                       return;
+                               buttons = value;
+
+                               Gtk.ButtonBox actionArea = dialog.ActionArea;
+
+                               Gtk.Widget[] children = actionArea.Children;
+                               foreach (Gtk.Widget w in children) {
+                                       if (w != helpButton)
+                                               w.Destroy ();
+                               }
+
+                               switch (buttons) {
+                               case StandardButtons.Close:
+                                       AddButton (Gtk.Stock.Close, 
Gtk.ResponseType.Close, true);
+                                       break;
+
+                               case StandardButtons.Ok:
+                                       AddButton (Gtk.Stock.Ok, 
Gtk.ResponseType.Ok, true);
+                                       break;
+
+                               case StandardButtons.CancelOk:
+                                       AddButton (Gtk.Stock.Cancel, 
Gtk.ResponseType.Cancel, false);
+                                       AddButton (Gtk.Stock.Ok, 
Gtk.ResponseType.Ok, true);
+                                       break;
+
+                               case StandardButtons.Custom:
+                                       AddButton (null, 0, true);
+                                       break;
+                               }
+                       }
+               }
+
+               WidgetSite helpButton;
+
+               [Description ("Help Button", "Whether or not to display a 
\"Help\" button")]
+               public bool HelpButton {
+                       get {
+                               return helpButton != null;
+                       }
+                       set {
+                               if (HelpButton == value)
+                                       return;
+
+                               if (value) {
+                                       helpButton = AddButton (Gtk.Stock.Help, 
Gtk.ResponseType.Help, false);
+                               } else {
+                                       helpButton.Destroy ();
+                                       helpButton = null;
+                               }
+                       }
+               }
+
+               WidgetSite AddButton (string stockId, Gtk.ResponseType 
response, bool hasDefault)
+               {
+                       Stetic.Wrapper.Button button;
+                       Gtk.Button widget;
+
+                       button = ObjectWrapper.Create (stetic, typeof 
(Stetic.Wrapper.Button)) as Stetic.Wrapper.Button;
+                       widget = (Gtk.Button)button.Wrapped;
+                       if (stockId != null) {
+                               button.StockId = stockId;
+                               button.UseStock = true;
+                       } else {
+                               button.Label = widget.Name;
+                               button.UseStock = false;
+                       }
+                       button.ResponseId = (int)response;
+
+                       Stetic.Wrapper.Container actionArea = 
Stetic.Wrapper.Container.Lookup (dialog.ActionArea);
+                       WidgetSite site = actionArea.AddPlaceholder ();
+                       site.Add (widget);
+
+                       widget.CanDefault = true;
+                       button.HasDefault = hasDefault;
+
+                       if (stockId == Gtk.Stock.Help)
+                               
((Gtk.ButtonBox)actionArea.Wrapped).SetChildSecondary (site, true);
+
+                       return site;
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/MessageDialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/MessageDialog.cs     2005-03-17 19:43:32 UTC 
(rev 41959)
+++ trunk/stetic/libstetic/wrapper/MessageDialog.cs     2005-03-17 19:53:27 UTC 
(rev 41960)
@@ -131,7 +131,7 @@
                Gtk.ButtonsType buttons;
 
                [Description ("Buttons", "The buttons to offer")]
-               public Gtk.ButtonsType Buttons {
+               public new Gtk.ButtonsType Buttons {
                        get {
                                return buttons;
                        }

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-17 19:43:32 UTC (rev 
41959)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-03-17 19:53:27 UTC (rev 
41960)
@@ -85,14 +85,31 @@
                        }
                }
 
-               [GladeProperty (GladeProperty.LateImport)]
+               bool hasDefault;
+               [GladeProperty]
                public bool HasDefault {
                        get {
-                               return ((Gtk.Widget)Wrapped).HasDefault;
+                               return hasDefault;
                        }
                        set {
-                               ((Gtk.Widget)Wrapped).HasDefault = value;
+                               hasDefault = value;
+
+                               Gtk.Widget widget = (Gtk.Widget)Wrapped;
+                               if (widget.Toplevel != null)
+                                       widget.HasDefault = hasDefault;
+                               else
+                                       widget.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;
+                       }
+               }
        }
 }

Modified: trunk/stetic/stetic/ContextMenu.cs
===================================================================
--- trunk/stetic/stetic/ContextMenu.cs  2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/stetic/ContextMenu.cs  2005-03-17 19:53:27 UTC (rev 41960)
@@ -40,7 +40,7 @@
                        }
 
                        item = new MenuItem ("Cu_t");
-                       if (!site.Occupied)
+                       if (!site.Occupied || site.Internal)
                                item.Sensitive = false;
                        Add (item);
                        item = new MenuItem ("_Copy");
@@ -52,7 +52,7 @@
                                item.Sensitive = false;
                        Add (item);
                        item = new MenuItem ("_Delete");
-                       if (site.Occupied)
+                       if (site.Occupied && !site.Internal)
                                item.Activated += DoDelete;
                        else
                                item.Sensitive = false;

Modified: trunk/stetic/stetic/PropertyGrid.cs
===================================================================
--- trunk/stetic/stetic/PropertyGrid.cs 2005-03-17 19:43:32 UTC (rev 41959)
+++ trunk/stetic/stetic/PropertyGrid.cs 2005-03-17 19:53:27 UTC (rev 41960)
@@ -32,6 +32,9 @@
 
                void AppendProperty (PropertyDescriptor prop, ObjectWrapper 
wrapper)
                {
+                       if (!prop.VisibleFor (wrapper))
+                               return;
+
                        PropertyEditor rep = PropertyEditor.MakeEditor (prop, 
wrapper);
                        editors[prop.Name] = rep;
                        if (prop.ParamSpec != null)

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

Reply via email to