Hello,

I am kind of new to GTK+ programming, so please bear with me.  Would it
be better to use global variables for Gtk widgets, and have all
functions in that file use them, or create separate widgets for each
function?

Here is an example bit of code:

<start>
#include <gtk/gtk.h>

/* globals */
GtkWidget *window;
GtkWidget *button;

void exfunc(void)
{
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    button = gtk_button_new_with_label("Button");
    gtk_widget_show(button);
    gtk_widget_show(window);
}

int main(int argc, char *argv[])
{
    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    button = gtk_button_new_with_label("Button");
    gtk_widget_show(button);
    gtk_widget_show(window);

    gtk_main();
    return 0;
}
</stop>

By defining those widgets as globals, do I reduce the amount of memory
used by the program?
What is everyone else's opinion on this?

Thanks,
Aaron

--
This message is powered by RedHat 6.1 and Perl
Visit my web site at http://iconmedia.com/cgi-bin/index.pl

Current uptime:
 12:24am  up  5:13,  0 users,  load average: 0.15, 0.07, 0.06



-- 
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null

Reply via email to