Author: danw
Date: 2005-03-29 16:36:49 -0500 (Tue, 29 Mar 2005)
New Revision: 42357
Modified:
trunk/stetic/ChangeLog
trunk/stetic/libstetic/HandleWindow.cs
trunk/stetic/libstetic/editor/Image.cs
trunk/stetic/libstetic/wrapper/ButtonBox.cs
trunk/stetic/libstetic/wrapper/Container.cs
trunk/stetic/libstetic/wrapper/Label.cs
trunk/stetic/libstetic/wrapper/Notebook.cs
trunk/stetic/libstetic/wrapper/Table.cs
trunk/stetic/libstetic/wrapper/Widget.cs
trunk/stetic/stetic/ContextMenu.cs
Log:
* libstetic/HandleWindow.cs (SelectionEvent): simplify for gdk#
changes
* libstetic/editor/Image.cs: Use reflection to get the list of
stock IDs rather than Gtk.Stock.ListIds, since the latter will
return 2.6-specific IDs if you have libgtk 2.6.
(Image): pack the combobox into a vbox so it won't expand
incorrectly.
* libstetic/wrapper/ButtonBox.cs (GladeImportChild): fix
ResponseId handling.
* libstetic/wrapper/Container.cs (Select, UnSelect): virtualize
(Delete): new method to delete a widget and replace it with a
Placeholder.
* libstetic/wrapper/Label.cs (Label (string)): pass "true" to Wrap
so it doesn't bash the passed-in label string
* libstetic/wrapper/Notebook.cs (GladeImportChild, InsertPage):
Remove FIXMEs.
(GladeExportChild): fix a leftover WidgetSiteism.
(Select): override this; if a tab is selected, switch to its page.
(ReplaceChild): allow tabs to be replaced, and don't muck things
up when pages get replaced
* libstetic/wrapper/Table.cs (Sync): fix to not get caught in
infinite loops again.
* libstetic/wrapper/Widget.cs (WidgetEvent): simply for gdk#
changes.
(FindWrapper): search all children (not just non-internal ones)
(Delete): new method to delete a widget (by calling
ParentWrapper.Delete)
* stetic/ContextMenu.cs (DoDelete): use Wrapper.Widget.Delete()
Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog 2005-03-29 21:27:09 UTC (rev 42356)
+++ trunk/stetic/ChangeLog 2005-03-29 21:36:49 UTC (rev 42357)
@@ -1,5 +1,44 @@
2005-03-29 Dan Winship <[EMAIL PROTECTED]>
+ * libstetic/HandleWindow.cs (SelectionEvent): simplify for gdk#
+ changes
+
+ * libstetic/editor/Image.cs: Use reflection to get the list of
+ stock IDs rather than Gtk.Stock.ListIds, since the latter will
+ return 2.6-specific IDs if you have libgtk 2.6.
+ (Image): pack the combobox into a vbox so it won't expand
+ incorrectly.
+
+ * libstetic/wrapper/ButtonBox.cs (GladeImportChild): fix
+ ResponseId handling.
+
+ * libstetic/wrapper/Container.cs (Select, UnSelect): virtualize
+ (Delete): new method to delete a widget and replace it with a
+ Placeholder.
+
+ * libstetic/wrapper/Label.cs (Label (string)): pass "true" to Wrap
+ so it doesn't bash the passed-in label string
+
+ * libstetic/wrapper/Notebook.cs (GladeImportChild, InsertPage):
+ Remove FIXMEs.
+ (GladeExportChild): fix a leftover WidgetSiteism.
+ (Select): override this; if a tab is selected, switch to its page.
+ (ReplaceChild): allow tabs to be replaced, and don't muck things
+ up when pages get replaced
+
+ * libstetic/wrapper/Table.cs (Sync): fix to not get caught in
+ infinite loops again.
+
+ * libstetic/wrapper/Widget.cs (WidgetEvent): simply for gdk#
+ changes.
+ (FindWrapper): search all children (not just non-internal ones)
+ (Delete): new method to delete a widget (by calling
+ ParentWrapper.Delete)
+
+ * stetic/ContextMenu.cs (DoDelete): use Wrapper.Widget.Delete()
+
+2005-03-29 Dan Winship <[EMAIL PROTECTED]>
+
* libstetic/WidgetBox.cs:
* libstetic/WidgetSite.cs: GONE!
Modified: trunk/stetic/libstetic/HandleWindow.cs
===================================================================
--- trunk/stetic/libstetic/HandleWindow.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/HandleWindow.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -122,7 +122,7 @@
switch (args.Event.Type) {
case Gdk.EventType.ButtonPress:
- Gdk.EventButton evb = new Gdk.EventButton
(args.Event.Handle);
+ Gdk.EventButton evb =
(Gdk.EventButton)args.Event;
args.RetVal = true;
if (evb.Type == Gdk.EventType.ButtonPress &&
evb.Button == 1) {
@@ -132,7 +132,7 @@
return;
case Gdk.EventType.MotionNotify:
- Gdk.EventMotion evm = new Gdk.EventMotion
(args.Event.Handle);
+ Gdk.EventMotion evm =
(Gdk.EventMotion)args.Event;
args.RetVal = true;
if (!dragHandles)
Modified: trunk/stetic/libstetic/editor/Image.cs
===================================================================
--- trunk/stetic/libstetic/editor/Image.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/editor/Image.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -1,5 +1,6 @@
using System;
using System.Collections;
+using System.Reflection;
namespace Stetic.Editor {
@@ -19,8 +20,21 @@
static Image ()
{
+ ArrayList tmpIds = new ArrayList ();
+
+ // We can't use Gtk.Stock.ListIds, because that returns
different
+ // values depending on what version of libgtk you have
installed...
+ foreach (PropertyInfo info in typeof
(Gtk.Stock).GetProperties (BindingFlags.Public | BindingFlags.Static)) {
+ if (info.CanRead && info.PropertyType == typeof
(string))
+ tmpIds.Add (info.GetValue (null, null));
+ }
+ foreach (PropertyInfo info in typeof
(Gnome.Stock).GetProperties (BindingFlags.Public | BindingFlags.Static)) {
+ if (info.CanRead && info.PropertyType == typeof
(string))
+ tmpIds.Add (info.GetValue (null, null));
+ }
+
ArrayList items = new ArrayList (), nonItems = new
ArrayList ();
- foreach (string id in Gtk.Stock.ListIds ()) {
+ foreach (string id in tmpIds) {
Gtk.StockItem item = Gtk.Stock.Lookup (id);
if (item.StockId == null)
nonItems.Add (id);
@@ -75,9 +89,14 @@
combo.PackStart (iconRenderer, false);
combo.Reorder (iconRenderer, 0);
combo.AddAttribute (iconRenderer, "stock-id",
IconColumn);
- PackStart (combo, true, true, 0);
combo.Changed += combo_Changed;
+ // Pack the combo non-expandily into a VBox so
it doesn't
+ // get stretched to the file button's height
+ Gtk.VBox vbox = new Gtk.VBox (false, 0);
+ vbox.PackStart (combo, true, false, 0);
+ PackStart (vbox, true, true, 0);
+
entry = (Gtk.Entry)combo.Child;
entry.Changed += entry_Changed;
Modified: trunk/stetic/libstetic/wrapper/ButtonBox.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ButtonBox.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/ButtonBox.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -35,22 +35,24 @@
public override Widget GladeImportChild (string className,
string id, Hashtable props, Hashtable childprops)
{
- Gtk.ResponseType response = 0;
+ int response = 0;
string response_id = props["response_id"] as string;
if (response_id != null) {
props.Remove ("response_id");
- response = (Gtk.ResponseType)Int32.Parse
(response_id);
+ response = Int32.Parse (response_id);
}
Widget wrapper = base.GladeImportChild (className, id,
props, childprops);
+ Button button = wrapper as Stetic.Wrapper.Button;
+ if (button != null)
+ button.ResponseId = response;
- if (response == Gtk.ResponseType.Help) {
+ if (response == (int)Gtk.ResponseType.Help) {
Gtk.ButtonBox.ButtonBoxChild bbc =
((Gtk.Container)Wrapped)[((Gtk.Widget)wrapper.Wrapped).Parent] as
Gtk.ButtonBox.ButtonBoxChild;
bbc.Secondary = true;
}
- // FIXME; need to do something useful with the
response_id
return wrapper;
}
}
Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -291,7 +291,7 @@
Gtk.Widget selection;
HandleWindow handles;
- public void Select (Stetic.Wrapper.Widget wrapper)
+ public virtual void Select (Stetic.Wrapper.Widget wrapper)
{
if (wrapper == null)
Select (null, false);
@@ -300,13 +300,13 @@
stetic.Selection = wrapper;
}
- public void UnSelect (Stetic.Wrapper.Widget wrapper)
+ public virtual void UnSelect (Stetic.Wrapper.Widget wrapper)
{
if (selection == wrapper.Wrapped)
Select (null, false);
}
- public void Select (Placeholder ph)
+ public virtual void Select (Placeholder ph)
{
Select (ph, false);
stetic.Selection = null;
@@ -349,6 +349,14 @@
handles.Shape ();
}
+ public void Delete (Stetic.Wrapper.Widget wrapper)
+ {
+ if (wrapper.Wrapped == selection)
+ Select (null, false);
+ ReplaceChild (wrapper.Wrapped, CreatePlaceholder ());
+ wrapper.Wrapped.Destroy ();
+ }
+
protected bool ChildHExpandable (Gtk.Widget child)
{
if (child == dragSource)
Modified: trunk/stetic/libstetic/wrapper/Label.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Label.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/Label.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -24,7 +24,7 @@
public Label (string text)
{
- Wrap (new Gtk.Label (text), false);
+ Wrap (new Gtk.Label (text), true);
}
public override void Wrap (object obj, bool initialized)
Modified: trunk/stetic/libstetic/wrapper/Notebook.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Notebook.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/Notebook.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -47,8 +47,6 @@
if (childprops.Count == 1 &&
((string)childprops["type"]) == "tab") {
ObjectWrapper wrapper =
Stetic.ObjectWrapper.GladeImport (stetic, className, id, props);
Gtk.Widget widget = (Gtk.Widget)wrapper.Wrapped;
-// FIXME widget.Selected += LabelSelected;
-
notebook.SetTabLabel (notebook.GetNthPage
(notebook.NPages - 1), widget);
tabs.Add (widget);
return (Widget)wrapper;
@@ -62,7 +60,7 @@
out Hashtable childprops)
{
Gtk.Widget widget = wrapper.Wrapped as Gtk.Widget;
- if (!tabs.Contains (widget.Parent)) {
+ if (!tabs.Contains (widget)) {
base.GladeExportChild (wrapper, out className,
out internalId,
out id, out props, out
childprops);
return;
@@ -80,13 +78,36 @@
}
}
+ public override void Select (Stetic.Wrapper.Widget wrapper)
+ {
+ int index = tabs.IndexOf (wrapper.Wrapped);
+ if (index != -1 && index != notebook.CurrentPage)
+ notebook.CurrentPage = index;
+ base.Select (wrapper);
+ }
+
+ protected override void ReplaceChild (Gtk.Widget oldChild,
Gtk.Widget newChild)
+ {
+ int index = tabs.IndexOf (oldChild);
+ if (index != -1) {
+ tabs[index] = newChild;
+ Gtk.Widget page = notebook.GetNthPage (index);
+ notebook.SetTabLabel (page, newChild);
+ } else {
+ Gtk.Widget tab = notebook.GetTabLabel
(oldChild);
+ int current = notebook.CurrentPage;
+ base.ReplaceChild (oldChild, newChild);
+ notebook.CurrentPage = current;
+ notebook.SetTabLabel (newChild, tab);
+ }
+ }
+
int InsertPage (int position)
{
Gtk.Widget widget;
Stetic.Wrapper.Label label = new Stetic.Wrapper.Label
("page" + (notebook.NPages + 1).ToString ());
- widget = (Gtk.Widget)label.Wrapped;
-// FIXME widget.Selected += LabelSelected;
+ widget = label.Wrapped;
tabs.Insert (position, widget);
return notebook.InsertPage (CreatePlaceholder (),
widget, position);
@@ -165,16 +186,6 @@
}
}
- void LabelSelected (object obj, EventArgs args)
- {
- Gtk.Widget label = obj as Gtk.Widget;
- int index = tabs.IndexOf (label);
- if (index != -1 && index != notebook.CurrentPage) {
- notebook.CurrentPage = index;
- label.GrabFocus ();
- }
- }
-
public class NotebookChild : Container.ContainerChild {
public static new Type WrappedType = typeof
(Gtk.Notebook.NotebookChild);
Modified: trunk/stetic/libstetic/wrapper/Table.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Table.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/Table.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -82,9 +82,6 @@
children = table.Children;
grid = new Gtk.Widget[NRows,NColumns];
- foreach (Gtk.Widget child in children)
- child.FreezeChildNotify ();
-
// First fill in the placeholders in the grid. If we
find any
// placeholders covering more than one grid square,
remove them.
// (New ones will be created below.)
@@ -124,7 +121,7 @@
w = grid[row,col];
if (w is Placeholder)
table.Remove
(grid[row,col]);
- grid[row,col] = w;
+ grid[row,col] = child;
}
}
}
@@ -144,7 +141,6 @@
w = grid[row,col];
if (w == null) {
w = CreatePlaceholder ();
- w.FreezeChildNotify ();
table.Attach (w, col, col + 1,
row, row + 1);
grid[row,col] = w;
addedPlaceholders = true;
@@ -157,7 +153,9 @@
if (!AutoSize[w])
continue;
tc = table[w] as Gtk.Table.TableChild;
- tc.YOptions = allPlaceholders ?
expandOpts : fillOpts;
+ Gtk.AttachOptions opts =
allPlaceholders ? expandOpts : fillOpts;
+ if (tc.YOptions != opts)
+ tc.YOptions = opts;
}
if (allPlaceholders)
@@ -183,16 +181,15 @@
if (!AutoSize[w])
continue;
tc = table[w] as Gtk.Table.TableChild;
- tc.XOptions = allPlaceholders ?
expandOpts : fillOpts;
+ Gtk.AttachOptions opts =
allPlaceholders ? expandOpts : fillOpts;
+ if (tc.XOptions != opts)
+ tc.XOptions = opts;
}
if (allPlaceholders)
hexpandable = true;
}
- foreach (Gtk.Widget child in table.Children)
- child.ThawChildNotify ();
-
if (addedPlaceholders)
EmitContentsChanged ();
}
Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs 2005-03-29 21:27:09 UTC (rev
42356)
+++ trunk/stetic/libstetic/wrapper/Widget.cs 2005-03-29 21:36:49 UTC (rev
42357)
@@ -63,7 +63,7 @@
if (args.Event.Type != Gdk.EventType.ButtonPress)
return;
- Gdk.EventButton evb = new Gdk.EventButton
(args.Event.Handle);
+ Gdk.EventButton evb = (Gdk.EventButton)args.Event;
int x = (int)evb.X, y = (int)evb.Y;
int erx, ery, wrx, wry;
@@ -87,13 +87,33 @@
}
}
+ class ChildEnumerator : IEnumerable {
+ public ChildEnumerator (Gtk.Container container)
+ {
+ children = new ArrayList ();
+ container.Forall (Add);
+ }
+
+ ArrayList children;
+
+ public void Add (Gtk.Widget widget)
+ {
+ children.Add (widget);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ return children.GetEnumerator ();
+ }
+ }
+
Widget FindWrapper (Gtk.Widget top, int x, int y)
{
Gtk.Container container = top as Gtk.Container;
if (container == null)
return Lookup (top);
- foreach (Gtk.Widget child in container.Children) {
+ foreach (Gtk.Widget child in new ChildEnumerator
(container)) {
Gdk.Rectangle alloc = child.Allocation;
if (alloc.Contains (x, y)) {
Widget wrapper;
@@ -130,6 +150,14 @@
((Container)this).UnSelect (this);
}
+ public void Delete ()
+ {
+ if (ParentWrapper != null)
+ ParentWrapper.Delete (this);
+ else
+ Wrapped.Destroy ();
+ }
+
protected virtual void GladeImport (string className, string
id, Hashtable props)
{
GladeUtils.ImportWidget (stetic, this, className, id,
props);
Modified: trunk/stetic/stetic/ContextMenu.cs
===================================================================
--- trunk/stetic/stetic/ContextMenu.cs 2005-03-29 21:27:09 UTC (rev 42356)
+++ trunk/stetic/stetic/ContextMenu.cs 2005-03-29 21:36:49 UTC (rev 42357)
@@ -117,7 +117,7 @@
void DoDelete (object obj, EventArgs args)
{
- wrapper.Wrapped.Destroy ();
+ wrapper.Delete ();
}
static MenuItem LabelItem (string labelString)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches