Commit dfb3a1b0 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Call setlocale (LC_ALL, ""). (#60606)

Wed Oct 10 12:48:38 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkmain.c (gtk_init_check): Call setlocale (LC_ALL, "").
	(#60606)

	* gtk/gtkmain.c (gtk_disable_setlocale): Add function
	to disable calling setlocale (LC_ALL, "").

	* gtk/gtkmain.c (gtk_set_locale): Indicate in the
	docs that this function is not typically useful.

	* gdk/x11/{gdkim-x11.c,gdkmain-x11.c,gdkprivate-x11.h}:
	Automatically initialize GDK for the current locale
	on gdk_init(). Don't reset locale to C when
	XSupportsLocale() fails.

	* gdk/linux-fb/gdkim-fb.c (gdk_set_locale): Remove
	useless checks for UTF-8 locale breakage that mattered
	only for X.

	* examples/calendar/calendar.c
	tests/{testgtk.c,testtext.c,testcalendar.c}: Remove calls to
	gtk_set_locale().

	* gtk/gtkiconfactory.c gtk/gtkitemfactory.c:
	gdk_pixbuf_new_from_stream => gdk_pixbuf_new_from_inline.
parent 63bd2b30
...@@ -552,7 +552,7 @@ main (int argc, char **argv) ...@@ -552,7 +552,7 @@ main (int argc, char **argv)
} }
/* Test loading from inline data. */ /* Test loading from inline data. */
pixbuf = gdk_pixbuf_new_from_stream (-1, apple_red, FALSE, &error); pixbuf = gdk_pixbuf_new_from_inline (-1, apple_red, FALSE, &error);
if (!pixbuf) if (!pixbuf)
{ {
fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n", fprintf (stderr, "failed to construct \"red apple\" pixbuf: %s\n",
...@@ -562,7 +562,7 @@ main (int argc, char **argv) ...@@ -562,7 +562,7 @@ main (int argc, char **argv)
else else
new_testrgb_window (pixbuf, "Red apple from inlined RLE data"); new_testrgb_window (pixbuf, "Red apple from inlined RLE data");
pixbuf = gdk_pixbuf_new_from_stream (sizeof (gnome_foot), gnome_foot, TRUE, NULL); pixbuf = gdk_pixbuf_new_from_inline (sizeof (gnome_foot), gnome_foot, TRUE, NULL);
new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data"); new_testrgb_window (pixbuf, "GNOME Foot from inlined RLE data");
found_valid = TRUE; found_valid = TRUE;
......
...@@ -412,7 +412,6 @@ void create_calendar() ...@@ -412,7 +412,6 @@ void create_calendar()
int main(int argc, int main(int argc,
char *argv[] ) char *argv[] )
{ {
gtk_set_locale ();
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
create_calendar(); create_calendar();
......
...@@ -335,7 +335,7 @@ sized_icon_set_from_inline (const guchar *inline_data, ...@@ -335,7 +335,7 @@ sized_icon_set_from_inline (const guchar *inline_data,
set = gtk_icon_set_new (); set = gtk_icon_set_new ();
source.pixbuf = gdk_pixbuf_new_from_stream (-1, inline_data, FALSE, NULL); source.pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
g_assert (source.pixbuf); g_assert (source.pixbuf);
...@@ -361,7 +361,7 @@ sized_with_fallback_icon_set_from_inline (const guchar *fallback_data, ...@@ -361,7 +361,7 @@ sized_with_fallback_icon_set_from_inline (const guchar *fallback_data,
set = gtk_icon_set_new (); set = gtk_icon_set_new ();
source.pixbuf = gdk_pixbuf_new_from_stream (-1, inline_data, FALSE, NULL); source.pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
g_assert (source.pixbuf); g_assert (source.pixbuf);
...@@ -371,7 +371,7 @@ sized_with_fallback_icon_set_from_inline (const guchar *fallback_data, ...@@ -371,7 +371,7 @@ sized_with_fallback_icon_set_from_inline (const guchar *fallback_data,
source.any_size = TRUE; source.any_size = TRUE;
source.pixbuf = gdk_pixbuf_new_from_stream (-1, fallback_data, FALSE, NULL); source.pixbuf = gdk_pixbuf_new_from_inline (-1, fallback_data, FALSE, NULL);
g_assert (source.pixbuf); g_assert (source.pixbuf);
...@@ -393,7 +393,7 @@ unsized_icon_set_from_inline (const guchar *inline_data) ...@@ -393,7 +393,7 @@ unsized_icon_set_from_inline (const guchar *inline_data)
set = gtk_icon_set_new (); set = gtk_icon_set_new ();
source.pixbuf = gdk_pixbuf_new_from_stream (-1, inline_data, FALSE, NULL); source.pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
g_assert (source.pixbuf); g_assert (source.pixbuf);
...@@ -1079,7 +1079,7 @@ render_fallback_image (GtkStyle *style, ...@@ -1079,7 +1079,7 @@ render_fallback_image (GtkStyle *style,
static GtkIconSource fallback_source = { NULL, NULL, 0, 0, 0, TRUE, TRUE, TRUE }; static GtkIconSource fallback_source = { NULL, NULL, 0, 0, 0, TRUE, TRUE, TRUE };
if (fallback_source.pixbuf == NULL) if (fallback_source.pixbuf == NULL)
fallback_source.pixbuf = gdk_pixbuf_new_from_stream (-1, MISSING_IMAGE_INLINE, FALSE, NULL); fallback_source.pixbuf = gdk_pixbuf_new_from_inline (-1, MISSING_IMAGE_INLINE, FALSE, NULL);
return gtk_style_render_icon (style, return gtk_style_render_icon (style,
&fallback_source, &fallback_source,
......
...@@ -1225,7 +1225,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory, ...@@ -1225,7 +1225,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory,
GdkPixbuf *pixbuf = NULL; GdkPixbuf *pixbuf = NULL;
image = NULL; image = NULL;
pixbuf = gdk_pixbuf_new_from_stream (-1, pixbuf = gdk_pixbuf_new_from_inline (-1,
entry->extra_data, entry->extra_data,
FALSE, FALSE,
NULL); NULL);
......
...@@ -363,6 +363,28 @@ load_modules (const char *module_str) ...@@ -363,6 +363,28 @@ load_modules (const char *module_str)
return gtk_modules; return gtk_modules;
} }
static gboolean do_setlocale = TRUE;
/**
* gtk_disable_setlocale:
*
* Prevents gtk_init() and gtk_init_check() from automatically
* calling setlocale (LC_ALL, ""). You would want to use this
* function if you wanted to set the locale for your program
* to something other than the user's locale, or if you wanted
* to set different values for different locale categories.
*
* Most programs should not need to call this function.
**/
static void
gtk_disable_setlocale (void)
{
if (gtk_initialized)
g_warning ("gtk_disable_setlocale() must be called before gtk_init()");
do_setlocale = FALSE;
}
gboolean gboolean
gtk_init_check (int *argc, gtk_init_check (int *argc,
char ***argv) char ***argv)
...@@ -384,6 +406,9 @@ gtk_init_check (int *argc, ...@@ -384,6 +406,9 @@ gtk_init_check (int *argc,
g_set_message_handler (gtk_message); g_set_message_handler (gtk_message);
g_set_print_handler (gtk_print); g_set_print_handler (gtk_print);
#endif #endif
if (do_setlocale)
setlocale (LC_ALL, "");
/* Initialize "gdk". We pass along the 'argc' and 'argv' /* Initialize "gdk". We pass along the 'argc' and 'argv'
* parameters as they contain information that GDK uses * parameters as they contain information that GDK uses
...@@ -656,17 +681,23 @@ gtk_exit (gint errorcode) ...@@ -656,17 +681,23 @@ gtk_exit (gint errorcode)
/** /**
* gtk_set_locale: * gtk_set_locale:
* *
* Initializes internationalization support for GTK+. gtk_init()
* automatically does this, so there is typically no point
* in calling this function.
* *
* Initializes internationalization support for GTK+. You * If you are calling this function because you changed the locale
* should call this function before gtk_init() if your application * after GTK+ is was initialized, then calling this function
* supports internationalization. * may help a bit. (Note, however, that changing the locale
* after GTK+ is initialized may produce inconsistent results and
* is not really supported.)
* *
* (In gory detail - sets the current locale according to the * In detail - sets the current locale according to the
* program environment. This is the same as calling the libc function * program environment. This is the same as calling the libc function
* setlocale (LC_ALL, "") but also takes care of the locale specific * setlocale (LC_ALL, "") but also takes care of the locale specific
* setup of the windowing system used by GDK.) * setup of the windowing system used by GDK.
* *
* Return value: a string corresponding to the locale set, as with the C library function setlocale() * Return value: a string corresponding to the locale set, as with the
* C library function setlocale()
**/ **/
gchar* gchar*
gtk_set_locale (void) gtk_set_locale (void)
......
...@@ -410,7 +410,6 @@ void create_calendar() ...@@ -410,7 +410,6 @@ void create_calendar()
int main(int argc, int main(int argc,
char *argv[] ) char *argv[] )
{ {
gtk_set_locale ();
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
create_calendar(); create_calendar();
......
...@@ -10918,7 +10918,6 @@ main (int argc, char *argv[]) ...@@ -10918,7 +10918,6 @@ main (int argc, char *argv[])
srand (time (NULL)); srand (time (NULL));
test_init (); test_init ();
gtk_set_locale ();
/* Check to see if we are being run from the correct /* Check to see if we are being run from the correct
* directory. * directory.
......
...@@ -2310,7 +2310,6 @@ main (int argc, char** argv) ...@@ -2310,7 +2310,6 @@ main (int argc, char** argv)
int i; int i;
test_init (); test_init ();
gtk_set_locale ();
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
buffer = create_buffer (); buffer = create_buffer ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment