After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 690705 - Call setlocale from GApplication initialiser
Call setlocale from GApplication initialiser
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-12-25 11:59 UTC by Philip Withnall
Modified: 2018-05-24 14:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2012-12-25 11:59:49 UTC
gtk_init() (or one of its friends) is needed so that setlocale() is called and gettext is set up correctly (see gettext_initialization() and setlocale_initialization() in gtkmain.c).

GtkApplication is encouraging applications to drop their use of gtk_init() in favour of local command line parsing (for example, none of the examples in the GApplication/GtkApplication documentation call gtk_init()). It would make sense to call gtk_init() from somewhere in GtkApplication’s initialisation code.
Comment 1 Philip Withnall 2012-12-25 12:03:37 UTC
See bug #690682 for an example of problems caused by this.
Comment 2 Allison Karlitskaya (desrt) 2012-12-26 02:29:31 UTC
gtk_init() should only be called in the primary instance and we don't know if we are the primary instance until we have finished registration.  To that end, the base implementation for GtkApplication.startup() does already call gtk_init().

As for gettext -- the best thing to do for now is to do the setlocale() business from main() alongside your bindtextdomain() for your package (which Gtk could not possibly do for you).  Later we should try to have a better way for dealing with this from inside of GApplication...
Comment 3 Philip Withnall 2012-12-26 12:03:18 UTC
(In reply to comment #2)
> As for gettext -- the best thing to do for now is to do the setlocale()
> business from main() alongside your bindtextdomain() for your package (which
> Gtk could not possibly do for you).  Later we should try to have a better way
> for dealing with this from inside of GApplication...

What stopped me from just calling setlocale() is that GTK+ has a lump of helper code for it which is used on Windows. Totem isn’t packaged for Windows, so that isn’t a problem for us; but it would be nice if that code (in setlocale_initialization()) could be exposed for applications to use even if they can’t call gtk_init(). Maybe move it to GLib?
Comment 4 Allison Karlitskaya (desrt) 2012-12-26 15:44:27 UTC
I think it makes sense for this to be part of GApplication, indeed...

We have some functions in GLib for this type of thing already -- the "package install dir" stuff, if I recall correctly.  I really don't know too much about the best practices for dealing with installing executables on Windows...
Comment 5 Matthias Clasen 2013-08-31 20:35:09 UTC
I think this is a GApplication feature request
Comment 6 GNOME Infrastructure Team 2018-05-24 14:55:04 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/648.