Author: danw
Date: 2005-04-07 16:17:06 -0400 (Thu, 07 Apr 2005)
New Revision: 42654

Added:
   trunk/stetic/libstetic/ObjectWrapperType.cs
   trunk/stetic/libstetic/RadioGroupManager.cs
   trunk/stetic/libstetic/wrapper/RadioToolButton.cs
   trunk/stetic/libstetic/wrapper/SeparatorToolItem.cs
   trunk/stetic/libstetic/wrapper/ToggleToolButton.cs
   trunk/stetic/libstetic/wrapper/ToolButton.cs
   trunk/stetic/libstetic/wrapper/Toolbar.cs
Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/DND.cs
   trunk/stetic/libstetic/HandleWindow.cs
   trunk/stetic/libstetic/Makefile.am
   trunk/stetic/libstetic/ObjectWrapperAttribute.cs
   trunk/stetic/libstetic/Placeholder.cs
   trunk/stetic/libstetic/PropertyDescriptor.cs
   trunk/stetic/libstetic/TranslatableAttribute.cs
   trunk/stetic/libstetic/editor/GroupPicker.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/RadioButton.cs
   trunk/stetic/libstetic/wrapper/Widget.cs
   trunk/stetic/stetic/Palette.cs
Log:
        Add Toolbar and its children, plus a bunch of things I had to fix
        to get there.
        
        * libstetic/DND.cs (Cancel): Returns the widget that was being
        dragged, after removing it from the DragWindow, so we don't get
        errors when you cancel a drag.

        * libstetic/HandleWindow.cs (Dispose): disconnect from
        selection.WidgetEvent.
        (SelectionEvent): if the event occurred in the handle window,
        always return true. Fixes the bug where widgets sometimes undrew
        themselves when they were selected.

        * libstetic/ObjectWrapperAttribute.cs (ObjectWrapperType): kill
        this enum
        (Type): make this a string

        * libstetic/ObjectWrapperType.cs: new static class containing
        constant strings for the predefined wrapper types (including the
        new ToolbarItem type).

        * libstetic/Placeholder.cs (OnDragDrop): remove this; Container
        can handle the event itself.

        * libstetic/PropertyDescriptor.cs: Fix this to be able to handle
        the case of a subproperty of a wrapper type (eg,
        ToolItem.IsImportant in Wrapper.Toolbar.ToolbarChild)

        * libstetic/RadioGroupManager.cs: Move the group-handling code
        from Wrapper.RadioButton here, and genericize it to be able to
        work with RadioToolButtons and RadioMenuItems as well.

        * libstetic/editor/GroupPicker.cs: update to use RadioGroupManager.

        * libstetic/wrapper/Container.cs (PlaceholderDragDrop): connect to
        this directly rather than having the Placeholder proxy it to us.
        (CreateDragSource): new virtual method to create a Placeholder (or
        not) specifically for when dragging something out of a container
        (CreatePlaceholder): update signal-handling here
        (RealChildren): make this virtual

        * libstetic/wrapper/Toolbar.cs: Wrap this.
        (RealChildren, ReplaceChild): Override these to handle "invisible"
        ToolItem wrappers around non-ToolItem objects stuck into the
        toolbar.
        (DoSync, Drop): do DND autoexpanding. (At some point, we should
        use the actual toolbar DND editing methods.)
        (CreateDragSource, DragEnd): return a Gtk.Invisible rather than
        adding a placeholder to the toolbar.
        (ToolbarChild): wrap this, putting the three ToolItem properties
        here, since it's where they really belong.

        * libstetic/wrapper/RadioButton.cs: port to use RadioGroupManager

        * libstetic/wrapper/Widget.cs (Wrap, InterceptClicks): recursively
        set up event interception, so that widgets with internal embedded
        widgets work correctly.
        (ParentWrapper): Make this able to cope with non-wrapped widgets
        in the hierarchy.

        * libstetic/wrapper/RadioToolButton.cs: 
        * libstetic/wrapper/SeparatorToolItem.cs: 
        * libstetic/wrapper/ToggleToolButton.cs: 
        * libstetic/wrapper/ToolButton.cs: Wrap

        * stetic/Palette.cs: update for ObjectWrapperType changes


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-04-07 20:05:52 UTC (rev 42653)
+++ trunk/stetic/ChangeLog      2005-04-07 20:17:06 UTC (rev 42654)
@@ -1,3 +1,72 @@
+2005-04-07  Dan Winship  <[EMAIL PROTECTED]>
+
+       Add Toolbar and its children, plus a bunch of things I had to fix
+       to get there.
+       
+       * libstetic/DND.cs (Cancel): Returns the widget that was being
+       dragged, after removing it from the DragWindow, so we don't get
+       errors when you cancel a drag.
+
+       * libstetic/HandleWindow.cs (Dispose): disconnect from
+       selection.WidgetEvent.
+       (SelectionEvent): if the event occurred in the handle window,
+       always return true. Fixes the bug where widgets sometimes undrew
+       themselves when they were selected.
+
+       * libstetic/ObjectWrapperAttribute.cs (ObjectWrapperType): kill
+       this enum
+       (Type): make this a string
+
+       * libstetic/ObjectWrapperType.cs: new static class containing
+       constant strings for the predefined wrapper types (including the
+       new ToolbarItem type).
+
+       * libstetic/Placeholder.cs (OnDragDrop): remove this; Container
+       can handle the event itself.
+
+       * libstetic/PropertyDescriptor.cs: Fix this to be able to handle
+       the case of a subproperty of a wrapper type (eg,
+       ToolItem.IsImportant in Wrapper.Toolbar.ToolbarChild)
+
+       * libstetic/RadioGroupManager.cs: Move the group-handling code
+       from Wrapper.RadioButton here, and genericize it to be able to
+       work with RadioToolButtons and RadioMenuItems as well.
+
+       * libstetic/editor/GroupPicker.cs: update to use RadioGroupManager.
+
+       * libstetic/wrapper/Container.cs (PlaceholderDragDrop): connect to
+       this directly rather than having the Placeholder proxy it to us.
+       (CreateDragSource): new virtual method to create a Placeholder (or
+       not) specifically for when dragging something out of a container
+       (CreatePlaceholder): update signal-handling here
+       (RealChildren): make this virtual
+
+       * libstetic/wrapper/Toolbar.cs: Wrap this.
+       (RealChildren, ReplaceChild): Override these to handle "invisible"
+       ToolItem wrappers around non-ToolItem objects stuck into the
+       toolbar.
+       (DoSync, Drop): do DND autoexpanding. (At some point, we should
+       use the actual toolbar DND editing methods.)
+       (CreateDragSource, DragEnd): return a Gtk.Invisible rather than
+       adding a placeholder to the toolbar.
+       (ToolbarChild): wrap this, putting the three ToolItem properties
+       here, since it's where they really belong.
+
+       * libstetic/wrapper/RadioButton.cs: port to use RadioGroupManager
+
+       * libstetic/wrapper/Widget.cs (Wrap, InterceptClicks): recursively
+       set up event interception, so that widgets with internal embedded
+       widgets work correctly.
+       (ParentWrapper): Make this able to cope with non-wrapped widgets
+       in the hierarchy.
+
+       * libstetic/wrapper/RadioToolButton.cs: 
+       * libstetic/wrapper/SeparatorToolItem.cs: 
+       * libstetic/wrapper/ToggleToolButton.cs: 
+       * libstetic/wrapper/ToolButton.cs: Wrap
+
+       * stetic/Palette.cs: update for ObjectWrapperType changes
+
 2005-04-05  Dan Winship  <[EMAIL PROTECTED]>
 
        * libstetic/wrapper/Widget.cs (ToString): override

Modified: trunk/stetic/libstetic/DND.cs
===================================================================
--- trunk/stetic/libstetic/DND.cs       2005-04-07 20:05:52 UTC (rev 42653)
+++ trunk/stetic/libstetic/DND.cs       2005-04-07 20:17:06 UTC (rev 42654)
@@ -103,15 +103,23 @@
                                return null;
                        }
 
+                       Gtk.Widget w = Cancel ();
+                       Gtk.Drag.Finish (ctx, true, true, time);
+                       return w;
+               }
+
+               // Call this from a DragEnd event to check if the widget wasn't 
dropped
+               public static Gtk.Widget Cancel ()
+               {
                        Gtk.Widget w = dragWidget;
                        dragWidget = null;
 
                        // Remove the widget from its dragWindow
                        Gtk.Container parent = w.Parent as Gtk.Container;
-                       if (parent != null)
+                       if (parent != null) {
                                parent.Remove (w);
-
-                       Gtk.Drag.Finish (ctx, true, true, time);
+                               parent.Destroy ();
+                       }
                        return w;
                }
 

Modified: trunk/stetic/libstetic/HandleWindow.cs
===================================================================
--- trunk/stetic/libstetic/HandleWindow.cs      2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/HandleWindow.cs      2005-04-07 20:17:06 UTC (rev 
42654)
@@ -46,6 +46,7 @@
                {
                        if (selection != null) {
                                selection.SizeAllocated -= SelectionResized;
+                               selection.WidgetEvent -= SelectionEvent;
                                selection = null;
                        }
 
@@ -119,11 +120,11 @@
                {
                        if (args.Event.Window != window)
                                return;
+                       args.RetVal = true;
 
                        switch (args.Event.Type) {
                        case Gdk.EventType.ButtonPress:
                                Gdk.EventButton evb = 
(Gdk.EventButton)args.Event;
-                               args.RetVal = true;
 
                                if (evb.Type == Gdk.EventType.ButtonPress && 
evb.Button == 1) {
                                        clickX = (int)evb.XRoot;
@@ -133,7 +134,6 @@
 
                        case Gdk.EventType.MotionNotify:
                                Gdk.EventMotion evm = 
(Gdk.EventMotion)args.Event;
-                               args.RetVal = true;
 
                                if (!dragHandles)
                                        return;

Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am  2005-04-07 20:05:52 UTC (rev 42653)
+++ trunk/stetic/libstetic/Makefile.am  2005-04-07 20:17:06 UTC (rev 42654)
@@ -15,10 +15,12 @@
        IStetic.cs                      \
        ObjectWrapper.cs                \
        ObjectWrapperAttribute.cs       \
+       ObjectWrapperType.cs            \
        ParamSpec.cs                    \
        Placeholder.cs                  \
        PropertyDescriptor.cs           \
        PropertyEditorAttribute.cs      \
+       RadioGroupManager.cs            \
        RangeAttribute.cs               \
        Set.cs                          \
        TranslatableAttribute.cs        \
@@ -73,14 +75,19 @@
        wrapper/Paned.cs                \
        wrapper/ProgressBar.cs          \
        wrapper/RadioButton.cs          \
+       wrapper/RadioToolButton.cs      \
        wrapper/Range.cs                \
        wrapper/Scale.cs                \
        wrapper/ScrolledWindow.cs       \
+       wrapper/SeparatorToolItem.cs    \
        wrapper/SpinButton.cs           \
        wrapper/Statusbar.cs            \
        wrapper/Table.cs                \
        wrapper/TextView.cs             \
        wrapper/ToggleButton.cs         \
+       wrapper/ToggleToolButton.cs     \
+       wrapper/Toolbar.cs              \
+       wrapper/ToolButton.cs           \
        wrapper/TreeView.cs             \
        wrapper/VBox.cs                 \
        wrapper/VButtonBox.cs           \

Modified: trunk/stetic/libstetic/ObjectWrapperAttribute.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapperAttribute.cs    2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/ObjectWrapperAttribute.cs    2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -2,17 +2,9 @@
 
 namespace Stetic {
 
-       public enum ObjectWrapperType {
-               Object,
-               Widget,
-               Container,
-               Window
-       };
-
        [AttributeUsage (AttributeTargets.Class)]
        public sealed class ObjectWrapperAttribute : Attribute {
-               string name, iconName;
-               ObjectWrapperType type;
+               string name, iconName, type;
                bool deprecated;
 
                [Translatable]
@@ -26,7 +18,7 @@
                        set { iconName = value; }
                }
 
-               public ObjectWrapperType Type {
+               public string Type {
                        get { return type; }
                        set { type = value; }
                }
@@ -36,7 +28,7 @@
                        set { deprecated = value; }
                }
 
-               public ObjectWrapperAttribute (string name, string iconName, 
ObjectWrapperType type)
+               public ObjectWrapperAttribute (string name, string iconName, 
string type)
                {
                        this.name = name;
                        this.iconName = iconName;

Added: trunk/stetic/libstetic/ObjectWrapperType.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapperType.cs 2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/ObjectWrapperType.cs 2005-04-07 20:17:06 UTC (rev 
42654)
@@ -0,0 +1,22 @@
+using System;
+
+namespace Stetic {
+
+       public static class ObjectWrapperType {
+
+               [Translatable]
+               public const string Widget = "Widgets";
+
+               [Translatable]
+               public const string ToolbarItem = "Toolbar Items";
+
+               [Translatable]
+               public const string Container = "Layout Containers";
+
+               [Translatable]
+               public const string Window = "Windows and Dialogs";
+
+
+               public const string Internal = "Internal";
+       }
+}

Modified: trunk/stetic/libstetic/Placeholder.cs
===================================================================
--- trunk/stetic/libstetic/Placeholder.cs       2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/Placeholder.cs       2005-04-07 20:17:06 UTC (rev 
42654)
@@ -9,7 +9,6 @@
                {
                        DND.DestSet (this, true);
                        Events |= Gdk.EventMask.ButtonPressMask;
-
                }
 
                const int minSize = 10;
@@ -65,21 +64,5 @@
 
                        return base.OnExposeEvent (evt);
                }
-
-               public delegate void DropHandler (Placeholder ph, Widget w);
-               public event DropHandler Drop;
-
-               protected override bool OnDragDrop (Gdk.DragContext ctx, int x, 
int y, uint time)
-               {
-                       Widget dragged = DND.Drop (ctx, time);
-                       if (dragged == null)
-                               return false;
-
-                       if (Drop != null)
-                               Drop (this, dragged);
-                       else
-                               dragged.Destroy ();
-                       return true;
-               }
        }
 }

Modified: trunk/stetic/libstetic/PropertyDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/PropertyDescriptor.cs        2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/PropertyDescriptor.cs        2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -26,7 +26,8 @@
 
                        if (dot != -1) {
                                // Sub-property (eg, "Alignment.Value")
-                               memberInfo = FindProperty (objectType, 
propertyName.Substring (0, dot));
+                               memberInfo = FindProperty (wrapperType, 
objectType, propertyName.Substring (0, dot));
+                               isWrapperProperty = 
memberInfo.DeclaringType.IsSubclassOf (typeof (ObjectWrapper));
                                gladeProperty = new PropertyDescriptor 
(wrapperType, objectType, memberInfo.Name);
                                propertyInfo = FindProperty 
(memberInfo.PropertyType, propertyName.Substring (dot + 1));
                        } else if (slash != -1) {

Added: trunk/stetic/libstetic/RadioGroupManager.cs
===================================================================
--- trunk/stetic/libstetic/RadioGroupManager.cs 2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/RadioGroupManager.cs 2005-04-07 20:17:06 UTC (rev 
42654)
@@ -0,0 +1,143 @@
+using System;
+using System.Collections;
+using System.Reflection;
+
+// The external (UI/glade file) representation of "radio widget"
+// (Gtk.RadioButton, Gtk.RadioToolButton, and Gtk.RadioMenuItem) groups
+// is that the groups have names, and each widget's "group" property stores
+// the name of its group.
+//
+// The internal (Gtk) representation of groups is that each radio widget
+// has a GLib.SList "Group" property. The content of the list is essentially
+// opaque. (For Gtk.RadioButton, the list contains all of the RadioButtons
+// in the group. But for Gtk.ToolRadioButton it contains pointers to internal
+// widgets, not the ToolRadioButtons themselves.) The only thing we can do
+// with them then is to read one widget's group and then immediately assign
+// it to another widget. We can't look into the list, or assume that a
+// widget's Group property will keep the same value if any other widget's
+// Group changes.
+//
+// Each radio widget type wrapper class keeps a static RadioGroupManager to
+// handle this string<->GLib.SList translation for it.
+
+namespace Stetic {
+
+       public class RadioGroup {
+               public string Name;
+               public ArrayList Widgets;
+
+               public RadioGroup (string name)
+               {
+                       Name = name;
+                       Widgets = new ArrayList ();
+               }
+       }
+
+       public class RadioGroupManager {
+               PropertyInfo groupProperty;
+               ArrayList groups;
+               Hashtable widgets;
+
+               public RadioGroupManager (Type widgetType)
+               {
+                       groupProperty = widgetType.GetProperty ("Group");
+                       if (groupProperty == null || groupProperty.PropertyType 
!= typeof (GLib.SList))
+                               throw new ArgumentException ("No 'public 
GLib.SList Group' property on '" + widgetType.FullName + "'");
+
+                       groups = new ArrayList ();
+                       widgets = new Hashtable ();
+               }
+
+               public delegate void GroupsChangedDelegate ();
+               public event GroupsChangedDelegate GroupsChanged;
+
+               void EmitGroupsChanged ()
+               {
+                       if (GroupsChanged != null)
+                               GroupsChanged ();
+               }
+
+               public IEnumerable GroupNames {
+                       get {
+                               string[] names = new string[groups.Count];
+                               for (int i = 0; i < groups.Count; i++)
+                                       names[i] = ((RadioGroup)groups[i]).Name;
+                               return names;
+                       }
+               }
+
+               public string LastGroup {
+                       get {
+                               if (groups.Count == 0)
+                                       Add ("group1");
+                               RadioGroup group = groups[groups.Count - 1] as 
RadioGroup;
+                               return group.Name;
+                       }
+               }
+
+               public RadioGroup FindGroup (string name)
+               {
+                       for (int i = 0; i < groups.Count; i++) {
+                               RadioGroup group = groups[i] as RadioGroup;
+                               if (group.Name == name)
+                                       return group;
+                       }
+                       return null;
+               }
+
+               public RadioGroup Add (string name)
+               {
+                       RadioGroup group = new RadioGroup (name);
+                       groups.Add (group);
+                       EmitGroupsChanged ();
+                       return group;
+               }
+
+               public RadioGroup Rename (string oldName, string newName)
+               {
+                       RadioGroup group = FindGroup (oldName);
+                       if (group != null) {
+                               group.Name = newName;
+                               EmitGroupsChanged ();
+                       }
+                       return group;
+               }
+
+               public string this[Gtk.Widget radio] {
+                       get {
+                               RadioGroup group = widgets[radio] as RadioGroup;
+                               if (group != null)
+                                       return group.Name;
+                               else
+                                       return null;
+                       }
+                       set {
+                               GLib.SList group_value;
+
+                               RadioGroup oldGroup = widgets[radio] as 
RadioGroup;
+                               if (oldGroup != null) {
+                                       if (oldGroup.Name == value)
+                                               return;
+                                       oldGroup.Widgets.Remove (radio);
+                                       if (oldGroup.Widgets.Count == 0) {
+                                               groups.Remove (oldGroup);
+                                               EmitGroupsChanged ();
+                                       }
+                               }
+
+                               RadioGroup newGroup = FindGroup (value);
+                               if (newGroup == null)
+                                       newGroup = Add (value);
+
+                               if (newGroup.Widgets.Count == 0)
+                                       group_value = new GLib.SList 
(IntPtr.Zero);
+                               else
+                                       group_value = 
(GLib.SList)groupProperty.GetValue (newGroup.Widgets[0], null);
+
+                               groupProperty.SetValue (radio, group_value, 
null);
+                               newGroup.Widgets.Add (radio);
+                               widgets[radio] = newGroup;
+                       }
+               }
+       }
+}

Modified: trunk/stetic/libstetic/TranslatableAttribute.cs
===================================================================
--- trunk/stetic/libstetic/TranslatableAttribute.cs     2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/TranslatableAttribute.cs     2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -2,7 +2,7 @@
 
 namespace Stetic {
 
-       [AttributeUsage (AttributeTargets.Property)]
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Field)]
        public sealed class TranslatableAttribute : Attribute {
        }
 }

Modified: trunk/stetic/libstetic/editor/GroupPicker.cs
===================================================================
--- trunk/stetic/libstetic/editor/GroupPicker.cs        2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/editor/GroupPicker.cs        2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -11,35 +11,30 @@
        class GroupPicker : Gtk.HBox {
 
                Gtk.ComboBox combo;
+               RadioGroupManager manager;
                ArrayList values;
-               EventInfo groupChanged;
+               string group;
 
                public GroupPicker (PropertyInfo info) : base (false, 0)
                {
                        BindingFlags flags = BindingFlags.Static | 
BindingFlags.Public | BindingFlags.NonPublic;
                        Type owner = info.DeclaringType;
 
-                       FieldInfo groupInfo = owner.GetField (info.Name + 
"List", flags);
-                       if (groupInfo == null || groupInfo.FieldType != typeof 
(ArrayList))
-                               throw new ArgumentException ("No 'static 
ArrayList " + info.Name + "List' property on " + owner.FullName);
+                       FieldInfo managerInfo = owner.GetField (info.Name + 
"Manager", flags);
+                       if (managerInfo == null || managerInfo.FieldType != 
typeof (Stetic.RadioGroupManager))
+                               throw new ArgumentException ("No 'static 
RadioGroupManager " + info.Name + "Manager' property on " + owner.FullName);
 
-                       values = groupInfo.GetValue (null) as ArrayList;
-
-                       groupChanged = owner.GetEvent (info.Name + 
"ListChanged", flags);
-                       if (groupChanged != null)
-                               groupChanged.AddEventHandler (null, new 
ListChangedDelegate (ListChanged));
-
-                       ListChanged ();
+                       manager = managerInfo.GetValue (null) as 
RadioGroupManager;
+                       manager.GroupsChanged += GroupsChanged;
+                       GroupsChanged ();
                }
 
                protected override void OnDestroyed ()
                {
-                       groupChanged.RemoveEventHandler (null, new 
ListChangedDelegate (ListChanged));
+                       manager.GroupsChanged -= GroupsChanged;
                }
 
-               public delegate void ListChangedDelegate ();
-
-               void ListChanged ()
+               void GroupsChanged ()
                {
                        if (combo != null) {
                                combo.Changed -= combo_Changed;
@@ -51,27 +46,32 @@
                        combo.Show ();
                        PackStart (combo, true, true, 0);
 
-                       for (int i = 0; i < values.Count; i++) {
-                               combo.AppendText (values[i] as string);
-                               if (values[i] == groupname)
+                       values = new ArrayList ();
+                       int i = 0;
+                       foreach (string name in manager.GroupNames) {
+                               values.Add (name);
+                               combo.AppendText (name);
+                               if (name == group)
                                        combo.Active = i;
+                               i++;
                        }
 
+                       // FIXME: once we go to 2.6, add a separator here
+
                        combo.AppendText ("Rename Group...");
                        combo.AppendText ("New Group...");
                }
 
-               int group;
-               string groupname;
-               public int Group {
+               public string Group {
                        get {
                                return group;
                        }
                        set {
-                               if (value < 0 || value >= values.Count)
-                                       return;
-                               group = combo.Active = value;
-                               groupname = values[value] as string;
+                               int index = values.IndexOf (value);
+                               if (index != -1) {
+                                       combo.Active = index;
+                                       group = values[index] as string;
+                               }
                        }
                }
 
@@ -84,8 +84,7 @@
                                return;
                        }
 
-                       group = combo.Active;
-                       groupname = values[group] as string;
+                       group = values[combo.Active] as string;
                        if (Changed != null)
                                Changed (this, EventArgs.Empty);
                }
@@ -112,7 +111,7 @@
                        hbox.PackStart (label, false, false, 0);
                        entry.ActivatesDefault = true;
                        if (rename)
-                               entry.Text = groupname;
+                               entry.Text = group;
                        hbox.PackStart (entry, true, true, 0);
                        dialog.VBox.PackStart (hbox, false, false, 0);
 
@@ -122,18 +121,22 @@
                        Gtk.ResponseType response = 
(Gtk.ResponseType)dialog.Run ();
                        if (response == Gtk.ResponseType.Cancel || 
entry.Text.Length == 0) {
                                dialog.Destroy ();
-                               combo.Active = group;
+                               Group = group; // reset combo.Active
                                return;
                        }
 
-                       groupname = entry.Text;
+                       string oldname = group;
+                       group = entry.Text;
                        dialog.Destroy ();
 
+                       // FIXME: check that the new name doesn't already exist
+
+                       // This will trigger a GroupsChanged, which will 
eventually
+                       // update combo.Active
                        if (rename)
-                               values[group] = groupname;
+                               manager.Rename (oldname, group);
                        else
-                               values.Add (groupname);
-                       ListChanged ();
+                               manager.Add (group);
                }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-04-07 20:17:06 UTC (rev 
42654)
@@ -182,8 +182,7 @@
                {
                        Placeholder ph = new Placeholder ();
                        ph.Show ();
-                       ph.Drop += PlaceholderDrop;
-                       ph.DragEnd += PlaceholderDragEnd;
+                       ph.DragDrop += PlaceholderDragDrop;
                        ph.ButtonPressEvent += PlaceholderButtonPress;
                        AutoSize[ph] = true;
                        return ph;
@@ -205,28 +204,22 @@
                        }
                }
 
-               void PlaceholderDrop (Placeholder ph, Gtk.Widget dropped)
+               void PlaceholderDragDrop (object obj, Gtk.DragDropArgs args)
                {
+                       Placeholder ph = obj as Placeholder;
+                       Gtk.Widget dropped = DND.Drop (args.Context, args.Time);
+                       if (dropped == null)
+                               return;
+
                        ReplaceChild (ph, dropped);
                        ph.Destroy ();
                        Stetic.Wrapper.Widget wrapper = 
Stetic.Wrapper.Widget.Lookup (dropped);
                        if (wrapper != null)
                                wrapper.Select ();
                        EmitContentsChanged ();
+                       args.RetVal = true;
                }
 
-               void PlaceholderDragEnd (object obj, Gtk.DragEndArgs args)
-               {
-                       Placeholder ph = obj as Placeholder;
-
-                       dragSource = null;
-                       if (DND.DragWidget == null) {
-                               ph.SetSizeRequest (-1, -1);
-                               Sync ();
-                       } else
-                               ReplaceChild (ph, DND.DragWidget);
-               }
-
                protected virtual void ChildContentsChanged (Container child) {
                        ;
                }
@@ -251,7 +244,7 @@
                        }
                }
 
-               public IEnumerable RealChildren {
+               public virtual IEnumerable RealChildren {
                        get {
                                RealChildEnumerator rce = new 
RealChildEnumerator ();
                                container.Forall (rce.Add);
@@ -332,16 +325,36 @@
                void HandleWindowDrag (Gdk.EventMotion evt)
                {
                        Gtk.Widget dragWidget = selection;
-                       Gdk.Rectangle alloc = dragWidget.Allocation;
 
                        Select ((Stetic.Wrapper.Widget)null);
 
-                       dragSource = CreatePlaceholder ();
-                       dragSource.SetSizeRequest (alloc.Width, alloc.Height);
-                       ReplaceChild (dragWidget, dragSource);
+                       dragSource = CreateDragSource (dragWidget);
                        DND.Drag (dragSource, evt, dragWidget);
                }
 
+               protected virtual Gtk.Widget CreateDragSource (Gtk.Widget 
dragWidget)
+               {
+                       Placeholder ph = CreatePlaceholder ();
+                       Gdk.Rectangle alloc = dragWidget.Allocation;
+                       ph.SetSizeRequest (alloc.Width, alloc.Height);
+                       ph.DragEnd += DragEnd;
+                       ReplaceChild (dragWidget, ph);
+                       return ph;
+               }
+
+               void DragEnd (object obj, Gtk.DragEndArgs args)
+               {
+                       Placeholder ph = obj as Placeholder;
+                       ph.DragEnd -= DragEnd;
+
+                       dragSource = null;
+                       if (DND.DragWidget == null) {
+                               ph.SetSizeRequest (-1, -1);
+                               Sync ();
+                       } else
+                               ReplaceChild (ph, DND.Cancel ());
+               }
+
                void SizeAllocated (object obj, Gtk.SizeAllocatedArgs args)
                {
                        if (handles != null)

Modified: trunk/stetic/libstetic/wrapper/RadioButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/RadioButton.cs       2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/wrapper/RadioButton.cs       2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -6,10 +6,6 @@
        [ObjectWrapper ("Radio Button", "radiobutton.png", 
ObjectWrapperType.Widget)]
        public class RadioButton : Button {
 
-               static ArrayList GroupList = new ArrayList ();
-               static event Stetic.Editor.GroupPicker.ListChangedDelegate 
GroupListChanged;
-               static ArrayList GroupLeaders = new ArrayList ();
-
                public static new Type WrappedType = typeof (Gtk.RadioButton);
 
                static new void Register (Type type)
@@ -22,129 +18,39 @@
                                      "DrawIndicator");
                }
 
+               static RadioGroupManager GroupManager = new RadioGroupManager 
(WrappedType);
+
                public override void Wrap (object obj, bool initialized)
                {
                        base.Wrap (obj, initialized);
-                       if (!initialized) {
-                               Gtk.RadioButton radiobutton = 
(Gtk.RadioButton)Wrapped;
 
+                       Gtk.RadioButton radiobutton = (Gtk.RadioButton)Wrapped;
+                       if (!initialized) {
                                radiobutton.Label = radiobutton.Name;
-
-                               if (GroupList.Count == 0) {
-                                       GroupList.Add ("radiogroup1");
-                                       GroupLeaders.Add (radiobutton);
-                               }
-                               Group = GroupList.Count - 1;
-                       }
+                               Group = GroupManager.LastGroup;
+                       } else if (radiobutton.Group == null)
+                               Group = radiobutton.Name;
                }
 
-               string group;
-
                protected override void GladeImport (string className, string 
id, Hashtable props)
                {
-                       group = GladeUtils.ExtractProperty ("group", props);
+                       string group = GladeUtils.ExtractProperty ("group", 
props);
                        base.GladeImport (className, id, props);
 
                        if (group != null)
-                               stetic.GladeImportComplete += SetGroup;
-                       else {
-                               GroupList.Add (Wrapped.Name);
-                               GroupLeaders.Add (Wrapped);
-                       }
+                               Group = group;
+                       else
+                               Group = Wrapped.Name;
                }
 
-               void SetGroup ()
-               {
-                       Gtk.Widget leader = stetic.LookupWidgetById (group);
-                       if (leader != null) {
-                               int index = GroupLeaders.IndexOf (leader);
-                               if (index != -1)
-                                       Group = index;
-                       }
-                       stetic.GladeImportComplete -= SetGroup;
-               }
-
-               public override void GladeExport (out string className, out 
string id, out Hashtable props)
-               {
-                       base.GladeExport (out className, out id, out props);
-
-                       Gtk.RadioButton leader = 
(Gtk.RadioButton)GroupLeaders[Group];
-                       if (leader != (Gtk.RadioButton)Wrapped)
-                               props["group"] = leader.Name;
-               }
-
                [Editor (typeof (Stetic.Editor.GroupPicker))]
                [Description ("Group", "The name of the radio button group that 
this button belongs to")]
-               public int Group {
+               public string Group {
                        get {
-                               // We can't store this in an instance variable
-                               // because groups may be removed from the list. 
So
-                               // just figure it out from scratch each time.
-
-                               Gtk.RadioButton radio = 
(Gtk.RadioButton)Wrapped;
-                               GLib.SList group = radio.Group;
-
-                               for (int i = 0; i < GroupLeaders.Count; i++) {
-                                       if ((Gtk.RadioButton)GroupLeaders[i] == 
radio)
-                                               return i;
-                                       foreach (object member in group) {
-                                               if (member == GroupLeaders[i])
-                                                       return i;
-                                       }
-                               }
-
-                               // can't happen?
-                               return -1;
+                               return GroupManager[Wrapped];
                        }
                        set {
-                               Gtk.RadioButton radio = 
(Gtk.RadioButton)Wrapped;
-                               GLib.SList group;
-                               bool killGroup = false;
-
-                               // shouldn't happen...
-                               if (value < 0 || value > GroupLeaders.Count)
-                                       return;
-
-                               // check if we are currently the leader of a 
group
-                               int oldGroup = GroupLeaders.IndexOf (radio);
-                               if (oldGroup == value)
-                                       return; // no change
-                               else if (oldGroup != -1) {
-                                       group = radio.Group;
-                                       killGroup = true;
-                                       foreach (Gtk.RadioButton member in 
group) {
-                                               if (member != radio) {
-                                                       GroupLeaders[oldGroup] 
= member;
-                                                       killGroup = false;
-                                               }
-                                       }
-                               }
-
-                               if (value < GroupLeaders.Count) {
-                                       // Add us to an existing group
-                                       group = 
((Gtk.RadioButton)GroupLeaders[value]).Group;
-                                       bool found = false;
-                                       foreach (Gtk.RadioButton member in 
group) {
-                                               if (member == radio) {
-                                                       found = true;
-                                                       break;
-                                               }
-                                       }
-                                       if (!found)
-                                               radio.Group = group;
-                               } else {
-                                       // Create a new group for just us
-                                       GroupLeaders.Add (radio);
-                                       radio.Group = new 
GLib.SList(IntPtr.Zero);
-                               }
-
-                               EmitNotify ("Group");
-                               if (killGroup) {
-                                       GroupLeaders.RemoveAt (oldGroup);
-                                       GroupList.RemoveAt (oldGroup);
-                                       if (GroupListChanged != null)
-                                               GroupListChanged ();
-                               }
+                               GroupManager[Wrapped] = value;
                        }
                }
 

Added: trunk/stetic/libstetic/wrapper/RadioToolButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/RadioToolButton.cs   2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/wrapper/RadioToolButton.cs   2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -0,0 +1,61 @@
+using System;
+using System.Collections;
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Toolbar Radio Button", "radiobutton.png", 
ObjectWrapperType.ToolbarItem)]
+       public class RadioToolButton : ToggleToolButton {
+
+               public static new Type WrappedType = typeof 
(Gtk.RadioToolButton);
+
+               static new void Register (Type type)
+               {
+                       AddItemGroup (type, "Toolbar Toggle Button Properties",
+                                     "Icon",
+                                     "Label",
+                                     "UseUnderline",
+                                     "Group",
+                                     "Active");
+               }
+
+               public static new Gtk.ToolButton CreateInstance ()
+               {
+                       return new Gtk.RadioToolButton (new GLib.SList 
(IntPtr.Zero), Gtk.Stock.SortAscending);
+               }
+
+               static RadioGroupManager GroupManager = new RadioGroupManager 
(WrappedType);
+
+               public override void Wrap (object obj, bool initialized)
+               {
+                       base.Wrap (obj, initialized);
+
+                       Gtk.RadioToolButton radio = 
(Gtk.RadioToolButton)Wrapped;
+                       if (!initialized)
+                               Group = GroupManager.LastGroup;
+                       else if (radio.Group == null)
+                               Group = radio.Name;
+               }
+
+               protected override void GladeImport (string className, string 
id, Hashtable props)
+               {
+                       string group = GladeUtils.ExtractProperty ("group", 
props);
+                       base.GladeImport (className, id, props);
+
+                       if (group != null)
+                               Group = group;
+                       else
+                               Group = Wrapped.Name;
+               }
+
+               [Editor (typeof (Stetic.Editor.GroupPicker))]
+               [Description ("Group", "The name of the radio button group that 
this button belongs to")]
+               public string Group {
+                       get {
+                               return GroupManager[Wrapped];
+                       }
+                       set {
+                               GroupManager[Wrapped] = value;
+                       }
+               }
+       }
+}

Added: trunk/stetic/libstetic/wrapper/SeparatorToolItem.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/SeparatorToolItem.cs 2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/wrapper/SeparatorToolItem.cs 2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -0,0 +1,16 @@
+using System;
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Toolbar Separator", "vseparator.png", 
ObjectWrapperType.ToolbarItem)]
+       public class SeparatorToolItem : Widget {
+
+               public static new Type WrappedType = typeof 
(Gtk.SeparatorToolItem);
+
+               static new void Register (Type type)
+               {
+                       AddItemGroup (type, "Toolbar Separator Properties",
+                                     "Draw");
+               }
+       }
+}

Added: trunk/stetic/libstetic/wrapper/ToggleToolButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ToggleToolButton.cs  2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/wrapper/ToggleToolButton.cs  2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -0,0 +1,44 @@
+using System;
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Toolbar Toggle Button", "checkbutton.png", 
ObjectWrapperType.ToolbarItem)]
+       public class ToggleToolButton : ToolButton {
+
+               public static new Type WrappedType = typeof 
(Gtk.ToggleToolButton);
+
+               static new void Register (Type type)
+               {
+                       AddItemGroup (type, "Toolbar Toggle Button Properties",
+                                     "Icon",
+                                     "Label",
+                                     "UseUnderline",
+                                     "Active");
+               }
+
+               public static new Gtk.ToolButton CreateInstance ()
+               {
+                       return new Gtk.ToggleToolButton (Gtk.Stock.Bold);
+               }
+
+               // FIXME. Not needed in 2.6
+               [GladeProperty (Name = "active", Proxy = "GladeActive")]
+               public bool Active {
+                       get {
+                               return ((Gtk.ToggleToolButton)Wrapped).Active;
+                       }
+                       set {
+                               ((Gtk.ToggleToolButton)Wrapped).Active = value;
+                       }
+               }
+
+               public string GladeActive {
+                       get {
+                               return Active ? "True" : "False";
+                       }
+                       set {
+                               Active = (value == "True");
+                       }
+               }
+       }
+}

Added: trunk/stetic/libstetic/wrapper/ToolButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ToolButton.cs        2005-04-07 20:05:52 UTC 
(rev 42653)
+++ trunk/stetic/libstetic/wrapper/ToolButton.cs        2005-04-07 20:17:06 UTC 
(rev 42654)
@@ -0,0 +1,75 @@
+using System;
+using System.Collections;
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Toolbar Button", "button.png", 
ObjectWrapperType.ToolbarItem)]
+       public class ToolButton : Widget {
+
+               public static new Type WrappedType = typeof (Gtk.ToolButton);
+
+               static new void Register (Type type)
+               {
+                       if (type == typeof (Stetic.Wrapper.ToolButton)) {
+                               AddItemGroup (type, "Toolbar Button Properties",
+                                             "Icon",
+                                             "Label",
+                                             "UseUnderline");
+                       }
+               }
+
+               public static new Gtk.ToolButton CreateInstance ()
+               {
+                       return new Gtk.ToolButton (Gtk.Stock.New);
+               }
+
+               public override void Wrap (object obj, bool initialized)
+               {
+                       base.Wrap (obj, initialized);
+                       Gtk.ToolButton toolbutton = (Gtk.ToolButton)Wrapped;
+
+                       if (toolbutton.StockId != null)
+                               icon = "stock:" + toolbutton.StockId;
+               }
+
+               protected override void GladeImport (string className, string 
id, Hashtable props)
+               {
+                       string icon = GladeUtils.ExtractProperty ("icon", 
props);
+                       base.GladeImport (className, id, props);
+                       if (icon != null)
+                               Icon = "file:" + icon;
+                       else if (((Gtk.ToolButton)Wrapped).StockId == null)
+                               Icon = null;
+               }
+
+               string icon;
+
+               [Editor (typeof (Stetic.Editor.Image))]
+               [Description ("Icon", "The icon to display in the button")]
+               public string Icon {
+                       get {
+                               return icon;
+                       }
+                       set {
+                               Gtk.ToolButton toolbutton = 
(Gtk.ToolButton)Wrapped;
+
+                               icon = value;
+                               if (icon != null && icon.StartsWith ("stock:")) 
{
+                                       toolbutton.IconWidget = null;
+                                       Gtk.StockItem item = Gtk.Stock.Lookup 
(icon.Substring (6));
+                                       if (item.Label != null) {
+                                               toolbutton.StockId = 
item.StockId;
+                                               toolbutton.Label = item.Label;
+                                               toolbutton.UseUnderline = true;
+                                       }
+                               } else if (icon != null && icon.StartsWith 
("file:")) {
+                                       toolbutton.IconWidget = new Gtk.Image 
(icon.Substring (5));
+                                       toolbutton.IconWidget.Show ();
+                               } else {
+                                       toolbutton.IconWidget = new Gtk.Image 
(Gtk.Stock.MissingImage, Gtk.IconSize.SmallToolbar);
+                                       toolbutton.IconWidget.Show ();
+                               }
+                       }
+               }
+       }
+}

Added: trunk/stetic/libstetic/wrapper/Toolbar.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Toolbar.cs   2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/wrapper/Toolbar.cs   2005-04-07 20:17:06 UTC (rev 
42654)
@@ -0,0 +1,209 @@
+using System;
+using System.Collections;
+
+namespace Stetic.Wrapper {
+
+       [ObjectWrapper ("Toolbar", "toolbar.png", ObjectWrapperType.Widget)]
+       public class Toolbar : Container {
+
+               public static new Type WrappedType = typeof (Gtk.Toolbar);
+
+               static new void Register (Type type)
+               {
+                       AddItemGroup (type, "Tool Bar Properties",
+                                     "Orientation",
+                                     "ShowArrow",
+                                     "ToolbarStyle",
+                                     "Tooltips");
+               }
+
+               public override void Wrap (object obj, bool initialized)
+               {
+                       base.Wrap (obj, initialized);
+                       toolbar.SizeAllocated += toolbar_SizeAllocated;
+               }
+
+               public override IEnumerable RealChildren {
+                       get {
+                               // Don't return Gtk.ToolItems that are only 
being used
+                               // to hold other non-ToolItem widgets. Just 
return the
+                               // contained widgets themselves.
+
+                               Gtk.Widget[] children = toolbar.Children;
+                               for (int i = 0; i < children.Length; i++) {
+                                       if (children[i].GetType () == typeof 
(Gtk.ToolItem))
+                                               children[i] = 
((Gtk.ToolItem)children[i]).Child;
+                               }
+                               return children;
+                       }
+               }
+
+               // FIXME. Not needed in 2.6
+               [GladeProperty (Name = "tooltips", Proxy = "GladeTooltips")]
+               public bool Tooltips {
+                       get {
+                               return toolbar.Tooltips;
+                       }
+                       set {
+                               toolbar.Tooltips = value;
+                       }
+               }
+
+               public string GladeTooltips {
+                       get {
+                               return Tooltips ? "True" : "False";
+                       }
+                       set {
+                               Tooltips = (value == "True");
+                       }
+               }
+
+               Gtk.Toolbar toolbar {
+                       get {
+                               return (Gtk.Toolbar)Wrapped;
+                       }
+               }
+
+               public override bool HExpandable {
+                       get {
+                               return toolbar.Orientation == 
Gtk.Orientation.Horizontal;
+                       }
+               }
+
+               public override bool VExpandable {
+                       get {
+                               return toolbar.Orientation == 
Gtk.Orientation.Vertical;
+                       }
+               }
+
+               public Gtk.Orientation Orientation {
+                       get {
+                               return toolbar.Orientation;
+                       }
+                       set {
+                               toolbar.Orientation = value;
+                               EmitContentsChanged ();
+                       }
+               }
+
+               protected override void DoSync ()
+               {
+                       DND.ClearFaults (this);
+                       Gtk.Orientation faultOrientation =
+                               Orientation == Gtk.Orientation.Horizontal ? 
Gtk.Orientation.Vertical : Gtk.Orientation.Horizontal;
+                       Gdk.Rectangle tbAlloc = toolbar.Allocation;
+
+                       Gtk.Widget[] children = toolbar.Children;
+                       if (children.Length == 0) {
+                               DND.AddFault (this, 0, faultOrientation, 
tbAlloc);
+                               return;
+                       }
+
+                       if (faultOrientation == Gtk.Orientation.Horizontal) {
+                               DND.AddHFault (this, 0, null, children[0]);
+                               DND.AddHFault (this, children.Length, 
children[children.Length - 1], null);
+                       } else {
+                               DND.AddVFault (this, 0, null, children[0]);
+                               DND.AddVFault (this, children.Length, 
children[children.Length - 1], null);
+                       }
+
+                       for (int i = 1; i < children.Length; i++) {
+                               if (faultOrientation == 
Gtk.Orientation.Horizontal)
+                                       DND.AddHFault (this, i, children[i - 
1], children[i]);
+                               else
+                                       DND.AddVFault (this, i, children[i - 
1], children[i]);
+                       }
+               }
+
+               void toolbar_SizeAllocated (object obj, Gtk.SizeAllocatedArgs 
args)
+               {
+                       Sync ();
+               }
+
+               // Insert widget at index, wrapping a ToolItem around it if 
needed
+               void ToolItemize (Gtk.Widget widget, int index)
+               {
+                       Gtk.ToolItem toolItem = widget as Gtk.ToolItem;
+                       if (toolItem == null) {
+                               toolItem = new Gtk.ToolItem ();
+                               toolItem.Show ();
+                               toolItem.Add (widget);
+                       }
+                       toolbar.Insert (toolItem, index);
+               }
+
+               // Remove widget (or its ToolItem parent), returning its 
position
+               int ToolDeItemize (Gtk.Widget widget)
+               {
+                       Gtk.ToolItem toolItem = widget as Gtk.ToolItem;
+                       if (toolItem == null) {
+                               toolItem = (Gtk.ToolItem)widget.Parent;
+                               toolItem.Remove (widget);
+                       }
+
+                       int index = toolbar.GetItemIndex (toolItem);
+
+                       toolbar.Remove (toolItem);
+                       if (toolItem != (widget as Gtk.ToolItem))
+                               toolItem.Destroy ();
+
+                       return index;
+               }
+
+               protected override void ReplaceChild (Gtk.Widget oldChild, 
Gtk.Widget newChild)
+               {
+                       ToolItemize (newChild, ToolDeItemize (oldChild));
+               }
+
+               int dragIndex;
+
+               protected override Gtk.Widget CreateDragSource (Gtk.Widget 
dragWidget)
+               {
+                       Gtk.Invisible invis = new Gtk.Invisible ();
+                       invis.Show ();
+                       invis.DragEnd += DragEnd;
+
+                       dragIndex = ToolDeItemize (dragWidget);
+                       return invis;
+               }
+
+               void DragEnd (object obj, Gtk.DragEndArgs args)
+               {
+                       Gtk.Invisible invis = obj as Gtk.Invisible;
+                       invis.DragEnd -= DragEnd;
+                       invis.Destroy ();
+
+                       if (DND.DragWidget != null)
+                               ToolItemize (DND.Cancel (), dragIndex);
+                       dragIndex = -1;
+               }
+
+               public override void Drop (Gtk.Widget w, object faultId)
+               {
+                       ToolItemize (w, (int)faultId);
+                       EmitContentsChanged ();
+                       Sync ();
+               }
+
+               public class ToolbarChild : Container.ContainerChild {
+                       public static new Type WrappedType = typeof 
(Gtk.Toolbar.ToolbarChild);
+
+                       static new void Register (Type type)
+                       {
+                               AddItemGroup (type, "Tool Bar Child Properties",
+                                             "Homogeneous",
+                                             "Expand",
+                                             "ToolItem.IsImportant",
+                                             "ToolItem.VisibleHorizontal",
+                                             "ToolItem.VisibleVertical");
+                       }
+
+                       public Gtk.ToolItem ToolItem {
+                               get {
+                                       Gtk.Container.ContainerChild cc = 
(Gtk.Container.ContainerChild)Wrapped;
+                                       return (Gtk.ToolItem)cc.Child;
+                               }
+                       }
+               }
+       }
+}

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-04-07 20:05:52 UTC (rev 
42653)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-04-07 20:17:06 UTC (rev 
42654)
@@ -40,11 +40,24 @@
                                Wrapped.Name = type.Name.ToLower () + 
((int)counters[type]).ToString ();
                        counters[type] = (int)counters[type] + 1;
 
-                       Wrapped.Events |= Gdk.EventMask.ButtonPressMask;
-                       Wrapped.WidgetEvent += WidgetEvent;
                        Wrapped.PopupMenu += PopupMenu;
+                       InterceptClicks (Wrapped);
                }
 
+               void InterceptClicks (Gtk.Widget widget)
+               {
+                       widget.Events |= Gdk.EventMask.ButtonPressMask;
+                       widget.WidgetEvent += WidgetEvent;
+
+                       Gtk.Container container = widget as Gtk.Container;
+                       if (container != null) {
+                               foreach (Gtk.Widget child in new 
ChildEnumerator (container)) {
+                                       if (Lookup (child) == null)
+                                               InterceptClicks (child);
+                               }
+                       }
+               }
+
                public new Gtk.Widget Wrapped {
                        get {
                                return (Gtk.Widget)base.Wrapped;
@@ -53,7 +66,13 @@
 
                public Stetic.Wrapper.Container ParentWrapper {
                        get {
-                               return Stetic.Wrapper.Container.Lookup 
(Wrapped.Parent);
+                               Gtk.Widget parent = Wrapped;
+                               Container wrapper = null;
+                               while (wrapper == null && parent != null) {
+                                       wrapper = 
Stetic.Wrapper.Container.Lookup (parent);
+                                       parent = parent.Parent;
+                               }
+                               return wrapper;
                        }
                }
 

Modified: trunk/stetic/stetic/Palette.cs
===================================================================
--- trunk/stetic/stetic/Palette.cs      2005-04-07 20:05:52 UTC (rev 42653)
+++ trunk/stetic/stetic/Palette.cs      2005-04-07 20:17:06 UTC (rev 42654)
@@ -49,9 +49,10 @@
                        main = new VBox (false, 2);
                        AddWithViewport (main);
 
-                       AddOrGetGroup ("Widgets");
-                       AddOrGetGroup ("Containers");
-                       AddOrGetGroup ("Windows");
+                       AddOrGetGroup (Stetic.ObjectWrapperType.Widget);
+                       AddOrGetGroup (Stetic.ObjectWrapperType.Container);
+                       AddOrGetGroup (Stetic.ObjectWrapperType.ToolbarItem);
+                       AddOrGetGroup (Stetic.ObjectWrapperType.Window);
                }
                
                private Group AddOrGetGroup(string name)
@@ -87,24 +88,18 @@
                                Stetic.ObjectWrapper.Register (type);
 
                                ObjectWrapperAttribute owattr = attr as 
ObjectWrapperAttribute;
-                               if (owattr.Deprecated)
+                               if (owattr.Deprecated || owattr.Type == 
ObjectWrapperType.Internal)
                                        return;
 
                                Pixbuf icon = Palette.IconForType (type);
+                               WidgetFactory factory;
 
-                               switch (owattr.Type) {
-                               case ObjectWrapperType.Container:
-                                       AddOrGetGroup("Containers").Append (new 
WidgetFactory (project, owattr.Name, icon, type));
-                                       break;
+                               if (owattr.Type == ObjectWrapperType.Window)
+                                       factory = new WindowFactory (project, 
owattr.Name, icon, type);
+                               else
+                                       factory = new WidgetFactory (project, 
owattr.Name, icon, type);
 
-                               case ObjectWrapperType.Window:
-                                       AddOrGetGroup("Windows").Append (new 
WindowFactory (project, owattr.Name, icon, type));
-                                       break;
-
-                               default:
-                                       AddOrGetGroup("Widgets").Append (new 
WidgetFactory (project, owattr.Name, icon, type));
-                                       break;
-                               }
+                               AddOrGetGroup(owattr.Type).Append (factory);
                        }
                }
 

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

Reply via email to