[Gtk-sharp-list] How to show dialog modal and wait for it?
Rafa
galvesband at gmail.com
Fri Dec 25 05:47:37 EST 2009
On Viernes, 25 de Diciembre de 2009 10:20:05 Maciej Pilichowski escribió:
> Neither Hide or passing null changes anything. The result is -7.
>
> Maybe I rephrase my wish to be more precise -- when I call modal
> dialog I would like the events in main dialog won't be run in
> parallel. Because some events in main dialog cause the modal dialog
> to show up, and if they are run in parallel I end up with several
> error dialog boxes informing user that (for example) loading of data
> were not successful.
>
> Cheers,
I'm a big noob in Gtk#, but i'll try to help.
Are you sure the error is there? I say it becouse your code example works in
my workstation. See the next code:
using System;
using Gtk;
namespace deleteme
{
public class EmptyWindow : Gtk.Window
{
public EmptyWindow() : base(WindowType.Toplevel) {
Button b = new Button("Do something");
b.Clicked += HandleBClicked;
Button b2 = new Button("Do other thing");
b2.Clicked += HandleB2Clicked;
HButtonBox box = new HButtonBox();
box.PackStart(b, false, false, 0);
box.PackStart(b2, false, false, 0);
this.Add(box);
this.Title = "Lame example";
this.ShowAll();
}
void HandleBClicked (object sender, EventArgs e) {
MessageDialog md = new MessageDialog(this, DialogFlags.Modal,
MessageType.Error, ButtonsType.Close, "Some error");
md.Response += delegate(object o, ResponseArgs args) {
if (args.ResponseId == ResponseType.Close)
Console.WriteLine("Response: Closed");
else
Console.WriteLine("Other response happened.");
};
md.Run();
md.Destroy();
}
void HandleB2Clicked (object sender, EventArgs e) {
MessageDialog md = new MessageDialog(this, DialogFlags.Modal,
MessageType.Error, ButtonsType.Close, "some error");
md.Run ();
// <-- here, I would like to stop and wait for dialog to be closed
md.Destroy();
}
}
}
There you have the example I was writing to ilustrate the technique and your
code example. Both works for me. In fact they are actually pretty much the
same, but using a delegate to receive the response event and destroying the
dialog just after run().
Maybe you are hitting some bug?
More information about the Gtk-sharp-list
mailing list