Re: GtkBuilder and widget names



On Sun, 25 Dec 2011 16:21:40 +0900, Tristan Van Berkom wrote:

> For what it's worth, I see your point, and I don't consider your code to
> be messy or obfuscated in any way for that, however it's a sort of API
> abuse.
Well, may be it is, but if we would have an "official" ability to read 
widget names/ids as they defined in the glade file - then there wont be a 
need for abuse, would it?

 
> You will have the limitation that your settings keys must not conflict
> in name with any other widget names in your project, which is probably
> not an issue for you in any case.
It is not issue at all. You cannot have two widgets with the same name in 
a glade file. And the set of functions which deals with that glade file 
is an encapsulated object by itself. So if we want to serialize the data 
from the widgets of some glade file - we just put all the data in one 
segment of key file.

> On the other hand, an elegant and more extendable solution would be to:
Sorry, I do not think so.
This additional wrapping looks nice on paper, but I believe it would be 
too much and too one-sided.
I use the approach I showed not just for saving the data from checkboxes, 
it is also how I save visibility of toolbars, position and visibility of 
docked windows, the active page in notebooks... Everything which needs to 
be saved between restarts is saved-restored by using the 
gtk_buildable_get_name() function.
It is a global approach - whatever is defined in glade file as the 
object's ID - this string is used as identifier during any kind of 
serialization of that widget and/or data associated with it.



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