Re: basic libglademm and design questions
- From: "Markus" <gnufriend gmx de>
- To: gtkmm-list gnome org
- Cc: gtkmm-list gnome org
- Subject: Re: basic libglademm and design questions
- Date: Sun, 01 Jul 2007 23:25:18 +0200
>> 1. the examples always name the variables for GUI elements pButton or
>> m_pButton. Why does they use the "p"? What does it stands for?
>
> Rather than creating an actual Gtk::Button element you create a pointer
> to a button, therefore the p.
Thank you. Sounds quite logical.
> Can't answer the other questions because I handcode my UI. I'm sure
> glade has some auto code constructors for providing signal handlers and
> connecting them for you, thereby producing skeleton code. Ah yes indeed
> it does. If you click on the "Signals" tab in the interface designer for
> a certain object you will see that you can name the handler and even
> handled objects directly there.
Thanks for your answer.
Yes you can define the signals in glade. You can also create C++ code out of glade but is
recommend to don't use it and use instead the xml file with libglademm. Libglade also offers a
"autoconnect" function for many languages to automatically connect all defined signals to the
methods within one class but libglademm doesn't have this functionality. Therefore you have
to do it by hand. I just wonder if there are some "tricks" to make it a little bit easier and more
"sexy" and repeat many times line for line the same 4 lines. I have already thought about
something like defining a array with strings of all widgets and functions and than do the
connect in a for loop. Something like this:
char* signals[SIGNALS_NUM][2] = {
{"widget-1", "callback-1"},
{"widget-2", "callback-2"},
{"widget-3", "callback-3"},
{"widget-N", "callback-N"}
};
for (i = 0; i < SIGNALS_NUM; i++) {
/* take widget-X out of the xml file and connect the callback-X */
m_refGlade->get_widget(signals[i][0], m_pWidget);
if(m_pWidget) {
m_pWidget->signal_clicked().connect( sigc::mem_fun(*this, signals[i][1]) );
}
}
But this would obvious not work. I could use this to get the widget because get_widget() wants
a string for the name of the widget but the signal_clicked() couldn't handle the name of the
callback-method as a string.
Hope someone else can answer my question 2 and 3.
Also a answer like "you have to write the get_widget() and connect() for every widget by hand
and there is no way to make it more "sexy"" for question 3 would help. I just want to know if i
do it right if i write it that way or if there is a way to do it in a shorter way.
Thanks!
Markus
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]