Re: code explanation and a question about signals



On Tue, 2007-10-16 at 23:50 -0400, Tralfas D wrote:
> i was reading over the source for the range widget example and i was
> wonder why this was there 
> 
> #ifndef GTKMM_DISABLE_DEPRECATED
> Gtk::OptionMenu m_OptionMenu;
> #endif //GTKMM_DISABLE_DEPRECATED
> 
> why is it in ifndef? i looked up some stuff about it im guessing it
> means it is showing newer code for option menus and disabling old
> obselete code. 


Gtk::OptionMenu is deprecated. If you need a similar widget you should
use Gtk::ComboBox

> and then another random thought i had was about signals. i wanted to
> make two buttons do different things when clicked but i dont know how
> to connect them to a on_button_clicked. can there be multiple
> on_button_clicked signals or only one and then you have to use a new
> signal. 
> 
on_button_clicked is just a callback, you can create different callbacks
for different widgets, i.e.:


button1.signal_clicked().connect(sigc::mem_fun(*this, &Something::foo));

button2.signal_clicked().connect(sigc::mem_fun(*this, &Something::bar));

//...

void Something::foo() { std::cout << "button 1 clicked\n"; }
void Something::bar() { std::cout << "button 2 clicked\n"; }

To learn more about signals, you could read sigc++ tutorial:
http://libsigc.sourceforge.net/libsigc2/docs/manual/html/index.html

Regards,

s.



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