Re: [gtk-list] Re: Callback function troubles
- From: Brandon Long <blong fiction net>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Callback function troubles
- Date: Fri, 25 Sep 1998 15:52:04 -0700
On 09/25/98 Greg Kaup uttered the following other thing:
> Brent Briggs wrote:
> >
> > I have been working on a robotics program and have never been able to
> > get my widgets to call my functions the way that I want them to.
> > I have a callback function that looks like this:
> >
> > void init_arm_callback(GtkWidget *widget, GdkEvent *event,
> > command_struct *data)
> > {
> > cout << "data in init_arm_callback :\n";
> > cout << "data->fdesrcipter " << data->fdescripter << "\n";
> > arm_initialize(data);
> > }
> >
> ...
> > I am calling this callback with a button like so:
> >
> > /*setup the initialize button */
> > button = gtk_button_new_with_label ("Re-Initialize");
> > gtk_container_add (GTK_CONTAINER (control_vbox), button);
> > gtk_widget_show (button);
> > gtk_signal_connect (GTK_OBJECT (button), "clicked",
> > GTK_SIGNAL_FUNC (init_arm_callback),
> > &command_data);
> >
> > The values in the structure seem to get changed when the data is passed
> > fron gtk_signal_connect (......) to init_arm_callback(........). For
> > instance, command_data.fdescripter has a value of 3 when checked from
> > main but when the same value is checked from
> > init_arm_callback(........) I get a value of something like 607312 . Why
> > is this happening? This doesn't make sense to me but then again I am a
> > newbie to GTK developement. Can someone Please help me out?
> >
>
> I've been having the same type of problems... PLEASE try your callback
> WITHOUT the GdkEvent *event arg... i.e.
> void init_arm_callback(GtkWidget *widget, (gpointer)data)
> {
> command_struct *ptr = (command_struct*)data;
> then... use the ptr!
> }
>
> I've been getting the "data" in the second arg... I'm still trying to
> figure out if it is g++ 2.7.2.3, the cvs version of gtk+ or some silly
> thing I'm doing wrong! If you are having the same problem, maybe we
> can narrow it down.
You are using C++?
Left field guess, you might need to wrap your function header with:
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#ifdef __cplusplus
}
#endif /* __cplusplus */
maybe.
Brandon
--
Brandon Long
MD6 Crash Test Dummy "Mithras -- the Reason for the Season"
Intel Corporation
I'm too low on the totem pole to speak for Intel.
http://www.fiction.net/blong/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]