[Glade-users] g_signal_connect and passing data



Hello:
BTW: I am using C.
I am having a problem printing out the data I pass to a callback function.
 I am using the g_signal_connect. The function is getting
called and if I hard code the data it prints just FINE, but I can't.

Here is my stuff:

1. This is the struct holding the data:
  typedef struct my_paths {
     char bin[1000];
     char doc[1000];
  } MY_PATHS;

2. This is a chunk of the code that sets up the callback:

  MY_PATHS       mydata;

  strcpy(mydata.bin,"TESTING");
  printf("Data is <%s> before callback activated\n",mydata.bin);
  printf("Data is at %p before callback activated\n",mydata);

  g_signal_connect(G_OBJECT (tableCells[r][6]),
                   "button_press_event",
                   G_CALLBACK (selectActionBin),
                   (gpointer) &mydata);

3. This is the callback function
void selectActionBin(MY_PATHS    *data)
{
    printf("In CB, data = <%s>\n",data->bin);
    printf("In CB, data is at %p\n", data);
    printf("In CB, data is at %p\n", &data);
                                                                    
           
    gtk_widget_show (selectDialog_window); <--- This shows up as expected.
                                                                    
           
}

4. Finally, this is the output.
  ./testIt
  ---- The following prints out from #2 above
  Data is <TESTING> before callback activated
  Data is at 0x504f4f50 before callback activated

  ---- The following prints out from #3 above
  In CB, data = <>          <---- I want to see my data here :{
  In CB, data is at 0x80b2a30
  In CB, data is at 0xbfffeb40



BTW, the following data prints out in the CB function, given the type
of data is changed to char *data.
          g_signal_connect(G_OBJECT (tableCells[r][6]),
                          "button_press_event",
                          G_CALLBACK (selectActionBin),
                          "POOP");
Any help would be apprecited.
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]