Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-12-04 00:02:01 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-12-04 00:02:01 +0400
commit189e4ce8368fa3e8669d196fa40242f8d1f482af (patch)
treec7f887620a9ad5fe0928d03ffc324ad14d3b07ac /Xwt.Gtk
parent69796cae181c18599d42ee0964018c8c463442b2 (diff)
parent94c669a2e9a33b1fd96cfb4e3c22631d73ea0ddd (diff)
Merge branch 'close-window-fixes'
Conflicts: Testing/GtkTestRunner.csproj Testing/WpfTestRunner.csproj
Diffstat (limited to 'Xwt.Gtk')
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend/DialogBackend.cs19
-rw-r--r--Xwt.Gtk/Xwt.GtkBackend/WindowFrameBackend.cs22
2 files changed, 30 insertions, 11 deletions
diff --git a/Xwt.Gtk/Xwt.GtkBackend/DialogBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/DialogBackend.cs
index 6f744817..c6a0af1e 100644
--- a/Xwt.Gtk/Xwt.GtkBackend/DialogBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/DialogBackend.cs
@@ -121,8 +121,6 @@ namespace Xwt.GtkBackend
UpdateButton (btn, buttons[i]);
}
- bool endLoopRequested;
-
public void RunLoop (IWindowFrameBackend parent)
{
// GTK adds a border to the root widget, for some unknown reason
@@ -133,21 +131,26 @@ namespace Xwt.GtkBackend
do {
var res = MessageService.RunCustomDialog (Window, p != null ? p.Window : null);
keepRunning = false;
- endLoopRequested = false;
if (res == (int) Gtk.ResponseType.DeleteEvent) {
- ApplicationContext.InvokeUserCode(delegate {
- keepRunning = !EventSink.OnCloseRequested ();
- });
+ keepRunning = !PerformClose (false);
}
- } while (keepRunning && !endLoopRequested);
+ } while (keepRunning);
}
public void EndLoop ()
{
- endLoopRequested = true;
Window.Respond (Gtk.ResponseType.Ok);
}
+ public override bool Close ()
+ {
+ if (PerformClose (false)) {
+ Window.Respond (Gtk.ResponseType.Ok);
+ return true;
+ } else
+ return false;
+ }
+
public override void GetMetrics (out Size minSize, out Size decorationSize)
{
base.GetMetrics (out minSize, out decorationSize);
diff --git a/Xwt.Gtk/Xwt.GtkBackend/WindowFrameBackend.cs b/Xwt.Gtk/Xwt.GtkBackend/WindowFrameBackend.cs
index 1d5a6b65..91bbd77e 100644
--- a/Xwt.Gtk/Xwt.GtkBackend/WindowFrameBackend.cs
+++ b/Xwt.Gtk/Xwt.GtkBackend/WindowFrameBackend.cs
@@ -246,6 +246,7 @@ namespace Xwt.GtkBackend
case WindowFrameEvent.BoundsChanged:
Window.AddEvents ((int)Gdk.EventMask.StructureMask);
Window.ConfigureEvent += HandleConfigureEvent; break;
+ case WindowFrameEvent.Closed:
case WindowFrameEvent.CloseRequested:
Window.DeleteEvent += HandleCloseRequested; break;
case WindowFrameEvent.Shown:
@@ -262,8 +263,6 @@ namespace Xwt.GtkBackend
switch ((WindowFrameEvent)ev) {
case WindowFrameEvent.BoundsChanged:
Window.ConfigureEvent -= HandleConfigureEvent; break;
- case WindowFrameEvent.CloseRequested:
- Window.DeleteEvent -= HandleCloseRequested; break;
case WindowFrameEvent.Shown:
Window.Shown -= HandleShown; break;
case WindowFrameEvent.Hidden:
@@ -296,9 +295,21 @@ namespace Xwt.GtkBackend
void HandleCloseRequested (object o, Gtk.DeleteEventArgs args)
{
+ args.RetVal = !PerformClose (true);
+ }
+
+ internal bool PerformClose (bool userClose)
+ {
+ bool close = false;
ApplicationContext.InvokeUserCode(delegate {
- args.RetVal = !EventSink.OnCloseRequested ();
+ close = EventSink.OnCloseRequested ();
});
+ if (close) {
+ if (!userClose)
+ Window.Hide ();
+ ApplicationContext.InvokeUserCode(EventSink.OnClosed);
+ }
+ return close;
}
public void Present ()
@@ -308,6 +319,11 @@ namespace Xwt.GtkBackend
Window.Present ();
}
+ public virtual bool Close ()
+ {
+ return PerformClose (false);
+ }
+
public virtual void GetMetrics (out Size minSize, out Size decorationSize)
{
minSize = decorationSize = Size.Zero;