-----Original Message-----
>From: Daniel Haude
>To: gtk-app-devel-list@gnome.org
>Sent: 2/4/05 3:54 AM
>Subject: GUI programming vs encapsulation
>
>Hello list,
>
>as my Glade/GTK project is growing larger, I find myself confronted with
>
>code organization issues. I have all my callbacks in a single file, but 
>of course there are groups of related widgets that logically go together
>
>(say, the widgets inside a top-level dialog window). Also the widgets of
>
>one dialog only need to know about each other, but not about widgets in 
>other windows.
>
>The issue is how to separate these things logically other than just 
>splitting up the source code in comment-separated chunks.
>
>1. Separate source files for each dialog.
>    -> unpractical because this is a single Glade project, and Glade 
>only writes single source files.

    I have run into the same problem and I decide to use this simple
approach.  The problem that I see is that glade writes two sets of files:
interface.[ch] and callbacks.[ch].  interface.c is not to be edited and I
don't want to edit it as long as I am using glade to modify the gui.  All of
the callbacks go into callbacks.c.  You can edit callbacks.c and glade will
not modify your code, it just adds stubs for new callback routines.  The
problem is that interface only includes callbacks.h so that it only has
prototypes for the functions defined in callbacks.c.

    I chose to create seperate sets of *.c and *.h files that contain the
function definitions and prototypes for logically related sets of widgets.
Instead of editing interface.c to include my header files, I just edited
callbacks.h (which is OK as far as glade is concerned) to add a #include for
each of my *.h files.  That way interface.c sees the prototypes for the
functions in my *.c files and everything compiles and links without
complaint and I don't have to create any additional interface functions or
global data structures.

Nathan
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to