Author: danw
Date: 2005-02-28 17:31:18 -0500 (Mon, 28 Feb 2005)
New Revision: 41295
Added:
trunk/stetic/libstetic/wrapper/pixmaps/missing.png
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/GladeUtils.cs
trunk/stetic/libstetic/WidgetSite.cs
trunk/stetic/libstetic/wrapper/ComboBox.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/libstetic/wrapper/Dialog.cs
trunk/stetic/libstetic/wrapper/Expander.cs
trunk/stetic/libstetic/wrapper/Image.cs
trunk/stetic/libstetic/wrapper/Label.cs
trunk/stetic/libstetic/wrapper/Notebook.cs
trunk/stetic/libstetic/wrapper/OptionMenu.cs
trunk/stetic/libstetic/wrapper/Table.cs
trunk/stetic/libstetic/wrapper/Window.cs
Log:
* libstetic/GladeUtils.cs (HydrateProperties): Handle "adjustment"
properties, which glade serializes as 6 doubles separated by
spaces.
* libstetic/WidgetSite.cs (Selected): new event
(Focus): emit it
* libstetic/wrapper/ComboBox.cs (GladeImport): use CreateInstance
rather than calling down to base.GladeImport, so that we end up
with a text-only combobox. Handle the "items" property.
(Items): ignore trailing newlines
* libstetic/wrapper/Dialog.cs (Wrap): Put WidgetSites around the
VBox and ActionArea.
* libstetic/wrapper/Container.cs (FindInternalChild): make this a
little more complicated (read: grosser) to deal with the extra
WidgetSites inside a Dialog now.
* libstetic/wrapper/Expander.cs (GladeImport): Do the same label
widget hack as in Notebook and Frame
* libstetic/wrapper/Image.cs: if filename is "", use a "broken
image" image.
* libstetic/wrapper/Label.cs: add a new ctor that takes a string
and constructs a label with that string, and a wrapper around the
label.
* libstetic/wrapper/Notebook.cs: connect to the Selected event
on the label WidgetSites, and switch pages when a label is
selected.
(InsertPage): use the new Stetic.Wrapper.Label ctor
* libstetic/wrapper/OptionMenu.cs (Wrap): if the optionmenu has no
Menu, create one here rather than in FlattenMenu.
* libstetic/wrapper/Table.cs (GladeImportChild): if x_options or
y_options is unspecified, consider it to be "expand|fill", which
is glade's default value.
(SiteOccupancyChanged): don't adjust the cell's packing unless it
is set to AutoSize.
* libstetic/wrapper/Window.cs (Type): make this a shadow prop too
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-02-28 18:16:38 UTC (rev 41294)
+++ trunk/stetic/ChangeLog 2005-02-28 22:31:18 UTC (rev 41295)
@@ -1,5 +1,52 @@
2005-02-28 Dan Winship <[EMAIL PROTECTED]>
+ * libstetic/GladeUtils.cs (HydrateProperties): Handle "adjustment"
+ properties, which glade serializes as 6 doubles separated by
+ spaces.
+
+ * libstetic/WidgetSite.cs (Selected): new event
+ (Focus): emit it
+
+ * libstetic/wrapper/ComboBox.cs (GladeImport): use CreateInstance
+ rather than calling down to base.GladeImport, so that we end up
+ with a text-only combobox. Handle the "items" property.
+ (Items): ignore trailing newlines
+
+ * libstetic/wrapper/Dialog.cs (Wrap): Put WidgetSites around the
+ VBox and ActionArea.
+
+ * libstetic/wrapper/Container.cs (FindInternalChild): make this a
+ little more complicated (read: grosser) to deal with the extra
+ WidgetSites inside a Dialog now.
+
+ * libstetic/wrapper/Expander.cs (GladeImport): Do the same label
+ widget hack as in Notebook and Frame
+
+ * libstetic/wrapper/Image.cs: if filename is "", use a "broken
+ image" image.
+
+ * libstetic/wrapper/Label.cs: add a new ctor that takes a string
+ and constructs a label with that string, and a wrapper around the
+ label.
+
+ * libstetic/wrapper/Notebook.cs: connect to the Selected event
+ on the label WidgetSites, and switch pages when a label is
+ selected.
+ (InsertPage): use the new Stetic.Wrapper.Label ctor
+
+ * libstetic/wrapper/OptionMenu.cs (Wrap): if the optionmenu has no
+ Menu, create one here rather than in FlattenMenu.
+
+ * libstetic/wrapper/Table.cs (GladeImportChild): if x_options or
+ y_options is unspecified, consider it to be "expand|fill", which
+ is glade's default value.
+ (SiteOccupancyChanged): don't adjust the cell's packing unless it
+ is set to AutoSize.
+
+ * libstetic/wrapper/Window.cs (Type): make this a shadow prop too
+
+2005-02-28 Dan Winship <[EMAIL PROTECTED]>
+
* libstetic/ObjectWrapperAttribute.cs: add a "Deprecated" flag
* libstetic/wrapper/OptionMenu.cs: New, wrap Gtk.OptionMenu, but
Modified: trunk/stetic/libstetic/GladeUtils.cs
===================================================================
--- trunk/stetic/libstetic/GladeUtils.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/GladeUtils.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -27,39 +27,65 @@
[DllImport("libsteticglue")]
static extern bool stetic_g_value_hydrate (ref GLib.Value
value, string data);
+ static bool Hydrate (IntPtr gtype, bool childprop, string name,
string strval, out GLib.Value value)
+ {
+ value = new GLib.Value ();
+ bool inited = false;
+
+ if (childprop)
+ inited = stetic_g_value_init_for_child_property
(ref value, gtype, name);
+ else
+ inited = stetic_g_value_init_for_property (ref
value, gtype, name);
+
+ if (!inited) {
+ Console.WriteLine ("Unrecognized {0}property
name '{1}'",
+ childprop ? "child " : "",
name);
+ return false;
+ }
+
+ if (name == "adjustment") {
+ try {
+ string[] vals = strval.Split (' ');
+ double deflt, min, max, step, page_inc,
page_size;
+
+ deflt = Double.Parse (vals[0]);
+ min = Double.Parse (vals[1]);
+ max = Double.Parse (vals[2]);
+ step = Double.Parse (vals[3]);
+ page_inc = Double.Parse (vals[4]);
+ page_size = Double.Parse (vals[5]);
+
+ value.Val = new Gtk.Adjustment (deflt,
min, max, step, page_inc, page_size);
+ return true;
+ } catch {
+ ;
+ }
+ }
+
+ if (!stetic_g_value_hydrate (ref value, strval)) {
+ Console.WriteLine ("Could not hydrate
{0}property '{1}' with value '{2}'",
+ childprop ? "child " : "",
name, strval);
+ return false;
+ }
+
+ return true;
+ }
+
static void HydrateProperties (IntPtr gtype, bool childprops,
ArrayList names, ArrayList strvals, out ArrayList values)
{
values = new ArrayList ();
int i = 0;
while (i < names.Count) {
- string name = names[i] as string;
- string strval = strvals[i] as string;
+ GLib.Value value;
- GLib.Value value = new GLib.Value ();
- bool inited = false;
-
- if (childprops)
- inited =
stetic_g_value_init_for_child_property (ref value, gtype, name);
- else
- inited =
stetic_g_value_init_for_property (ref value, gtype, name);
-
- if (!inited) {
- Console.WriteLine ("Unrecognized
{0}property name '{1}'",
- childprops ? "child
" : "", name);
+ if (Hydrate (gtype, childprops, names[i] as
string, strvals[i] as string, out value)) {
+ values.Add (value);
+ i++;
+ } else {
names.RemoveAt (i);
strvals.RemoveAt (i);
- continue;
}
- if (!stetic_g_value_hydrate (ref value,
strval)) {
- Console.WriteLine ("Could not hydrate
{0}property '{1}' with value '{2}'",
- childprops ? "child
" : "", name, strval);
- names.RemoveAt (i);
- strvals.RemoveAt (i);
- }
-
- values.Add (value);
- i++;
}
}
Modified: trunk/stetic/libstetic/WidgetSite.cs
===================================================================
--- trunk/stetic/libstetic/WidgetSite.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/WidgetSite.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -284,9 +284,13 @@
return false;
}
+ public event EventHandler Selected;
+
public void Focus ()
{
ShowHandles = true;
+ if (Selected != null)
+ Selected (this, EventArgs.Empty);
}
public void UnFocus ()
Modified: trunk/stetic/libstetic/wrapper/ComboBox.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ComboBox.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/ComboBox.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
namespace Stetic.Wrapper {
@@ -23,6 +24,16 @@
return Gtk.ComboBox.NewText ();
}
+ protected override void GladeImport (string className, string
id, ArrayList propNames, ArrayList propVals)
+ {
+ Gtk.ComboBox combobox = CreateInstance ();
+ string items = GladeUtils.ExtractProperty ("items",
propNames, propVals);
+ GladeUtils.SetProps (combobox, propNames, propVals);
+ combobox.Name = id;
+ Wrap (combobox, true);
+ Items = items;
+ }
+
string items = "";
string[] item = new string[0];
@@ -33,6 +44,9 @@
return items;
}
set {
+ while (value.EndsWith ("\n"))
+ value = value.Substring (0,
value.Length - 1);
+
Gtk.ComboBox combobox = (Gtk.ComboBox)Wrapped;
string[] newitem = value.Split ('\n');
int active = combobox.Active;
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -70,25 +70,28 @@
return site;
}
- protected virtual Gtk.Widget FindInternalChild (string
childName)
+ Gtk.Widget FindInternalChild (string childName, Gtk.Container
container)
{
- // The fact that this tends to work does not mean it is
not an
- // awful kludge
-
Type type = container.GetType ();
PropertyInfo pinfo = type.GetProperty
(childName.Replace ("_", ""), BindingFlags.Public | BindingFlags.IgnoreCase |
BindingFlags.Instance);
if (pinfo != null &&
(pinfo.PropertyType == typeof (Gtk.Widget) ||
pinfo.PropertyType.IsSubclassOf (typeof
(Gtk.Widget))))
return pinfo.GetValue (container, null) as
Gtk.Widget;
+ return null;
+ }
- if (container.Parent != null) {
- type = container.Parent.GetType ();
- pinfo = type.GetProperty (childName.Replace
("_", ""), BindingFlags.Public | BindingFlags.IgnoreCase |
BindingFlags.Instance);
- if (pinfo != null &&
- (pinfo.PropertyType == typeof (Gtk.Widget)
||
- pinfo.PropertyType.IsSubclassOf (typeof
(Gtk.Widget))))
- return pinfo.GetValue
(container.Parent, null) as Gtk.Widget;
+ protected virtual Gtk.Widget FindInternalChild (string
childName)
+ {
+ // The fact that this tends to work does not mean it is
not an
+ // awful kludge
+
+ Gtk.Container ancestor = container;
+ while (ancestor != null) {
+ Gtk.Widget child = FindInternalChild
(childName, ancestor);
+ if (child != null)
+ return child;
+ ancestor = ancestor.Parent as Gtk.Container;
}
Console.WriteLine ("Could not find internal child {0}
of {1}",
@@ -168,10 +171,8 @@
void SiteRemoved (object obj, Gtk.RemovedArgs args)
{
WidgetSite site = args.Widget as WidgetSite;
-
- if (site != null) {
+ if (site != null)
site.OccupancyChanged -= SiteOccupancyChanged;
- }
}
protected virtual void SiteRemoved (WidgetSite site)
Modified: trunk/stetic/libstetic/wrapper/Dialog.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Dialog.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Dialog.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -29,13 +29,25 @@
protected override void Wrap (object obj, bool initialized)
{
+ WidgetSite site;
+
base.Wrap (obj, initialized);
+ Gtk.Dialog dialog = (Gtk.Dialog)Wrapped;
+
+ site = CreateWidgetSite ();
+ dialog.VBox.Reparent (site);
+ dialog.Add (site);
+
+ site = CreateWidgetSite ();
+ dialog.ActionArea.Reparent (site);
+ dialog.VBox.PackEnd (site, false, true, 0);
+
if (!initialized) {
- WidgetSite site = CreateWidgetSite ();
+ site = CreateWidgetSite ();
Gtk.Requisition req;
req.Width = req.Height = 200;
site.EmptySize = req;
- ((Gtk.Dialog)Wrapped).VBox.Add (site);
+ dialog.VBox.Add (site);
}
}
}
Modified: trunk/stetic/libstetic/wrapper/Expander.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Expander.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Expander.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -36,6 +36,26 @@
};
}
+ public override Widget GladeImportChild (string className,
string id,
+ ArrayList propNames,
ArrayList propVals,
+ ArrayList
packingNames, ArrayList packingVals)
+ {
+ if (packingNames.Count == 1 &&
+ (string)packingNames[0] == "type" &&
+ (string)packingVals[0] == "label_item") {
+ ObjectWrapper wrapper =
Stetic.ObjectWrapper.GladeImport (stetic, className, id, propNames, propVals);
+ WidgetSite site = CreateWidgetSite ();
+ site.Add ((Gtk.Widget)wrapper.Wrapped);
+
+ expander.LabelWidget = site;
+ return (Widget)wrapper;
+ } else {
+ return base.GladeImportChild (className, id,
+ propNames,
propVals,
+ packingNames,
packingVals);
+ }
+ }
+
Gtk.Expander expander {
get {
return (Gtk.Expander)Wrapped;
Modified: trunk/stetic/libstetic/wrapper/Image.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Image.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Image.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -25,6 +25,8 @@
return new Gtk.Image (Gtk.Stock.Execute,
Gtk.IconSize.Dialog);
}
+ static Gdk.Pixbuf missing = Gdk.Pixbuf.LoadFromResource
("missing.png");
+
protected override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
@@ -32,7 +34,8 @@
if (useStock) {
stock = Stock;
iconSize = IconSize;
- }
+ } else
+ File = filename;
}
Gtk.Image image {
@@ -92,6 +95,8 @@
}
set {
image.File = filename = value;
+ if (value == "")
+ image.Pixbuf = missing;
}
}
}
Modified: trunk/stetic/libstetic/wrapper/Label.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Label.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Label.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -20,6 +20,13 @@
"Selectable");
}
+ public Label () {}
+
+ public Label (string text)
+ {
+ Wrap (new Gtk.Label (text), false);
+ }
+
protected override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
Modified: trunk/stetic/libstetic/wrapper/Notebook.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Notebook.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Notebook.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -33,6 +33,8 @@
"InsertAfter");
}
+ ArrayList tabs = new ArrayList ();
+
protected override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
@@ -49,9 +51,11 @@
(string)packingVals[0] == "tab") {
ObjectWrapper wrapper =
Stetic.ObjectWrapper.GladeImport (stetic, className, id, propNames, propVals);
WidgetSite site = CreateWidgetSite ();
+ site.Selected += LabelSelected;
site.Add ((Gtk.Widget)wrapper.Wrapped);
notebook.SetTabLabel (notebook.GetNthPage
(notebook.NPages - 1), site);
+ tabs.Add (site);
return (Widget)wrapper;
} else {
return base.GladeImportChild (className, id,
@@ -68,10 +72,16 @@
int InsertPage (int position)
{
- WidgetSite pageSite;
+ WidgetSite labelSite, pageSite;
+ labelSite = CreateWidgetSite ();
+ labelSite.Selected += LabelSelected;
+ Stetic.Wrapper.Label label = new Stetic.Wrapper.Label
("page" + (notebook.NPages + 1).ToString ());
+ labelSite.Add ((Gtk.Widget)label.Wrapped);
+ tabs.Insert (position, labelSite);
+
pageSite = CreateWidgetSite ();
- return notebook.InsertPage (pageSite, null /* FIXME */,
position);
+ return notebook.InsertPage (pageSite, labelSite,
position);
}
[Command ("Go to Previous Page", "Show the previous page",
"CheckPreviousPage")]
@@ -99,6 +109,7 @@
[Command ("Delete Page", "Delete the current page")]
void DeletePage ()
{
+ tabs.RemoveAt (notebook.CurrentPage);
notebook.RemovePage (notebook.CurrentPage);
}
@@ -146,6 +157,16 @@
}
}
+ void LabelSelected (object obj, EventArgs args)
+ {
+ WidgetSite site = obj as WidgetSite;
+ int index = tabs.IndexOf (site);
+ if (index != -1 && index != notebook.CurrentPage) {
+ notebook.CurrentPage = index;
+ site.GrabFocus ();
+ }
+ }
+
public class NotebookChild : Container.ContainerChild {
public static new Type WrappedType = typeof
(Gtk.Notebook.NotebookChild);
Modified: trunk/stetic/libstetic/wrapper/OptionMenu.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/OptionMenu.cs 2005-02-28 18:16:38 UTC
(rev 41294)
+++ trunk/stetic/libstetic/wrapper/OptionMenu.cs 2005-02-28 22:31:18 UTC
(rev 41295)
@@ -21,6 +21,11 @@
protected override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
+ if (optionmenu.Menu == null) {
+ Gtk.Menu menu = new Gtk.Menu ();
+ menu.Show ();
+ optionmenu.Menu = menu;
+ }
}
protected override void GladeImport (string className, string
id, ArrayList propNames, ArrayList propVals)
@@ -48,12 +53,6 @@
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) {
Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Table.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -47,6 +47,24 @@
base.GladeImport (className, id, propNames, propVals);
}
+ public override Widget GladeImportChild (string className,
string id,
+ ArrayList propNames,
ArrayList propVals,
+ ArrayList
packingNames, ArrayList packingVals)
+ {
+ if (packingNames.IndexOf ("x_options") == -1) {
+ packingNames.Add ("x_options");
+ packingVals.Add ("expand|fill");
+ }
+ if (packingNames.IndexOf ("y_options") == -1) {
+ packingNames.Add ("y_options");
+ packingVals.Add ("expand|fill");
+ }
+
+ return base.GladeImportChild (className, id,
+ propNames, propVals,
+ packingNames,
packingVals);
+ }
+
void DoSync ()
{
Sync ();
@@ -358,14 +376,10 @@
protected override void SiteOccupancyChanged (WidgetSite site)
{
Freeze ();
- if (site.Occupied) {
+ if (site.Occupied && AutoSize[site]) {
Gtk.Table.TableChild tc = table[site] as
Gtk.Table.TableChild;
- // FIXME: This check is to workaround a weird
- // gtk warning. Something is going wrong.
- if (tc.Child.Parent == tc.Parent) {
- tc.XOptions = 0;
- tc.YOptions = 0;
- }
+ tc.XOptions = 0;
+ tc.YOptions = 0;
}
Thaw ();
base.SiteOccupancyChanged (site);
Modified: trunk/stetic/libstetic/wrapper/Window.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Window.cs 2005-02-28 18:16:38 UTC (rev
41294)
+++ trunk/stetic/libstetic/wrapper/Window.cs 2005-02-28 22:31:18 UTC (rev
41295)
@@ -65,11 +65,14 @@
{
string modal = GladeUtils.ExtractProperty ("modal",
propNames, propVals);
string type_hint = GladeUtils.ExtractProperty
("type_hint", propNames, propVals);
+ string type = GladeUtils.ExtractProperty ("type",
propNames, propVals);
base.GladeImport (className, id, propNames, propVals);
Modal = (modal == "True");
if (type_hint != null && type_hint.StartsWith
("GDK_WINDOW_TYPE_HINT_"))
TypeHint = (Gdk.WindowTypeHint) Enum.Parse
(typeof (Gdk.WindowTypeHint), type_hint.Substring (21), true);
+ if (type != null && type.StartsWith ("GTK_WINDOW_"))
+ Type = (Gtk.WindowType) Enum.Parse (typeof
(Gtk.WindowType), type.Substring (11), true);
}
[ConnectBefore]
@@ -103,5 +106,15 @@
typeHint = value;
}
}
+
+ Gtk.WindowType type;
+ public Gtk.WindowType Type {
+ get {
+ return type;
+ }
+ set {
+ type = value;
+ }
+ }
}
}
Copied: trunk/stetic/libstetic/wrapper/pixmaps/missing.png (from rev 41281,
trunk/stetic/stetic/missing.png)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches