Author: danw
Date: 2005-03-21 12:10:19 -0500 (Mon, 21 Mar 2005)
New Revision: 42050
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/GladeUtils.cs
trunk/stetic/libstetic/editor/Image.cs
trunk/stetic/libstetic/wrapper/Button.cs
trunk/stetic/libstetic/wrapper/Dialog.cs
trunk/stetic/libstetic/wrapper/Image.cs
trunk/stetic/libstetic/wrapper/ToggleButton.cs
Log:
* libstetic/wrapper/Button.cs: Remove "UseStock" property and just
use a Stetic.Editor.Image to select either a stock icon or a file.
Also allow stock icon (or file) with non-stock label.
(GladeImportChild, FixupGladeChildren): import correctly
* libstetic/wrapper/ToggleButton.cs: likewise
* libstetic/wrapper/Dialog.cs (AddButton): update for Button changes
* libstetic/wrapper/Image.cs (File): This is equivalent to the
GladeProperty "pixbuf".
* libstetic/editor/Image.cs: fixes
* libstetic/GladeUtils.cs (ParseGladeProperty): don't try to parse
string properties, since they don't need to be (and might not
correspond to underlying properties anyway).
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-03-21 14:29:24 UTC (rev 42049)
+++ trunk/stetic/ChangeLog 2005-03-21 17:10:19 UTC (rev 42050)
@@ -1,5 +1,25 @@
2005-03-21 Dan Winship <[EMAIL PROTECTED]>
+ * libstetic/wrapper/Button.cs: Remove "UseStock" property and just
+ use a Stetic.Editor.Image to select either a stock icon or a file.
+ Also allow stock icon (or file) with non-stock label.
+ (GladeImportChild, FixupGladeChildren): import correctly
+
+ * libstetic/wrapper/ToggleButton.cs: likewise
+
+ * libstetic/wrapper/Dialog.cs (AddButton): update for Button changes
+
+ * libstetic/wrapper/Image.cs (File): This is equivalent to the
+ GladeProperty "pixbuf".
+
+ * libstetic/editor/Image.cs: fixes
+
+ * libstetic/GladeUtils.cs (ParseGladeProperty): don't try to parse
+ string properties, since they don't need to be (and might not
+ correspond to underlying properties anyway).
+
+2005-03-21 Dan Winship <[EMAIL PROTECTED]>
+
* glue/paramspec.c:
* libstetic/ParamSpec.cs: Simplify based on the latest version of
the patch in #70061.
Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs 2005-03-21 14:29:24 UTC (rev
42049)
+++ trunk/stetic/libstetic/GladeUtils.cs 2005-03-21 17:10:19 UTC (rev
42050)
@@ -195,7 +195,8 @@
static void ParseGladeProperty (ObjectWrapper wrapper, IntPtr
klass, bool childprop,
PropertyDescriptor prop, string
strval)
{
- if ((prop.GladeFlags & GladeProperty.Proxied) != 0)
+ if (((prop.GladeFlags & GladeProperty.Proxied) != 0) ||
+ prop.PropertyType == typeof (string))
prop.GladeSetValue (wrapper, strval);
else {
GLib.Value value;
Modified: trunk/stetic/libstetic/editor/Image.cs
===================================================================
--- trunk/stetic/libstetic/editor/Image.cs 2005-03-21 14:29:24 UTC (rev
42049)
+++ trunk/stetic/libstetic/editor/Image.cs 2005-03-21 17:10:19 UTC (rev
42050)
@@ -3,6 +3,7 @@
namespace Stetic.Editor {
+ [PropertyEditor ("Value", "Changed")]
public class Image : Gtk.HBox {
Gtk.Image image;
Gtk.ComboBoxEntry combo;
@@ -206,13 +207,22 @@
public string Value {
get {
- if (useStock)
- return "stock:" + StockId;
- else
- return "file:" + File;
+ if (useStock) {
+ if (StockId != null)
+ return "stock:" + StockId;
+ else
+ return null;
+ } else {
+ if (File != null)
+ return "file:" + File;
+ else
+ return null;
+ }
}
set {
- if (value.StartsWith ("stock:"))
+ if (value == null)
+ File = null;
+ else if (value.StartsWith ("stock:"))
StockId = value.Substring (6);
else if (value.StartsWith ("file:"))
File = value.Substring (5);
Modified: trunk/stetic/libstetic/wrapper/Button.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Button.cs 2005-03-21 14:29:24 UTC (rev
42049)
+++ trunk/stetic/libstetic/wrapper/Button.cs 2005-03-21 17:10:19 UTC (rev
42050)
@@ -12,8 +12,7 @@
{
if (type == typeof (Stetic.Wrapper.Button)) {
ItemGroup props = AddItemGroup (type, "Button
Properties",
- "UseStock",
- "StockId",
+ "Icon",
"Label",
"ResponseId",
"RemoveContents",
@@ -28,11 +27,8 @@
typeof
(Gtk.Button),
"HasContents");
- props["UseStock"].DependsOn (hasLabel);
- props["StockId"].DependsOn (hasLabel);
- props["StockId"].DependsOn (props["UseStock"]);
+ props["Icon"].DependsOn (hasLabel);
props["Label"].DependsOn (hasLabel);
- props["Label"].DependsInverselyOn
(props["UseStock"]);
props["RestoreLabel"].DependsInverselyOn
(hasLabel);
props["RemoveContents"].DependsOn (hasContents);
@@ -66,24 +62,69 @@
public override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
- if (!initialized) {
- if (button.UseStock) {
- stockId = button.Label;
- label = button.Name;
- } else {
- label = button.Name;
- stockId = Gtk.Stock.Ok;
- }
+ if (!initialized)
+ button.Label = button.Name;
+
+ if (button.UseStock)
+ Icon = "stock:" + button.Label;
+ else {
+ Icon = null;
+ Label = button.Label;
}
}
+ public override Widget GladeImportChild (string className,
string id,
+ Hashtable props,
Hashtable childprops)
+ {
+ stetic.GladeImportComplete += FixupGladeChildren;
+
+ if (button.Child != null)
+ button.Remove (button.Child);
+ return base.GladeImportChild (className, id, props,
childprops);
+ }
+
+ void FixupGladeChildren ()
+ {
+ stetic.GladeImportComplete -= FixupGladeChildren;
+
+ WidgetSite site = button.Child as WidgetSite;
+ Gtk.Alignment alignment = (site == null) ? null :
site.Contents as Gtk.Alignment;
+ if (alignment == null)
+ return;
+
+ site = alignment.Child as WidgetSite;
+ Gtk.HBox box = (site == null) ? null : site.Contents as
Gtk.HBox;
+ if (box == null)
+ return;
+
+ Gtk.Widget[] children = box.Children;
+ if (children == null || children.Length != 2)
+ return;
+
+ site = children[0] as WidgetSite;
+ Gtk.Image image = (site == null) ? null : site.Contents
as Gtk.Image;
+ site = children[1] as WidgetSite;
+ Gtk.Label label = (site == null) ? null : site.Contents
as Gtk.Label;
+ if (image == null || label == null)
+ return;
+ Stetic.Wrapper.Image iwrap =
Stetic.ObjectWrapper.Lookup (image) as Stetic.Wrapper.Image;
+ if (iwrap == null)
+ return;
+
+ if (iwrap.UseStock)
+ Icon = "stock:" + iwrap.Stock;
+ else
+ Icon = "file:" + iwrap.File;
+ Label = label.LabelProp;
+ }
+
private Gtk.Button button {
get {
return (Gtk.Button)Wrapped;
}
}
- // true if the button has a label rather than custom contents
+ // true if the button has an icon+label rather than custom
contents
public bool HasLabel {
get {
return (button.Child as WidgetSite) == null;
@@ -117,48 +158,71 @@
[Command ("Restore Button Label", "Restore the button's label")]
void RestoreLabel ()
{
+ ConstructChild ();
+ EmitNotify ("HasContents");
+ EmitNotify ("HasLabel");
+ }
+
+ Gtk.Image iconWidget;
+ Gtk.Label labelWidget;
+ string icon;
+ string label;
+
+ void ConstructChild ()
+ {
if (button.Child != null)
button.Remove (button.Child);
+ iconWidget = null;
+ labelWidget = null;
- if (UseStock)
- button.Label = stockId;
+ if (button.UseUnderline) {
+ labelWidget = new Gtk.Label (label);
+ labelWidget.MnemonicWidget = button;
+ } else
+ labelWidget = Gtk.Label.New (label);
+ labelWidget.Show ();
+
+ if (icon == null) {
+ labelWidget.Xalign = button.Xalign;
+ labelWidget.Yalign = button.Yalign;
+ button.Add (labelWidget);
+ return;
+ }
+
+ if (icon.StartsWith ("stock:"))
+ iconWidget = new Gtk.Image (icon.Substring (6),
Gtk.IconSize.Button);
+ else if (icon.StartsWith ("file:"))
+ iconWidget = new Gtk.Image (icon.Substring (5));
else
- button.Label = label;
+ iconWidget = new Gtk.Image
(Gtk.Stock.MissingImage, Gtk.IconSize.Button);
- EmitNotify ("HasContents");
- EmitNotify ("HasLabel");
- }
+ Gtk.HBox box = new Gtk.HBox (false, 2);
+ box.PackStart (iconWidget, false, false, 0);
+ box.PackEnd (labelWidget, false, false, 0);
- string stockId;
- string label;
+ Gtk.Alignment alignment = new Gtk.Alignment
(button.Xalign, button.Yalign, 0.0f, 0.0f);
+ alignment.Add (box);
+ alignment.ShowAll ();
- public bool UseStock {
- get {
- return button.UseStock;
- }
- set {
- if (value)
- button.Label = stockId;
- else
- button.Label = label;
- button.UseStock = value;
- }
+ button.Add (alignment);
}
- [Editor (typeof (Stetic.Editor.StockItem))]
- [Description ("Stock Item", "The stock icon and label to
display in the button")]
- public string StockId {
+ [Editor (typeof (Stetic.Editor.Image))]
+ [Description ("Icon", "The icon to display in the button")]
+ public string Icon {
get {
- return stockId;
+ return icon;
}
set {
- stockId = value;
- if (UseStock)
- button.Label = value;
-
- Gtk.StockItem item = Gtk.Stock.Lookup (value);
- if (item.Label != null)
- label = item.Label;
+ icon = value;
+ if (icon != null && icon.StartsWith ("stock:"))
{
+ Gtk.StockItem item = Gtk.Stock.Lookup
(icon.Substring (6));
+ if (item.Label != null) {
+ label = item.Label;
+ EmitNotify ("Label");
+ }
+ }
+ ConstructChild ();
}
}
@@ -169,11 +233,20 @@
}
set {
label = value;
- if (!UseStock)
- button.Label = value;
+ ConstructChild ();
}
}
+ public bool UseUnderline {
+ get {
+ return button.UseUnderline;
+ }
+ set {
+ button.UseUnderline = value;
+ ConstructChild ();
+ }
+ }
+
public bool HasResponseId {
get {
WidgetSite site = button.Parent as WidgetSite;
Modified: trunk/stetic/libstetic/wrapper/Dialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Dialog.cs 2005-03-21 14:29:24 UTC (rev
42049)
+++ trunk/stetic/libstetic/wrapper/Dialog.cs 2005-03-21 17:10:19 UTC (rev
42050)
@@ -143,12 +143,11 @@
button = ObjectWrapper.Create (stetic, typeof
(Stetic.Wrapper.Button)) as Stetic.Wrapper.Button;
widget = (Gtk.Button)button.Wrapped;
- if (stockId != null) {
- button.StockId = stockId;
- button.UseStock = true;
- } else {
+ if (stockId != null)
+ button.Icon = "stock:" + stockId;
+ else {
+ button.Icon = null;
button.Label = widget.Name;
- button.UseStock = false;
}
button.ResponseId = (int)response;
Modified: trunk/stetic/libstetic/wrapper/Image.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Image.cs 2005-03-21 14:29:24 UTC (rev
42049)
+++ trunk/stetic/libstetic/wrapper/Image.cs 2005-03-21 17:10:19 UTC (rev
42050)
@@ -88,6 +88,7 @@
string filename = "";
[Editor (typeof (Stetic.Editor.ImageFile))]
+ [GladeProperty (Name = "pixbuf")]
public string File {
get {
return filename;
Modified: trunk/stetic/libstetic/wrapper/ToggleButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ToggleButton.cs 2005-03-21 14:29:24 UTC
(rev 42049)
+++ trunk/stetic/libstetic/wrapper/ToggleButton.cs 2005-03-21 17:10:19 UTC
(rev 42050)
@@ -10,21 +10,40 @@
static new void Register (Type type)
{
ItemGroup props = AddItemGroup (type, "Toggle Button
Properties",
- "UseStock",
- "StockId",
+ "Icon",
"Label",
"Active",
- "Inconsistent");
- props["StockId"].DependsOn (props["UseStock"]);
- props["Label"].DependsInverselyOn (props["UseStock"]);
+ "Inconsistent",
+ "RemoveContents",
+ "RestoreLabel");
+
+ PropertyDescriptor hasLabel =
+ new PropertyDescriptor (typeof
(Stetic.Wrapper.Button),
+ typeof (Gtk.Button),
+ "HasLabel");
+ PropertyDescriptor hasContents =
+ new PropertyDescriptor (typeof
(Stetic.Wrapper.Button),
+ typeof (Gtk.Button),
+ "HasContents");
+
+ props["Icon"].DependsOn (hasLabel);
+ props["Label"].DependsOn (hasLabel);
+ props["RestoreLabel"].DependsInverselyOn (hasLabel);
+ props["RemoveContents"].DependsOn (hasContents);
+
+ props = AddContextMenuItems (type,
+ "RemoveContents",
+ "RestoreLabel");
+ props["RemoveContents"].DependsOn (hasContents);
+ props["RestoreLabel"].DependsInverselyOn (hasLabel);
}
public override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
if (!initialized) {
- Gtk.ToggleButton button =
(Gtk.ToggleButton)Wrapped;
- button.Label = button.Name;
+ Icon = null;
+ Label = ((Gtk.Widget)Wrapped).Name;
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches