[Geany-devel] encoding combo boxes bug

Lex Trotman elextr at xxxxx
Sun Jan 22 22:00:46 UTC 2012


On Mon, Jan 23, 2012 at 1:45 AM, Matthew Brush <mbrush at codebrainz.ca> wrote:
> 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
>

Nick, Matthew, All,

When working with a common well known library like GTK it is better to
use the well known interface directly rather than creating private
partial wrappers.

Contributors who know GTK don't have to learn the private interface
(or complain about what is missing, or just use GTK directly anyway
since they don't know about the private interface) and contributors
who don't know GTK can learn an interface that is useful to them
elsewhere, rather than one that just works in Geany.

Cheers
Lex



>
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel



More information about the Devel mailing list