Thursday, March 31, 2011

the GTK wagon

I pulled out my GTK book to see if it had any Cairo info but it really doesn't have much more than a brief 1 page mention of it.

The two chapters of that book that I got through were very enlightening, and I stopped because the rest of it seemed like just adding on specialty widgets to what I had already learned and that seemed like more gruntwork. Gruntwork isn't motivating.

Now that I have a goal I think I should get through the next chapter.

The biggest GTK mystery to me is passing data to callback functions. If I have a callback function to run whenever I press a button I have to pass the window handle, the button handle, and ONE pointer to misc data of my choosing. The general consensus is that I should be packing all of my variables into structures and then passing a pointer to the structure. This seems wrong in some way. I've spent time learning how to pass data to functions and now you're telling me that if I use GTK I have to wrap all of my variables in a structure? Maybe I'm missing something. This makes shoehorning a GTK interface into existing programs impossible because it would require an entire rewrite if your necessary functions.

Well, now that I think about it this might not be true.

Press button, THEN pack variables into structure, pass structure to callback, unpack variables and then pass to more interesting function?

-sigh-

Yea I think I need to get another chapter of this book under my belt before tackling anything else. Gotta walk before you can run, right?

No comments:

Post a Comment