I'm starting to make my first C program in awhile using GTK+. I've learned C to some extent and I've worked with PyGTK, so I have a decent understanding of both. But, I've never created GUI program with C. Though it worked, my last GUI program was a bit of a mess because the program logic was all mixed in with the GUI stuff. I've read that it's best to write the GUI and program logic in a decoupled way so that if you switch GUI libraries, it'd be rather painless.
Is this right? Let's say I'm adding an item to a visual list. Do I have a function that adds the item to a logical list and run that in a function that looks at that list and then updates the gui?
For example,
void new_item_button_handler()
{
add_item_to_array() /* Code dealing with program logic*/
/*
* Code here to look at array and update visual list using GUI commands
*/
}
What's the general process for doing this?
Any advice would be appreciated!
EDIT:
Thanks for the advice regarding MVC. Could you perhaps explain that in the context of the example I gave? There's a lot of info on MVC out there, and I'm having a hard time trying to figure out how it applies to my code example here.