GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Jul 30, 2014 7:15 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using Structures
PostPosted: Mon Nov 20, 2006 6:37 am 
Offline
Familiar Face

Joined: Tue Nov 14, 2006 6:06 am
Posts: 7
Hello ,

I am trying to use structures
Code:
typedef struct testing {
          GtkWidget *checkbutton6;
          GtkWidget *checkbutton7;
          GtkWidget *checkbutton8;
  }ex;

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


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


In callbacks.c function definition
Code:
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:
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.


Top
 Profile  
 
 Post subject: try this
PostPosted: Mon Nov 20, 2006 8:45 am 
Offline
GTK+ Geek

Joined: Fri Oct 06, 2006 6:37 am
Posts: 57
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 9:27 am 
Offline
Familiar Face

Joined: Tue Nov 14, 2006 6:06 am
Posts: 7
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 20, 2006 4:59 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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:
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group