|
From: <dwa...@us...> - 2012-06-13 13:34:40
|
Revision: 10834
http://zaf.svn.sourceforge.net/zaf/?rev=10834&view=rev
Author: dwaynebailey
Date: 2012-06-13 13:34:30 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
Add a first run and version page
We can now specify a first run and version page
for our checkers. This introduces a small little
app that just open the firstrun or version page
based on the status of some preference entries.
Modified Paths:
--------------
trunk/dict/utils/Makefile.language
Added Paths:
-----------
trunk/dict/utils/mozilla/chrome/
trunk/dict/utils/mozilla/chrome/content/
trunk/dict/utils/mozilla/chrome/content/dict.js.in
trunk/dict/utils/mozilla/chrome/content/dict.xul
trunk/dict/utils/mozilla/chrome.manifest
trunk/dict/utils/mozilla/defaults/
trunk/dict/utils/mozilla/defaults/preferences/
trunk/dict/utils/mozilla/defaults/preferences/dict.js
Modified: trunk/dict/utils/Makefile.language
===================================================================
--- trunk/dict/utils/Makefile.language 2012-06-13 13:32:08 UTC (rev 10833)
+++ trunk/dict/utils/Makefile.language 2012-06-13 13:34:30 UTC (rev 10834)
@@ -233,11 +233,29 @@
hunspell/dictionaries:
mkdir -p hunspell/dictionaries
-hunspell/spell-$(LANG)-$(REGION)-$(VERSION).xpi: hunspell/install.js hunspell/install.rdf hunspell/README-$(LANG)-$(REGION).txt hunspell/dictionaries hunspell/dictionaries/$(LANG)-$(REGION).dic hunspell/dictionaries/$(LANG)-$(REGION).aff
+hunspell/chrome/content:
+ mkdir -p hunspell/chrome/content
+
+hunspell/chrome/content/dict.xul: ../utils/mozilla/chrome/content/dict.xul
+ cp $^ $@
+
+hunspell/chrome/content/dict.js: ../utils/mozilla/chrome/content/dict.js.in
+ sed "s/{LANG}/$(LANG)/; s/{REGION}/$(REGION)/; s/{LANGNAME}/$(LANGNAME)/; s/{REGIONNAME}/$(REGIONNAME)/; s/{VERSION}/$(VERSION)/" < $< > $@
+
+hunspell/defaults/preferences:
+ mkdir -p hunspell/defaults/preferences
+
+hunspell/defaults/preferences/dict.js: ../utils/mozilla/defaults/preferences/dict.js
+ sed "s/{LANG}/$(LANG)/; s/{REGION}/$(REGION)/; s/{LANGNAME}/$(LANGNAME)/; s/{REGIONNAME}/$(REGIONNAME)/; s/{VERSION}/$(VERSION)/" < $< > $@
+
+hunspell/chrome.manifest: ../utils/mozilla/chrome.manifest
+ cp $^ $@
+
+hunspell/spell-$(LANG)-$(REGION)-$(VERSION).xpi: hunspell/install.js hunspell/install.rdf hunspell/README-$(LANG)-$(REGION).txt hunspell/dictionaries hunspell/dictionaries/$(LANG)-$(REGION).dic hunspell/dictionaries/$(LANG)-$(REGION).aff hunspell/defaults/preferences hunspell/defaults/preferences/dict.js hunspell/chrome/content hunspell/chrome/content/dict.js hunspell/chrome/content hunspell/chrome/content/dict.xul hunspell/chrome.manifest
cd hunspell/ ;\
ls ;\
rm -f spell-$(LANG)-$(REGION)-$(VERSION).xpi ;\
- zip -r spell-$(LANG)-$(REGION)-$(VERSION).xpi dictionaries/ README-$(LANG)-$(REGION).txt install.js install.rdf ;\
+ zip -r spell-$(LANG)-$(REGION)-$(VERSION).xpi dictionaries/ README-$(LANG)-$(REGION).txt install.js install.rdf chrome.manifest defaults/ chrome/ ;\
#=============================================================================
Added: trunk/dict/utils/mozilla/chrome/content/dict.js.in
===================================================================
--- trunk/dict/utils/mozilla/chrome/content/dict.js.in (rev 0)
+++ trunk/dict/utils/mozilla/chrome/content/dict.js.in 2012-06-13 13:34:30 UTC (rev 10834)
@@ -0,0 +1,51 @@
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+dict = {
+
+ curVersion: "{VERSION}",
+
+ firstrunURL: "http://translate.org.za/spellchecker/{LANG}-{REGION}/mozilla/firstrun",
+
+ versionBaseURL: "http://translate.org.za/spellchecker/{LANG}-{REGION}/mozilla/version",
+
+ prefs: Services.prefs.getBranch("extensions.{LANG}-{REGION}@dictionaries.addons.mozilla.org."),
+
+ init: function () {
+
+ // Register to receive notifications of preference changes
+ Services.prefs.addObserver("extensions.{LANG}-{REGION}@dictionaries.addons.mozilla.org.", this, false);
+
+ var firstrun = dict.prefs.getBoolPref("firstrun");
+ var infoURL, openInfo = false;
+
+ if (firstrun) {
+ dict.prefs.setBoolPref("firstrun", false);
+ dict.prefs.setCharPref("installedVersion", this.curVersion);
+
+ openInfo = true;
+ infoURL = dict.firstrunURL;
+ } else {
+ try {
+ var installedVersion = dict.prefs.getCharPref("installedVersion");
+
+ /* We are in the middle of an upgrade */
+ if (this.curVersion != installedVersion) {
+ dict.prefs.setCharPref("installedVersion", this.curVersion);
+
+ openInfo = true;
+ infoURL = dict.versionBaseURL +
+ this.curVersion.replace(/\./g, '');
+ }
+ } catch (ex) { /* Reinstall: do we need to do something in this situation? */
+ }
+ }
+
+ if (openInfo) {
+ setTimeout(function () {
+ gBrowser.selectedTab = gBrowser.addTab(infoURL);
+ }, 1000);
+ }
+ },
+};
+
+window.addEventListener("load", function(e) { dict.init(); }, false);
Added: trunk/dict/utils/mozilla/chrome/content/dict.xul
===================================================================
--- trunk/dict/utils/mozilla/chrome/content/dict.xul (rev 0)
+++ trunk/dict/utils/mozilla/chrome/content/dict.xul 2012-06-13 13:34:30 UTC (rev 10834)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/x-javascript" src="dict.js"/>
+</overlay>
Added: trunk/dict/utils/mozilla/chrome.manifest
===================================================================
--- trunk/dict/utils/mozilla/chrome.manifest (rev 0)
+++ trunk/dict/utils/mozilla/chrome.manifest 2012-06-13 13:34:30 UTC (rev 10834)
@@ -0,0 +1,3 @@
+content dict chrome/content/
+
+overlay chrome://browser/content/browser.xul chrome://dict/content/dict.xul
Added: trunk/dict/utils/mozilla/defaults/preferences/dict.js
===================================================================
--- trunk/dict/utils/mozilla/defaults/preferences/dict.js (rev 0)
+++ trunk/dict/utils/mozilla/defaults/preferences/dict.js 2012-06-13 13:34:30 UTC (rev 10834)
@@ -0,0 +1,2 @@
+pref("extensions.{LANG}-{REGION}@dictionaries.addons.mozilla.org.installedVersion", "0.0");
+pref("extensions.{LANG}-{REGION}@dictionaries.addons.mozilla.org.firstrun", true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|