aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-07-19 22:50:34 +0800
committerChristian Persch <chpe@src.gnome.org>2003-07-19 22:50:34 +0800
commit6832f5180a08aa2fa02924d5709ab8fc1173ab1c (patch)
tree3348312f2d288e6f65b11fec8587d0c777abd335 /embed
parent48d2a12d9641c79037aa125c2e1ae6cc651e0ea5 (diff)
downloadgsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar.gz
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar.bz2
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar.lz
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar.xz
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.tar.zst
gsoc2013-epiphany-6832f5180a08aa2fa02924d5709ab8fc1173ab1c.zip
Set the chrome locale on startup. That means that if the correct lang pack
2003-07-19 Christian Persch <chpe@cvs.gnome.org> * 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.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp66
1 files changed, 66 insertions, 0 deletions
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 <nsCCookieManager.h>
#include <nsCPasswordManager.h>
+// FIXME: For setting the locale. hopefully gtkmozembed will do itself soon
+#include <nsIChromeRegistry.h>
+#include <nsILocaleService.h>
+
#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<nsILocaleService> 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<nsIXULChromeRegistry> 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))