Permalink
Browse files

Icon at the startup in the navbar

  • Loading branch information...
1 parent 7d5212e commit fe25df25b9ce2fc959334f43df87065f2e7630e4 @bakulf committed Aug 29, 2011
Showing with 33 additions and 19 deletions.
  1. +16 −0 components/switchy.js
  2. +1 −3 content/main.xul
  3. +0 −15 content/switchy-overlay.js
  4. +15 −0 content/switchy.js
  5. +1 −1 defaults/preferences/switchy.js
View
@@ -197,12 +197,15 @@ const Switchy = {
// ...component implementation...
_initialized: false,
+ _preferences: null,
_profileService: null,
_ww: null,
_db: null,
_cache: {},
_timer: null,
+ _firstRun: true,
+
// Queries:
_createTableSQL: '' +
'CREATE TABLE IF NOT EXISTS data (' +
@@ -222,6 +225,15 @@ const Switchy = {
return;
this._initialized = true;
+ // Preferences:
+ var prefSvc = Components.classes['@mozilla.org/preferences-service;1']
+ .getService(Components.interfaces.nsIPrefService);
+ this._preferences = prefSvc.getBranch('extensions.switchy.');
+
+ this._firstRun = this._preferences.getBoolPref('firstRun');
+ if (this._firstRun == true)
+ this._preferences.setBoolPref('firstRun', false);
+
// Profile Service:
this._profileService = Components.classes["@mozilla.org/toolkit/profile-service;1"]
.createInstance(Components.interfaces.nsIToolkitProfileService);
@@ -257,6 +269,10 @@ const Switchy = {
os.removeObserver(this, "sessionstore-windows-restored");
},
+ firstRun: function() {
+ return this._firstRun;
+ },
+
browserReady: function() {
if (!this._switchyUtils)
return;
View
@@ -3,12 +3,10 @@
<?xml-stylesheet href="chrome://switchy/skin/main.css" type="text/css"?>
<overlay id="profile-overlay"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- onload="switchy_addIcon();">
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.7" src="switchy-manager.js" />
<script type="application/javascript;version=1.7" src="switchy.js" />
- <script type="application/javascript;version=1.7" src="switchy-overlay.js" />
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="switchy-toolbarbutton"
@@ -1,15 +0,0 @@
-var myId = "switchy-toolbarbutton";
-var navBar = document.getElementById("nav-bar");
-var curSet = navBar.currentSet.split(",");
-
-if (curSet.indexOf(myId) == -1) {
- var set = curSet.slice(0, curSet.length).concat(myId).concat(curSet.slice(curSet.length));
-
- navBar.setAttribute("currentset", set.join(","));
- navBar.currentSet = set.join(",");
- document.persist(navBar.id, "currentset");
- try {
- BrowserToolboxCustomizeDone(true);
- }
- catch (e) {}
-}
View
@@ -22,8 +22,23 @@ window.addEventListener("load", function() {
switchy.checkURL(evnt, window);
}, true);
}
+
+ if (switchy.firstRun()) {
+ switchy_addIcon();
+ }
}, false);
+// Add the icon to the navBar
+function switchy_addIcon() {
+ var icon = "switchy-toolbarbutton";
+ var navBar = document.getElementById("nav-bar") || document.getElementById("addon-bar");
+ var obj = document.getElementById(icon);
+
+ navBar.insertItem(icon, null, null, false);
+ navBar.setAttribute("currentset", navBar.currentSet);
+ document.persist(navBar.id, "currentset");
+}
+
// Populate the panel:
function switchy_panelOpen() {
var rows = document.getElementById('switchy-panel-rows');
@@ -1 +1 @@
-// Nothing yet
+pref("extensions.switchy.firstRun", true);

0 comments on commit fe25df2

Please sign in to comment.