Re: Question about Callback
- From: Rudolfo Pinewood <rudolfo pinewood googlemail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Question about Callback
- Date: Mon, 12 Jan 2009 21:05:33 +0100
Hi,
I think I should post some more lines of "my" code... as a sidenote: I
did not do much c++ programming before, neither anything with GTK.
Here is a link to what I have (actually):
http://ufoai.svn.sourceforge.net/viewvc/ufoai/ufoai/trunk/src/tools/radiant/radiant/sidebar/surfaceinspector.cpp?revision=21479&view=markup&pathrev=21796
I wanted to enhance ApplyFlags function (starting at line 957) to get an
additional parameter regarding the button/nonModalEntry that was
changed. For this I defined another class as following:
class ChangeIndicator
{
public:
const unsigned int m_surfaceBtnMask; /**< indicator about changed
surface button */
const unsigned int m_contentBtnMask; /**< indicator about changed
content button */
const bool m_valueChanged; /**< indicator, that value field was changed */
ChangeIndicator (const unsigned int surfaceBtnMask, const unsigned int
contentBtnMask, const bool valueChanged) :
m_surfaceBtnMask(surfaceBtnMask), m_contentBtnMask(contentBtnMask),
m_valueChanged(valueChanged)
{
}
};
for m_ValueEntry I would like to use ChangeIndicator(0, 0, true), for
the buttons something like ChangeIndicator(1<<btnid,0,false)
My problem is that I don't know where to put these values, as something
like ApplyFlagsCaller(*this, ChangeIndicator(1 << id, 0, false)))
is not working (obviously because Membercaller only has a Constructor
with an Environment).
Any help is welcome.
Greetings,
Christoph Hartwig
On Sun, 11 Jan 2009 12:42:41 +0100
Rudolfo Pinewood <rudolfo pinewood googlemail com> wrote:
> I have several togglebuttons, that are all registered to call one
> specific function (ApplyFlags). In this function I actually don't know
> which button was activated.
>
> My attempt was giving each button/callback an additional parameter that
> should be passed to my ApplyFlags function.
You yet have the caller widget in ApplyFlags(). If you're using
g_signal_connect_swapped(), just use the second arg:
void ApplyFlags(gpointer your_data, GtkWidget *button)
Ciao
--
Nicola
Rudolfo Pinewood schrieb:
Hi,
I have a question regarding Callback functions for Toggle buttons.
I have several togglebuttons, that are all registered to call one
specific function (ApplyFlags). In this function I actually don't know
which button was activated.
My attempt was giving each button/callback an additional parameter that
should be passed to my ApplyFlags function.
However I was not able to do so - MemberCaller1 seems to fit (regarding
the "call one function with one parameter") but I did not manage to get
my parameter into that Callback in
g_signal_connect_swapped(G_OBJECT(button), "toggled",
G_CALLBACK(callback.getThunk()), callback.getEnvironment()).
How could this be done?
Thanks in advance
Christoph Hartwig
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]