Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 076db37
Showing
7 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This is the quickfire2 add-on. It contains: | ||
|
||
* A program (lib/main.js). | ||
* A few tests. | ||
* Some meager documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The main module is a program that creates a widget. When a user clicks on | ||
the widget, the program loads the mozilla.org website in a new tab. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { Cc, Ci, Cm, Cu, Cr, components } = require("chrome"); | ||
|
||
let apps = []; | ||
|
||
function getAppsFromDirectory(aDir) { | ||
var dirs = [aDir]; | ||
while (dirs.length) { | ||
var dir = dirs.shift(); | ||
var entries = dir.directoryEntries; | ||
while (entries.hasMoreElements()) { | ||
var entry = entries.getNext(); | ||
entry.QueryInterface(Ci.nsIFile); | ||
if (/\.app$/.test(entry.path)) | ||
yield entry; | ||
else if (entry.isDirectory()) | ||
dirs.push(entry) | ||
} | ||
} | ||
} | ||
|
||
function getAppList(callback) { | ||
let apps = []; | ||
["LocApp", "UsrApp"].forEach(function(aDir) { | ||
var dirFile = Cc["@mozilla.org/file/directory_service;1"]. | ||
getService(Ci.nsIProperties).get(aDir, Ci.nsIFile); | ||
|
||
var appGetter = getAppsFromDirectory(dirFile); | ||
|
||
for (var app in appGetter) { | ||
if (/\.app$/.test(app.path)) | ||
apps.push(app); | ||
} | ||
}); | ||
callback(apps); | ||
} | ||
|
||
|
||
getAppList(function(theApps) { | ||
apps = theApps; | ||
}); | ||
|
||
exports.search = function(searchString, callback) { | ||
apps.forEach(function(app) { | ||
if (app.path.toLowerCase().indexOf(searchString.toLowerCase()) != -1) | ||
callback({ | ||
leafName: app.leafName, | ||
path: app.path | ||
}); | ||
}); | ||
}; | ||
|
||
|
||
function launchApp(aPath) { | ||
if (!apps.some(function(app) app.path == aPath)) | ||
return; | ||
var binFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); | ||
binFile.initWithPath(aPath); | ||
binFile.launch(); | ||
} | ||
|
||
exports.launch = launchApp; |
Oops, something went wrong.