aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp66
2 files changed, 77 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d1801f330..d37461e9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
+
2003-07-18 Marco Pesenti Gritti <marco@it.gnome.org>
* 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 <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))