GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using Structures

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
srikanth
Familiar Face


Joined: 14 Nov 2006
Posts: 7

PostPosted: Mon Nov 20, 2006 6:37 am    Post subject: Using Structures Reply with quote

Hello ,

I am trying to use structures
Code: (Plaintext)
1
2
3
4
5
typedef struct testing {
          GtkWidget *checkbutton6;
          GtkWidget *checkbutton7;
          GtkWidget *checkbutton8;
  }ex;

Code: (Plaintext)
1
ex *w = (ex*) g_malloc (sizeof (ex));


This is the callback function
Code: (Plaintext)
1
2
3
g_signal_connect ((gpointer) druidpagestandard2, "prepare",
                    G_CALLBACK (on_druidpagestandard2_prepare),
                    (gpointer) w);


In callbacks.c function definition
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11

void
on_druidpagestandard2_prepare          (GnomeDruidPage  *gnomedruidpage,
                                        GtkWidget       *widget,
                                        gpointer        w)

{
        gint box_status;
         printf("\n");
        box_status = gtk_toggle_button_get_active    ((GtkToggleButton *) w->checkbutton6);



When i compile the program i am getting following error
Code: (Plaintext)
1
2
3
4
5

callbacks.c: In function ‘on_druidpagestandard2_prepare’:
callbacks.c:54: warning: dereferencing ‘void *’ pointer
callbacks.c:54: error: request for member ‘checkbutton6’ in something not a structure or union
make: *** [callbacks.o] Error 1



What am i doing wrong ?

Thanks.
Back to top
cnu_sree
GTK+ Geek


Joined: 06 Oct 2006
Posts: 57

PostPosted: Mon Nov 20, 2006 8:45 am    Post subject: try this Reply with quote

void
on_druidpagestandard2_prepare (GnomeDruidPage *gnomedruidpage,
GtkWidget *widget,
gpointer w)

{
ex *x = (ex *) w;
gint box_status;
printf("\n");
box_status = gtk_toggle_button_get_active ((GtkToggleButton *)->checkbutton6);
}
i too faced the ssame problem after adding the line my problem is solved
so try this
Back to top
srikanth
Familiar Face


Joined: 14 Nov 2006
Posts: 7

PostPosted: Mon Nov 20, 2006 9:27 am    Post subject: Reply with quote

tried it did not work . I forgot to mention that i am using glade 2 so, i am making call from interface.c to callback.c .

Thanks.
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 376
Location: State College, Pennsylvania

PostPosted: Mon Nov 20, 2006 4:59 pm    Post subject: Reply with quote

First, when using Glade, you should use Libglade to dynamically load the user interface with the GladeXML object. Source code generation is depreciated and takes up a lot of space.

Second, you are trying to retrieve a member from a void pointer, which is what cru_sree recommended. He just forgot to add the 'x' like so:

Code: (Plaintext)
1
box_status = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (x->checkbutton6));


Also, GTK+ provides functions like GTK_TOGGLE_BUTTON() and GTK_WIDGET() for casting. Use them because they are provided by GObject. Either way will work, but this is the correct way.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP