Author: lluis
Date: 2006-06-09 16:59:49 -0400 (Fri, 09 Jun 2006)
New Revision: 61606
Added:
trunk/stetic/libstetic/wrapper/pixmaps/actiongroup.png
trunk/stetic/libstetic/wrapper/pixmaps/add-check-label.png
trunk/stetic/libstetic/wrapper/pixmaps/box-expand.png
trunk/stetic/libstetic/wrapper/pixmaps/box-fill.png
trunk/stetic/libstetic/wrapper/pixmaps/dec-border.png
trunk/stetic/libstetic/wrapper/pixmaps/inc-border.png
trunk/stetic/libstetic/wrapper/pixmaps/remove-check-label.png
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/AssemblyWidgetLibrary.cs
trunk/stetic/libstetic/ClassDescriptor.cs
trunk/stetic/libstetic/CommandDescriptor.cs
trunk/stetic/libstetic/ItemDescriptor.cs
trunk/stetic/libstetic/PropertyEditorCell.cs
trunk/stetic/libstetic/WidgetLibrary.cs
trunk/stetic/libstetic/editor/Accelerator.cs
trunk/stetic/libstetic/editor/ActionMenuBar.cs
trunk/stetic/libstetic/editor/ActionToolItem.cs
trunk/stetic/libstetic/editor/ActionToolbar.cs
trunk/stetic/libstetic/wrapper/Box.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/libstetic/wrapper/objects.xml
trunk/stetic/libstetic/wrapper/pixmaps/add-menu.png
trunk/stetic/libstetic/wrapper/pixmaps/remove-menu.png
trunk/stetic/libsteticui/WidgetActionBar.cs
Log:
2006-05-09 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* libstetic/CommandDescriptor.cs:
* libsteticui/WidgetActionBar.cs: Add support for icon based
commands and for toogle commands.
* libstetic/ItemDescriptor.cs: invisible-if and disable-if elements
now support calling a method to get the check value.
* libstetic/WidgetLibrary.cs: Assign the widget library to
class descriptors.
* libstetic/wrapper/Container.cs: Implemented IncBorder and DecBorder
commands.
* libstetic/wrapper/Box.cs: Implemented BoxExpand and BoxFill toggle
commands.
* libstetic/wrapper/objects.xml: Added IncBorder and DecBorder commands
to containers. Added BoxExpand and BoxFill to box child.
* libstetic/editor/Accelerator.cs: Fixed. Added button for clearing
the accelerator.
* libstetic/editor/ActionToolbar.cs:
* libstetic/editor/ActionMenuBar.cs: Make sure the menu has some height
when there are no items, so it can be easily selected.
* libstetic/editor/ActionToolItem.cs: Don't allow editing separators.
* libstetic/PropertyEditorCell.cs: Paint text, not markup.
* libstetic/ClassDescriptor.cs: Added property which returns the widget
library that implements the class descriptor.
* libstetic/AssemblyWidgetLibrary.cs: Implemented GetResource method.
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2006-06-09 20:27:18 UTC (rev 61605)
+++ trunk/stetic/ChangeLog 2006-06-09 20:59:49 UTC (rev 61606)
@@ -1,3 +1,32 @@
+2006-05-09 Lluis Sanchez Gual <[EMAIL PROTECTED]>
+
+ * libstetic/CommandDescriptor.cs:
+ * libsteticui/WidgetActionBar.cs: Add support for icon based
+ commands and for toogle commands.
+
+ * libstetic/ItemDescriptor.cs: invisible-if and disable-if elements
+ now support calling a method to get the check value.
+ * libstetic/WidgetLibrary.cs: Assign the widget library to
+ class descriptors.
+ * libstetic/wrapper/Container.cs: Implemented IncBorder and DecBorder
+ commands.
+ * libstetic/wrapper/Box.cs: Implemented BoxExpand and BoxFill toggle
+ commands.
+ * libstetic/wrapper/objects.xml: Added IncBorder and DecBorder commands
+ to containers. Added BoxExpand and BoxFill to box child.
+ * libstetic/editor/Accelerator.cs: Fixed. Added button for clearing
+ the accelerator.
+
+ * libstetic/editor/ActionToolbar.cs:
+ * libstetic/editor/ActionMenuBar.cs: Make sure the menu has some height
+ when there are no items, so it can be easily selected.
+
+ * libstetic/editor/ActionToolItem.cs: Don't allow editing separators.
+ * libstetic/PropertyEditorCell.cs: Paint text, not markup.
+ * libstetic/ClassDescriptor.cs: Added property which returns the widget
+ library that implements the class descriptor.
+ * libstetic/AssemblyWidgetLibrary.cs: Implemented GetResource method.
+
2006-05-08 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* libstetic/wrapper/Box.cs: In GladeChildren return children
Modified: trunk/stetic/libstetic/AssemblyWidgetLibrary.cs
===================================================================
--- trunk/stetic/libstetic/AssemblyWidgetLibrary.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/AssemblyWidgetLibrary.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -49,6 +49,11 @@
}
return null;
}
+
+ public override System.IO.Stream GetResource (string name)
+ {
+ return assembly.GetManifestResourceStream (name);
+ }
}
}
Modified: trunk/stetic/libstetic/ClassDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/ClassDescriptor.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/ClassDescriptor.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -19,6 +19,7 @@
protected ItemGroup contextMenu;
protected ItemGroup internalChildren;
+ WidgetLibrary library;
PropertyDescriptor[] initializationProperties;
static PropertyDescriptor[] emptyPropArray = new
PropertyDescriptor[0];
@@ -234,6 +235,10 @@
}
}
+ public WidgetLibrary Library {
+ get { return library; }
+ }
+
public virtual bool AllowChildren {
get { return allowChildren; }
}
@@ -245,5 +250,10 @@
else
throw new ApplicationException ("Bad item name
" + elem.Name + " in " + WrappedTypeName);
}
+
+ internal void SetLibrary (WidgetLibrary library)
+ {
+ this.library = library;
+ }
}
}
Modified: trunk/stetic/libstetic/CommandDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/CommandDescriptor.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/CommandDescriptor.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -7,7 +7,7 @@
public class CommandDescriptor : ItemDescriptor {
- string name, checkName, label, description;
+ string name, checkName, label, description, icon;
const BindingFlags flags = BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance;
@@ -17,6 +17,7 @@
label = elem.GetAttribute ("label");
description = elem.GetAttribute ("description");
checkName = elem.GetAttribute ("check");
+ icon = elem.GetAttribute ("icon");
}
public override string Name {
@@ -36,6 +37,55 @@
return description;
}
}
+
+ public bool IsToggleCommand (object obj)
+ {
+ object target;
+ return (FindBoolProperty (obj, out target) != null);
+ }
+
+ public bool IsToogled (object obj)
+ {
+ object target;
+ PropertyInfo prop = FindBoolProperty (obj, out target);
+ return (bool) prop.GetValue (target, null);
+ }
+
+ PropertyInfo FindBoolProperty (object obj, out object target)
+ {
+ PropertyInfo prop = obj.GetType().GetProperty (name,
flags);
+ if (prop != null && prop.PropertyType == typeof(bool)) {
+ target = obj;
+ return prop;
+ }
+
+ ObjectWrapper wrap = ObjectWrapper.Lookup (obj);
+ if (wrap != null) {
+ prop = wrap.GetType().GetProperty (name, flags);
+ if (prop != null && prop.PropertyType ==
typeof(bool)) {
+ target = wrap;
+ return prop;
+ }
+ }
+ target = null;
+ return null;
+ }
+
+ public Gtk.Image GetImage ()
+ {
+ if (icon == null)
+ return null;
+ if (icon.StartsWith ("res:")) {
+ System.IO.Stream s =
this.ClassDescriptor.Library.GetResource (icon.Substring (4));
+ if (s == null)
+ return null;
+ using (s) {
+ return new Gtk.Image (new Gdk.Pixbuf
(s));
+ }
+ } else {
+ return new Gtk.Image (icon,
Gtk.IconSize.SmallToolbar);
+ }
+ }
public bool Enabled (object obj)
{
@@ -67,6 +117,13 @@
object InvokeMethod (object target, string name, object
context, bool withContext)
{
+ object ptarget;
+ PropertyInfo prop = FindBoolProperty (target, out
ptarget);
+ if (prop != null) {
+ prop.SetValue (ptarget, !(bool)prop.GetValue
(ptarget, null), null);
+ return null;
+ }
+
if (withContext) {
MethodInfo metc = target.GetType().GetMethod
(name, flags, null, new Type[] {typeof(Gtk.Widget)}, null);
if (metc != null)
Modified: trunk/stetic/libstetic/ItemDescriptor.cs
===================================================================
--- trunk/stetic/libstetic/ItemDescriptor.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/ItemDescriptor.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -1,45 +1,62 @@
using System;
using System.Collections;
using System.Xml;
+using System.Reflection;
namespace Stetic {
public abstract class ItemDescriptor {
- Hashtable deps, visdeps;
+ ArrayList deps, visdeps;
bool isInternal;
+ ClassDescriptor klass;
protected ItemDescriptor () {}
protected ItemDescriptor (XmlElement elem, ItemGroup group,
ClassDescriptor klass)
{
+ this.klass = klass;
isInternal = elem.HasAttribute ("internal");
deps = AddSubprops (elem.SelectNodes ("./disabled-if"),
group, klass);
visdeps = AddSubprops (elem.SelectNodes
("./invisible-if"), group, klass);
}
- Hashtable AddSubprops (XmlNodeList nodes, ItemGroup group,
ClassDescriptor klass)
+ ArrayList AddSubprops (XmlNodeList nodes, ItemGroup group,
ClassDescriptor klass)
{
- Hashtable hash = null;
+ ArrayList list = null;
+
+ // Sub-properties can have a name+value (which checks
for the value of a
+ // property) or a method name, which should return true
if the item has
+ // to be disabled/hidden.
foreach (XmlElement elem in nodes) {
string name = elem.GetAttribute ("name");
- string value = elem.GetAttribute ("value");
+ if (name.Length > 0) {
+ string value = elem.GetAttribute
("value");
- PropertyDescriptor prop =
(PropertyDescriptor)group[name];
- if (prop == null)
- prop = (PropertyDescriptor)klass[name];
- if (prop == null)
- throw new ArgumentException ("Bad
sub-prop " + name);
- if (hash == null)
- hash = new Hashtable ();
- ArrayList values = (ArrayList)hash[prop];
- if (values == null)
- hash[prop] = values = new ArrayList ();
-
- values.Add (prop.StringToValue (value));
+ PropertyDescriptor prop =
(PropertyDescriptor)group[name];
+ if (prop == null)
+ prop =
(PropertyDescriptor)klass[name];
+ if (prop == null)
+ throw new ArgumentException
("Bad sub-prop " + name);
+ if (list == null)
+ list = new ArrayList ();
+
+ DepInfo info = new DepInfo ();
+ info.Property = prop;
+ info.Value = prop.StringToValue (value);
+ list.Add (info);
+ } else if ((name = elem.GetAttribute
("check")).Length > 0) {
+ DepInfo info = new DepInfo ();
+ info.CheckName = name;
+ if (list == null)
+ list = new ArrayList ();
+ list.Add (info);
+ } else {
+ throw new ArgumentException ("Bad
sub-prop");
+ }
}
- return hash;
+ return list;
}
// The property's display name
@@ -56,12 +73,9 @@
if (deps == null)
return true;
- foreach (PropertyDescriptor dep in deps.Keys) {
- object depValue = dep.GetValue (obj);
- foreach (object value in (ArrayList)deps[dep]) {
- if (value.Equals (depValue))
- return false;
- }
+ foreach (DepInfo dep in deps) {
+ if (dep.Check (obj))
+ return false;
}
return true;
}
@@ -77,12 +91,9 @@
if (visdeps == null)
return true;
- foreach (PropertyDescriptor dep in visdeps.Keys) {
- object depValue = dep.GetValue (obj);
- foreach (object value in
(ArrayList)visdeps[dep]) {
- if (value.Equals (depValue))
- return false;
- }
+ foreach (DepInfo dep in visdeps) {
+ if (dep.Check (obj))
+ return false;
}
return true;
}
@@ -92,5 +103,28 @@
return isInternal;
}
}
+
+ public ClassDescriptor ClassDescriptor {
+ get { return klass; }
+ }
+
+ class DepInfo
+ {
+ public string CheckName;
+ public PropertyDescriptor Property;
+ public object Value;
+
+ public bool Check (object obj)
+ {
+ if (Property != null) {
+ object depValue = Property.GetValue
(obj);
+ return Value.Equals (depValue);
+ } else {
+ object wrapper = ObjectWrapper.Lookup
(obj);
+ object res = obj.GetType().InvokeMember
(CheckName, BindingFlags.Public | BindingFlags.NonPublic, null, wrapper, null);
+ return (bool) res;
+ }
+ }
+ }
}
}
Modified: trunk/stetic/libstetic/PropertyEditorCell.cs
===================================================================
--- trunk/stetic/libstetic/PropertyEditorCell.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/PropertyEditorCell.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -110,7 +110,7 @@
protected virtual void Initialize ()
{
- layout.SetMarkup (GetNormalizedText ());
+ layout.SetText (GetNormalizedText ());
}
public virtual void GetSize (int availableWidth, out int width,
out int height)
Modified: trunk/stetic/libstetic/WidgetLibrary.cs
===================================================================
--- trunk/stetic/libstetic/WidgetLibrary.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/WidgetLibrary.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -33,6 +33,7 @@
foreach (XmlElement element in objects.SelectNodes
("/objects/object")) {
ClassDescriptor klass = LoadClassDescriptor
(element);
if (klass == null) continue;
+ klass.SetLibrary (this);
classes_by_cname[klass.CName] = klass;
classes_by_csname[klass.WrappedTypeName] =
klass;
}
@@ -94,6 +95,11 @@
return null;
}
+ public virtual System.IO.Stream GetResource (string name)
+ {
+ return null;
+ }
+
protected virtual void OnChanged ()
{
if (Changed != null)
Modified: trunk/stetic/libstetic/editor/Accelerator.cs
===================================================================
--- trunk/stetic/libstetic/editor/Accelerator.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/editor/Accelerator.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -4,11 +4,14 @@
namespace Stetic.Editor {
[PropertyEditor ("Accel", "AccelChanged")]
- public class Accelerator : Gtk.Entry, IPropertyEditor {
+ public class Accelerator : Gtk.HBox, IPropertyEditor {
uint keyval;
Gdk.ModifierType mask;
bool editing;
+
+ Gtk.Button clearButton;
+ Gtk.Entry entry;
const Gdk.ModifierType AcceleratorModifierMask = ~(
Gdk.ModifierType.Button1Mask |
@@ -19,7 +22,17 @@
public Accelerator ()
{
- IsEditable = false;
+ entry = new Gtk.Entry ();
+ clearButton = new Gtk.Button (new Gtk.Image
(Gtk.Stock.Clear, Gtk.IconSize.Menu));
+ PackStart (entry, true, true, 0);
+ PackStart (clearButton, false, false, 3);
+ clearButton.Clicked += delegate (object s, EventArgs
args) {
+ Value = null;
+ };
+ entry.IsEditable = false;
+ entry.ButtonPressEvent += OnButtonPressEvent;
+ entry.KeyPressEvent += OnKeyPressEvent;
+ ShowAll ();
}
public void Initialize (PropertyDescriptor descriptor)
@@ -33,13 +46,14 @@
Value = null;
}
- protected override bool OnButtonPressEvent (Gdk.EventButton evt)
+ [GLib.ConnectBefore]
+ void OnButtonPressEvent (object s, Gtk.ButtonPressEventArgs
args)
{
if (editing)
- Ungrab (evt.Time);
+ Ungrab (args.Event.Time);
else
- Grab (evt.Window, evt.Time);
- return true;
+ Grab (args.Event.Window, args.Event.Time);
+ args.RetVal = true;
}
void Ungrab (uint time)
@@ -50,7 +64,10 @@
Gdk.Keyboard.Ungrab (time);
Gdk.Pointer.Ungrab (time);
- Text = (string) Value;
+ if (Value != null)
+ entry.Text = (string) Value;
+ else
+ entry.Text = "";
}
void Grab (Gdk.Window window, uint time)
@@ -65,28 +82,24 @@
Gdk.Keyboard.Ungrab (time);
return;
}
- GrabFocus ();
+ entry.GrabFocus ();
editing = true;
- Text = "New Accelerator...";
+ entry.Text = "Press a key...";
}
-// [DllImport ("libsteticglue")]
-// static extern bool stetic_keycode_is_modifier (uint keycode);
-
- protected override bool OnKeyPressEvent (Gdk.EventKey evt)
+ [GLib.ConnectBefore]
+ void OnKeyPressEvent (object s, Gtk.KeyPressEventArgs args)
{
-// if (!editing || stetic_keycode_is_modifier
(evt.HardwareKeycode))
-// return base.OnKeyPressEvent (evt);
+ Gdk.EventKey evt = args.Event;
- // FIXME: check for modifier
- if (!editing)
- return base.OnKeyPressEvent (evt);
-
+ if (!editing || !Gtk.Accelerator.Valid (evt.KeyValue,
evt.State))
+ return;
+
uint keyval;
int effectiveGroup, level;
Gdk.ModifierType consumedMods, mask;
-
+
// We know this will succeed, since we're already
here...
Gdk.Keymap.Default.TranslateKeyboardState
(evt.HardwareKeycode, evt.State, evt.Group, out keyval, out effectiveGroup, out
level, out consumedMods);
mask = evt.State & AcceleratorModifierMask &
~consumedMods;
@@ -95,21 +108,14 @@
this.keyval = keyval;
this.mask = mask;
}
+
+ clearButton.Sensitive = true;
Ungrab (evt.Time);
EmitAccelChanged ();
- return true;
+ args.RetVal = true;
}
- public new string Text {
- set {
- if (value == null)
- base.Text = "";
- else
- base.Text = value;
- }
- }
-
public object Value {
get {
if (keyval != 0)
@@ -122,9 +128,15 @@
if (s == null) {
keyval = 0;
mask = 0;
- } else
+ clearButton.Sensitive = false;
+ } else {
Gtk.Accelerator.Parse (s, out keyval,
out mask);
- Text = (string) Value;
+ clearButton.Sensitive = true;
+ }
+ if (Value != null)
+ entry.Text = (string) Value;
+ else
+ entry.Text = "";
EmitAccelChanged ();
}
}
Modified: trunk/stetic/libstetic/editor/ActionMenuBar.cs
===================================================================
--- trunk/stetic/libstetic/editor/ActionMenuBar.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/editor/ActionMenuBar.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -15,6 +15,7 @@
ArrayList menuItems = new ArrayList ();
bool showPlaceholder;
Gtk.Widget addLabel;
+ Gtk.Widget spacerItem;
public ActionMenuBar ()
{
@@ -32,8 +33,7 @@
this.actionTree = actionTree;
if (actionTree == null) {
- Insert (new Gtk.MenuItem (""), -1);
- ShowAll ();
+ AddSpacerItem ();
return;
}
@@ -58,13 +58,13 @@
AddCreateItemLabel ();
} else if (actionTree.Children.Count == 0) {
// Give some height to the toolbar
- Insert (new Gtk.MenuItem (""), -1);
- ShowAll ();
+ AddSpacerItem ();
}
}
void AddCreateItemLabel ()
{
+ HideSpacerItem ();
Gtk.Label emptyLabel = new Gtk.Label ();
emptyLabel.Xalign = 0;
emptyLabel.Markup = "<i><span
foreground='darkgrey'>Click to create menu</span></i>";
@@ -76,6 +76,24 @@
addLabel = mit;
}
+ void AddSpacerItem ()
+ {
+ if (spacerItem == null) {
+ Gtk.MenuItem mi = new Gtk.MenuItem ("");
+ Insert (mi, -1);
+ spacerItem = mi;
+ ShowAll ();
+ }
+ }
+
+ void HideSpacerItem ()
+ {
+ if (spacerItem != null) {
+ Remove (spacerItem);
+ spacerItem = null;
+ }
+ }
+
void AddItem (ActionMenuItem aitem, int pos)
{
Gtk.Table t = new Gtk.Table (1, 3, false);
@@ -100,6 +118,8 @@
} else if (!value && addLabel != null) {
Remove (addLabel);
addLabel = null;
+ if (menuItems.Count == 0)
+ AddSpacerItem ();
}
}
}
@@ -130,6 +150,8 @@
if (w is CustomMenuBarItem &&
((CustomMenuBarItem)w).ActionMenuItem.Node == args.Node) {
Remove (w);
menuItems.Remove
(((CustomMenuBarItem)w).ActionMenuItem);
+ if (menuItems.Count == 0 &&
!showPlaceholder)
+ AddSpacerItem ();
break;
}
}
Modified: trunk/stetic/libstetic/editor/ActionToolItem.cs
===================================================================
--- trunk/stetic/libstetic/editor/ActionToolItem.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/editor/ActionToolItem.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -57,7 +57,7 @@
public void StartEditing (bool doClick)
{
- if (!editing) {
+ if (!editing && node.Action != null) {
// Don't allow efiting global actions
if (wrapper != null &&
wrapper.Project.ActionGroups.IndexOf (node.Action.ActionGroup) != -1)
return;
Modified: trunk/stetic/libstetic/editor/ActionToolbar.cs
===================================================================
--- trunk/stetic/libstetic/editor/ActionToolbar.cs 2006-06-09 20:27:18 UTC
(rev 61605)
+++ trunk/stetic/libstetic/editor/ActionToolbar.cs 2006-06-09 20:59:49 UTC
(rev 61606)
@@ -14,6 +14,7 @@
ArrayList toolItems = new ArrayList ();
bool showPlaceholder = true;
Gtk.Widget addLabel;
+ Gtk.Widget spacerItem;
public ActionToolbar ()
{
@@ -32,10 +33,7 @@
this.actionTree = actionTree;
if (actionTree == null) {
- Gtk.ToolButton tb = new Gtk.ToolButton
(Gnome.Stock.Blank);
- Insert (tb, -1);
- this.HeightRequest = tb.SizeRequest().Height;
- ShowAll ();
+ AddSpacerItem ();
return;
}
@@ -56,29 +54,28 @@
AddItem (aitem, -1);
toolItems.Add (aitem);
}
+
+ if (actionTree.Children.Count == 0) {
+ // If there are no buttons in the toolbar, give
it some height so it is selectable.
+ AddSpacerItem ();
+ }
if (showPlaceholder) {
AddCreateItemLabel ();
}
-
- if (actionTree.Children.Count == 0) {
- // If there are no buttons in the toolbar, give
it some height so it is selectable.
- Gtk.ToolButton tb = new Gtk.ToolButton
(Gnome.Stock.Blank);
- if (Orientation == Gtk.Orientation.Horizontal)
- this.HeightRequest =
tb.SizeRequest().Height;
- else
- this.WidthRequest =
tb.SizeRequest().Width;
- } else
- this.HeightRequest = this.WidthRequest = -1;
}
void AddCreateItemLabel ()
{
+ HideSpacerItem ();
Gtk.EventBox ebox = new Gtk.EventBox ();
ebox.VisibleWindow = false;
Gtk.Label emptyLabel = new Gtk.Label ();
emptyLabel.Xalign = 0;
- emptyLabel.Markup = "<i><span
foreground='darkgrey'>Click to create button</span></i>";
+ if (this.Orientation == Gtk.Orientation.Vertical)
+ emptyLabel.Markup = "<i><span
foreground='darkgrey'>New\nbutton</span></i>";
+ else
+ emptyLabel.Markup = "<i><span
foreground='darkgrey'>New button</span></i>";
ebox.BorderWidth = 3;
ebox.Add (emptyLabel);
Gtk.ToolItem mit = new Gtk.ToolItem ();
@@ -89,6 +86,25 @@
addLabel = mit;
}
+ void AddSpacerItem ()
+ {
+ if (spacerItem == null) {
+ Gtk.ToolItem tb = new Gtk.ToolItem ();
+ tb.Child = new Gtk.Label (" ");
+ Insert (tb, -1);
+ ShowAll ();
+ spacerItem = tb;
+ }
+ }
+
+ void HideSpacerItem ()
+ {
+ if (spacerItem != null) {
+ Remove (spacerItem);
+ spacerItem = null;
+ }
+ }
+
void AddItem (ActionToolItem aitem, int pos)
{
aitem.KeyPressEvent += OnItemKeyPress;
@@ -103,12 +119,16 @@
public bool ShowInsertPlaceholder {
get { return showPlaceholder; }
set {
+ Console.WriteLine ("ShowInsertPlaceholder: " +
value);
showPlaceholder = value;
if (value && addLabel == null) {
AddCreateItemLabel ();
} else if (!value && addLabel != null) {
Remove (addLabel);
addLabel = null;
+ Console.WriteLine
("actionTree.Children.Count: " + actionTree.Children.Count);
+ if (actionTree.Children.Count == 0)
+ AddSpacerItem ();
}
}
}
@@ -138,6 +158,8 @@
if (w is CustomToolbarItem &&
((CustomToolbarItem)w).ActionToolItem.Node == args.Node) {
Remove (w);
toolItems.Remove
(((CustomToolbarItem)w).ActionToolItem);
+ if (!showPlaceholder && toolItems.Count
== 0)
+ AddSpacerItem ();
break;
}
}
@@ -190,7 +212,7 @@
aitem.EditingDone += OnEditingDone;
aitem.Select ();
aitem.StartEditing (false);
- ShowInsertPlaceholder = false;
+ //ShowInsertPlaceholder = false;
}
void OnEditingDone (object ob, EventArgs args)
@@ -211,7 +233,6 @@
wrapper.LocalActionGroups.Add (new
ActionGroup ("Default"));
wrapper.LocalActionGroups[0].Actions.Add
(item.Node.Action);
}
- ShowInsertPlaceholder = true;
}
public void Select (ActionTreeNode node)
Modified: trunk/stetic/libstetic/wrapper/Box.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Box.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/wrapper/Box.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -231,7 +231,23 @@
}
public class BoxChild : Container.ContainerChild {
+
+ public bool BoxExpand {
+ get { return
((Gtk.Box.BoxChild)Wrapped).Expand; }
+ set {
+ AutoSize = false;
+ ((Gtk.Box.BoxChild)Wrapped).Expand =
value;
+ }
+ }
+ public bool BoxFill {
+ get { return ((Gtk.Box.BoxChild)Wrapped).Fill; }
+ set {
+ AutoSize = false;
+ ((Gtk.Box.BoxChild)Wrapped).Fill =
value;
+ }
+ }
+
protected override void EmitNotify (string propertyName)
{
if (propertyName == "AutoSize") {
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -75,7 +75,20 @@
get { return designHeight; }
set { designHeight = value; NotifyChanged (); }
}
+
+ public void IncreaseBorderWidth ()
+ {
+ container.BorderWidth += 3;
+ }
+ public void DecreaseBorderWidth ()
+ {
+ if (container.BorderWidth >= 3)
+ container.BorderWidth -= 3;
+ else
+ container.BorderWidth = 0;
+ }
+
int freeze;
protected void Freeze ()
{
Modified: trunk/stetic/libstetic/wrapper/objects.xml
===================================================================
--- trunk/stetic/libstetic/wrapper/objects.xml 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libstetic/wrapper/objects.xml 2006-06-09 20:59:49 UTC (rev
61606)
@@ -137,12 +137,18 @@
</object>
<object type="Gtk.Container,gtk-sharp" wrapper="Stetic.Wrapper.Container">
+ <itemgroups>
+ <itemgroup name="Commands">
+ <command name="IncreaseBorderWidth" label="Increase
Border Width" icon="res:inc-border.png" />
+ <command name="DecreaseBorderWidth" label="Decrease
Border Width" icon="res:dec-border.png" />
+ </itemgroup>
+ </itemgroups>
<signals>
<itemgroup label="Container Signals">
- <signal name="Added" />
- <signal name="FocusChildSet" />
- <signal name="Removed" />
- <signal name="ResizeChecked" />
+ <signal name="Added" />
+ <signal name="FocusChildSet" />
+ <signal name="Removed" />
+ <signal name="ResizeChecked" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
</signals>
@@ -180,6 +186,7 @@
<property name="SkipTaskbarHint" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Window Signals">
@@ -212,6 +219,7 @@
<property name="Position" />
<property name="BorderWidth" />
</itemgroup>
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Paned Signals">
@@ -303,6 +311,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -329,6 +338,7 @@
label="Bin" icon="custom.png">
<itemgroups>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -338,9 +348,9 @@
<object type="Gtk.Box,gtk-sharp" wrapper="Stetic.Wrapper.Box">
<itemgroups>
<itemgroup label="Box Properties">
- <property name="Homogeneous" />
- <property name="Spacing" />
- <property name="BorderWidth" />
+ <property name="Homogeneous" />
+ <property name="Spacing" />
+ <property name="BorderWidth" />
</itemgroup>
</itemgroups>
<contextmenu>
@@ -354,6 +364,7 @@
<itemgroup ref="Gtk.Container" />
</signals>
</object>
+
<object type="Gtk.Box+BoxChild,gtk-sharp"
wrapper="Stetic.Wrapper.Box+BoxChild">
<itemgroups>
<itemgroup label="Box Child Layout">
@@ -369,6 +380,8 @@
<disabled-if name="Expand" value="false" />
</property>
<property name="Padding" />
+ <command name="BoxExpand" label="Expand"
icon="res:box-expand.png" />
+ <command name="BoxFill" label="Fill" icon="res:box-fill.png" />
</itemgroup>
</itemgroups>
</object>
@@ -383,6 +396,7 @@
<property name="Spacing" />
<property name="BorderWidth" />
</itemgroup>
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -456,6 +470,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Button Signals">
@@ -507,14 +522,14 @@
<property name="Inconsistent" />
<property name="DrawIndicator" />
<property name="HasLabel" internal="true" />
- <command name="RemoveLabel" label="Remove Label"
+ <command name="RestoreLabel" label="Restore Label"
icon="res:add-check-label.png"
+ description="Restore the button's label">
+ <disabled-if name="HasLabel" value="true" />
+ </command>
+ <command name="RemoveLabel" label="Remove Label"
icon="res:remove-check-label.png"
description="Remove the button's label">
<disabled-if name="HasLabel" value="false" />
</command>
- <command name="RestoreLabel" label="Restore Label"
- description="Restore the button's label">
- <disabled-if name="HasLabel" value="true" />
- </command>
</itemgroup>
<itemgroup ref="Gtk.Button.Extra" />
<itemgroup ref="Gtk.Widget" />
@@ -611,6 +626,7 @@
</itemgroup>
<itemgroup ref="Gtk.Button.Extra" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Color Button Signals">
@@ -689,6 +705,7 @@
</itemgroup>
<itemgroup ref="Gtk.Window.Size" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Dialog Signals">
@@ -765,6 +782,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -781,6 +799,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Expander Signals">
@@ -806,6 +825,7 @@
</itemgroup>
<itemgroup ref="Gtk.Button.Extra" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Font Button Signals">
@@ -827,6 +847,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -839,6 +860,7 @@
<itemgroups>
<itemgroup ref="Gtk.Box" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -853,6 +875,7 @@
<itemgroups>
<itemgroup ref="Gtk.ButtonBox" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -882,6 +905,7 @@
<itemgroups>
<itemgroup ref="Gtk.Paned" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -994,6 +1018,7 @@
label="Menu Bar" icon="menubar.png" palette-category="widget">
<itemgroups>
<itemgroup ref="Gtk.Widget" important="false" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Menu Bar Signals">
@@ -1047,6 +1072,7 @@
<itemgroup ref="Gtk.Dialog.Misc" />
<itemgroup ref="Gtk.Window.Size" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1067,12 +1093,14 @@
<property name="Scrollable" />
<property name="BorderWidth" />
<command name="InsertBefore" label="Insert Page Before"
- check="CheckInsertBefore"
- description="Insert a blank page before this one" />
+ description="Insert a blank page before this one">
+ <disabled-if check="CheckInsertBefore" />
+ </command>
<command name="InsertAfter" label="Insert Page After"
description="Insert a blank page after this one" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Notebook Signals">
@@ -1087,20 +1115,25 @@
</signals>
<contextmenu>
<command name="PreviousPage" label="Go to Previous Page"
- description="Show the previous page"
- check="CheckPreviousPage" />
+ description="Show the previous page">
+ <disabled-if check="CheckPreviousPage" />
+ </command>
<command name="NextPage" label="Go to Next Page"
- description="Show the next page"
- check="CheckNextPage" />
+ description="Show the next page">
+ <disabled-if check="CheckNextPage" />
+ </command>
<command name="DeletePage" label="Delete Page"
- description="Delete the current page"
- check="CheckDeletePage" />
+ description="Delete the current page">
+ <disabled-if check="CheckDeletePage" />
+ </command>
<command name="SwapPrevious" label="Swap with Previous Page"
- description="Swap the contents of this page with the
contents of the previous page"
- check="CheckPreviousPage" />
+ description="Swap the contents of this page with the
contents of the previous page">
+ <disabled-if check="CheckPreviousPage" />
+ </command>
<command name="SwapNext" label="Swap with Next Page"
- description="Swap the contents of this page with the
contents of the next page"
- check="CheckNextPage" />
+ description="Swap the contents of this page with the
contents of the next page">
+ <disabled-if check="CheckNextPage" />
+ </command>
<command ref="InsertBefore" />
<command ref="InsertAfter" />
</contextmenu>
@@ -1125,6 +1158,7 @@
description="The active menu item" min="0" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Option Menu Signals">
@@ -1296,6 +1330,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Scrolled Window Signals">
@@ -1376,6 +1411,7 @@
<property name="HasResizeGrip" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Statusbar Signals">
@@ -1399,6 +1435,7 @@
<property name="BorderWidth" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1574,6 +1611,7 @@
</itemgroup>
<itemgroup ref="Gtk.Button.Extra" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Toggle Button Signals">
@@ -1618,6 +1656,7 @@
<property name="IconSize" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Toolbar Signals">
@@ -1659,6 +1698,7 @@
<!-- 2.6 <property name="HoverExpand" /> -->
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Tree View Signals">
@@ -1689,6 +1729,7 @@
<itemgroups>
<itemgroup ref="Gtk.Box" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1703,6 +1744,7 @@
<itemgroups>
<itemgroup ref="Gtk.ButtonBox" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1718,6 +1760,7 @@
<property name="ShadowType" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Viewport Signals">
@@ -1734,6 +1777,7 @@
<itemgroups>
<itemgroup ref="Gtk.Paned" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1834,6 +1878,7 @@
<property name="HasOpacityControl" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="Color Selection Signals">
@@ -1856,6 +1901,7 @@
<itemgroup ref="Gtk.Dialog.Misc" />
<itemgroup ref="Gtk.Window.Size" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1885,6 +1931,7 @@
<!-- 2.6 <property name="ShowHidden" /> -->
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="File Chooser Widget Signals">
@@ -1937,6 +1984,7 @@
<itemgroup ref="Gtk.Dialog.Misc" />
<itemgroup ref="Gtk.Window.Size" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup label="File Chooser Dialog Signals">
@@ -1965,6 +2013,7 @@
<property name="PreviewText" translatable="true" />
</itemgroup>
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
@@ -1984,6 +2033,7 @@
<itemgroup ref="Gtk.Dialog.Misc" />
<itemgroup ref="Gtk.Window.Size" />
<itemgroup ref="Gtk.Widget" />
+ <itemgroup ref="Gtk.Container.Commands" />
</itemgroups>
<signals>
<itemgroup ref="Gtk.Widget" />
Added: trunk/stetic/libstetic/wrapper/pixmaps/actiongroup.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/actiongroup.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/stetic/libstetic/wrapper/pixmaps/add-check-label.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/add-check-label.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/stetic/libstetic/wrapper/pixmaps/add-menu.png
===================================================================
(Binary files differ)
Added: trunk/stetic/libstetic/wrapper/pixmaps/box-expand.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/box-expand.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/stetic/libstetic/wrapper/pixmaps/box-fill.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/box-fill.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/stetic/libstetic/wrapper/pixmaps/dec-border.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/dec-border.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/stetic/libstetic/wrapper/pixmaps/inc-border.png
===================================================================
(Binary files differ)
Property changes on: trunk/stetic/libstetic/wrapper/pixmaps/inc-border.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/stetic/libstetic/wrapper/pixmaps/remove-check-label.png
===================================================================
(Binary files differ)
Property changes on:
trunk/stetic/libstetic/wrapper/pixmaps/remove-check-label.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/stetic/libstetic/wrapper/pixmaps/remove-menu.png
===================================================================
(Binary files differ)
Modified: trunk/stetic/libsteticui/WidgetActionBar.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetActionBar.cs 2006-06-09 20:27:18 UTC (rev
61605)
+++ trunk/stetic/libsteticui/WidgetActionBar.cs 2006-06-09 20:59:49 UTC (rev
61606)
@@ -13,14 +13,19 @@
WidgetTreeCombo combo;
ToolItem comboItem;
Stetic.Wrapper.Widget selection;
- Hashtable editors;
+ Hashtable editors, wrappers;
Hashtable sensitives, invisibles;
+ ArrayList toggles;
+ Gtk.Tooltips tips = new Gtk.Tooltips ();
+ bool updating;
public WidgetActionBar (Stetic.Wrapper.Widget rootWidget)
{
editors = new Hashtable ();
+ wrappers = new Hashtable ();
sensitives = new Hashtable ();
invisibles = new Hashtable ();
+ toggles = new ArrayList ();
IconSize = IconSize.SmallToolbar;
Orientation = Orientation.Horizontal;
@@ -61,13 +66,20 @@
void Clear ()
{
- if (selection != null)
+ if (selection != null) {
selection.Notify -= Notified;
+ Stetic.Wrapper.Container.ContainerChild
packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
+ if (packingSelection != null)
+ packingSelection.Notify -= Notified;
+ }
+
selection = null;
editors.Clear ();
+ wrappers.Clear ();
sensitives.Clear ();
invisibles.Clear ();
+ toggles.Clear ();
foreach (Gtk.Widget child in Children)
if (child != comboItem)
@@ -95,30 +107,60 @@
return;
combo.SetSelection (selection);
+
selection.Notify += Notified;
+ Stetic.Wrapper.Container.ContainerChild
packingSelection = Stetic.Wrapper.Container.ChildWrapper (selection);
+ if (packingSelection != null)
+ packingSelection.Notify += Notified;
+
AddWidgetCommands (selection);
UpdateSensitivity ();
}
- protected virtual void AddWidgetCommands (Stetic.Wrapper.Widget
widget)
+ protected virtual void AddWidgetCommands (ObjectWrapper wrapper)
{
- foreach (ItemGroup igroup in
widget.ClassDescriptor.ItemGroups) {
+ foreach (ItemGroup igroup in
wrapper.ClassDescriptor.ItemGroups) {
foreach (ItemDescriptor desc in igroup) {
if (desc is CommandDescriptor)
- AppendCommand
((CommandDescriptor) desc);
+ AppendCommand
((CommandDescriptor) desc, wrapper);
}
}
+
+ Stetic.Wrapper.Widget widget = wrapper as
Stetic.Wrapper.Widget;
+ if (widget != null) {
+ Stetic.Wrapper.Container.ContainerChild
packingSelection = Stetic.Wrapper.Container.ChildWrapper (widget);
+ if (packingSelection != null)
+ AddWidgetCommands (packingSelection);
+ }
}
- void AppendCommand (CommandDescriptor cmd)
+ void AppendCommand (CommandDescriptor cmd, ObjectWrapper widget)
{
- Gtk.ToolButton button = new Gtk.ToolButton (null, null);
- button.Label = cmd.Label;
- button.IsImportant = true;
+ Gtk.ToolButton button;
+
+ if (cmd.IsToggleCommand (widget.Wrapped)) {
+ button = new Gtk.ToggleToolButton ();
+ ((Gtk.ToggleToolButton)button).Active =
cmd.IsToogled (widget.Wrapped);
+ toggles.Add (cmd);
+ editors[cmd.Name] = button;
+ } else {
+ button = new Gtk.ToolButton (null, null);
+ }
+
+ Gtk.Image img = cmd.GetImage ();
+ if (img != null)
+ button.IconWidget = img;
+ if (cmd.Label != null && cmd.Label.Length > 0)
+ button.SetTooltip (tips, cmd.Label, "");
+ else {
+ button.Label = cmd.Label;
+ button.IsImportant = true;
+ }
button.Clicked += delegate (object o, EventArgs args) {
- cmd.Run (selection.Wrapped);
+ if (!updating)
+ cmd.Run (widget.Wrapped);
};
- button.Show ();
+ button.ShowAll ();
Insert (button, -1);
if (cmd.HasDependencies) {
@@ -129,6 +171,7 @@
editors[cmd.Name] = button;
invisibles[cmd] = cmd;
}
+ wrappers [cmd] = widget;
}
void Notified (object s, string propertyName)
@@ -141,17 +184,28 @@
foreach (ItemDescriptor item in sensitives.Keys) {
Widget w = editors[item.Name] as Widget;
if (w != null) {
- object ob = sensitives.Contains (item)
? selection.Wrapped : null;
+ ObjectWrapper wrapper = wrappers [item]
as ObjectWrapper;
+ object ob = sensitives.Contains (item)
? wrapper.Wrapped : null;
w.Sensitive = item.EnabledFor (ob);
}
}
foreach (ItemDescriptor item in invisibles.Keys) {
Widget w = editors[item.Name] as Widget;
if (w != null) {
- object ob = invisibles.Contains (item)
? selection.Wrapped : null;
+ ObjectWrapper wrapper = wrappers [item]
as ObjectWrapper;
+ object ob = invisibles.Contains (item)
? wrapper.Wrapped : null;
w.Visible = item.VisibleFor (ob);
}
}
+ foreach (CommandDescriptor cmd in toggles) {
+ ToggleToolButton w = editors[cmd.Name] as
ToggleToolButton;
+ if (w != null) {
+ ObjectWrapper wrapper = wrappers [cmd]
as ObjectWrapper;
+ updating = true;
+ w.Active = cmd.IsToogled
(wrapper.Wrapped);
+ updating = false;
+ }
+ }
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches