question about design



Hi,

I'm learning how (or trying at least) to program with
GTK. I'm using the tutorial and the book by Eric
Harlow, which I find very illustrative. Starting from
the program described there, I want to implement a
calculator as an exercise with an extra button. When
this button is pressed, a new window opens with extra
buttons and extra operations and constants there.

I'm trying to do this as follows. I create a new
function create_window2(GtkWidget *display) whose
argument is the label (display) of the main window
calculator. This function creates the second window
and the buttons and uses the same signal functions for
the buttons window1 used. As I have the display passed
as an argument, i can operate with it and do
everything.

I have 2 questions:

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."

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?

Finally,  I would like to apologize if this is not the
proper mailing list to ask this sort of questions. In
that case, I would appreciate if somebody can give me
a proper place to post them.

Thanks again,

Alfonso Alba García


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com




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