[Glade-users] data in g_signal_connect



Hello again:
This is a follow-up of a previous thread I started in early Nov.
I appreciate the help I got from the list, but I am still having difficulty.
Someone suggested I use a different prototype, but I got the same (wrong)results:
   void slectActionBin (GtkWidget     *widget,
                        GdkEvenButton *event,
                        MY_DATA       *data)

The problem is the data is not being printed out in the callback routine.
You can see, at the bottom of this post, that there is
nothing in data and the address is diff :(

Can someone help get my data so it is visable/correct in the called cb
routine.
I think (maybe) I am not casting it properly or something, but when I
called the callback routine directly (commented out the g_connect_signal)
the data was correct....hmmmm

Here is the code that does not work:
=========================================================
mySupport.h:
struct MY_DATA {
   char bin[1000];
   char doc[1000];
};
                                                                    
           
struct MY_DATA mydata;

=========================================================
mySupport.c:
void selectActionBin(GtkWidget      *button,
                     struct MY_DATA *data)
{
  /* This is the code that does not work */
  printf("In call back, data = <%s>\n",data->bin);
  printf("In call back, data = <%s>\n",data->doc);
  printf("In call back, data is at %p\n", data);
  printf("In call back, &data is at %p\n", &data);
}
=========================================================
SQLstuff.c:
-- This is where I set up my callback/data 
extern struct MY_DATA mydata;
int doQuery(char *sqlStr)
{
  strcpy(mydata.bin,"Test data");
  strcpy(mydata.doc,"Test data");
  printf("Data is <%s> before callback\n",mydata.bin);
  printf("Data is <%s> before callback\n", mydata.doc);
  printf("Data is at %p before callback\n", mydata);
  printf(" &data is at %p before callback\n", &mydata);
  g_signal_connect(G_OBJECT (butWidget),
                   "button_press_event",
                   G_CALLBACK (selectActionBin),
                   &mydata);
}
=========================================================
output: (as you can see the callback is called but nothing is
         in the data and the address are diff) :(

Data is <Test data> before callback
Data is <Test data> before callback
Data is at 0x74736554 before callback
&data is at 0x80513a0 before callback

In call back, data = <>
In call back, data = <>
In call back, data is at 0x8a3e6e0
In call back, &data is at 0xbfffd944


Thanks,
O




Concerned about your privacy? Follow this link to get
FREE encrypted email: https://www.hushmail.com/?l=2

Free, ultra-private instant messaging with Hush Messenger
https://www.hushmail.com/services.php?subloc=messenger&l=434

Promote security and make money with the Hushmail Affiliate Program: 
https://www.hushmail.com/about.php?subloc=affiliate&l=427




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