[Gtk-sharp-list] Good resource for learning how to build graphical applications inside monodevelop.

Adam Tauno Williams awilliam at whitemice.org
Mon Feb 9 13:01:04 EST 2009

On Mon, 2009-02-09 at 17:27 +0000, Neil Munro wrote:
> Alright specific questions it is then. 
> I have created my main application window, but before it opens another
> user authentication window should open and alert the user to the fact
> that if they are not root then they need to close the application and
> run it as root, and I learned how to display a dialog window, but the
> user clicking ok or the close button closes the dialog bur the main
> window does not close, I had the function to display the window
> include only two lines:
> UserWindow uw = new UserWindow( );
> Application.Quit( );
> Also I was unable to close the window in the
> UserWindow.BTN_OK_Clicked( ) method I could hide it, and with the
> desired outcome being the application would then close I wasn't too
> concerned about the window hiding and not being closed. So if someone
> could assist me in finding examples of this I would be very grateful.


void on_btn_clicked (object obj, EventArgs args)
  dialog = new Dialog
           ("Sample", win, Gtk.DialogFlags.DestroyWithParent);
  dialog.Modal = true;
  dialog.AddButton ("Close", ResponseType.Close);
  dialog.Response += new ResponseHandler (on_dialog_response);
  dialog.Run ();
  dialog.Destroy ();
void on_dialog_response (object obj, ResponseArgs args)
  Console.WriteLine (args.ResponseId);

If your dialog is a Dialog created in Stetic (Monodevelop) then you just
create that class instead of Dialog;  you can assign ResponseType
buttons in Stetic.  In on_dialog_response just execute
Application.Quit() if the response is appropriate to that action.

More information about the Gtk-sharp-list mailing list