On 01/22/2012 04:59 AM, Nick Treleaven wrote:
On 20/01/2012 21:29, Matthew Brush wrote:
@All: I added ui_builder_get_object() to be able to fetch a non-widget
(list store here) from prefs.c, but I'm not completely sure it's the
prefect fix. If you have any idea on how to improve this, spread
them! :)
IMO, it'd be better to just move the builder object to the header file
(maybe in a suitable struct), so that all files can access it. Then
there's no need to add 1 line wrapper functions for every function we
use from GtkBuilder's API. This isn't unprecedented, I think there's at
least a handful of globals like this in Geany already (even in
ui_utils.h). Alternatively, we could add a function called
`ui_get_builder()` to get access to the builder to use with GtkBuilder
API.
Otherwise, it's not too big of a deal, maybe we don't need much more
from the GtkBuilder API.
I think Colomban's function is fine. I don't understand avoiding adding
functions that are obviously useful and cleaner:
obj = ui_builder_get_object("name");
vs.
obj = gtk_builder_get_object(ui_get_builder(), "name");
The former is easier to read and it's obvious what it does.
But the latter exposes the full functionality of the GtkBuilder API
without us having to maintain but a single function.
For example, consider the following:
GtkBuilder *builder = ui_get_builder();
gtk_builder_add_from_string (builder, TOOLBAR_XML, -1, NULL);
...
I basically just don't think it's worth maintaining a thin wrapper
around common C/GTK+ code/idioms making our own "framework" to save a
line or two of code here and there. Unless you wrote the wrapper
function yourself, it makes the code harder to read, IMO.
Cheers,
Matthew Brush
_______________________________________________
Geany-devel mailing list
Geany-devel@uvena.de
https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel