Read mozilla prefs from a js file

master
Marco Pesenti Gritti 18 years ago
parent 96b150d2bb
commit 581a3a0cb4

1
.gitignore vendored

@ -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

@ -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

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

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

@ -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");

@ -1,28 +1,29 @@
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)
libsugarprivate_la_SOURCES = \ libsugarprivate_la_SOURCES = \
$(BUILT_SOURCES) \ $(BUILT_SOURCES) \
eggaccelerators.h \ eggaccelerators.h \
eggaccelerators.c \ eggaccelerators.c \
sugar-browser.h \ sugar-browser.h \
sugar-browser.cpp \ sugar-browser.cpp \
sugar-address-entry.h \ sugar-content-handler.h \
sugar-address-entry.c \ sugar-content-handler.cpp \
sugar-key-grabber.h \ sugar-address-entry.h \
sugar-key-grabber.c \ sugar-address-entry.c \
sugar-push-scroller.c \ sugar-key-grabber.h \
sugar-push-scroller.h \ sugar-key-grabber.c \
sugar-tray-manager.c \ sugar-push-scroller.c \
sugar-tray-manager.h \ sugar-push-scroller.h \
sugar-content-handler.h \ sugar-tray-manager.c \
sugar-content-handler.cpp sugar-tray-manager.h
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 \

@ -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);
nsCOMPtr<nsIPrefBranch> pref; /* Read our predefined default prefs */
prefService->GetBranch("", getter_AddRefs(pref)); nsCOMPtr<nsILocalFile> file;
NS_ENSURE_TRUE(pref, FALSE); NS_NewNativeLocalFile(nsCString(SHARE_DIR"/gecko-prefs.js"),
PR_TRUE, getter_AddRefs(file));
NS_ENSURE_TRUE(file, FALSE);
/* Block onload popups */ rv = prefService->ReadUserPrefs (file);
pref->SetBoolPref("dom.disable_open_during_load", TRUE); if (NS_FAILED(rv)) {
g_warning ("failed to read default preferences, error: %x", rv);
return FALSE;
}
/* Disable useless security warning */ nsCOMPtr<nsIPrefBranch> pref;
pref->SetBoolPref("security.warn_submit_insecure", FALSE); prefService->GetBranch ("", getter_AddRefs(pref));
NS_ENSURE_TRUE(pref, FALSE);
/* Style tweaks */ rv = prefService->ReadUserPrefs (nsnull);
pref->SetCharPref("ui.buttontext", "#000000"); if (NS_FAILED(rv)) {
pref->SetCharPref("ui.buttonface", "#D3D3DD"); g_warning ("failed to read user preferences, error: %x", rv);
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);

Loading…
Cancel
Save