You can use a few tricks to help manage these one-shot constructs...
One that I used quite a while ago, was a wrapper around a simple array that
stores array size and free functions for each member, so a simple "free"
function can rip through and clear everything out. It's good as long as you'r
As I've said in he past, I believe the best thing is to sub-class GtkWindow
and then make all the pointers you want to pass around members of your new
class. Conceptually this looks like:
class MyWindow : GtkWindow {
GtkWidget *w_label;
GtkWidget *w_button;
Hi, Jens
Yes, your way is good (thank you for a small code, maybe I will use it
in my projects). But, are you sure your way is safe?
You don't know the size of array (at the first),
where do you free the array of pointers itself (try g_malloc and
g_free, because it is GLIB :) ) (at the second).
An
Hi All.
Thanks for all ideas, to this problem. I figured out how to pass more
widgets in an array, which is IMHO the best way to do it. Just for
reference, the following snippet.
"Packing" the widgets pointers in the array
GtkWidget * *data;
data = malloc(sizeof(GtkWidget *)*3);
data[0]=spinbu
Hello again
Well, yes, you are right about globals (I don't use them, but tried to
show one of the ways to resolve a task). But, I think, usage of many
structures also makes code hard readable. Just imagine, you have
Struct1 (with some objects), Struct2, Struct3 etc. There are too many
structures w
On Tue, Apr 21, 2009 at 08:57:41AM +0400, Vlad Volodin wrote:
> Hello, Jens
>
> The other way is to make your widgets global. Especially, me? I use
> GOjects, and always pass "self" object. For example, I inherit main
> window object from GtkWindow and later in widgets definition pass
> itself to
Hello, Jens
The other way is to make your widgets global. Especially, me? I use
GOjects, and always pass "self" object. For example, I inherit main
window object from GtkWindow and later in widgets definition pass
itself to callback. Also, you can use g_object_set_data for storing
some useful poi
Hello.
The common solution to this problem is to create a structure
containing all of the widgets you may need in callbacks and than pass
pointer to it around.
Some sample code can be found here:
http://gtkforums.com/viewtopic.php?t=2913#8098
Hope this helps a bit.
Bye
2009/4/20 Jens Hansen :
Hello All.
I'm quite new to C, but have done some gtk programming in perl.
I've been looking for answers on the web, and in various tutorials, without
any luck.
My question is how to pass more widgets as a gpointer, to a callback
function. (in C )
For instance if a "OK" button, has to read the st