Author: lluis
Date: 2008-01-21 09:57:55 -0500 (Mon, 21 Jan 2008)
New Revision: 93395

Modified:
   trunk/stetic/ChangeLog
   trunk/stetic/libstetic/wrapper/CheckButton.cs
   trunk/stetic/libstetic/wrapper/Container.cs
   trunk/stetic/libstetic/wrapper/Frame.cs
   trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
   trunk/stetic/libsteticui/GuiDispatchServerSink.cs
   trunk/stetic/libsteticui/Project.cs
   trunk/stetic/libsteticui/WidgetDesigner.cs
Log:
* libsteticui/GuiDispatchServerSink.cs, libsteticui/WidgetDesigner.cs,
  libsteticui/Project.cs: Made events fired by the designer
  synchronous. Fixes some criticals caused by events being fired in
  the wrong order.
* libstetic/wrapper/Frame.cs, libstetic/wrapper/CheckButton.cs,
  libstetic/wrapper/Container.cs,
  libstetic/wrapper/ScrolledWindow.cs: Fix some gtk warnings and
  criticals.

Modified: trunk/stetic/ChangeLog
===================================================================
--- trunk/stetic/ChangeLog      2008-01-21 14:41:54 UTC (rev 93394)
+++ trunk/stetic/ChangeLog      2008-01-21 14:57:55 UTC (rev 93395)
@@ -1,3 +1,12 @@
+2008-01-21  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
+       * libsteticui/GuiDispatchServerSink.cs, libsteticui/WidgetDesigner.cs,
+         libsteticui/Project.cs: Made events fired by the designer synchronous.
+         Fixes some criticals caused by events being fired in the wrong order.
+       * libstetic/wrapper/Frame.cs, libstetic/wrapper/CheckButton.cs,
+         libstetic/wrapper/Container.cs, libstetic/wrapper/ScrolledWindow.cs: 
Fix
+         some gtk warnings and criticals.
+
 2008-01-16  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * libsteticui/WidgetDesigner.cs: Fix typo.

Modified: trunk/stetic/libstetic/wrapper/CheckButton.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/CheckButton.cs       2008-01-21 14:41:54 UTC 
(rev 93394)
+++ trunk/stetic/libstetic/wrapper/CheckButton.cs       2008-01-21 14:57:55 UTC 
(rev 93395)
@@ -46,13 +46,17 @@
 
                internal void RemoveLabel ()
                {
-                       if (checkbutton.Child != null)
-                               checkbutton.Remove (checkbutton.Child);
-
                        AddPlaceholder ();
                        HasLabel = false;
                }
 
+               public override Placeholder AddPlaceholder ()
+               {
+                       if (checkbutton.Child != null)
+                               checkbutton.Remove (checkbutton.Child);
+                       return base.AddPlaceholder ();
+               }
+               
                internal void RestoreLabel ()
                {
                        checkbutton.Label = checkbutton.Name;

Modified: trunk/stetic/libstetic/wrapper/Container.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Container.cs 2008-01-21 14:41:54 UTC (rev 
93394)
+++ trunk/stetic/libstetic/wrapper/Container.cs 2008-01-21 14:57:55 UTC (rev 
93395)
@@ -1093,7 +1093,8 @@
 
                void SelectionDestroyed (object obj, EventArgs args)
                {
-                       UnSelect (selection);
+                       if (!IsDisposed)
+                               UnSelect (selection);
                }
 
                Gtk.Widget dragSource;

Modified: trunk/stetic/libstetic/wrapper/Frame.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/Frame.cs     2008-01-21 14:41:54 UTC (rev 
93394)
+++ trunk/stetic/libstetic/wrapper/Frame.cs     2008-01-21 14:57:55 UTC (rev 
93395)
@@ -28,7 +28,7 @@
 
                void LabelWidgetChanged (object obj, GLib.NotifyArgs args)
                {
-                       if (frame.LabelWidget != null && !(frame.LabelWidget is 
Stetic.Placeholder))
+                       if (!IsDisposed && frame.LabelWidget != null && 
!(frame.LabelWidget is Stetic.Placeholder))
                                ObjectWrapper.Create (proj, frame.LabelWidget);
                }
 
@@ -79,5 +79,12 @@
                        else
                                base.ReplaceChild (oldChild, newChild);
                }
+
+               public override void Delete (Stetic.Placeholder ph)
+               {
+                       using (UndoManager.AtomicChange) {
+                               Delete ();
+                       }
+               }
        }
 }

Modified: trunk/stetic/libstetic/wrapper/ScrolledWindow.cs
===================================================================
--- trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2008-01-21 14:41:54 UTC 
(rev 93394)
+++ trunk/stetic/libstetic/wrapper/ScrolledWindow.cs    2008-01-21 14:57:55 UTC 
(rev 93395)
@@ -102,5 +102,11 @@
                                base.GenerateChildBuildCode (ctx, parentVar, 
wrapper);
                }
 
+               public override void Delete (Stetic.Placeholder ph)
+               {
+                       using (UndoManager.AtomicChange) {
+                               Delete ();
+                       }
+               }
        }
 }

Modified: trunk/stetic/libsteticui/GuiDispatchServerSink.cs
===================================================================
--- trunk/stetic/libsteticui/GuiDispatchServerSink.cs   2008-01-21 14:41:54 UTC 
(rev 93394)
+++ trunk/stetic/libsteticui/GuiDispatchServerSink.cs   2008-01-21 14:57:55 UTC 
(rev 93395)
@@ -115,4 +115,28 @@
                }
        }
        
+       class GuiDispatch
+       {
+               public static void InvokeSync (EventHandler h)
+               {
+                       if (GLib.MainContext.Depth > 0)
+                               h (null, null);
+                       else {
+                               object wo = new object ();
+                               lock (wo) {
+                                       Gtk.Application.Invoke (delegate {
+                                               try {
+                                                       h (null, null);
+                                               } finally {
+                                                       lock (wo) {
+                                                               
System.Threading.Monitor.PulseAll (wo);
+                                                       }
+                                               }
+                                       });
+                                       System.Threading.Monitor.Wait (wo);
+                               }
+                       }
+               }
+       }
+       
 }

Modified: trunk/stetic/libsteticui/Project.cs
===================================================================
--- trunk/stetic/libsteticui/Project.cs 2008-01-21 14:41:54 UTC (rev 93394)
+++ trunk/stetic/libsteticui/Project.cs 2008-01-21 14:57:55 UTC (rev 93395)
@@ -475,7 +475,7 @@
                
                internal void NotifyWidgetAdded (object obj, string name, 
string typeName)
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate {
                                        Component c = App.GetComponent (obj, 
name, typeName);
                                        if (c != null) {
@@ -493,7 +493,7 @@
                
                internal void NotifyWidgetRemoved (string name)
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate {
                                        WidgetInfo wi = GetWidget (name);
                                        if (wi != null) {
@@ -507,7 +507,7 @@
                
                internal void NotifyModifiedChanged ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate {
                                        if (ModifiedChanged != null)
                                                ModifiedChanged (this, 
EventArgs.Empty);
@@ -517,7 +517,7 @@
                
                internal void NotifyChanged ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate {
                                        if (Changed != null)
                                                Changed (this, EventArgs.Empty);
@@ -543,7 +543,7 @@
                                        wi.NotifyNameChanged (newName);
                        }
                        
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate {
                                        if (c != null) {
                                                if (ComponentNameChanged != 
null)
@@ -555,7 +555,7 @@
                
                internal void NotifyActionGroupAdded (string group)
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                ActionGroupInfo gi = GetActionGroup (group);
                                if (gi == null) {
                                        gi = new ActionGroupInfo (this, group);
@@ -568,7 +568,7 @@
                
                internal void NotifyActionGroupRemoved (string group)
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                ActionGroupInfo gi = GetActionGroup (group);
                                if (gi != null) {
                                        groups.Remove (gi);
@@ -580,7 +580,7 @@
                
                internal void NotifySignalAdded (object obj, string name, 
Signal signal)
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (SignalAdded != null) {
                                        Component c = App.GetComponent (obj, 
name, null);
                                        if (c != null)
@@ -591,7 +591,7 @@
                
                internal void NotifySignalRemoved (object obj, string name, 
Signal signal)
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (SignalRemoved != null) {
                                        Component c = App.GetComponent (obj, 
name, null);
                                        if (c != null)
@@ -602,7 +602,7 @@
                
                internal void NotifySignalChanged (object obj, string name, 
Signal oldSignal, Signal signal)
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (SignalChanged != null) {
                                        Component c = App.GetComponent (obj, 
name, null);
                                        if (c != null)
@@ -613,7 +613,7 @@
                
                internal void NotifyProjectReloaded ()
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (ProjectReloaded != null)
                                        ProjectReloaded (this, EventArgs.Empty);
                        });
@@ -621,7 +621,7 @@
                
                internal void NotifyProjectReloading ()
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (ProjectReloading != null)
                                        ProjectReloading (this, 
EventArgs.Empty);
                        });
@@ -629,7 +629,7 @@
                
                internal void NotifyComponentTypesChanged ()
                {
-                       Gtk.Application.Invoke (delegate {
+                       GuiDispatch.InvokeSync (delegate {
                                if (ComponentTypesChanged != null)
                                        ComponentTypesChanged (this, 
EventArgs.Empty);
                        });
@@ -639,23 +639,9 @@
                {
                        if (importFileDelegate != null) {
                                string res = null;
-                               if (Gtk.Main.Level () > 0) {
-                                       return importFileDelegate (filePath);
-                               }
-
-                               object ob = new Object ();
-                               lock (ob) {
-                                       Gtk.Application.Invoke (delegate {
-                                               lock (ob) {
-                                                       try {
-                                                               res = 
importFileDelegate (filePath);
-                                                       } finally {
-                                                               
System.Threading.Monitor.PulseAll (ob);
-                                                       }
-                                               }
-                                       });
-                                       System.Threading.Monitor.Wait (ob);
-                               }
+                               GuiDispatch.InvokeSync (delegate {
+                                       res = importFileDelegate (filePath);
+                               });
                                return res;
                        }
                        else

Modified: trunk/stetic/libsteticui/WidgetDesigner.cs
===================================================================
--- trunk/stetic/libsteticui/WidgetDesigner.cs  2008-01-21 14:41:54 UTC (rev 
93394)
+++ trunk/stetic/libsteticui/WidgetDesigner.cs  2008-01-21 14:57:55 UTC (rev 
93395)
@@ -387,42 +387,42 @@
                
                public void NotifyBindField ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifyBindField (); }
                        );
                }
                
                public void NotifyModifiedChanged ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifyModifiedChanged (); }
                        );
                }
                
                public void NotifyChanged ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifyChanged (); }
                        );
                }
                
                internal void NotifySelectionChanged (object ob, bool canCut, 
bool canCopy, bool canPaste, bool canDelete)
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifySelectionChanged (ob, canCut, canCopy, canPaste, canDelete); }
                        );
                }
 
                public void NotifyRootWidgetChanged ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifyRootWidgetChanged (); }
                        );
                }
 
                public void NotifyRootWidgetChanging ()
                {
-                       Gtk.Application.Invoke (
+                       GuiDispatch.InvokeSync (
                                delegate { if (!disposed) 
designer.NotifyRootWidgetChanging (); }
                        );
                }

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to