3
using System.Collections;
7
namespace Stetic.Editor
9
public class WidgetSelector: ComboBox, IPropertyEditor
13
Hashtable widgets = new Hashtable ();
15
public void Initialize (PropertyDescriptor descriptor)
17
store = new ListStore (typeof(Pixbuf), typeof(string));
19
store.SetSortColumnId (1, SortType.Ascending);
20
CellRendererPixbuf crp = new CellRendererPixbuf ();
21
CellRendererText crt = new CellRendererText ();
22
PackStart (crp, false);
23
PackStart (crt, true);
24
SetAttributes (crp, "pixbuf", 0);
25
SetAttributes (crt, "text", 1);
28
public void AttachObject (object obj)
30
this.obj = obj as Gtk.Widget;
39
Stetic.Wrapper.Widget widget = Stetic.Wrapper.Widget.Lookup (obj);
43
while (!widget.IsTopLevel)
44
widget = widget.ParentWrapper;
46
store.AppendValues (null, "(None)");
47
FillWidgets (widget, 0);
50
void FillWidgets (Stetic.Wrapper.Widget widget, int level)
52
if (!widget.Unselectable) {
53
TreeIter iter = store.AppendValues (widget.ClassDescriptor.Icon, widget.Wrapped.Name);
54
widgets [widget.Wrapped.Name] = iter;
56
Gtk.Container cont = widget.Wrapped as Gtk.Container;
57
if (cont != null && widget.ClassDescriptor.AllowChildren) {
58
foreach (Gtk.Widget child in cont.AllChildren) {
59
Stetic.Wrapper.Widget cwidget = Stetic.Wrapper.Widget.Lookup (child);
61
FillWidgets (cwidget, level+1);
73
if (!GetActiveIter (out iter))
75
return (string) store.GetValue (iter, 1);
81
else if (widgets.Contains ((string) value)) {
82
TreeIter iter = (TreeIter) widgets [value];
88
protected override void OnChanged ()
91
if (ValueChanged != null)
92
ValueChanged (this, EventArgs.Empty);
95
// To be fired when the edited value changes.
96
public event EventHandler ValueChanged;