[libslab] Fixes a crash when locale isn't UTF-8



commit f1d131f7e2e898b41c55b5c89dcdf920d16a56e7
Author: Stephen Shaw <sshaw decriptor com>
Date:   Thu Jun 2 16:26:53 2011 -0600

    Fixes a crash when locale isn't UTF-8
    
    Closes: bnc#650196, bgo#411586, lp#86557

 libslab/Makefile.am |    1 +
 libslab/app-shell.c |   15 +++++++++++++++
 libslab/app-shell.h |    2 ++
 3 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/libslab/Makefile.am b/libslab/Makefile.am
index 3506016..1eca8b6 100644
--- a/libslab/Makefile.am
+++ b/libslab/Makefile.am
@@ -1,5 +1,6 @@
 INCLUDES =					\
 	-I$(top_srcdir)				\
+	-DLOCALE_DIR=\""$(localedir)"\"		\
 	$(LIBSLAB_CFLAGS)			\
 	$(WARN_CFLAGS)				\
 	$(DISABLE_DEPRECATED)
diff --git a/libslab/app-shell.c b/libslab/app-shell.c
index a7a91ef..e0fa67e 100644
--- a/libslab/app-shell.c
+++ b/libslab/app-shell.c
@@ -847,6 +847,8 @@ AppShellData *
 appshelldata_new (const gchar * menu_name, NewAppConfig * new_apps, const gchar * gconf_keys_prefix,
 	GtkIconSize icon_size, gboolean show_tile_generic_name, gboolean exit_on_close)
 {
+	initialize_i18n ();
+
 	AppShellData *app_data = g_new0 (AppShellData, 1);
 	app_data->gconf_prefix = gconf_keys_prefix;
 	app_data->new_apps = new_apps;
@@ -1413,3 +1415,16 @@ handle_menu_action_performed (Tile * launcher, TileEvent * event, TileAction * a
 	else
 		g_warning ("Unknown Action");
 }
+
+void
+initialize_i18n (void)
+{
+	static gboolean initialized = FALSE;
+
+	if (!initialized)
+	{
+		bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+		bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+		initialized = TRUE;
+	}
+}
diff --git a/libslab/app-shell.h b/libslab/app-shell.h
index 0be9a8b..7608206 100644
--- a/libslab/app-shell.h
+++ b/libslab/app-shell.h
@@ -137,5 +137,7 @@ void hide_shell (AppShellData * app_data);
 
 void show_shell (AppShellData * app_data);
 
+void initialize_i18n (void);
+
 G_END_DECLS
 #endif /* __APP_SHELL_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]