Global Variables



In a program I'm working on, I have about 20 or so widgets that need to
be accessible my multiple functions in multiple files. I've been using
global variables, but I recently saw the gtk_object_{get,set}_data functions
used instead.

For example, instead of having LocalEntry a global variable, the author
used

	gtk_object_set_data(GTK_OBJECT(main_window), "LocalEntry", entry);

to store a pointer to the widget, and

	entry = gtk_object_get_data(GTK_OBJECT(main_window), "LocalEntry");

to retrieve it.

Is there any actual benefit to doing this?

-- 
/-----------------------------------------------------------\
|  Eric Gillespie, Jr.        |  epgilles@olemiss.edu       |
|----------------------------<*>----------------------------|
| "Between depriving a man of one hour from his life and    |
|  depriving him of his life there exists only a difference |
|  of degree."                                              |
|  --Emperor Paul Muad'dib (Frank Herbert's Dune Messiah)   |
\-----------------------------------------------------------/



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