Read mozilla prefs from a js file

This commit is contained in:
Marco Pesenti Gritti 2006-10-25 15:43:37 +02:00
parent 96b150d2bb
commit 581a3a0cb4
7 changed files with 68 additions and 35 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@ config.h.in
config.log config.log
config.status config.status
configure configure
compile
install-sh install-sh
missing missing
py-compile py-compile

View File

@ -57,6 +57,7 @@ activities/chat/Makefile
activities/terminal/Makefile activities/terminal/Makefile
activities/sketch/Makefile activities/sketch/Makefile
lib/Makefile lib/Makefile
lib/data/Makefile
lib/src/Makefile lib/src/Makefile
lib/python/Makefile lib/python/Makefile
lib/threadframe/Makefile lib/threadframe/Makefile

View File

@ -1 +1 @@
SUBDIRS = src python threadframe SUBDIRS = data src python threadframe

4
lib/data/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
geckoconfdir = $(pkgdatadir)
geckoconf_DATA = gecko-prefs.js
EXTRA_DIST = $(confgecko_DATA)

18
lib/data/gecko-prefs.js Normal file
View File

@ -0,0 +1,18 @@
# Mozilla User Preferences
/* Do not edit this file.
*
* If you make changes to this file while the application is running,
* the changes will be overwritten when the application exits.
*
* To make a manual change to preferences, you can visit the URL about:config
* For more information, see http://www.mozilla.org/unix/customizing.html#prefs
*/
user_pref("dom.disable_open_during_load", true);
user_pref("network.cookie.prefsMigrated", true);
user_pref("security.warn_submit_insecure", false);
user_pref("ui.-moz-field", "#FFFFFF");
user_pref("ui.-moz-fieldtext", "#000000");
user_pref("ui.buttonface", "#D3D3DD");
user_pref("ui.buttontext", "#000000");

View File

@ -1,8 +1,3 @@
INCLUDES = \
$(WARN_CFLAGS) \
$(LIB_CFLAGS) \
-I$(MOZILLA_INCLUDE_DIR)/exthandler
noinst_LTLIBRARIES = libsugarprivate.la noinst_LTLIBRARIES = libsugarprivate.la
libsugarprivate_la_LIBADD = $(GECKO_LIBS) libsugarprivate_la_LIBADD = $(GECKO_LIBS)
@ -13,6 +8,8 @@ libsugarprivate_la_SOURCES = \
eggaccelerators.c \ eggaccelerators.c \
sugar-browser.h \ sugar-browser.h \
sugar-browser.cpp \ sugar-browser.cpp \
sugar-content-handler.h \
sugar-content-handler.cpp \
sugar-address-entry.h \ sugar-address-entry.h \
sugar-address-entry.c \ sugar-address-entry.c \
sugar-key-grabber.h \ sugar-key-grabber.h \
@ -20,9 +17,13 @@ libsugarprivate_la_SOURCES = \
sugar-push-scroller.c \ sugar-push-scroller.c \
sugar-push-scroller.h \ sugar-push-scroller.h \
sugar-tray-manager.c \ sugar-tray-manager.c \
sugar-tray-manager.h \ sugar-tray-manager.h
sugar-content-handler.h \
sugar-content-handler.cpp libsugarprivate_la_CPPFLAGS = \
$(WARN_CFLAGS) \
$(LIB_CFLAGS) \
-I$(MOZILLA_INCLUDE_DIR)/exthandler \
-DSHARE_DIR=\"$(pkgdatadir)\"
BUILT_SOURCES = \ BUILT_SOURCES = \
sugar-marshal.c \ sugar-marshal.c \

View File

@ -24,6 +24,8 @@
#include <nsCOMPtr.h> #include <nsCOMPtr.h>
#include <nsIPrefService.h> #include <nsIPrefService.h>
#include <nsServiceManagerUtils.h> #include <nsServiceManagerUtils.h>
#include <nsStringAPI.h>
#include <nsILocalFile.h>
#include <nsIWebBrowser.h> #include <nsIWebBrowser.h>
#include <nsIWebBrowserFocus.h> #include <nsIWebBrowserFocus.h>
#include <nsIDOMWindow.h> #include <nsIDOMWindow.h>
@ -56,28 +58,34 @@ static const nsModuleComponentInfo sSugarComponents[] = {
gboolean gboolean
sugar_browser_startup(void) sugar_browser_startup(void)
{ {
nsCOMPtr<nsIPrefService> prefService;
nsresult rv; nsresult rv;
nsCOMPtr<nsIPrefService> prefService;
prefService = do_GetService(NS_PREFSERVICE_CONTRACTID); prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefService, FALSE); NS_ENSURE_TRUE(prefService, FALSE);
/* Read our predefined default prefs */
nsCOMPtr<nsILocalFile> file;
NS_NewNativeLocalFile(nsCString(SHARE_DIR"/gecko-prefs.js"),
PR_TRUE, getter_AddRefs(file));
NS_ENSURE_TRUE(file, FALSE);
rv = prefService->ReadUserPrefs (file);
if (NS_FAILED(rv)) {
g_warning ("failed to read default preferences, error: %x", rv);
return FALSE;
}
nsCOMPtr<nsIPrefBranch> pref; nsCOMPtr<nsIPrefBranch> pref;
prefService->GetBranch ("", getter_AddRefs(pref)); prefService->GetBranch ("", getter_AddRefs(pref));
NS_ENSURE_TRUE(pref, FALSE); NS_ENSURE_TRUE(pref, FALSE);
/* Block onload popups */ rv = prefService->ReadUserPrefs (nsnull);
pref->SetBoolPref("dom.disable_open_during_load", TRUE); if (NS_FAILED(rv)) {
g_warning ("failed to read user preferences, error: %x", rv);
/* Disable useless security warning */ }
pref->SetBoolPref("security.warn_submit_insecure", FALSE);
/* Style tweaks */
pref->SetCharPref("ui.buttontext", "#000000");
pref->SetCharPref("ui.buttonface", "#D3D3DD");
pref->SetCharPref("ui.-moz-field", "#FFFFFF");
pref->SetCharPref("ui.-moz-fieldtext", "#000000");
/* Register our components */
nsCOMPtr<nsIComponentRegistrar> componentRegistrar; nsCOMPtr<nsIComponentRegistrar> componentRegistrar;
NS_GetComponentRegistrar(getter_AddRefs(componentRegistrar)); NS_GetComponentRegistrar(getter_AddRefs(componentRegistrar));
NS_ENSURE_TRUE (componentRegistrar, FALSE); NS_ENSURE_TRUE (componentRegistrar, FALSE);