diff --git a/content/browser.js b/content/browser.js
index c8e7387..4e50557 100644
--- a/content/browser.js
+++ b/content/browser.js
@@ -151,14 +151,19 @@ let Snowl = {
}
}
- // Hierarchy init
- let hmenuitems = document.getElementsByAttribute("name", "snowlHierarchyMenuitemGroup");
- let isHierarchical = this._prefs.get("collection.hierarchicalView");
+ // Flat/Grouped init
+ let isFlatList;
+ let sidebarDoc = document.getElementById("sidebar").contentDocument;
+ let sourcesView = sidebarDoc.getElementById("sourcesView");
+ if (sourcesView)
+ isFlatList = sourcesView.getAttribute("flat") == "true";
+
+ let hmenuitems = document.getElementsByAttribute("name", "snowlFlatListMenuitemGroup");
let rivertab = this._snowlRiverTab();
if (hmenuitems) {
for (var i = 0; i < hmenuitems.length; i++) {
hmenuitems[i].setAttribute("disabled", !lchecked && !(rivertab));
- if (i == isHierarchical)
+ if (i == isFlatList)
hmenuitems[i].setAttribute("checked", true);
}
}
@@ -352,27 +357,34 @@ let Snowl = {
return headerDeck;
},
- // Collections hierarchy toggle
- kHierarchyOff: 0,
- kHierarchyOn: 1,
+ // Collections flat/grouped toggle, menu disabled if not in List view
+ kFlatListOff: 0,
+ kFlatListOn: 1,
- _toggleHierarchy: function(val) {
+ _toggleFlatList: function(val) {
let sidebarDoc = document.getElementById("sidebar").contentWindow;
let lchecked = document.getElementById("viewSnowlList").hasAttribute("checked");
if (lchecked) {
- sidebarDoc.CollectionsView.isHierarchical = val;
- sidebarDoc.CollectionsView._buildCollectionTree();
+ sidebarDoc.CollectionsView._tree.setAttribute("flat", val ? true : false);
+ sidebarDoc.CollectionsView._tree.place = val ?
+ SnowlPlaces.queryFlat : SnowlPlaces.queryGrouped;
+ // Ensure collection selection maintained, if in List sidebar
+ if (document.getElementById("snowlSidebar") && SnowlUtils.gListViewCollectionItemId) {
+ sidebarDoc.CollectionsView._tree.
+ selectItems([SnowlUtils.gListViewCollectionItemId]);
+ sidebarDoc.CollectionsView._tree.boxObject.
+ ensureRowIsVisible(sidebarDoc.CollectionsView._tree.currentIndex);
+ }
}
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();
+ tabDoc.CollectionsView._tree.setAttribute("flat", val ? true : false);
+ tabDoc.CollectionsView._tree.place = val ?
+ SnowlPlaces.queryFlat : SnowlPlaces.queryGrouped;
}
-
- this._prefs.set("collection.hierarchicalView", val);
},
// Need to init onLoad due to xul structure, toolbar exists in list and stream
diff --git a/content/browser.xul b/content/browser.xul
index d0b5c55..ce6e045 100644
--- a/content/browser.xul
+++ b/content/browser.xul
@@ -161,18 +161,18 @@
headerType="Snowl.kFullHeader"
oncommand="Snowl._toggleHeader(event)"/>
-
-
+
+ accesskey="&groupedOff.accesskey;"
+ name="snowlFlatListMenuitemGroup"
+ oncommand="Snowl._toggleFlatList(Snowl.kFlatListOn)"/>