mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:47:59 +01:00
Add favicons to :ba and :fo
This commit is contained in:
@@ -60,7 +60,7 @@ function Bookmarks() //{{{
|
||||
const historyService = PlacesUtils.history;
|
||||
const bookmarksService = PlacesUtils.bookmarks;
|
||||
const taggingService = PlacesUtils.tagging;
|
||||
const faviconService = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
|
||||
const faviconService = services.get("favicon");
|
||||
|
||||
// XXX for strange Firefox bug :(
|
||||
// Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]"
|
||||
@@ -863,7 +863,7 @@ function History() //{{{
|
||||
|
||||
context.anchored = false;
|
||||
context.completions = sh.slice(0, sh.index).reverse();
|
||||
context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title" };
|
||||
context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.filters = [CompletionContext.Filter.textDescription];
|
||||
},
|
||||
@@ -905,7 +905,7 @@ function History() //{{{
|
||||
|
||||
context.anchored = false;
|
||||
context.completions = sh.slice(sh.index + 1);
|
||||
context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title" };
|
||||
context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.filters = [CompletionContext.Filter.textDescription];
|
||||
},
|
||||
@@ -988,7 +988,11 @@ function History() //{{{
|
||||
obj.index = sh.index;
|
||||
obj.__iterator__ = function() util.Array.iteritems(this)
|
||||
for (let i in util.range(0, sh.count))
|
||||
{
|
||||
obj[i] = { index: i, __proto__: sh.getEntryAtIndex(i, false) };
|
||||
util.memoize(obj[i], "icon",
|
||||
function (obj) services.get("favicon").getFaviconImageForPage(obj.URI).spec);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
@@ -1232,7 +1232,7 @@ function Completion() //{{{
|
||||
{
|
||||
let arg = str.substring(prev + 1, idx);
|
||||
prev = idx;
|
||||
args.__defineGetter__(i, function () self.eval(arg));
|
||||
util.memoize(args, i, function () self.eval(arg));
|
||||
}
|
||||
let key = getKey();
|
||||
args.push(key + string);
|
||||
|
||||
@@ -94,6 +94,7 @@ function Services()
|
||||
self.add("directory", "@mozilla.org/file/directory_service;1", Ci.nsIProperties);
|
||||
self.add("environment", "@mozilla.org/process/environment;1", Ci.nsIEnvironment);
|
||||
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
||||
self.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
||||
self.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
|
||||
self.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
|
||||
self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
||||
|
||||
@@ -178,6 +178,25 @@ const util = { //{{{
|
||||
return dest;
|
||||
},
|
||||
|
||||
/**
|
||||
* Memoize the lookup of a property in an object.
|
||||
*
|
||||
* @param {object} obj The object to alter.
|
||||
* @param {string} key The name of the property to memoize.
|
||||
* @param {function} getter A function of zero to two arguments which
|
||||
* will return the property's value. <b>obj</b> is
|
||||
* passed as the first argument, <b>key</b> as the
|
||||
* second.
|
||||
*/
|
||||
memoize: function memoize(obj, key, getter)
|
||||
{
|
||||
obj.__defineGetter__(key, function() {
|
||||
delete obj[key]
|
||||
obj[key] = getter(obj, key);
|
||||
return obj[key];
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Split a string on literal occurrences of a marker.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user