Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2006-10-25 13:43:37 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2006-10-25 13:43:37 (GMT)
commit581a3a0cb402fdc337ea04c5673baed5e98d671d (patch)
tree65c1b7aafb8fa17a01b85fec2e2b0f8ceaea81de
parent96b150d2bb63720983d1957bb955367a6747c2f7 (diff)
Read mozilla prefs from a js file
-rw-r--r--.gitignore1
-rw-r--r--configure.ac1
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/data/Makefile.am4
-rw-r--r--lib/data/gecko-prefs.js18
-rw-r--r--lib/src/Makefile.am43
-rw-r--r--lib/src/sugar-browser.cpp34
7 files changed, 68 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
index a45a035..214150f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ config.h.in
config.log
config.status
configure
+compile
install-sh
missing
py-compile
diff --git a/configure.ac b/configure.ac
index b57d73a..b134783 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,7 @@ activities/chat/Makefile
activities/terminal/Makefile
activities/sketch/Makefile
lib/Makefile
+lib/data/Makefile
lib/src/Makefile
lib/python/Makefile
lib/threadframe/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3021e12..845b2c3 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1 +1 @@
-SUBDIRS = src python threadframe
+SUBDIRS = data src python threadframe
diff --git a/lib/data/Makefile.am b/lib/data/Makefile.am
new file mode 100644
index 0000000..a31043f
--- /dev/null
+++ b/lib/data/Makefile.am
@@ -0,0 +1,4 @@
+geckoconfdir = $(pkgdatadir)
+geckoconf_DATA = gecko-prefs.js
+
+EXTRA_DIST = $(confgecko_DATA)
diff --git a/lib/data/gecko-prefs.js b/lib/data/gecko-prefs.js
new file mode 100644
index 0000000..df2ca53
--- /dev/null
+++ b/lib/data/gecko-prefs.js
@@ -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");
diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am
index 688170a..1d5cd3b 100644
--- a/lib/src/Makefile.am
+++ b/lib/src/Makefile.am
@@ -1,28 +1,29 @@
-INCLUDES = \
- $(WARN_CFLAGS) \
- $(LIB_CFLAGS) \
- -I$(MOZILLA_INCLUDE_DIR)/exthandler
-
noinst_LTLIBRARIES = libsugarprivate.la
libsugarprivate_la_LIBADD = $(GECKO_LIBS)
-libsugarprivate_la_SOURCES = \
- $(BUILT_SOURCES) \
- eggaccelerators.h \
- eggaccelerators.c \
- sugar-browser.h \
- sugar-browser.cpp \
- sugar-address-entry.h \
- sugar-address-entry.c \
- sugar-key-grabber.h \
- sugar-key-grabber.c \
- sugar-push-scroller.c \
- sugar-push-scroller.h \
- sugar-tray-manager.c \
- sugar-tray-manager.h \
- sugar-content-handler.h \
- sugar-content-handler.cpp
+libsugarprivate_la_SOURCES = \
+ $(BUILT_SOURCES) \
+ eggaccelerators.h \
+ eggaccelerators.c \
+ sugar-browser.h \
+ sugar-browser.cpp \
+ sugar-content-handler.h \
+ sugar-content-handler.cpp \
+ sugar-address-entry.h \
+ sugar-address-entry.c \
+ sugar-key-grabber.h \
+ sugar-key-grabber.c \
+ sugar-push-scroller.c \
+ sugar-push-scroller.h \
+ sugar-tray-manager.c \
+ sugar-tray-manager.h
+
+libsugarprivate_la_CPPFLAGS = \
+ $(WARN_CFLAGS) \
+ $(LIB_CFLAGS) \
+ -I$(MOZILLA_INCLUDE_DIR)/exthandler \
+ -DSHARE_DIR=\"$(pkgdatadir)\"
BUILT_SOURCES = \
sugar-marshal.c \
diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp
index 3ba7fdc..d75bfc8 100644
--- a/lib/src/sugar-browser.cpp
+++ b/lib/src/sugar-browser.cpp
@@ -24,6 +24,8 @@
#include <nsCOMPtr.h>
#include <nsIPrefService.h>
#include <nsServiceManagerUtils.h>
+#include <nsStringAPI.h>
+#include <nsILocalFile.h>
#include <nsIWebBrowser.h>
#include <nsIWebBrowserFocus.h>
#include <nsIDOMWindow.h>
@@ -56,28 +58,34 @@ static const nsModuleComponentInfo sSugarComponents[] = {
gboolean
sugar_browser_startup(void)
{
- nsCOMPtr<nsIPrefService> prefService;
nsresult rv;
+ nsCOMPtr<nsIPrefService> prefService;
prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
NS_ENSURE_TRUE(prefService, FALSE);
- nsCOMPtr<nsIPrefBranch> pref;
- prefService->GetBranch("", getter_AddRefs(pref));
- NS_ENSURE_TRUE(pref, 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);
- /* Block onload popups */
- pref->SetBoolPref("dom.disable_open_during_load", TRUE);
+ rv = prefService->ReadUserPrefs (file);
+ if (NS_FAILED(rv)) {
+ g_warning ("failed to read default preferences, error: %x", rv);
+ return FALSE;
+ }
- /* Disable useless security warning */
- pref->SetBoolPref("security.warn_submit_insecure", FALSE);
+ nsCOMPtr<nsIPrefBranch> pref;
+ prefService->GetBranch ("", getter_AddRefs(pref));
+ NS_ENSURE_TRUE(pref, 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");
+ rv = prefService->ReadUserPrefs (nsnull);
+ if (NS_FAILED(rv)) {
+ g_warning ("failed to read user preferences, error: %x", rv);
+ }
+ /* Register our components */
nsCOMPtr<nsIComponentRegistrar> componentRegistrar;
NS_GetComponentRegistrar(getter_AddRefs(componentRegistrar));
NS_ENSURE_TRUE (componentRegistrar, FALSE);