Re: question about design



apatruduque <apatruduque yahoo es> writes: 
1- I don't know what is the best thing to do when I
want to close the second window: hide it with
gtk_widget_hide or destroy it with gtk_widget_destroy.
May be in this example is not very important but what
would it happen in a program like gimp? There, you can
finish with a lot of windows in your screen and  if
every time you close and open a window you have to
create from scratch, it takes some time. On the other
hand, if  you keep all the windows hide, you might be
wasting resources...I guess the answer is "It depends
on your application."

In nearly all cases, destroy is correct because creating the window
takes no appreciable amount of time, but keeping all your windows
around does use a noticeable amount of memory.

2- What to do when it is not only a label but some
more complicated data structure what two windows or
widgets share? Is using global variables and data
structures a solution?

Global variables are fine for simple cases, for a larger program you'd
usually want to use structs or the like and an object-oriented coding
style.

To get data into callbacks, two options are gtk_object_set_data() and
the callback data itself.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]