Re: A signal for Gtk::MessageDialog



On Thursday 28 December 2006 03:03, Jamiil Abduqadir wrote:
> Hello,
> I am writing a class that derives from 'Gtk::MessageDialog'. What does the
> class do? you got it, it displays a dialog box with some information on it.
> Now, to the problem. Just like any 'Gtk::MessageDialog' it has a button in
> there that I need to connect to a signal, but since I don't know the name
> of the button, I cannot write something like
>
> Mybutton.signal_clicked().connect(sigc::ptr_fun(&on_button_clicked));

Gtk::MessageDialog derives from Gtk::Dialog which has a 
Gtk::Dialog::get_action_area() method returning a pointer to its 
Gtk::HButtonBox member.  Gtk::HButtonBox derives from Gtk::Box and you can 
obtain its childer (the buttons) with Gtk::Box::children().

However you should rarely need to do that.  You can just connect to 
Gtk::Dialog::signal_response signal.  The response_id parameter will indicate 
which button was pressed (if the dialog has more than one button).

Chris




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