Re: GTK_ENTRY text retrieval




On Nov 30, 2004, at 6:33 AM, Tim Müller wrote:

You could also allocate yourself a custom-made struct containing all the widgets you need access to, and pass that struct around instead. Something
like

    gtk_widget_show (foo->treeview);

I used to do that. I started using the object data after I looked at some of the glade generated code, liked the idea, and adopted it in my own code. It is much cleaner (in my experience).

is usually more readable than code littered with g_object_get_data() like

    gtk_widget_show (GTK_WIDGET (g_object_get_data (G_OBJECT (win),
"treeview")));

Actually, with a few macros and functions, most of which I lifted from the glade generated code and modified for my own purposes, the resulting code is nowhere near that ugly. I generally lookup the widgets I am going to need at the start of the handler, store pointers in meaningful variables, and use the meaningful variable names in the actual gtk_widget_foo() function calls.

You might want to generate some code from glade and take a look...

I think in general it makes more sense to look at code that was written by
experienced programmers rather than to look at generated code ...

In general, but there is certainly nothing wrong with looking at the glade generated code, either, especially since it does contain some rather good ideas (IMHO).

--
Ken Sodemann (stuffle mac com)
Go Yankees, Go Brewers, Go #17, #20, #24, #97
http://homepage.mac.com/stuffle/
http://webpages.charter.net/stuffle/




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