зеркало из https://github.com/mozilla/snowl.git
menuitem to show flat or hierarchical collections, fix stream to unload/remove observer, wiring for menuitems and view states.
This commit is contained in:
Родитель
b9419b14a6
Коммит
c67b26dc9c
|
@ -155,6 +155,18 @@ let Snowl = {
|
|||
}
|
||||
}
|
||||
|
||||
// Hierarchy init
|
||||
let hmenuitems = document.getElementsByAttribute("name", "snowlHierarchyMenuitemGroup");
|
||||
let isHierarchical = this._prefs.get("collection.hierarchicalView");
|
||||
let rivertab = this._snowlRiverTab();
|
||||
if (hmenuitems) {
|
||||
for (var i = 0; i < hmenuitems.length; i++) {
|
||||
hmenuitems[i].setAttribute("disabled", !lchecked && !(rivertab));
|
||||
if (i == isHierarchical)
|
||||
hmenuitems[i].setAttribute("checked", true);
|
||||
}
|
||||
}
|
||||
|
||||
// Toolbars
|
||||
document.getElementById("snowlToolbarMenuitem").setAttribute("disabled",
|
||||
(!lchecked && !schecked) ? true : false);
|
||||
|
@ -322,6 +334,29 @@ let Snowl = {
|
|||
return headerDeck;
|
||||
},
|
||||
|
||||
// Collections hierarchy toggle
|
||||
kHierarchyOff: 0,
|
||||
kHierarchyOn: 1,
|
||||
|
||||
_toggleHierarchy: function(val) {
|
||||
let sidebarDoc = document.getElementById("sidebar").contentWindow;
|
||||
let lchecked = document.getElementById("viewSnowlList").hasAttribute("checked");
|
||||
if (lchecked) {
|
||||
sidebarDoc.CollectionsView.isHierarchical = val;
|
||||
sidebarDoc.CollectionsView._buildCollectionTree();
|
||||
}
|
||||
|
||||
let rivertab = this._snowlRiverTab();
|
||||
if (rivertab) {
|
||||
let tabWindowDoc = gBrowser.getBrowserAtIndex(rivertab._tPos).contentWindow;
|
||||
let tabDoc = new XPCNativeWrapper(tabWindowDoc).wrappedJSObject;
|
||||
tabDoc.CollectionsView.isHierarchical = val;
|
||||
tabDoc.CollectionsView._buildCollectionTree();
|
||||
}
|
||||
|
||||
this._prefs.set("collection.hierarchicalView", val);
|
||||
},
|
||||
|
||||
// Need to init onLoad due to xul structure, toolbar exists in list and stream
|
||||
_initSnowlToolbar: function() {
|
||||
let menuitem = document.getElementById("snowlToolbarMenuitem");
|
||||
|
@ -336,14 +371,27 @@ let Snowl = {
|
|||
_toggleToolbar: function(event) {
|
||||
let name = event.target.getAttribute("name");
|
||||
let menuitem = document.getElementById(name+"Menuitem");
|
||||
let doc = (name == "snowlToolbar") ?
|
||||
document.getElementById("sidebar").contentDocument : document;
|
||||
let toolbar = doc.getElementById(name);
|
||||
let doc, toolbar, rtoolbar = null;
|
||||
|
||||
if (name == "snowlToolbar") {
|
||||
doc = document.getElementById("sidebar").contentDocument;
|
||||
let rivertab = this._snowlRiverTab();
|
||||
if (rivertab)
|
||||
rtoolbar = gBrowser.getBrowserAtIndex(rivertab._tPos).
|
||||
contentDocument.getElementById(name);
|
||||
}
|
||||
else
|
||||
doc = document;
|
||||
|
||||
toolbar = doc.getElementById(name);
|
||||
if (toolbar) {
|
||||
toolbar.hidden = !toolbar.hidden;
|
||||
menuitem.setAttribute("checked", !toolbar.hidden);
|
||||
}
|
||||
if (rtoolbar)
|
||||
rtoolbar.hidden = !rtoolbar.hidden;
|
||||
|
||||
|
||||
},
|
||||
|
||||
// See if River tab exists
|
||||
|
|
|
@ -167,6 +167,19 @@
|
|||
headerType="Snowl.kFullHeader"
|
||||
oncommand="Snowl._toggleHeader(event)"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="snowlHierarchyOffMenuitem"
|
||||
label="&hierarchyOff.label;"
|
||||
type="radio"
|
||||
accesskey="&hierarchyOff.accesskey;"
|
||||
name="snowlHierarchyMenuitemGroup"
|
||||
oncommand="Snowl._toggleHierarchy(Snowl.kHierarchyOff)"/>
|
||||
<menuitem id="snowlHierarchyOnMenuitem"
|
||||
label="&hierarchyOn.label;"
|
||||
type="radio"
|
||||
accesskey="&hierarchyOn.accesskey;"
|
||||
name="snowlHierarchyMenuitemGroup"
|
||||
oncommand="Snowl._toggleHierarchy(Snowl.kHierarchyOn)"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="snowlToolbarMenuitem"
|
||||
label="&toolbar.label;"
|
||||
type="checkbox"
|
||||
|
|
|
@ -44,8 +44,12 @@ Cu.import("resource://snowl/modules/identity.js");
|
|||
Cu.import("resource://snowl/modules/collection.js");
|
||||
Cu.import("resource://snowl/modules/opml.js");
|
||||
|
||||
// FIXME: make this configurable.
|
||||
const SNOWL_COLLECTIONS_HIERARCHICAL = false;
|
||||
let gBrowserWindow = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIDocShellTreeItem).
|
||||
rootTreeItem.
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindow);
|
||||
|
||||
let CollectionsView = {
|
||||
_log: null,
|
||||
|
@ -69,6 +73,7 @@ let CollectionsView = {
|
|||
return this._children = this._tree.getElementsByTagName("treechildren")[0];
|
||||
},
|
||||
|
||||
isHierarchical: gBrowserWindow.Snowl._prefs.get("collection.hierarchicalView"),
|
||||
|
||||
//**************************************************************************//
|
||||
// Initialization & Destruction
|
||||
|
@ -77,7 +82,7 @@ let CollectionsView = {
|
|||
this._log = Log4Moz.Service.getLogger("Snowl.Sidebar");
|
||||
this._obsSvc.addObserver(this, "sources:changed", true);
|
||||
this._getCollections();
|
||||
this._tree.view = this;
|
||||
this._buildCollectionTree();
|
||||
|
||||
// Ensure collection selection maintained, if in List sidebar
|
||||
if (document.getElementById("snowlSidebar"))
|
||||
|
@ -148,7 +153,7 @@ let CollectionsView = {
|
|||
getLevel: function(row) {
|
||||
//this._log.info("getLevel: " + row);
|
||||
|
||||
if (!SNOWL_COLLECTIONS_HIERARCHICAL)
|
||||
if (!this.isHierarchical)
|
||||
return 0;
|
||||
|
||||
return this._rows[row].level;
|
||||
|
@ -252,7 +257,7 @@ let CollectionsView = {
|
|||
// Since the number of rows might have changed, we do this by reinitializing
|
||||
// the view instead of merely invalidating the box object (which doesn't
|
||||
// expect changes to the number of rows).
|
||||
this._tree.view = this;
|
||||
this._buildCollectionTree();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -285,12 +290,13 @@ let CollectionsView = {
|
|||
finally {
|
||||
statement.reset();
|
||||
}
|
||||
},
|
||||
|
||||
// Build the list of rows in the tree. By default, all containers
|
||||
// are closed, so this is the same as the list of collections, although
|
||||
// in the future we might persist and restore the open state.
|
||||
// XXX Should this work be in a separate function?
|
||||
if (SNOWL_COLLECTIONS_HIERARCHICAL) {
|
||||
// Build the list of rows in the tree. By default, all containers
|
||||
// are closed, so this is the same as the list of collections, although
|
||||
// in the future we might persist and restore the open state.
|
||||
_buildCollectionTree: function() {
|
||||
if (this.isHierarchical) {
|
||||
this._rows = [collection for each (collection in this._collections)];
|
||||
}
|
||||
else {
|
||||
|
@ -303,6 +309,8 @@ let CollectionsView = {
|
|||
this._rows.push(collection);
|
||||
}
|
||||
}
|
||||
|
||||
this._tree.view = this;
|
||||
},
|
||||
|
||||
onSelect: function(aEvent) {
|
||||
|
|
|
@ -176,6 +176,10 @@ let SnowlMessageView = {
|
|||
gBrowserWindow.Snowl._initSnowlToolbar();
|
||||
},
|
||||
|
||||
onunLoad: function() {
|
||||
Observers.remove(this, "snowl:message:added");
|
||||
},
|
||||
|
||||
_setMidnightTimout: function() {
|
||||
let t = this;
|
||||
let now = new Date();
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&page.title;"
|
||||
onload="SnowlMessageView.onLoad()"
|
||||
onunload="SnowlMessageView.onunLoad()"
|
||||
onclick="return window.parent.contentAreaClick(event, true);"
|
||||
onresize="try { SnowlMessageView.onResize() }
|
||||
catch(ex) { /* before script loaded */ }">
|
||||
|
|
Загрузка…
Ссылка в новой задаче