Re: Set maximum length for text control
- From: cecashon aol com
- To: ikorot01 gmail com
- Cc: gtk-list gnome org
- Subject: Re: Set maximum length for text control
- Date: Wed, 11 Jan 2017 14:21:59 -0500
Check that your callback looks similar to the following.
https://developer.gnome.org/gtk3/stable/GtkTextBuffer.html#GtkTextBuffer-insert-text
It looks like you have "gint WXUNUSED(len), gpointer *user_data" that is likely giving you trouble.
A couple of notes about this. It is a good idea to look up the callback in the documentation. If you get the parameters wrong your code may compile without warning and then later segfault. This is something in C you have to be careful of. The compiler might not help you here. Also a gpointer is a void* pointer.
https://developer.gnome.org/glib/stable/glib-Basic-Types.html#gpointer
This can cause confusion. When you are using a gpointer *user_data, that is a pointer to an array of pointers like a void **user_data or a void *user_data[]. That is valid if you are sending to your callback a pointer to some array of pointers and you might want to do this. Again, the compiler might not be able to help you when using void* pointers and you will probably get a segfault if you get it wrong. The documentation has a gpointer user_data parameter so that you can pass a pointer of any type to your callback along with the other required callback parameters. If you know the type of the pointer you can use the type in the callback so the compiler can help find potential errors. If you are sending a GRand* to your callback you can type it as such. If you are sending a pointer to an array of widget pointers you might have something like GtkWidget **widgets or GtkWidget *widgets[] although gpointer *widgets will work also and is valid but the compiler can't type check it for you.
Eric
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]