[Pkg-mozext-commits] [nosquint] 01/47: Import of 0.9.0 release into git

David Prévot taffit at moszumanska.debian.org
Tue Apr 28 01:41:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 2.1.6
in repository nosquint.

commit 724a0342c3a300e7be0b5d7163ab16a5e78f1643
Author: Jason Tackaberry <tack at urandom.ca>
Date:   Fri Jan 13 19:40:47 2012 -0500

    Import of 0.9.0 release into git
---
 build-xpi.sh                         |  28 ++++
 src/chrome.manifest                  |   6 +
 src/chrome.manifest.in               |   6 +
 src/content/init.js                  |  18 +++
 src/content/nosquint.js              | 284 +++++++++++++++++++++++++++++++++++
 src/content/overlay.xul              |  12 ++
 src/content/prefs.xul                |  23 +++
 src/defaults/preferences/nosquint.js |   5 +
 src/install.rdf                      |  27 ++++
 src/locale/en-US/overlay.dtd         |   1 +
 src/locale/en-US/prefs.dtd           |   4 +
 11 files changed, 414 insertions(+)

diff --git a/build-xpi.sh b/build-xpi.sh
new file mode 100755
index 0000000..028b436
--- /dev/null
+++ b/build-xpi.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+[ ! -f "src/install.rdf" ] && {
+    echo src/install.rdf is not found
+    exit 1
+}
+
+version=`cat "src/install.rdf" | grep "em:version" | sed 's/.*version>\(.*\)<.*/\1/'`
+[ -z "$version" ] && {
+    echo Unable to determine version.
+    exit 1
+}
+
+mkdir -p dist
+cp -a src dist/$version.$$
+pushd dist/$version.$$
+find -name '.*.swp' -exec rm -f {} \;
+cat chrome.manifest.in | sed 's/${JAR}/jar:chrome\/nosquint.jar!\//' > chrome.manifest
+rm -f chrome.manifest.in
+mkdir chrome
+zip -9 -r chrome/nosquint.jar content locale skin
+rm -rf content locale skin
+rm -f ../nosquint-$version.xpi
+zip -9 -r ../nosquint-$version.xpi *
+popd
+rm -rf dist/$version.$$
+
+echo Packaged dist/nosquint-$version.xpi
diff --git a/src/chrome.manifest b/src/chrome.manifest
new file mode 100644
index 0000000..c01d036
--- /dev/null
+++ b/src/chrome.manifest
@@ -0,0 +1,6 @@
+content nosquint content/
+overlay chrome://browser/content/browser.xul chrome://nosquint/content/overlay.xul
+
+locale nosquint en-US locale/en-US/
+
+skin nosquint classic/1.0 jar:chrome:/nosquint.jar!/skin/
diff --git a/src/chrome.manifest.in b/src/chrome.manifest.in
new file mode 100644
index 0000000..4086a0d
--- /dev/null
+++ b/src/chrome.manifest.in
@@ -0,0 +1,6 @@
+content nosquint ${JAR}content/
+overlay chrome://browser/content/browser.xul chrome://nosquint/content/overlay.xul
+
+locale nosquint en-US ${JAR}locale/en-US/
+
+skin nosquint classic/1.0 jar:chrome:/nosquint.jar!/skin/
diff --git a/src/content/init.js b/src/content/init.js
new file mode 100644
index 0000000..e4d0367
--- /dev/null
+++ b/src/content/init.js
@@ -0,0 +1,18 @@
+window.addEventListener("load", NoSquint.init, false); 
+window.addEventListener("unload", NoSquint.destroy, false); 
+
+
+ZoomManager.prototype.getInstance().reset = function() {
+    ZoomManager.prototype.getInstance().textZoom = NoSquint.defaultZoomLevel;
+    NoSquint.saveCurrentZoom();
+}
+
+ZoomManager.prototype.getInstance().enlarge = function() {
+    ZoomManager.prototype.getInstance().textZoom += 10;
+    NoSquint.saveCurrentZoom();
+}
+
+ZoomManager.prototype.getInstance().reduce = function() {
+    ZoomManager.prototype.getInstance().textZoom -= 10;
+    NoSquint.saveCurrentZoom();
+}
diff --git a/src/content/nosquint.js b/src/content/nosquint.js
new file mode 100644
index 0000000..c856a49
--- /dev/null
+++ b/src/content/nosquint.js
@@ -0,0 +1,284 @@
+var NoSquint = {
+
+    prefs: null,
+    mousePrefs: null,
+    initialized: false,
+    url: null,
+    tabbrowser: null,
+    listeners: [],
+    rObserver: {
+        observe: function(subject, topic, data) { NoSquint.prefsChanged(); }
+    },
+    eatNextPrefChange: false,
+
+    // Prefs
+    domains: {},
+    defaultZoomLevel: 120,
+    rememberDomains: true,
+    wheelZoomEnabled: true,
+    wheelActionSave: -1,
+
+    init: function() {
+        if (NoSquint.initialized)
+            return;
+
+        NoSquint.initPrefs();
+
+        NoSquint.tabbrowser = document.getElementById("content");
+        NoSquint.tabbrowser.addEventListener("DOMNodeInserted", NoSquint.handleNewBrowser, false);
+        window.addEventListener("DOMMouseScroll", NoSquint.handleScrollWheel, false); 
+
+        var pbi = NoSquint.prefs.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
+        pbi.addObserver("", NoSquint.rObserver, false);
+
+        NoSquint.initialized = true;
+    },
+
+    destroy: function() {
+        var pbi = NoSquint.prefs.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
+        pbi.removeObserver("", NoSquint.rObserver);
+        // Restore previous mousewheel.withcontrolkey.action value
+        if (NoSquint.mousePrefs && NoSquint.wheelActionSave != -1) {
+            NoSquint.mousePrefs.setIntPref("action", NoSquint.wheelActionSave);
+            NoSquint.prefs.setIntPref("wheelActionSave", -1);
+        }
+
+        // Clean up active progress listeners, unregistering DOMNodeRemoved event listeners
+        for (var i = 0; i < NoSquint.listeners.length; i++) {
+            var browser = NoSquint.listeners[i].browser;
+            browser.parentNode.removeEventListener("DOMNodeRemoved", NoSquint.handleRemoveBrowser, false);
+        }
+        NoSquint.listeners = [];
+        // Unregister the event listeners setup during init.
+        NoSquint.tabbrowser.removeEventListener("DOMNodeInserted", NoSquint.handleNewBrowser, false);
+        window.removeEventListener("DOMMouseScroll", NoSquint.handleScrollWheel, false);
+    },
+
+    handleScrollWheel: function(event) {
+        if (!event.ctrlKey || !NoSquint.wheelZoomEnabled)
+            return;
+        //alert(event.detail + ' -- target -- ' + event.target.nodeName);
+        if (event.detail < 0)
+            ZoomManager.prototype.getInstance().reduce();
+        else if (event.detail > 0)
+            ZoomManager.prototype.getInstance().enlarge();
+
+        event.stopPropagation();
+        event.preventDefault();
+    },
+
+    getCurrentBrowser: function() {
+        var nodes = NoSquint.tabbrowser.mPanelContainer.getElementsByTagName("browser");
+        var cur = nodes[NoSquint.tabbrowser.mPanelContainer.selectedIndex];
+        return cur;
+    },
+
+    getDomainFromHost: function(host) {
+        return host.replace(/^.*?([^.]*\.[^.]*$)/, "$1");
+    },
+
+    handleNewBrowser: function(event) {
+        var nodes = NoSquint.tabbrowser.mPanelContainer.getElementsByTagName("browser");
+        var last = nodes[nodes.length - 1];
+        for (var i = 0; i < NoSquint.listeners.length; i++) {
+            if (NoSquint.listeners[i].browser == last) {
+                //alert("Not making lisener");
+                return;
+            }
+        }
+        last.parentNode.addEventListener("DOMNodeRemoved", NoSquint.handleRemoveBrowser, false);
+
+        var listener = new ProgressListener(last);
+        //alert("Create new listener");
+        NoSquint.listeners[NoSquint.listeners.length] = listener;
+        last.addProgressListener(listener, Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
+        //window.setTimeout(function() { NoSquint.zoom(last, null); }, 1);
+    },
+    
+    handleRemoveBrowser: function(event) {
+        var nodes = event.target.getElementsByTagName("browser");
+        if (nodes.length == 0) // should this ever happen?
+            return;
+        // Find the listener for this browser and remove it.
+        // XXX: should we assume nodes.length == 1 here, or should we iterate
+        // over each node?
+        var browser = nodes[0];
+        for (var i = 0; i < NoSquint.listeners.length; i++) {
+            if (NoSquint.listeners[i].browser == browser) {
+                NoSquint.listeners.splice(i, 1);
+                return;
+            }
+        }
+    },
+
+    zoom: function(node, domain) {
+        if (!node)
+            return;
+
+        if (domain == null && node.currentURI)
+            domain = NoSquint.getDomainFromHost(node.currentURI.asciiHost);
+
+        try {
+            if (!domain)
+                throw "blah";
+            if (!NoSquint.domains[domain] || !NoSquint.rememberDomains)
+                level = NoSquint.defaultZoomLevel;
+            else
+                level = NoSquint.domains[domain];
+
+            //alert("Set zoom for host: " + host + " -- " + level + " -- " + NoSquint.rememberDomains);
+            if (node.markupDocumentViewer.textZoom != level / 100.0)
+                node.markupDocumentViewer.textZoom = level / 100.0;
+        } catch(ex) {
+            window.setTimeout(function() { NoSquint.zoom(node, domain); }, 100);
+        }
+    },
+
+    zoomAll: function() {
+        var nodes;
+        try { 
+            nodes = NoSquint.tabbrowser.mPanelContainer.getElementsByTagName("browser"); 
+        } catch(ex) {
+            return;
+        }
+        for (var i = 0; i < nodes.length; i++) {
+            NoSquint.zoom(nodes[i]);
+        }
+    },
+
+    onMenuItemCommand: function() {
+        window.openDialog("chrome://nosquint/content/prefs.xul", "", "chrome");
+    },
+
+    initPrefs: function() {
+        if (NoSquint.prefs)
+            return;
+
+        var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(
+                          Components.interfaces.nsIPrefService);
+        NoSquint.prefs = prefs.getBranch("extensions.nosquint.");
+        NoSquint.mousePrefs = prefs.getBranch("mousewheel.withcontrolkey.");
+
+        try { NoSquint.prefs.getIntPref("zoomlevel"); } 
+        catch (err) { NoSquint.prefs.setIntPref("zoomlevel", NoSquint.defaultZoomLevel); }
+
+        try { NoSquint.prefs.getCharPref("domains"); }
+        catch (err) { NoSquint.prefs.setCharPref("domains", ""); }
+
+        try { NoSquint.prefs.getBoolPref("rememberDomains"); } 
+        catch (err) { NoSquint.prefs.setBoolPref("rememberDomains", NoSquint.rememberDomains); }
+
+        try { NoSquint.prefs.getBoolPref("wheelZoomEnabled"); } 
+        catch (err) { NoSquint.prefs.setBoolPref("wheelZoomEnabled", NoSquint.wheelZoomEnabled); }
+
+        try { NoSquint.wheelActionSave = NoSquint.prefs.getBoolPref("wheelActionSave"); } 
+        catch (err) { NoSquint.prefs.setIntPref("wheelActionSave", NoSquint.wheelActionSave); }
+
+
+        if (NoSquint.wheelActionSave == -1) {
+            NoSquint.wheelActionSave = NoSquint.mousePrefs.getIntPref("action");
+            NoSquint.prefs.setIntPref("wheelActionSave", NoSquint.wheelActionSave);
+        }
+
+        NoSquint.mousePrefs.setIntPref("action", 0);
+        NoSquint.prefsChanged();
+    },
+
+    initPrefsDialog: function(doc) {
+        NoSquint.initPrefs();
+        doc.getElementById("defaultZoomLevel").value = NoSquint.defaultZoomLevel;
+        doc.getElementById("rememberDomains").selectedIndex = NoSquint.rememberDomains ? 0 : 1;
+        //doc.getElementById("wheelZoomEnabled").checked = NoSquint.wheelZoomEnabled;
+    },
+
+    savePrefs: function(doc) {
+        if (doc) {
+            NoSquint.prefs.setIntPref("zoomlevel", doc.getElementById("defaultZoomLevel").value);
+            var val = doc.getElementById("rememberDomains").selectedIndex == 0 ? true : false;
+            NoSquint.prefs.setBoolPref("rememberDomains", val);
+            //NoSquint.prefs.setBoolPref("wheelZoomEnabled", doc.getElementById("wheelZoomEnabled").checked);
+            return;
+        }
+
+        var domains = [];
+        for (var domain in NoSquint.domains) {
+            if (NoSquint.domains[domain]) {
+                domains[domains.length] = domain + "=" + NoSquint.domains[domain];
+            }
+        }
+        var domainList = domains.join(" ");
+        NoSquint.eatNextPrefChange = true;
+        NoSquint.prefs.setCharPref("domains", domainList);
+    },
+
+    prefsChanged: function() {
+        if (NoSquint.eatNextPrefChange) {
+            NoSquint.eatNextPrefChange = false;
+            return;
+        }
+        NoSquint.defaultZoomLevel = NoSquint.prefs.getIntPref("zoomlevel");
+        NoSquint.wheelZoomEnabled = NoSquint.prefs.getBoolPref("wheelZoomEnabled");
+        // TODO: if rememberDomains has been changed from false to true, iterate
+        // over current browsers and remember current zoom levels for these windows.
+        NoSquint.rememberDomains = NoSquint.prefs.getBoolPref("rememberDomains");
+        var domainList = NoSquint.prefs.getCharPref("domains");
+        var domains = domainList.split(" ");
+        NoSquint.domains = {};
+        for (var i = 0; i < domains.length; i++) {
+            var domain = domains[i].split("=");
+            NoSquint.domains[domain[0]] = parseInt(domain[1]);
+        }
+        NoSquint.zoomAll();
+    },
+
+    locationChanged: function(browser, uri) {
+        NoSquint.zoom(browser, NoSquint.getDomainFromHost(uri.asciiHost));
+    },
+
+    saveCurrentZoom: function() {
+        if (!NoSquint.rememberDomains)
+            return;
+
+        var browser = NoSquint.getCurrentBrowser();
+        var domain = NoSquint.getDomainFromHost(browser.currentURI.asciiHost);
+        var level = Math.round(browser.markupDocumentViewer.textZoom * 100);
+        if (level != NoSquint.defaultZoomLevel)
+            NoSquint.domains[domain] = level;
+        else
+            delete NoSquint.domains[domain];
+
+        NoSquint.savePrefs(null);
+    }
+};
+
+
+
+// Listener used to receive notifications when a new URI is about to be loaded.
+function ProgressListener(browser) {
+    this.browser = browser;
+    this.lastURI = null;
+}
+
+ProgressListener.prototype.QueryInterface = function(aIID) {
+    if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
+        aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
+        aIID.equals(Components.interfaces.nsISupports))
+        return this;
+    throw Components.results.NS_NOINTERFACE;
+}
+
+ProgressListener.prototype.onLocationChange = function(progress, request, uri) {
+    //alert("Location change: " + uri.spec + " -- old: " + this.lastURI);
+    if (uri.spec == this.lastURI)
+        return;
+    this.lastURI = uri.spec;
+    NoSquint.locationChanged(this.browser, uri);
+}
+
+ProgressListener.prototype.onProgressChange =
+ProgressListener.prototype.onStatusChange =
+ProgressListener.prototype.onStateChange =
+ProgressListener.prototype.onSecurityChange =
+ProgressListener.prototype.onLinkIconAvailable = function() {
+    return 0;
+}
diff --git a/src/content/overlay.xul b/src/content/overlay.xul
new file mode 100644
index 0000000..e6287be
--- /dev/null
+++ b/src/content/overlay.xul
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://nosquint/locale/overlay.dtd">
+<overlay id="nosquint-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+    <script src="nosquint.js" />
+    <script src="init.js" />
+
+    <menupopup id="menu_ToolsPopup">
+        <menuitem id="nosquint-menuitem" label="&nosquint;" oncommand="NoSquint.onMenuItemCommand(event);"
+                  insertbefore="devToolsSeparator" />
+    </menupopup>
+
+</overlay> 
diff --git a/src/content/prefs.xul b/src/content/prefs.xul
new file mode 100644
index 0000000..17960d2
--- /dev/null
+++ b/src/content/prefs.xul
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/global.css"  type="text/css"?>
+<!DOCTYPE window SYSTEM "chrome://nosquint/locale/prefs.dtd">
+
+<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        title="&title.label;"
+        buttons="accept,cancel" 
+        ondialogaccept="NoSquint.savePrefs(document)"
+        persist="screenX screenY"
+        onload="NoSquint.initPrefsDialog(document)">
+
+    <script src="nosquint.js" />
+
+    <hbox align="center">
+        <description flex="0">&level.label;</description>
+        <textbox id="defaultZoomLevel" size="5"/>
+        <description flex="0">%</description>
+    </hbox>
+    <radiogroup id="rememberDomains">
+        <radio label="&rememberDomains;" />
+        <radio label="&noRememberDomains;" />
+    </radiogroup>
+</dialog>
diff --git a/src/defaults/preferences/nosquint.js b/src/defaults/preferences/nosquint.js
new file mode 100644
index 0000000..8f09068
--- /dev/null
+++ b/src/defaults/preferences/nosquint.js
@@ -0,0 +1,5 @@
+pref("extensions.nosquint.zoomlevel", 120);
+pref("extensions.nosquint.rememberDomains", true);
+pref("extensions.nosquint.domains", "");
+pref("extensions.nosquint.wheelZoomEnabled", true);
+pref("extensions.nosquint.wheelActionSave", -1);
diff --git a/src/install.rdf b/src/install.rdf
new file mode 100644
index 0000000..4487aa6
--- /dev/null
+++ b/src/install.rdf
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:install-manifest">
+  
+    <em:id>nosquint at urandom.ca</em:id>
+    <em:name>No Squint</em:name>
+    <em:version>0.9.0</em:version>
+    <em:description>Zooms text by user-configurable percentage</em:description>
+    <em:creator>Jason Tackaberry</em:creator>
+   
+    <em:homepageURL>http://urandom.ca/nosquint/</em:homepageURL>
+    <em:optionsURL>chrome://nosquint/content/prefs.xul</em:optionsURL>
+
+    <!-- Firefox -->
+    <em:targetApplication>
+      <Description>
+        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+        <em:minVersion>1.5</em:minVersion>
+        <em:maxVersion>1.5.0.*</em:maxVersion>
+      </Description>
+    </em:targetApplication>
+
+  </Description>
+
+</RDF>
diff --git a/src/locale/en-US/overlay.dtd b/src/locale/en-US/overlay.dtd
new file mode 100644
index 0000000..dfffc68
--- /dev/null
+++ b/src/locale/en-US/overlay.dtd
@@ -0,0 +1 @@
+<!ENTITY nosquint "NoSquint Settings">
diff --git a/src/locale/en-US/prefs.dtd b/src/locale/en-US/prefs.dtd
new file mode 100644
index 0000000..1b20f30
--- /dev/null
+++ b/src/locale/en-US/prefs.dtd
@@ -0,0 +1,4 @@
+<!ENTITY title.label "NoSquint Options">
+<!ENTITY level.label "Default text zoom level:">
+<!ENTITY rememberDomains "Remember text zoom level per domain">
+<!ENTITY noRememberDomains "Use the default text zoom level for all domains">

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/nosquint.git



More information about the Pkg-mozext-commits mailing list