1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 15:57:57 +01:00

Add favicons to :ba and :fo

This commit is contained in:
Kris Maglione
2009-07-21 14:48:30 -04:00
parent 773814c985
commit a7de8b8cd0
4 changed files with 28 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ function Bookmarks() //{{{
const historyService = PlacesUtils.history; const historyService = PlacesUtils.history;
const bookmarksService = PlacesUtils.bookmarks; const bookmarksService = PlacesUtils.bookmarks;
const taggingService = PlacesUtils.tagging; 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 :( // XXX for strange Firefox bug :(
// Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]" // Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]"
@@ -863,7 +863,7 @@ function History() //{{{
context.anchored = false; context.anchored = false;
context.completions = sh.slice(0, sh.index).reverse(); 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.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription]; context.filters = [CompletionContext.Filter.textDescription];
}, },
@@ -905,7 +905,7 @@ function History() //{{{
context.anchored = false; context.anchored = false;
context.completions = sh.slice(sh.index + 1); 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.compare = CompletionContext.Sort.unsorted;
context.filters = [CompletionContext.Filter.textDescription]; context.filters = [CompletionContext.Filter.textDescription];
}, },
@@ -988,7 +988,11 @@ function History() //{{{
obj.index = sh.index; obj.index = sh.index;
obj.__iterator__ = function() util.Array.iteritems(this) obj.__iterator__ = function() util.Array.iteritems(this)
for (let i in util.range(0, sh.count)) for (let i in util.range(0, sh.count))
{
obj[i] = { index: i, __proto__: sh.getEntryAtIndex(i, false) }; 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; return obj;
}, },

View File

@@ -1232,7 +1232,7 @@ function Completion() //{{{
{ {
let arg = str.substring(prev + 1, idx); let arg = str.substring(prev + 1, idx);
prev = idx; prev = idx;
args.__defineGetter__(i, function () self.eval(arg)); util.memoize(args, i, function () self.eval(arg));
} }
let key = getKey(); let key = getKey();
args.push(key + string); args.push(key + string);

View File

@@ -94,6 +94,7 @@ function Services()
self.add("directory", "@mozilla.org/file/directory_service;1", Ci.nsIProperties); self.add("directory", "@mozilla.org/file/directory_service;1", Ci.nsIProperties);
self.add("environment", "@mozilla.org/process/environment;1", Ci.nsIEnvironment); self.add("environment", "@mozilla.org/process/environment;1", Ci.nsIEnvironment);
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager); 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("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
self.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService); self.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService); self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);

View File

@@ -178,6 +178,25 @@ const util = { //{{{
return dest; 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. * Split a string on literal occurrences of a marker.
* *