Re: Program Structure

I was under the impression that this destroys the widget OOP concept.
I was not wanting to make a global variable of any sort, even a structure.
I have gone ahead and passed structures or pointers by callback to each
part in my program:

Well it orients a part of yer program as one object, say one `window'
as one object. Because yer trying to make something *useful* from
something that is OOP, not make an OOP out of something already OOP
(that's often used in wrappers and portability libraries).

/* I have to put a widget I will modify */
menu_selection_ callback (ctree_ptr)

/* I have to create a structure to pass more  args */
file_selection_ok_button_callback(struct(ctree_ptr, selection_dialog_ptr))

(Note: this is not actual code)

This passing of pointers is not too bad, but creating structures just to pass

information seems a little tedious.  Can the callbacks employ more than one
generic pointer arg?

Oh, I use a global `core structure', ie:

typedef struct {

        inventory_struct **inventory_window;
        int total_inventory_window;

} core_struct;

This one is allocated in main(), then passed to each widget as the signal
callback data.  There's no global variables involved as this one is
declared locally in main().

I guess I could make one big structure as you said and pass it through  the
That way I can reduce confusion as to what I am passsing and keep the data
being global.  It will have to be static though.

static can mean a lot of things in C>

But I think I know what yer trying to say, I've been writing GTK+ apps for
two years now using various styles and I've found this to be the most

Sometimes I would dereferance if the signal handler is for a widget
gauranteed to be within a structure like inventory_window.

Am I making this thing to hard?  Should I just make a bunch of globals?
Are globals really that bad?

Yes they are if you go into C++, best advice is to make one local variable
in main() called the core_struct, and dynamically allocate it.

That struct will hold pointers to all substructures, each substructure
is like a window with a bunch of GtkWidgets in there.

Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..

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