From 977e13469d48102bc3812140bdf3faf955e9f11a Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 7 Jan 2003 20:34:09 +0000 Subject: More work on the start here page. 2003-01-07 Marco Pesenti Gritti * data/starthere/Makefile.am: * data/starthere/index.xml.in: * data/starthere/section.css: * data/starthere/section.xsl: * embed/mozilla/StartHereProtocolHandler.cpp: * embed/mozilla/mozilla-embed-shell.cpp: * lib/ephy-file-helpers.c: (ephy_ensure_dir_exists), (ephy_find_file_recursive), (ephy_file_find): * lib/ephy-file-helpers.h: * lib/ephy-start-here.c: (ephy_start_here_init), (ephy_start_here_finalize), (is_my_lang), (mozilla_bookmarks), (attach_content), (build_content), (ephy_start_here_get_page), (ephy_start_here_get_base_uri): * lib/ephy-start-here.h: More work on the start here page. --- embed/mozilla/StartHereProtocolHandler.cpp | 22 +++++++++++++------ embed/mozilla/mozilla-embed-shell.cpp | 35 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 7 deletions(-) (limited to 'embed') diff --git a/embed/mozilla/StartHereProtocolHandler.cpp b/embed/mozilla/StartHereProtocolHandler.cpp index 4ea95294c..2d2bb3c35 100644 --- a/embed/mozilla/StartHereProtocolHandler.cpp +++ b/embed/mozilla/StartHereProtocolHandler.cpp @@ -41,7 +41,6 @@ class GStartHereProtocolHandler : public nsIProtocolHandler virtual ~GStartHereProtocolHandler(); nsCOMPtr mChannel; - nsCOMPtr mURI; }; /* Implementation file */ @@ -115,10 +114,9 @@ NS_IMETHODIMP GStartHereProtocolHandler::NewChannel(nsIURI *aURI, nsresult rv; EphyStartHere *sh; char *buf; + const char *aBaseURI; PRUint32 bytesWritten; - - mURI = aURI; - + nsCAutoString path; rv = aURI->GetPath(path); if (NS_FAILED(rv)) return rv; @@ -134,9 +132,16 @@ NS_IMETHODIMP GStartHereProtocolHandler::NewChannel(nsIURI *aURI, sh = ephy_start_here_new (); buf = ephy_start_here_get_page (sh, "index"); - rv = stream->Write (buf, strlen (buf), &bytesWritten); - g_free (buf); + aBaseURI = ephy_start_here_get_base_uri (sh); + rv = stream->Write (buf, strlen (buf), &bytesWritten); + if (NS_FAILED (rv)) return NS_ERROR_FAILURE; + + nsCOMPtr uri; + nsCAutoString spec(aBaseURI); + rv = NS_NewURI(getter_AddRefs(uri), spec.get()); + if (NS_FAILED (rv)) return NS_ERROR_FAILURE; + nsCOMPtr iStream; PRUint32 size; @@ -146,10 +151,13 @@ NS_IMETHODIMP GStartHereProtocolHandler::NewChannel(nsIURI *aURI, rv = sStream->NewInputStream(0, getter_AddRefs(iStream)); if (NS_FAILED(rv)) return rv; - rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), mURI, + rv = NS_NewInputStreamChannel(getter_AddRefs(mChannel), uri, iStream, NS_LITERAL_CSTRING("text/xml"), NS_LITERAL_CSTRING("utf-8"), size); + g_free (buf); + g_object_unref (sh); + NS_IF_ADDREF (*_retval = mChannel); return rv; diff --git a/embed/mozilla/mozilla-embed-shell.cpp b/embed/mozilla/mozilla-embed-shell.cpp index 8a66191b9..6b8c5e8f1 100644 --- a/embed/mozilla/mozilla-embed-shell.cpp +++ b/embed/mozilla/mozilla-embed-shell.cpp @@ -183,6 +183,39 @@ mozilla_embed_shell_class_init (MozillaEmbedShellClass *klass) shell_class->show_file_picker = impl_show_file_picker; } +static void +mozilla_load_language_prefs (MozillaEmbedShell *shell) +{ + GString *langs; + const GList *l; + + langs = g_string_new (NULL); + + l = gnome_i18n_get_language_list ("LC_MESSAGES"); + for (; l != NULL; l = l->next) + { + char *lang = (char *)l->data; + int len; + char *lg, *enc; + + g_print ("%s\n", lang); + + lg = strchr (lang, '_'); + enc = strchr (lang, '.'); + + len = strlen (lang); + if (enc) len = enc - lang; + if (lg) len = lg - lang; + + g_string_append (langs, ","); + g_string_append_len (langs, lang, len); + } + + mozilla_prefs_set_string ("intl.accept_languages", langs->str + 1); + + g_string_free (langs, TRUE); +} + static void mozilla_load_proxy_prefs (MozillaEmbedShell *shell) { @@ -424,6 +457,8 @@ mozilla_embed_shell_init (MozillaEmbedShell *mes) } mozilla_load_proxy_prefs (mes); + + mozilla_load_language_prefs (mes); mozilla_init_single (mes); -- cgit v1.2.3