Re: Problem with GtkTextView and GtkTextBuffer
Tristan Van Berkom <[email protected]>
| Newsgroups | gmane.comp.gnome.glade.user |
|---|---|
| Message-ID | <CAGUy9W+yRL4hqZnAEU3-8u9DQHCMYz7DU-j2yYHtcrNBb4=dvw@mail.gmail.com> |
On Tue, Jan 24, 2012 at 9:29 PM, Manuel Ferrero <[email protected]> wrote: > Il 24/01/2012 12.54, Tristan Van Berkom ha scritto: > > >>> typedef struct _ChData ChData; >>> struct _ChData >>> { >>> GtkWidget *window; >>> GtkWidget *connect_button; >>> GtkWidget *serial_data; >>> }; > > >>> // Now, in one callback function I'd like to write some text in the text >>> area >>> >>> // I get the buffer from the GtkTextView widget >>> GtkTextBuffer *serial_buffer_ptr; >>> >>> serial_buffer_ptr = >>> gtk_text_view_get_buffer(GTK_TEXT_VIEW(data.serial_data)); >> >> >> I think what you need is data->serial_data, i.e. you dont pass the >> structure to the callbacks but a pointer to a structure. > > > No, serial_data is a pointer to a GtkWidget. > If I use the -> operator I get an error in compilation: > error: invalid type argument of '->' (have 'ChData') Start with: ChData *data = g_slice_new (...); ... you have a pointer to a ChData struct ... Then, pass the pointer to gtk_builder_connect_signals (builder, data); its a pointer that you must pass ... Then, of course you need to prototype your callback correctly (look up the documentation to know what is the signature for the exact signal you are connecting to): static void on_something_in_the_gui_happened (GtkSomething *something, GtkOther *maybe_other_arguments_in_the_signal, ChData *data); The trailing user data argument must be typed as a *pointer*, you cannot pass structs as user data, you need to pass the pointer reference to gtk_builder_connect_signals() and take a pointer reference as the user data pointer. So then you must access the members with 'data->struct_member' Cheers, -Tristan > > -- > Regards, > Manuel Ferrero > R&D department > > Reer SpA > Tel. +39 011 2482215 > Fax. +39 011 859867 > > L'utilizzo non autorizzato del presente messaggio e' vietato e potrebbe > costituire reato. > Se il presente messaggio non e' a Lei indirizzato, il suo contenuto non deve > essere considerato > come trasmesso o autorizzato dalla Reer SpA; in tale caso Le saremmo grati > se, via e-mail, > ce ne comunicasse l'errata ricezione. > > The unauthorized use of this e-mail is prohibited and could constitute an > offence. > If you are not the intended recipient of this message its contents shall be > understood as neither > given nor endorsed by Reer SpA. Please notify Reer SpA by e-mail immediately > in that case. > > _______________________________________________ > Glade-users maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/glade-users _______________________________________________ Glade-users maillist - [email protected] http://lists.ximian.com/mailman/listinfo/glade-users