From 6832f5180a08aa2fa02924d5709ab8fc1173ab1c Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 19 Jul 2003 14:50:34 +0000 Subject: Set the chrome locale on startup. That means that if the correct lang pack 2003-07-19 Christian Persch * embed/mozilla/mozilla-embed-single.c: (getUILang), (mozilla_init_chrome), (mozilla_embed_single_init_services): Set the chrome locale on startup. That means that if the correct lang pack is installed, dialogues coming from mozilla will be translated. Set skin to 'classic' on startup, so we get native scrollbars. Ported from galeon. --- embed/mozilla/mozilla-embed-single.cpp | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'embed/mozilla/mozilla-embed-single.cpp') diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp index 9687aa38e..956c04d75 100644 --- a/embed/mozilla/mozilla-embed-single.cpp +++ b/embed/mozilla/mozilla-embed-single.cpp @@ -55,6 +55,10 @@ #include #include +// FIXME: For setting the locale. hopefully gtkmozembed will do itself soon +#include +#include + #define MOZILLA_PROFILE_DIR "/mozilla" #define MOZILLA_PROFILE_NAME "epiphany" #define MOZILLA_PROFILE_FILE "prefs.js" @@ -536,9 +540,64 @@ mozilla_embed_single_init (MozillaEmbedSingle *mes) NULL); } +static nsresult +getUILang (nsAString& aUILang) +{ + nsresult result; + + nsCOMPtr localeService = do_GetService (NS_LOCALESERVICE_CONTRACTID, &result); + if (NS_FAILED (result) || !localeService) + { + g_warning ("Could not get locale service!\n"); + return NS_ERROR_FAILURE; + } + + nsXPIDLString uiLang; + result = localeService->GetLocaleComponentForUserAgent (getter_Copies(uiLang)); + aUILang = uiLang; + if (NS_FAILED (result)) + { + g_warning ("Could not determine locale!\n"); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +static nsresult +mozilla_init_chrome (void) +{ + nsresult result; + nsAutoString uiLang; + + nsCOMPtr chromeRegistry = do_GetService (NS_CHROMEREGISTRY_CONTRACTID, &result); + if (NS_FAILED (result) || !chromeRegistry) + { + g_warning ("Could not get the chrome registry!\n"); + return NS_ERROR_FAILURE; + } + + // Set skin to 'classic' so we get native scrollbars. + result = chromeRegistry->SelectSkin (NS_LITERAL_CSTRING("classic/1.0"), PR_FALSE); + if (NS_FAILED (result)) return NS_ERROR_FAILURE; + + // set locale + chromeRegistry->SetRuntimeProvider(PR_TRUE); + + result = getUILang(uiLang); + if (NS_FAILED (result)) return NS_ERROR_FAILURE; + + result = chromeRegistry->SelectLocale (NS_ConvertUCS2toUTF8(uiLang), PR_FALSE); + if (NS_FAILED (result)) return NS_ERROR_FAILURE; + + return NS_OK; +} + gboolean mozilla_embed_single_init_services (MozillaEmbedSingle *single) { + nsresult result; + /* Pre initialization */ mozilla_init_home (); mozilla_init_profile (); @@ -546,6 +605,13 @@ mozilla_embed_single_init_services (MozillaEmbedSingle *single) /* Fire up the best */ gtk_moz_embed_push_startup (); + /* Until gtkmozembed does this itself */ + result = mozilla_init_chrome (); + if (NS_FAILED (result)) + { + g_warning ("Failed to set locale and skin.\n"); + } + mozilla_init_single (single); if (!mozilla_set_default_prefs (single)) -- cgit v1.2.3