Closing a Gtk::MessageDialog

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Closing a Gtk::MessageDialog

John Emmas-2
Suppose I'm writing an app whose purpose is just to test if something
exists and display an appropriate message box:-

       #include <gtkmm.h>

       int main (int argc, char *argv[])
       {
       Gtk::Main     app ( &argc, &argv );
       Glib::ustring message;

           if ( the_thing_exists () )
               message = "Yes, it existed";
           else
               message = "No, it didn't exist";

           Gtk::MessageDialog mainWnd (message, false,
Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE);

           app.run (mainWnd);

           return 0;
       }

The above code does display a MessageDialog (with the correct text) but
its CLOSE button doesn't close the dialog.  I've tried other buttons (OK
/ CANCEL etc) but none of them seems to close the dialog (which I
assumed would be the default action).  What am I missing here..?

John
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Closing a Gtk::MessageDialog

John Emmas-2
On 17/03/2017 17:57, John Emmas wrote:
>
> its CLOSE button doesn't close the dialog.  I've tried other buttons
> (OK / CANCEL etc) but none of them seems to close the dialog (which I
> assumed would be the default action).  What am I missing here..?
>

Sorry, I should have added that this is gtkmm 2.24 (rather than 3).

John
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Closing a Gtk::MessageDialog

Daniel Boles
You should be calling Dialog::run(), not using the Dialog as a main window. That is not how Dialogs are intended to be used. So I wouldn't be surprised if the close button does not have its intended effect without the nested main loop of Dialog::run() to process it. Though I've never tried what you did there.

Also, Dialogs are supposed to be used with a main (non-dialog) window as parent; running them without a parent is discouraged.


_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Closing a Gtk::MessageDialog

John Emmas-2
On 17/03/2017 19:20, Daniel Boles wrote:
>
> Dialogs are supposed to be used with a main (non-dialog) window as
> parent; running them without a parent is discouraged.
>

Thanks Daniel and Pavlo.  I was getting mixed up with MSVC where
dialog-based main windows are pretty common.

I followed your advice and rearranged things so that the application
will now launch Gtk::MessageDialog as a child dialog (rather than it
actually 'being' a Gtk::MessageDialog) and it's now working as expected.

John
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Loading...