Re: GUI programming vs encapsulation
- From: Keith Sharp <kms passback co uk>
- To: gtk-app-devel-list gnome org
- Subject: Re: GUI programming vs encapsulation
- Date: Fri, 04 Feb 2005 16:43:39 +0000
On Fri, 2005-02-04 at 09:23 -0500, John (J5) Palmieri wrote:
C's not flat. Use gobject or at least structs to organize your code.
Never use globals and only use static variables sparingly. Look how
other large projects organize their code. Open Source is good in that
way. Usually large apps with have a main gobject that acts as a factory
for the app. Sample main:
int
main (int argc, char *argv[])
{
MyApp *app;
app = my_app_new();
gtk_main();
}
MyApp would be a gobject that holds all the widgets you care about
manipulating and pointers to any other data needed by parts of the
program. The reference to this object would be passed to callbacks as
userdata. You also don't need to hold the glade widget tree in memory
if you do things this way. Hope this helps.
A good example of this style of programming is Gossip:
http://www.imendio.com/projects/gossip/
I am sure there are others, but I found the Gossip code quite easy to
read.
Keith.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]