spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit 241152d4f4e654785c2d6bd3c3469610bff60d41
parent 9cab91a32d549c4d9f831f3077ffffa3ba4cd28c
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Sat, 23 Apr 2011 15:28:55 +0800

Fix locale path on Windows and OS X

Diffstat:
Msrc/spek-platform.c | 28++++++++++++++++++++++++++++
Msrc/spek-platform.h | 3+++
Msrc/spek.vala | 2+-
Mvapi/spek-platform.vapi | 1+
4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/spek-platform.c b/src/spek-platform.c @@ -108,6 +108,34 @@ void spek_platform_fix_ui (GtkUIManager *ui) #endif } +gchar *spek_platform_locale_dir () { + static gchar *locale_dir = NULL; + + if (!locale_dir) { +#ifdef G_OS_WIN32 + gchar *win32_dir; + + win32_dir = g_win32_get_package_installation_directory_of_module (NULL); + locale_dir = g_build_filename (win32_dir, "share", "locale", NULL); + + g_free (win32_dir); +#else +#ifdef G_OS_DARWIN + GtkOSXApplication *app = NULL; + const gchar *res_dir; + + app = g_object_new (GTK_TYPE_OSX_APPLICATION, NULL); + res_dir = gtk_osxapplication_get_resource_path (app); + locale_dir = g_build_filename (res_dir, "share", "locale", NULL); +#else +#endif + locale_dir = LOCALEDIR; +#endif + } + + return locale_dir; +} + void spek_platform_show_uri (const gchar *uri) { #ifdef G_OS_WIN32 /* gtk_show_uri doesn't work on Windows... */ diff --git a/src/spek-platform.h b/src/spek-platform.h @@ -30,6 +30,9 @@ void spek_platform_fix_args (gchar **argv, gint argc); /* OSX has its own approach to menus and accelerators */ void spek_platform_fix_ui (GtkUIManager *ui); +/* Platform-specific locale directory */ +gchar *spek_platform_locale_dir (); + /* Open a link in the browser */ void spek_platform_show_uri (const gchar *uri); diff --git a/src/spek.vala b/src/spek.vala @@ -34,7 +34,7 @@ namespace Spek { Environment.set_variable ("LANGUAGE", Preferences.instance.language, true); } - Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); + Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Platform.locale_dir ()); Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); Intl.textdomain (Config.GETTEXT_PACKAGE); diff --git a/vapi/spek-platform.vapi b/vapi/spek-platform.vapi @@ -3,6 +3,7 @@ namespace Spek.Platform { public static void init (); public static void fix_args (string[] args); public static void fix_ui (Gtk.UIManager ui); + public static unowned string locale_dir (); public static void show_uri (string uri); public static string read_line (string uri); public static double get_font_scale ();