Skip to content

Commit

Permalink
Install toolbar button on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
mooz committed Oct 8, 2015
1 parent f22a53f commit 49db15d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions content/keysnail.js
Expand Up @@ -140,6 +140,7 @@

document.addEventListener("copy", function () { command.clipboardChanged(); }, true);
hook.callHook("KeySnailInitialized");
this.ensureToolbarButtonInstalled();
},

/**
Expand Down Expand Up @@ -167,6 +168,51 @@
}
},

// ------------------------------------------------------------ //
// Toolbar button {{{
// ------------------------------------------------------------ //

get isFirstRun() {
return util.getBoolPref("extensions.keysnail.first_run", true);
},

set isFirstRun(val) {
return util.setBoolPref("extensions.keysnail.first_run", val);
},

ensureToolbarButtonInstalled: function () {
if (this.isFirstRun) {
this.installToolbarButton();
this.isFirstRun = false;
}
},

toolbarButtonId: "keysnail-toolbar-button",

getToolbarButton: function () { return document.getElementById(this.toolbarButtonId); },

get toolbarButtonInstalled() { return !!this.getToolbarButton(); },

installToolbarButton: function () {
if (this.toolbarButtonInstalled)
return;

let navBar = document.getElementById("nav-bar");
navBar.insertItem(this.toolbarButtonId, null, null, false);

this.makeToolbarButtonsPersistent();
},

makeToolbarButtonsPersistent: function () {
let navBar = document.getElementById("nav-bar");
navBar.setAttribute("currentset", navBar.currentSet);
document.persist("nav-bar", "currentset");
},

// ------------------------------------------------------------ //
// }}} Toolbar button
// ------------------------------------------------------------ //

/**
* Create context menu
*/
Expand Down
1 change: 1 addition & 0 deletions defaults/preferences/keysnail-prefs.js
@@ -1,3 +1,4 @@
pref("extensions.keysnail.first_run", true);
pref("extensions.keysnail.userscript.location", "");
pref("extensions.keysnail.keyhandler.global_enabled", true);
pref("extensions.keysnail.keyhandler.low_priority", false);
Expand Down

0 comments on commit 49db15d

Please sign in to comment.