Author: danw
Date: 2005-07-08 13:37:00 -0400 (Fri, 08 Jul 2005)
New Revision: 47114

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/wrapper/Widget.cs
Log:
        * libstetic/wrapper/Widget.cs (InsensitiveManager): track
        realize/unrealize events and only create the intercepting window
        when the underlying widget is realized, or else it will end up as
        a child of the root window and we'll totally lose.


Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2005-07-08 17:17:14 UTC (rev 47113)
+++ trunk/stetic/ChangeLog      2005-07-08 17:37:00 UTC (rev 47114)
@@ -1,5 +1,12 @@
 2005-07-08  Dan Winship  <[EMAIL PROTECTED]>
 
+       * libstetic/wrapper/Widget.cs (InsensitiveManager): track
+       realize/unrealize events and only create the intercepting window
+       when the underlying widget is realized, or else it will end up as
+       a child of the root window and we'll totally lose.
+
+2005-07-08  Dan Winship  <[EMAIL PROTECTED]>
+
        * libstetic/wrapper/objects.xml: add <glade-transform> nodes with
        XSL transformations to fix some oddities in the glade file format.
        (GtkHButtonBox): set the "secondary" property on a Help button

Modified: trunk/stetic/libstetic/wrapper/Widget.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Widget.cs    2005-07-08 17:17:14 UTC (rev 
47113)
+++ trunk/stetic/libstetic/wrapper/Widget.cs    2005-07-08 17:37:00 UTC (rev 
47114)
@@ -265,36 +265,31 @@
                public static void Add (Widget wrapper)
                {
                        Gtk.Widget widget = wrapper.Wrapped;
-                       Gdk.WindowAttr attributes;
 
-                       attributes = new Gdk.WindowAttr ();
-                       attributes.WindowType = Gdk.WindowType.Child;
-                       attributes.Wclass = Gdk.WindowClass.InputOnly;
-                       attributes.Mask = Gdk.EventMask.ButtonPressMask;
-
-                       Gdk.Window win = new Gdk.Window (widget.GdkWindow, 
attributes, 0);
-                       win.UserData = invis.Handle;
-                       win.MoveResize (widget.Allocation);
-                       win.Show ();
-
-                       map[widget] = win;
-                       map[win] = widget;
                        widget.SizeAllocated += Insensitive_SizeAllocate;
+                       widget.Realized += Insensitive_Realized;
+                       widget.Unrealized += Insensitive_Unrealized;
                        widget.Mapped += Insensitive_Mapped;
                        widget.Unmapped += Insensitive_Unmapped;
+
+                       if (widget.IsRealized)
+                               Insensitive_Realized (widget, EventArgs.Empty);
+                       if (widget.IsMapped)
+                               Insensitive_Mapped (widget, EventArgs.Empty);
                }
 
                public static void Remove (Widget wrapper)
                {
                        Gtk.Widget widget = wrapper.Wrapped;
                        Gdk.Window win = (Gdk.Window)map[widget];
-                       if (win == null)
-                               return;
-
-                       map.Remove (widget);
-                       map.Remove (win);
-                       win.Destroy ();
+                       if (win != null) {
+                               map.Remove (widget);
+                               map.Remove (win);
+                               win.Destroy ();
+                       }
                        widget.SizeAllocated -= Insensitive_SizeAllocate;
+                       widget.Realized -= Insensitive_Realized;
+                       widget.Unrealized -= Insensitive_Unrealized;
                        widget.Mapped -= Insensitive_Mapped;
                        widget.Unmapped -= Insensitive_Unmapped;
                }
@@ -302,9 +297,27 @@
                static void Insensitive_SizeAllocate (object obj, 
Gtk.SizeAllocatedArgs args)
                {
                        Gdk.Window win = (Gdk.Window)map[obj];
-                       win.MoveResize (args.Allocation);
+                       if (win != null)
+                               win.MoveResize (args.Allocation);
                }
 
+               static void Insensitive_Realized (object obj, EventArgs args)
+               {
+                       Gtk.Widget widget = (Gtk.Widget)obj;
+
+                       Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
+                       attributes.WindowType = Gdk.WindowType.Child;
+                       attributes.Wclass = Gdk.WindowClass.InputOnly;
+                       attributes.Mask = Gdk.EventMask.ButtonPressMask;
+
+                       Gdk.Window win = new Gdk.Window (widget.GdkWindow, 
attributes, 0);
+                       win.UserData = invis.Handle;
+                       win.MoveResize (widget.Allocation);
+
+                       map[widget] = win;
+                       map[win] = widget;
+               }
+
                static void Insensitive_Mapped (object obj, EventArgs args)
                {
                        Gdk.Window win = (Gdk.Window)map[obj];
@@ -316,5 +329,13 @@
                        Gdk.Window win = (Gdk.Window)map[obj];
                        win.Hide ();
                }
+
+               static void Insensitive_Unrealized (object obj, EventArgs args)
+               {
+                       Gdk.Window win = (Gdk.Window)map[obj];
+                       win.Destroy ();
+                       map.Remove (obj);
+                       map.Remove (win);
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to