Author: lluis
Date: 2007-05-30 14:21:51 -0400 (Wed, 30 May 2007)
New Revision: 78247
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/CommandDescriptor.cs
trunk/stetic/libsteticui/Makefile.am
trunk/stetic/libsteticui/WidgetActionBar.cs
trunk/stetic/libsteticui/WidgetTreeCombo.cs
trunk/stetic/libsteticui/libsteticui.mdp
Log:
* libsteticui/libsteticui.mdp, libsteticui/Makefile.am: Added reference
to glib.
* libsteticui/WidgetActionBar.cs, libstetic/CommandDescriptor.cs: Use
Menu size for command icons.
* libsteticui/WidgetTreeCombo.cs: Replaced the popup widget menu by a
popup widget tree view. Fixes bug #81762.
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2007-05-30 18:06:57 UTC (rev 78246)
+++ trunk/stetic/ChangeLog 2007-05-30 18:21:51 UTC (rev 78247)
@@ -1,5 +1,14 @@
2007-05-30 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+ * libsteticui/libsteticui.mdp, libsteticui/Makefile.am: Added reference
+ to glib.
+ * libsteticui/WidgetActionBar.cs, libstetic/CommandDescriptor.cs: Use
+ Menu size for command icons.
+ * libsteticui/WidgetTreeCombo.cs: Replaced the popup widget menu by a
+ popup widget tree view. Fixes bug #81762.
+
+2007-05-30 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
* libstetic/wrapper/Window.cs: Store the WindowPosition property in the
Window wrapper, since it may sometimes be changed by the embedder
widget.
Modified: trunk/stetic/libstetic/CommandDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/CommandDescriptor.cs 2007-05-30 18:06:57 UTC (rev
78246)
+++ trunk/stetic/libstetic/CommandDescriptor.cs 2007-05-30 18:21:51 UTC (rev
78247)
@@ -83,7 +83,7 @@
return new Gtk.Image (new Gdk.Pixbuf
(s));
}
} else {
- return new Gtk.Image (icon,
Gtk.IconSize.SmallToolbar);
+ return new Gtk.Image (icon, Gtk.IconSize.Menu);
}
}
Modified: trunk/stetic/libsteticui/Makefile.am
===================================================================
--- trunk/stetic/libsteticui/Makefile.am 2007-05-30 18:06:57 UTC (rev
78246)
+++ trunk/stetic/libsteticui/Makefile.am 2007-05-30 18:21:51 UTC (rev
78247)
@@ -82,6 +82,7 @@
libsteticui_dll_references = \
-pkg:gconf-sharp-2.0 \
+ -pkg:glib-sharp-2.0 \
-pkg:gnome-sharp-2.0 \
-pkg:gtk-sharp-2.0 \
-r:$(top_builddir)/bin/libstetic.dll \
Modified: trunk/stetic/libsteticui/WidgetActionBar.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetActionBar.cs 2007-05-30 18:06:57 UTC (rev
78246)
+++ trunk/stetic/libsteticui/WidgetActionBar.cs 2007-05-30 18:21:51 UTC (rev
78247)
@@ -33,7 +33,7 @@
invisibles = new Hashtable ();
toggles = new ArrayList ();
- IconSize = IconSize.SmallToolbar;
+ IconSize = IconSize.Menu;
Orientation = Orientation.Horizontal;
ToolbarStyle = ToolbarStyle.BothHoriz;
Modified: trunk/stetic/libsteticui/WidgetTreeCombo.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetTreeCombo.cs 2007-05-30 18:06:57 UTC (rev
78246)
+++ trunk/stetic/libsteticui/WidgetTreeCombo.cs 2007-05-30 18:21:51 UTC (rev
78247)
@@ -11,6 +11,7 @@
Stetic.Wrapper.Widget rootWidget;
Stetic.IProject project;
Stetic.Wrapper.Widget selection;
+ WidgetTreePopup popup;
public WidgetTreeCombo ()
{
@@ -21,7 +22,7 @@
bb.PackStart (image, false, false, 3);
bb.PackStart (label, true, true, 3);
label.Xalign = 0;
- label.HeightRequest = 24;
+ label.HeightRequest = 18;
bb.PackStart (new VSeparator (), false, false, 1);
bb.PackStart (new Arrow (ArrowType.Down,
ShadowType.None), false, false, 1);
Child = bb;
@@ -29,6 +30,14 @@
Sensitive = false;
}
+ public override void Dispose ()
+ {
+ if (popup != null)
+ popup.Destroy ();
+ base.Dispose ();
+ }
+
+
public Stetic.Wrapper.Widget RootWidget {
get { return rootWidget; }
set {
@@ -50,7 +59,7 @@
{
if (selection != null) {
label.Text = selection.Wrapped.Name;
- image.Pixbuf = selection.ClassDescriptor.Icon;
+ image.Pixbuf =
selection.ClassDescriptor.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
image.Show ();
} else {
label.Text = " ";
@@ -61,73 +70,144 @@
protected override void OnPressed ()
{
base.OnPressed ();
+ if (popup == null) {
+ popup = new WidgetTreePopup (project);
+ popup.WidgetActivated += OnPopupActivated;
+ popup.SetDefaultSize (Allocation.Width, 500);
+ }
+ else if (popup.Visible) {
+ popup.Hide ();
+ return;
+ }
+
+ int x, y;
+ ParentWindow.GetOrigin (out x, out y);
+ x += Allocation.X;
+ y += Allocation.Y + Allocation.Height;
+
+ popup.Fill (RootWidget.Wrapped);
+ popup.Move (x, y);
+ popup.ShowAll ();
+ }
+
+ protected override bool OnFocusOutEvent (Gdk.EventFocus evnt)
+ {
+ if (popup != null)
+ popup.Hide ();
+ return base.OnFocusOutEvent (evnt);
+ }
- Gtk.Menu menu = new Gtk.Menu ();
- FillCombo (menu, RootWidget.Wrapped, 0);
- menu.ShowAll ();
- menu.Popup (null, null, new Gtk.MenuPositionFunc
(OnPosition), 0, Gtk.Global.CurrentEventTime);
+
+ void OnPopupActivated (object s, EventArgs a)
+ {
+ popup.Hide ();
+ Stetic.Wrapper.Widget wrapper =
Stetic.Wrapper.Widget.Lookup (popup.Selection);
+ GLib.Timeout.Add (10, delegate {
+ wrapper.Select ();
+ return false;
+ });
}
+ }
+
+ class WidgetTreePopup: Window
+ {
+ TreeView tree;
+ TreeStore store;
+ Gtk.Widget selection;
+ Stetic.IProject project;
- void OnPosition (Gtk.Menu menu, out int x, out int y, out bool
pushIn)
+ public event EventHandler WidgetActivated;
+
+ public WidgetTreePopup (Stetic.IProject project): base
(WindowType.Popup)
{
- ParentWindow.GetOrigin (out x, out y);
- x += Allocation.X;
- y += Allocation.Y + Allocation.Height;
- pushIn = true;
+ this.project = project;
+ Gtk.Frame frame = new Frame ();
+ frame.ShadowType = Gtk.ShadowType.Out;
+ Add (frame);
+
+ Gtk.ScrolledWindow sc = new ScrolledWindow ();
+ sc.VscrollbarPolicy = PolicyType.Automatic;
+ sc.HscrollbarPolicy = PolicyType.Automatic;
+ frame.Add (sc);
+
+ tree = new TreeView ();
+ store = new TreeStore (typeof(Gdk.Pixbuf),
typeof(string), typeof(Widget));
+ tree.Model = store;
+ tree.HeadersVisible = false;
+
+ TreeViewColumn col = new TreeViewColumn ();
+ CellRendererPixbuf cr = new CellRendererPixbuf ();
+ col.PackStart (cr, false);
+ col.AddAttribute (cr, "pixbuf", 0);
+
+ CellRendererText tr = new CellRendererText ();
+ col.PackStart (tr, true);
+ col.AddAttribute (tr, "markup", 1);
+
+ tree.AppendColumn (col);
+
+ tree.ButtonReleaseEvent += OnButtonRelease;
+ tree.RowActivated += OnButtonRelease;
+ sc.Add (tree);
+ tree.GrabFocus ();
+
}
- void FillCombo (Menu menu, Gtk.Widget widget, int level)
+ public void Fill (Gtk.Widget widget)
{
+ store.Clear ();
+ Fill (TreeIter.Zero, widget);
+ }
+
+ public void Fill (TreeIter iter, Gtk.Widget widget)
+ {
Stetic.Wrapper.Widget wrapper =
Stetic.Wrapper.Widget.Lookup (widget);
if (wrapper == null) return;
if (!wrapper.Unselectable) {
- MenuItem item = new WidgetMenuItem (widget);
- item.Activated += new EventHandler
(OnItemSelected);
- HBox box = new HBox ();
- Gtk.Image img = new Gtk.Image
(wrapper.ClassDescriptor.Icon);
- img.Xalign = 1;
- img.WidthRequest = level*30;
- box.PackStart (img, false, false, 0);
-
- Label lab = new Label ();
+ Gdk.Pixbuf icon =
wrapper.ClassDescriptor.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear);
+ string txt;
if (widget == project.Selection)
- lab.Markup = "<b>" + widget.Name +
"</b>";
+ txt = "<b>" + GLib.Markup.EscapeText
(widget.Name) + "</b>";
else
- lab.Text = widget.Name;
-
- box.PackStart (lab, false, false, 3);
- item.Child = box;
- menu.Append (item);
- } else
- level--;
+ txt = GLib.Markup.EscapeText
(widget.Name);
+
+ if (!iter.Equals (TreeIter.Zero))
+ iter = store.AppendValues (iter, icon,
txt, widget);
+ else
+ iter = store.AppendValues (icon, txt,
widget);
+ }
Gtk.Container cc = widget as Gtk.Container;
if (cc != null &&
wrapper.ClassDescriptor.AllowChildren) {
foreach (Gtk.Widget child in cc.Children)
- FillCombo (menu, child, level + 1);
+ Fill (iter, child);
}
+ if (widget == project.Selection) {
+ tree.ExpandToPath (store.GetPath (iter));
+ tree.ExpandRow (store.GetPath (iter), false);
+ tree.Selection.SelectIter (iter);
+ }
}
- void OnItemSelected (object sender, EventArgs args)
+ public Gtk.Widget Selection {
+ get { return selection; }
+ }
+
+ void OnButtonRelease (object s, EventArgs a)
{
- WidgetMenuItem item = (WidgetMenuItem) sender;
- Stetic.Wrapper.Widget wrapper =
Stetic.Wrapper.Widget.Lookup (item.Widget);
- GLib.Timeout.Add (10, delegate {
- wrapper.Select ();
- return false;
- });
+ NotifyActivated ();
}
- }
-
- class WidgetMenuItem: MenuItem
- {
- internal Gtk.Widget Widget;
- public WidgetMenuItem (Gtk.Widget widget)
+ void NotifyActivated ()
{
- this.Widget = widget;
+ TreeIter iter;
+ if (!tree.Selection.GetSelected (out iter))
+ return;
+ selection = (Gtk.Widget) store.GetValue (iter, 2);
+ if (WidgetActivated != null)
+ WidgetActivated (this, EventArgs.Empty);
}
}
}
Modified: trunk/stetic/libsteticui/libsteticui.mdp
===================================================================
--- trunk/stetic/libsteticui/libsteticui.mdp 2007-05-30 18:06:57 UTC (rev
78246)
+++ trunk/stetic/libsteticui/libsteticui.mdp 2007-05-30 18:21:51 UTC (rev
78247)
@@ -96,6 +96,7 @@
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="System.Xml,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <ProjectReference type="Gac" localcopy="True" refto="glib-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
<MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True"
RelativeMakefileName="./Makefile.am" SyncReferences="True"
IsAutotoolsProject="True" RelativeConfigureInPath="../">
<BuildFilesVar Sync="True" Name="libsteticui_dll_sources" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches