RE: Keep dialogs open and running even if clicking OK



Hi Mikhail!

I will look into this proposal later, just out of curiosity, to see if this too works well.

Thank you for your reply!

Best regards,
Paul


-----Original Message-----
From: Mikhail Titov [mailto:mlt gmx us] 
Sent: den 8 april 2011 18:40
To: Paul Everlund; 'Lex Trotman'; 'gtk-list'
Subject: RE: Keep dialogs open and running even if clicking OK

While I'm using gtkmm I can override MyDialog::on_response(int id) and don't call hide() there. I feel like there should be something inside plain gtk+ as well to validate result within dialog and not a main application.

I guess you can handle signal response not to close dialog at the first place if you don't like an idea of rerunning it.

Mikhail


-----Original Message-----
From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] On Behalf Of Paul Everlund
Sent: Friday, April 08, 2011 8:07 AM
To: Lex Trotman; gtk-list
Subject: RE: Keep dialogs open and running even if clicking OK

Thank you Lex!

It had also crossed my mind to move the validation to the main app, but of some reason I thought it would be neater to have it where it actually should be taken care of. But your solution will work perfectly ok, and actually also, when I think about it, look quite nice.

So, once again, thank you! And thank you for pointing things out about the delete-event. :o)

Best regards,
Paul


---------- Forwarded message ----------
From: Lex Trotman <elextr gmail com>
Date: 8 April 2011 21:41
Subject: Re: Keep dialogs open and running even if clicking OK
To: Paul Everlund <paul everlund axis com>


[...]
> Some pseudo/real-code maybe describes it better:
>
> class MainApp
>  def initialize()
>    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
>  end
>
>  def on_menuUserPassword_activate(widget)
>    gUP = UserPasswordDlgGlade.new()
>    dlg = gUP.get_widget("UPDlg")
>    dlg.show()
>    result = dlg.run()

Suggest you do the validation here and if it fails, show the fail message then loop back to dlg.run to give them another go, note you haven't hidden the dialog yet so the user won't see any change.

Go on to hide and destroy the dialog when the UP is correct or give up.

>    dlg.hide()
>  end
> end
>
> // Get the main app up and running.
> MainApp.new()
> Gtk.main
>
> class UserPasswordDlgGlade
>  def initialize()
>    @glade = GladeXML.new(bla, bla, bla) {|handler| method(handler)}
>  end
>
>  def on_btnApply_clicked(widget)
>    Get the user and password from the widget entries
>    If user and password were not valid

do this in main

>      gMsg = MessageDlgGlade.new()
>      dlg = gMsg.get_widget("MsgDlg")
>      dlg.show()
>      dlg.run()
>      dlg.close()
>      If here the user clicked the message dialog's OK button, and we should disregard the Apply click on this UPDlg, and let the user correct the input.
>    else
>      The user and password was correct, so now we should actually return the Apply response code to the MainApp.
>    end
>  end
>
>  def on_UPDlg_delete_event(a, b, c)
>    Here was where I tried to keep the UPDlg still running, by returning either TRUE or FALSE, but it never seemed to  enter this function, even though I connected this signal in Glade.
>  end
> end

As documented, delete isn't emitted on dialogs:

"If a dialog receives a delete event, the "response" signal will be emitted with a response ID of GTK_RESPONSE_DELETE_EVENT. "

Cheers
Lex
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]