Verifying input data before gtk_dialog_run returns

2007-03-21 Thread Jaap Haitsma
Hi,

Is there a recommended way to check if the data in a dialog is valid
when the user  presses the OK button? If the data is not OK I want to
present a modal dialog saying there is an error. If the user closes
that dialog the user can correct the error and press OK again.

The concrete case I'm looking at is in a file save dialog where I want
to check if a user entered a valid file extension when he/she presses
the save button.

Thanks

Jaap
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Verifying input data before gtk_dialog_run returns

2007-03-21 Thread Jaap Haitsma
On 3/21/07, David Nečas (Yeti) [EMAIL PROTECTED] wrote:
 On Wed, Mar 21, 2007 at 10:51:42PM +0100, Jaap Haitsma wrote:
  Is there a recommended way to check if the data in a dialog is valid
  when the user  presses the OK button? If the data is not OK I want to
  present a modal dialog saying there is an error. If the user closes
  that dialog the user can correct the error and press OK again.

 You can read the values, otherwise you would not be able to
 use the dialog at all.

 The dialog does not close itself on OK, you always
 explicitly destroy it.

 So you can read the values and *not* destroy the dialog if
 you don't like them (and display another dialog, etc.),
 right?  See also the recusrive dialogs in my last post
 (http://mail.gnome.org/archives/gtk-app-devel-list/2007-March/msg00154.html).

So the recommended way to do it is just do the following (in pseudo code)

do {
   response = gtk_dialog_run ()
} while (response == OK  !validated )

I thought of using this but it did not really seem like an elegant way
to do it. I was thinking that there might be some signal handler which
could do the checking and that gtk_dialog_run would only return if OK
was pressed and the data was valid

Jaap
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Verifying input data before gtk_dialog_run returns

2007-03-21 Thread Yeti
On Wed, Mar 21, 2007 at 11:56:36PM +0100, Jaap Haitsma wrote:
 So the recommended way to do it is just do the following (in pseudo code)
 
 do {
response = gtk_dialog_run ()
 } while (response == OK  !validated )
 
 I thought of using this but it did not really seem like an elegant way
 to do it.

If the dialog is modal, then this clearly expresses what's
going on.

 I was thinking that there might be some signal handler which
 could do the checking and that gtk_dialog_run would only return if OK
 was pressed and the data was valid

If the dialog is not modal or you like it the hard^welegant
way, do not use gtk_dialog_run(), set up a response
handler and put all the logic there.

Whatever you did before, just continue doing it.  Mixing
gtk_dialog_run() with a response handler is good only for
obfuscation...

Yeti

--
http://gwyddion.net/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list