Author: danw
Date: 2005-02-28 11:28:56 -0500 (Mon, 28 Feb 2005)
New Revision: 41287
Added:
trunk/stetic/libstetic/wrapper/Menu.cs
trunk/stetic/libstetic/wrapper/MenuItem.cs
trunk/stetic/libstetic/wrapper/OptionMenu.cs
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/Makefile.am
trunk/stetic/libstetic/ObjectWrapperAttribute.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/stetic/Palette.cs
Log:
* libstetic/ObjectWrapperAttribute.cs: add a "Deprecated" flag
* libstetic/wrapper/OptionMenu.cs: New, wrap Gtk.OptionMenu, but
mark it with the "Deprecated" ObjectWrapperAttribute flag. Also,
since we don't have a menu editor yet, we just wrap it the same
way as ComboBox, with a multiline text entry to specify the menu
items.
* libstetic/wrapper/Menu.cs:
* libstetic/wrapper/MenuItem.cs: Wrap these just enough for
importing OptionMenus from glade
* libstetic/wrapper/Container.cs (GladeImportChild): if the
container does not accept arbitrary GtkWidget children (according
to Gtk.Container.ChildType()), then don't interpose a WidgetSite
between parent and child.
* stetic/Palette.cs (AddWidget): skip widgets with "Deprecated"
set on their ObjectWrapperAttribute. (Meaning that for now, they
can be imported, but not created by hand.)
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-02-28 15:16:18 UTC (rev 41286)
+++ trunk/stetic/ChangeLog 2005-02-28 16:28:56 UTC (rev 41287)
@@ -1,3 +1,26 @@
+2005-02-28 Dan Winship <[EMAIL PROTECTED]>
+
+ * libstetic/ObjectWrapperAttribute.cs: add a "Deprecated" flag
+
+ * libstetic/wrapper/OptionMenu.cs: New, wrap Gtk.OptionMenu, but
+ mark it with the "Deprecated" ObjectWrapperAttribute flag. Also,
+ since we don't have a menu editor yet, we just wrap it the same
+ way as ComboBox, with a multiline text entry to specify the menu
+ items.
+
+ * libstetic/wrapper/Menu.cs:
+ * libstetic/wrapper/MenuItem.cs: Wrap these just enough for
+ importing OptionMenus from glade
+
+ * libstetic/wrapper/Container.cs (GladeImportChild): if the
+ container does not accept arbitrary GtkWidget children (according
+ to Gtk.Container.ChildType()), then don't interpose a WidgetSite
+ between parent and child.
+
+ * stetic/Palette.cs (AddWidget): skip widgets with "Deprecated"
+ set on their ObjectWrapperAttribute. (Meaning that for now, they
+ can be imported, but not created by hand.)
+
2005-02-27 Dan Winship <[EMAIL PROTECTED]>
* libstetic/GladeUtils.cs (ExtractProperty): utility to remove a
Modified: trunk/stetic/libstetic/Makefile.am
===================================================================
--- trunk/stetic/libstetic/Makefile.am 2005-02-28 15:16:18 UTC (rev 41286)
+++ trunk/stetic/libstetic/Makefile.am 2005-02-28 16:28:56 UTC (rev 41287)
@@ -63,9 +63,12 @@
wrapper/Image.cs \
wrapper/Label.cs \
wrapper/MessageDialog.cs \
+ wrapper/Menu.cs \
+ wrapper/MenuItem.cs \
wrapper/Misc.cs \
wrapper/Notebook.cs \
wrapper/Object.cs \
+ wrapper/OptionMenu.cs \
wrapper/Paned.cs \
wrapper/ProgressBar.cs \
wrapper/RadioButton.cs \
Modified: trunk/stetic/libstetic/ObjectWrapperAttribute.cs
===================================================================
--- trunk/stetic/libstetic/ObjectWrapperAttribute.cs 2005-02-28 15:16:18 UTC
(rev 41286)
+++ trunk/stetic/libstetic/ObjectWrapperAttribute.cs 2005-02-28 16:28:56 UTC
(rev 41287)
@@ -13,6 +13,7 @@
public sealed class ObjectWrapperAttribute : Attribute {
string name, iconName;
ObjectWrapperType type;
+ bool deprecated;
[Translatable]
public string Name {
@@ -30,6 +31,11 @@
set { type = value; }
}
+ public bool Deprecated {
+ get { return deprecated; }
+ set { deprecated = value; }
+ }
+
public ObjectWrapperAttribute (string name, string iconName,
ObjectWrapperType type)
{
this.name = name;
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-02-28 15:16:18 UTC (rev
41286)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-02-28 16:28:56 UTC (rev
41287)
@@ -49,11 +49,17 @@
if (wrapper == null)
return null;
- WidgetSite site = AddPlaceholder ();
- AutoSize[site] = false;
- site.Add ((Gtk.Widget)wrapper.Wrapped);
+ Gtk.Widget child = (Gtk.Widget)wrapper.Wrapped;
- GladeUtils.SetPacking (container, site, packingNames,
packingVals);
+ if (container.ChildType () == Gtk.Widget.GType) {
+ WidgetSite site = AddPlaceholder ();
+ AutoSize[site] = false;
+ site.Add (child);
+ child = site;
+ } else
+ container.Add (child);
+
+ GladeUtils.SetPacking (container, child, packingNames,
packingVals);
return (Widget)wrapper;
}
Added: trunk/stetic/libstetic/wrapper/Menu.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Menu.cs 2005-02-28 15:16:18 UTC (rev
41286)
+++ trunk/stetic/libstetic/wrapper/Menu.cs 2005-02-28 16:28:56 UTC (rev
41287)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections;
+
+namespace Stetic.Wrapper {
+
+ [ObjectWrapper ("Menu", "menu.png", ObjectWrapperType.Widget)]
+ public class Menu : Container {
+
+ public static new Type WrappedType = typeof (Gtk.Menu);
+ }
+}
Added: trunk/stetic/libstetic/wrapper/MenuItem.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/MenuItem.cs 2005-02-28 15:16:18 UTC (rev
41286)
+++ trunk/stetic/libstetic/wrapper/MenuItem.cs 2005-02-28 16:28:56 UTC (rev
41287)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections;
+
+namespace Stetic.Wrapper {
+
+ [ObjectWrapper ("MenuItem", "menuitem.png", ObjectWrapperType.Widget)]
+ public class MenuItem : Container {
+
+ public static new Type WrappedType = typeof (Gtk.MenuItem);
+
+ protected override void GladeImport (string className, string
id, ArrayList propNames, ArrayList propVals)
+ {
+ string label = GladeUtils.ExtractProperty ("label",
propNames, propVals);
+ string use_underline = GladeUtils.ExtractProperty
("use_underline", propNames, propVals);
+ base.GladeImport (className, id, propNames, propVals);
+
+ if (label != null) {
+ Gtk.MenuItem item = (Gtk.MenuItem)Wrapped;
+ Gtk.Label item_label = new Gtk.Label (label);
+ item_label.UseUnderline = (use_underline ==
"True");
+ item_label.Show ();
+ item.Add (item_label);
+ }
+ }
+ }
+}
Added: trunk/stetic/libstetic/wrapper/OptionMenu.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/OptionMenu.cs 2005-02-28 15:16:18 UTC
(rev 41286)
+++ trunk/stetic/libstetic/wrapper/OptionMenu.cs 2005-02-28 16:28:56 UTC
(rev 41287)
@@ -0,0 +1,129 @@
+using System;
+using System.Collections;
+
+// Don't warn that OptionMenu is deprecated. We know that.
+#pragma warning disable 612
+
+namespace Stetic.Wrapper {
+
+ [ObjectWrapper ("Option Menu", "optionmenu.png",
ObjectWrapperType.Widget, Deprecated = true)]
+ public class OptionMenu : Container {
+
+ public static new Type WrappedType = typeof (Gtk.OptionMenu);
+
+ static new void Register (Type type)
+ {
+ AddItemGroup (type, "Option Menu Properties",
+ "Items",
+ "Active");
+ }
+
+ protected override void Wrap (object obj, bool initialized)
+ {
+ base.Wrap (obj, initialized);
+ }
+
+ protected override void GladeImport (string className, string
id, ArrayList propNames, ArrayList propVals)
+ {
+ GladeUtils.ExtractProperty ("history", propNames,
propVals);
+ base.GladeImport (className, id, propNames, propVals);
+ stetic.GladeImportComplete += FlattenMenu;
+ }
+
+ public override Widget GladeImportChild (string className,
string id,
+ ArrayList propNames,
ArrayList propVals,
+ ArrayList
packingNames, ArrayList packingVals)
+ {
+ ObjectWrapper wrapper =
Stetic.ObjectWrapper.GladeImport (stetic, className, id, propNames, propVals);
+ if (wrapper == null)
+ return null;
+
+ Gtk.Menu menu = (Gtk.Menu)wrapper.Wrapped;
+ if (menu != null)
+ optionmenu.Menu = menu;
+
+ return wrapper as Stetic.Wrapper.Widget;
+ }
+
+ void FlattenMenu ()
+ {
+ Gtk.Menu menu = optionmenu.Menu as Gtk.Menu;
+ if (menu == null) {
+ menu = new Gtk.Menu ();
+ menu.Show ();
+ optionmenu.Menu = menu;
+ }
+
+ System.Text.StringBuilder sb = new
System.Text.StringBuilder ();
+
+ foreach (Gtk.Widget w in menu.Children) {
+ Gtk.MenuItem item = w as Gtk.MenuItem;
+ if (item == null)
+ continue;
+ Gtk.Label label = item.Child as Gtk.Label;
+ if (label != null)
+ sb.Append (label.LabelProp);
+ sb.Append ("\n");
+ }
+
+ Items = sb.ToString ();
+ }
+
+ Gtk.OptionMenu optionmenu {
+ get {
+ return (Gtk.OptionMenu)Wrapped;
+ }
+ }
+
+ string items = "";
+ string[] item = new string[0];
+
+ [Editor (typeof (Stetic.Editor.Text))]
+ [Description ("Items", "The items to display in the Option
Menu, one per line")]
+ public string Items {
+ get {
+ return items;
+ }
+ set {
+ int active = optionmenu.History;
+ Gtk.Menu menu = new Gtk.Menu ();
+
+ items = value;
+ while (items.EndsWith ("\n"))
+ items = items.Substring (0,
items.Length - 1);
+ item = items.Split ('\n');
+
+ for (int i = 0; i < item.Length; i++) {
+ Gtk.MenuItem mitem;
+ if (item[i] == "")
+ mitem = new
Gtk.SeparatorMenuItem ();
+ else
+ mitem = new Gtk.MenuItem
(item[i]);
+ mitem.Show ();
+ mitem.Activated += delegate (object
obj, EventArgs args) {
+ EmitNotify ("Active");
+ };
+ menu.Add (mitem);
+ }
+
+ menu.Show ();
+ optionmenu.Menu = menu;
+ optionmenu.SetHistory ((uint)active);
+
+ EmitNotify ("Items");
+ }
+ }
+
+ [Description ("Active", "The active menu item")]
+ [Range (0, System.Int32.MaxValue)]
+ public int Active {
+ get {
+ return optionmenu.History;
+ }
+ set {
+ optionmenu.SetHistory ((uint)value);
+ EmitNotify ("Active");
+ }
+ }
+ }
+}
Modified: trunk/stetic/stetic/Palette.cs
===================================================================
--- trunk/stetic/stetic/Palette.cs 2005-02-28 15:16:18 UTC (rev 41286)
+++ trunk/stetic/stetic/Palette.cs 2005-02-28 16:28:56 UTC (rev 41287)
@@ -87,6 +87,8 @@
Stetic.ObjectWrapper.Register (type);
ObjectWrapperAttribute owattr = attr as
ObjectWrapperAttribute;
+ if (owattr.Deprecated)
+ return;
Pixbuf icon = Palette.IconForType (type);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches