diff --git a/Donators b/Donators
index c55c1b86..50b8d20c 100644
--- a/Donators
+++ b/Donators
@@ -8,6 +8,7 @@
* Miron Tewfik
* Robert Heckel
* Stefan Krauth
+* Giuseppe Guida
I want to say a big THANK YOU for all people which supported this project in this way.
diff --git a/chrome/content/vimperator/bookmarks.js b/chrome/content/vimperator/bookmarks.js
index 9c3ae7bd..a5c32ddf 100644
--- a/chrome/content/vimperator/bookmarks.js
+++ b/chrome/content/vimperator/bookmarks.js
@@ -32,11 +32,14 @@ function Bookmarks() //{{{
////////////////////////////////////////////////////////////////////////////////
////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
-
- const search_service = Components.classes["@mozilla.org/browser/search-service;1"].
- getService(Components.interfaces.nsIBrowserSearchService);
- const rdf_service = Components.classes["@mozilla.org/rdf/rdf-service;1"].
- getService( Components.interfaces.nsIRDFService );
+ const history_service = Components.classes["@mozilla.org/browser/nav-history-service;1"]
+ .getService(Components.interfaces.nsINavHistoryService);
+ const bookmarks_service = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
+ .getService(Components.interfaces.nsINavBookmarksService);
+ const search_service = Components.classes["@mozilla.org/browser/search-service;1"].
+ getService(Components.interfaces.nsIBrowserSearchService);
+ const io_service = Components.classes['@mozilla.org/network/io-service;1']
+ .getService(Components.interfaces.nsIIOService);
var bookmarks = null;
var keywords = null;
@@ -47,21 +50,46 @@ function Bookmarks() //{{{
function load()
{
// update our bookmark cache
- var root = rdf_service.GetResource("NC:BookmarksRoot");
bookmarks = []; // also clear our bookmark cache
keywords = [];
+ var root = bookmarks_service.bookmarksRoot;
- var bmarks = []; // here getAllChildren will store the bookmarks
- BookmarksUtils.getAllChildren(root, bmarks);
- for (var bm in bmarks)
+ var folders = [root];
+ var query = history_service.getNewQuery();
+ var options = history_service.getNewQueryOptions();
+// query.searchTerms = "test";
+ while (folders.length > 0)
{
- if (bmarks[bm][0] && bmarks[bm][1])
- bookmarks.push([bmarks[bm][1].Value, bmarks[bm][0].Value ]);
+ //comment out the next line for now; the bug hasn't been fixed; final version should include the next line
+ //options.setGroupingMode(options.GROUP_BY_FOLDER);
+ query.setFolders(folders, 1);
+ var result = history_service.executeQuery(query, options);
+ result.sortingMode = options.SORT_BY_DATE_DESCENDING;
+ //result.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
+ var rootNode = result.root;
+ rootNode.containerOpen = true;
- // keyword
- if (bmarks[bm][1] && bmarks[bm][2])
- keywords.push([bmarks[bm][2].Value, bmarks[bm][0].Value, bmarks[bm][1].Value]);
+ folders.shift();
+ // iterate over the immediate children of this folder
+ for (var i = 0; i < rootNode.childCount; i ++)
+ {
+ var node = rootNode.getChild(i);
+ //dump("Child " + node.itemId + ": " + node.title + " - " + node.type + "\n");
+ if (node.type == node.RESULT_TYPE_FOLDER) // folder
+ folders.push(node.itemId);
+ else if (node.type == node.RESULT_TYPE_URI) // bookmark
+ {
+ bookmarks.push([node.uri, node.title]);
+ var kw = bookmarks_service.getKeywordForBookmark(node.itemId);
+ if (kw)
+ keywords.push([kw, node.title, node.uri]);
+ }
+ }
+
+ // close a container after using it!
+ rootNode.containerOpen = false;
}
+ return;
}
/////////////////////////////////////////////////////////////////////////////}}}
@@ -78,74 +106,42 @@ function Bookmarks() //{{{
return bookmarks;
}
- // TODO: keyword support
- this.add = function (title, uri, keyword)
+ this.add = function (title, url, keyword)
{
if (!bookmarks)
load();
- folder = rdf_service.GetResource("NC:BookmarksRoot");
- var rSource = BookmarksUtils.createBookmark(title, uri, keyword, title);
- var selection = BookmarksUtils.getSelectionFromResource(rSource);
- var target = BookmarksUtils.getTargetFromFolder(folder);
- BookmarksUtils.insertAndCheckSelection("newbookmark", selection, target);
+ var uri = io_service.newURI(url, null, null);
+ var id = bookmarks_service.insertBookmark(bookmarks_service.bookmarksRoot, uri, -1, title);
+ if (id && keyword)
+ {
+ bookmarks_service.setKeywordForBookmark(id, keyword);
+ keywords.unshift([keyword, title, url]);
+ }
//also update bookmark cache
- bookmarks.unshift([uri, title]);
+ bookmarks.unshift([url, title]);
return true;
}
- // NOTE: no idea what it does, it Just Works (TM)
// returns number of deleted bookmarks
this.remove = function(url)
{
- var deleted = 0;
if (!url)
return 0;
- // gNC_NS for trunk, NC_NS for 1.X
- //try { var pNC_NS; pNC_NS = gNC_NS;} catch (err) { pNC_NS = NC_NS;}
- if (!BMSVC || !BMDS || !RDF || !gNC_NS) // defined from firefox
- return 0;
+ var uri = io_service.newURI(url, null, null);
+ var count = {};
+ var bmarks = bookmarks_service.getBookmarkIdsForURI(uri, count);
- var curfolder = RDF.GetResource("NC:BookmarksRoot");
- var urlArc = RDF.GetResource(gNC_NS + "URL");
- var urlLiteral = RDF.GetLiteral(url);
- if (BMDS.hasArcIn(urlLiteral, urlArc))
- {
- var bmResources, bmResource, title, uri, type, ptype;
- bmResources = BMSVC.GetSources(urlArc, urlLiteral, true);
- while (bmResources.hasMoreElements())
- {
- bmResource = bmResources.getNext();
- type = BookmarksUtils.resolveType(bmResource);
- if (type != "ImmutableBookmark")
- {
- ptype = BookmarksUtils.resolveType(BMSVC.getParent(bmResource));
- // alert(type);
- // if ( type == "Folder") // store the current folder
- // curfolder = bmResource;
- if ( (type == "Bookmark" || type == "IEFavorite") && ptype != "Livemark")
- {
- title = BookmarksUtils.getProperty(bmResource, gNC_NS + "Name");
- uri = BookmarksUtils.getProperty(bmResource, gNC_NS + "URL");
-
- if (uri == url)
- {
- RDFC.Init(BMDS, BMSVC.getParent(bmResource));
- RDFC.RemoveElement(bmResource, true);
- deleted++;
- }
- }
- }
- }
- }
+ for (var i = 0; i < bmarks.length; i++)
+ bookmarks_service.removeItem(bmarks[i]);
// also update bookmark cache, if we removed at least one bookmark
- if (deleted > 0)
+ if (count.value > 0)
load();
- return deleted;
+ return count.value;
}
// also ensures that each search engine has a Vimperator-friendly alias
@@ -353,8 +349,8 @@ function History() //{{{
const rdf_service = Components.classes["@mozilla.org/rdf/rdf-service;1"].
getService( Components.interfaces.nsIRDFService );
- const global_history_service = Components.classes["@mozilla.org/browser/global-history;2"].
- getService(Components.interfaces.nsIRDFDataSource);
+// const global_history_service = Components.classes["@mozilla.org/browser/global-history;2"].
+// getService(Components.interfaces.nsIRDFDataSource);
var history = null;
@@ -365,40 +361,40 @@ function History() //{{{
{
history = [];
- var historytree = document.getElementById("hiddenHistoryTree");
- if (!historytree)
- return;
-
- if (historytree.hidden)
- {
- historytree.hidden = false;
- historytree.database.AddDataSource(global_history_service);
- }
-
- if (!historytree.ref)
- historytree.ref = "NC:HistoryRoot";
-
- var nameResource = rdf_service.GetResource(gNC_NS + "Name");
- var builder = historytree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
-
- var count = historytree.view.rowCount;
- for (var i = count - 1; i >= 0; i--)
- {
- var res = builder.getResourceAtIndex(i);
- var url = res.Value;
- var title;
- var titleRes = historytree.database.GetTarget(res, nameResource, true);
- if (!titleRes)
- continue;
-
- var titleLiteral = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral);
- if (titleLiteral)
- title = titleLiteral.Value;
- else
- title = "";
-
- history.push([url, title]);
- }
+// var historytree = document.getElementById("hiddenHistoryTree");
+// if (!historytree)
+// return;
+//
+// if (historytree.hidden)
+// {
+// historytree.hidden = false;
+// historytree.database.AddDataSource(global_history_service);
+// }
+//
+// if (!historytree.ref)
+// historytree.ref = "NC:HistoryRoot";
+//
+// var nameResource = rdf_service.GetResource(gNC_NS + "Name");
+// var builder = historytree.builder.QueryInterface(Components.interfaces.nsIXULTreeBuilder);
+//
+// var count = historytree.view.rowCount;
+// for (var i = count - 1; i >= 0; i--)
+// {
+// var res = builder.getResourceAtIndex(i);
+// var url = res.Value;
+// var title;
+// var titleRes = historytree.database.GetTarget(res, nameResource, true);
+// if (!titleRes)
+// continue;
+//
+// var titleLiteral = titleRes.QueryInterface(Components.interfaces.nsIRDFLiteral);
+// if (titleLiteral)
+// title = titleLiteral.Value;
+// else
+// title = "";
+//
+// history.push([url, title]);
+// }
}
/////////////////////////////////////////////////////////////////////////////}}}
@@ -415,6 +411,8 @@ function History() //{{{
return history;
}
+ // the history is automatically added to the Places global history
+ // so just update our cached history here
this.add = function (url, title)
{
if (!history)
@@ -429,6 +427,7 @@ function History() //{{{
};
// TODO: better names?
+ // and move to vimperator.buffer.?
this.stepTo = function(steps)
{
var index = getWebNavigation().sessionHistory.index + steps;
diff --git a/chrome/content/vimperator/default.css b/chrome/content/vimperator/default.css
index 0398439d..83e29e0c 100644
--- a/chrome/content/vimperator/default.css
+++ b/chrome/content/vimperator/default.css
@@ -141,7 +141,9 @@ fieldset.paypal {
#vimperator-bufferwindow, #vimperator-completion, #vimperator-previewwindow {
-moz-user-focus: ignore;
- overflow: -moz-scrollbars-none;
+ overflow: -moz-scrollbars-none !important; /* does not seem to work fully */
+ border-width: 0px !important;
+ -moz-appearance: none !important; /* prevent an ugly 3D border */
}
/* the selected item in listboxes is hardly readable without this */
diff --git a/chrome/content/vimperator/events.js b/chrome/content/vimperator/events.js
index e4fd58d8..a66b3b3c 100644
--- a/chrome/content/vimperator/events.js
+++ b/chrome/content/vimperator/events.js
@@ -72,6 +72,15 @@ function Events() //{{{
vimperator.setMode(); // trick to reshow the mode in the command line
}, null);
+ // Code for keeping track if a popup is currently active
+ // XXX: does currently not handle submenus
+ this.openPopupCount = 0;
+ this.menuBarActive = 100;
+ window.addEventListener("popupshown", function() { vimperator.log(++vimperator.events.openPopupCount); vimperator.addMode(null, vimperator.modes.MENU); }, true);
+ window.addEventListener("popuphidden", function() { vimperator.log(--vimperator.events.openPopupCount); vimperator.removeMode(null, vimperator.modes.MENU); }, true);
+ window.addEventListener("DOMMenuBarActive", function() { vimperator.log(++vimperator.events.menuBarActive);vimperator.addMode(null, vimperator.modes.MENU); }, true);
+ window.addEventListener("DOMMenuBarInactive", function() { vimperator.log(--vimperator.events.menuBarActive); vimperator.removeMode(null, vimperator.modes.MENU); }, true);
+
window.document.addEventListener("DOMTitleChanged", function(event)
{
//alert("titlechanged");
@@ -209,6 +218,11 @@ function Events() //{{{
window.dump("TODO: remove all eventlisteners");
getBrowser().removeProgressListener(this.progressListener);
+
+ window.removeEventListener("popupshowing");
+ window.removeEventListener("popuphidden");
+ window.removeEventListener("DOMMenuBarActive");
+ window.removeEventListener("DOMMenuBarInactive");
}
// This method pushes keys into the event queue from vimperator
@@ -356,12 +370,15 @@ function Events() //{{{
// if (event.target.id == "main-window")
// alert("focusContent();");
+ if (vimperator.hasMode(vimperator.modes.MENU))
+ return false;
// XXX: ugly hack for now pass certain keys to firefox as they are without beeping
// also fixes key navigation in menus, etc.
if (key == "" || key == "" || key == "" || key == "" || key == "")
return false;
+
// XXX: for now only, later: input mappings if form element focused
if (isFormElemFocused())
{
diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js
index d0e6019a..16701bc8 100644
--- a/chrome/content/vimperator/vimperator.js
+++ b/chrome/content/vimperator/vimperator.js
@@ -49,7 +49,8 @@ const vimperator = (function() //{{{
ESCAPE_ALL_KEYS: 1 << 15,
QUICK_HINT: 1 << 16,
EXTENDED_HINT: 1 << 17,
- ALWAYS_HINT: 1 << 18
+ ALWAYS_HINT: 1 << 18,
+ MENU: 1 << 19 // a popupmenu is active
}
var mode_messages = {};
diff --git a/install.rdf b/install.rdf
index e03149b2..4912f273 100644
--- a/install.rdf
+++ b/install.rdf
@@ -19,8 +19,8 @@
{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
- 2.0
- 2.0.0.*
+ 3.0a7
+ 3.0.0.*