Toolbar Button On Install

Talk about add-ons and extension development.
User avatar
Sephirot
Posts: 247
Joined: June 15th, 2004, 7:56 am

Post by Sephirot »

TheBaker, shure your button works? The method I posted above does work. I just tried it again and the address bar (urlbar-container) and the searchbar are still working.

insertItem() method and persist

Code: Select all

document.getElementById("nav-bar").insertItem("smxtra-button",null,null,false);
var currentset = document.getElementById("nav-bar").currentSet;
document.getElementById("nav-bar").setAttribute("currentset",currentset); //without it, the persist does not work
document.persist("nav-bar","currentset");


/edit:
I replaced the id of my button with yours

/edit2:
this is the way I'm adding the button to the nav-bar

Code: Select all

var currentset = document.getElementById("nav-bar").currentSet;
var erg = currentset.search(/button-id/gi);
if (erg == -1) {
   currentset = currentset.replace(/urlbar-container/i,"button-id,urlbar-container");
   document.getElementById("nav-bar").setAttribute("currentset",currentset);
   document.getElementById("nav-bar").currentSet = currentset;
   document.persist("nav-bar","currentset");
}

I can place it before the address bar because insertItem("button-id","urlbar-container",null,false) does nothing :(
Author of Bookmarks Menu Button, Autoclose Bookmark&History Folders and more

Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.19pre) Gecko/20110701 Firefox/3.6.19pre <-- build with MS VC++ 2010 SP1 and PGO on Win 7 x64
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

My host is down at the moment, so I can't upload a copy. Here's the code for the whole startup procedure. It all worked fine before, so I suspect it's just the toolbar portion of the code that is buggy. I will upload the XPI ASAP, but I can e-mail it to you if you want it sooner.

Code: Select all

var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);


function smxOnInit() {
   var str = document.getElementById("smx-overlay-str");
   insertTxt = str.getString("insert");

   var appcontent = document.getElementById("appcontent");
   if(appcontent)
      appcontent.addEventListener("load", smxOnPageLoad, true);
      
   var menu = document.getElementById("contentAreaContextMenu");
   menu.addEventListener("popupshowing", smxPopupShow, false);
   
   smxUpdateFavourites();
   
   //Pref Watch
   mBranch = prefs.getBranch("smxtra.");
        var pbi = mBranch.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
        pbi.addObserver("", smxPrefOb, false);
   
   //First Run?
   if(!prefs.prefHasUserValue("smxtra.firstrun")){
      //First Run - Add Button To Toolbar
      //var navToolbar = document.getElementById("nav-bar")
      //navToolbar.insertItem("smxtra-button", null, null, false);
      //document.persist("nav-bar","currentset");
      
      var navbar = document.getElementById("nav-bar");
      var newset = navbar.currentSet + ",smxtra-button";
      navbar.currentSet = newset;
      navbar.setAttribute("currentset", newset );
      document.persist("nav-bar", "currentset");
      
      prefs.setIntPref("smxtra.firstrun", 1);
   }
}


PM me with your e-mail if you'd like the XPI before my host is back up.
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

Sephirot, just tried your way of doing it (edit2 style with my own checking code (as posted above)) and I still get the screwed addressbar problem.
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

My server is back up. Find the XPI at http://smile.studio-network.co.uk/images/smxtra.xpi . Hope that helps.

P.S. Sorry for the triple post Image
asqueella
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post by asqueella »

your code works fine for me,
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

It does? Could someone please confirm this on their system?
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

I had someone else install it, and they encountered the same problem. Anyone have any idea why this is happenning?
User avatar
Sephirot
Posts: 247
Joined: June 15th, 2004, 7:56 am

Post by Sephirot »

asqueella wrote:your code works fine for me,
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

same here with the official german build
Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041108 Firefox/1.0
and with my version
Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.7.5) Gecko/20041120 Firefox/1.0 (Sephiroth/AXP)
Author of Bookmarks Menu Button, Autoclose Bookmark&History Folders and more

Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.19pre) Gecko/20110701 Firefox/3.6.19pre <-- build with MS VC++ 2010 SP1 and PGO on Win 7 x64
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

Hmm, more testing needed I believe. I shall ask some other people.
asqueella
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post by asqueella »

TheBaker, do you use official en-US 1.0 Windows build or what?
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.7.5) gecko/20041107 firefox/1.0

It's weird that it works for you, and not for me. I asked a friend to test it as well, and he had the same problem. I'm going to ask a few other people I knw to test it and see whether they get the same thing happenning.
asqueella
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post by asqueella »

Here's what I do:
1. Install Firefox 1.0 en-US official build
2. Create a new profile
3. Open Tools>Extensions
4. Drag smxtra.xpi (49360 bytes) to the EM window
5. Close Firefox
6. Restart Firefox.

I can type to the address bar and the auto-added smxtra toolbar button is functional.

btw, did you read this?
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

Ok, I've narrowed the bug down to these two lines:

Code: Select all

navbar.currentSet = newset;
navbar.setAttribute("currentset", newset );

Anyone see any problems with them?

And are you two sure you were looking for the right thing? Because I've had some other people test it, all using the official en-us build, and they've all hit the same problem.
The problem is that after it's added the toolbar button, the address bar is blank the first time it runs, and fails to function. It doesn't change when the page changes, and if you type text in and press enter/click go it just refreshes the page. It only happens the first time, i.e. when the add to toolbar code is run.

Note: If you plan to reinstall, make sure you remove the button from the toolbar if it's there and delete smxtra.firstrun from about:config
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

Cheers for that link asqueella. I've added user confirmation to add the toolbar button now. I'm going to uninstall Firefox and try it from scratch.
User avatar
TheBaker
Posts: 193
Joined: October 20th, 2004, 9:20 am

Post by TheBaker »

I tried a completly clean install, new profile, no extensions etc... As vanilla as it comes, but it still happenned. I followed asqueella's steps to the letter, yet I still ended up with a messed up address bar.

In other news, I've had to remove the user confirmation for the toolbar button as it didn't like having a confirm box when Firefox loaded. Maybe I'll fiddle about with it later.
Post Reply