I'm 28 (oops, 29 now) and I want to be C literate by the time I'm 30. That's two (one) years to become competent at something I've been wanting to do nearly my whole life. No pressure.
Tuesday, January 25, 2011
Exercise 2-1 in the GTK book
The exercise was to make a window with a title and a label (the text in the window). When you press a keyboard key the text in the window title and label should swap.
Didn't take too long to figure out how to get a property of a widget (the title text status is how I determine which way to swap things), and there is a GDK function for testing if strings are identical, or if the first is larger than the second, or vice versa. Also wasn't too hard to find.
Here's the problem - it doesn't always work. Sometimes I'll press a button and both texts will swap. Sometimes only the label will change (making both texts the same), and very rarely only the window title will change. I need to run this on my Windows box to see if the behavior is the same. If it is then I'll do some searching. If I had more time this morning I'd rewrite the swap text function just to see if that would alter the behavior.
I'm happy with this because I started from scratch and only had to reference the book or the API doc for new stuff that the book hadn't covered yet, like getting a widget attribute. That's what this book is good about. It says "do this exercise but be warned that you'll need functions regarding getting attributes we haven't covered yet and you need to look in the API docs to get that function".
The next exercise expands this program by using a button you click on instead of a keypress. Maybe tonight or tomorrow morning I'll work on that. Having two hours to myself in the morning (since Ana gets up so early and I wind up waking up, too) is a blast. Crashing at 3:30pm isn't, however.
*EDIT*
Also, I've started standardising how I use spaces. Spaces after commas in function calls, spaces in between function name and parameters list.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment