Skip to content

Commit

Permalink
New 'Native Popup' notification method, closes #8 and fixes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
diegocr committed Feb 23, 2014
1 parent cec1418 commit e8d50a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
22 changes: 18 additions & 4 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

function LOG(m) (m = addon.name + ' Message @ '
+ (new Date()).toISOString() + "\n> " + m,
Expand All @@ -39,10 +40,23 @@ let i$ = {
let showAlertNotification = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
showAlertNotification = showAlertNotification.showAlertNotification.bind(showAlertNotification);

function iNotify(aMsg, callback) {
function iNotify(aAddon, aMsg, callback) {
let nme = addon.branch.getIntPref('nme');

if(nme == 2) {
if(nme > 1) {
if(nme == 3) try {
if(aAddon) {
let info = {
installs: [{addon:aAddon,name:aAddon.name + ' ' + aAddon.version}],
originatingWindow: Services.wm.getMostRecentWindow('navigator:browser').gBrowser.contentWindow,
QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallInfo])
};
Services.obs.notifyObservers(info, 'addon-install-complete', null);
return callback(null);
}
} catch(e) {
Cu.reportError(e);
}
showAlertNotification(addon.icon,addon.name,aMsg,!1,"",
(s,t) => t == "alertshow" || callback(t));
} else {
Expand Down Expand Up @@ -136,10 +150,10 @@ function onClickHanlder(ev) {
}
f.style.animation = null;
f.className = f.className.replace('hourglass',c);
iNotify(aMsg, () => {
iNotify(aAddon, aMsg, aResult => {
oFile.remove(!1);

if(aAddon && aAddon.pendingOperations) {
if(aResult !== null && aAddon && aAddon.pendingOperations) {
let m = aAddon.name + ' requires restart.\n\n'
+ 'Would you like to restart '
+ Services.appinfo.name + ' now?';
Expand Down
3 changes: 2 additions & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<em:id>{86054B0A-BD85-42F9-8E58-8794EC6F6EA1}</em:id>
<em:type>2</em:type>
<em:name>GitHub Extension Installer</em:name>
<em:version>1.5a1</em:version>
<em:version>1.5a2</em:version>
<em:creator>Diego Casorran &lt;[email protected]&gt;</em:creator>
<em:description>Install Browser Extensions straight from GitHub Repositories</em:description>
<em:contributor>Jerone</em:contributor>
<em:contributor>Zulkarnain K.</em:contributor>
<em:bootstrap>true</em:bootstrap>
<em:targetApplication>
Expand Down
1 change: 1 addition & 0 deletions options.xul
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<menuitem value="0" label="None"/>
<menuitem value="1" label="Modal Dialog"/>
<menuitem value="2" label="Alerts Service"/>
<menuitem value="3" label="Native Popup"/>
</menupopup>
</menulist>
</setting>
Expand Down

0 comments on commit e8d50a8

Please sign in to comment.