[Glade-users] Two newbie questions

Tristan Van Berkom tristan.van.berkom at gmail.com
Thu May 16 09:25:28 UTC 2013


On Thu, May 16, 2013 at 6:10 PM, Carlos Franke
<carlos_franke at taunusstein.net> wrote:
> Sorry for bringing this month-old thread up again. I just did not get to it
> earlier. Anyway, here are my two cents.
>
>
> Ma Xiaojun wrote:
>>
>> 1. Where is the correct location to install .glade/.ui files with
>> regard to FHS or some freedesktop.org standards?
>
>
> and:
>
>> On Sun, Apr 7, 2013 at 7:23 PM, Tristan Van Berkom
>> <tristan.van.berkom at gmail.com> wrote:
>> > Rather, I would encourage you to use GResources to bind
>> > the XML into your app or library and use
>> > gtk_builder_add_from_resource().
>> > (note that GResources allows for a compression option too).
>>
>> This is available since GTK+ 3.4, I'm on GTK+ 2.24 though.
>
>
> First, I am very grateful for the hint to GResources. I wonder if embedding
> the glade files in the binaries would somehow allow for an easier way of UI
> localisation (i. e. translation of strings). On the first glance it appears
> that one would still have to maintain separate glade files for every
> supported language, just that they wouldn't all have to be installed in the
> file sytem, but in the executables (which might not be a good thing, as the
> executables would grow bigger with every supported translation). I may be
> missing something.

Indeed.

You don't need to maintain separate Glade files, you just simply mark the
strings as translatable in Glade (i.e. for all translatable strings, they
are marked for translation by default, you can control the context/comments
etc in a dialog which is accessible in the text entry, i.e. try GtkLabel:text
property for example).

To set the translation domain, use gtk_builder_set_translation_domain()
before calling _add_from_file() or such. Or in very recent Glade, you can
set the translation domain in the project properties dialog.

To extract strings for translation, intltool already understands .glade files,
if you want to call them .ui files, you need to annotate them correctly
in POTFILES.in.. like this:

[type: application/x-glade]path/to/gladefile.ui

I hope you have not been maintaining separate Glade files for too long,
this feature has been built into Glade for a very very long time ;-)

Cheers,
    -Tristan

>
> Second, for installation in the file system, the right place for glade files
> is probably the one specified in the $XDG_DATA_DIRS environment variable*,
> usually /usr/share. There is a Glib utility function to get the right
> directories, so they do not need to be hard-coded. In gtkmm, it is called
> Glib::get_system_data_dirs(), don't know about GTK+.
> * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
>
> There is also this four year old video explaining a way to embed glade files
> in executables:
> http://www.youtube.com/watch?v=5-8h6eOwKwA
> I don't know if this way is any good. On 2 Aug 2011 the above quoted Tristan
> Van Berkom had this to say about it:
> “Sure you can do that, unfortunately it means any graphic files in the Glade
> file need to be specified by full path, because GtkBuilder currently only
> uses the file load location to resolve relative paths for loaded resources
> (something that could/should be easily fixed in GtkBuilder).”
> (http://lists.ximian.com/pipermail/glade-users/2011-August/005355.html)
>
> Carlos
> _______________________________________________
> Glade-users maillist  -  Glade-users at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>


More information about the Glade-users mailing list