Toolbar Button On Install
- TheBaker
- Posts: 193
- Joined: October 20th, 2004, 9:20 am
Toolbar Button On Install
I want to get the button for my extension put into the toolbar when my extension is installed (or if that's not possible, the first time it is run). How would I do that?
- Lee_Dailey
- Posts: 14194
- Joined: July 27th, 2004, 4:33 pm
- Location: milky way galaxy, sol system, terra, north america, usa, tx, bedford
howdy thebaker,
have you looked at the install routine for this ...
http://www.extensionsmirror.nl/index.php?showtopic=1342
doesn't QUITE do what ya want, but it seems to get right close ...
hope that helps,
lee
have you looked at the install routine for this ...
http://www.extensionsmirror.nl/index.php?showtopic=1342
doesn't QUITE do what ya want, but it seems to get right close ...
hope that helps,
lee
- Lee_Dailey
- Posts: 14194
- Joined: July 27th, 2004, 4:33 pm
- Location: milky way galaxy, sol system, terra, north america, usa, tx, bedford
howdy thebaker,
you are welcome! i thot it might be a useful - and diffferent - approach.
if you are determined to do teh auto-add-button-to-toolbar bit, you might wanna try a brute force approach.
- setup ff as vanilla as possible
- xcopy the set of folders for app AND profile
- add ONE button to a toolbar
- xcopy the current set of folders for app & profil
- compare ...
[*grin*] it will at least let ya see what was done. once you have that you can look at ways to automate the process. graceless, but it might help.
take care,
lee
you are welcome! i thot it might be a useful - and diffferent - approach.
if you are determined to do teh auto-add-button-to-toolbar bit, you might wanna try a brute force approach.
- setup ff as vanilla as possible
- xcopy the set of folders for app AND profile
- add ONE button to a toolbar
- xcopy the current set of folders for app & profil
- compare ...
[*grin*] it will at least let ya see what was done. once you have that you can look at ways to automate the process. graceless, but it might help.
take care,
lee
- Lee_Dailey
- Posts: 14194
- Joined: July 27th, 2004, 4:33 pm
- Location: milky way galaxy, sol system, terra, north america, usa, tx, bedford
- Sephirot
- Posts: 247
- Joined: June 15th, 2004, 7:56 am
asqueella wrote:beter yet, look at how it's done in customizeToolbar.js (lxr it or look in chrome/toolkit.jar)
thanks for this hint
this will add the button on the outer right side, next to the searchbar and saves the postitions.
this should be done only once!
Code: Select all
var currentset = document.getElementById("nav-bar").currentSet;
currentset=currentset + ",your-button-id";
document.getElementById("nav-bar").setAttribute("currentset",currentset); //not needed I suppose
document.getElementById("nav-bar").currentSet = currentset;
document.persist("nav-bar","currentset");
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
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
- TheBaker
- Posts: 193
- Joined: October 20th, 2004, 9:20 am
Hey, thanks for your help everyone. I'm currently using:
To insert the toolbar button. However, this doesn't save the state of the toolbar, so when I run it again (it only adds the toolbar button the first time) the button doesn't appear.
How would I save the state of the toolbar so that it remembers the button?
Code: Select all
var navToolbar = document.getElementById("nav-bar")
navToolbar.insertItem("smxtra-button", null, null, false);
To insert the toolbar button. However, this doesn't save the state of the toolbar, so when I run it again (it only adds the toolbar button the first time) the button doesn't appear.
How would I save the state of the toolbar so that it remembers the button?
-
- Posts: 4019
- Joined: November 16th, 2003, 3:05 am
- Location: Russia, Moscow
The set of buttons is persisted on OK of Customize toolbars only. You need to persist it yourself.
I'd guess something like this (didn't try it):
Tell me if that works (along with as much code as possible - I might add it to kb).
I'd guess something like this (didn't try it):
Code: Select all
document.persist("nav-bar", "currentset");
Tell me if that works (along with as much code as possible - I might add it to kb).
- TheBaker
- Posts: 193
- Joined: October 20th, 2004, 9:20 am
Nope that didn't work. Here's a summary of what I've tried so far.
Started with
Inserted toolbar button fine, but didn't persist
Next tried
Still didn't persist.
Tried
This inserted and persisted, but screwed up firefox (address bar didn't work, about:config didn't work and probably some other stuff).
Any ideas?
Started with
Code: Select all
var navToolbar = document.getElementById("nav-bar")
navToolbar.insertItem("smxtra-button", null, null, false);
Inserted toolbar button fine, but didn't persist
Next tried
Code: Select all
var navToolbar = document.getElementById("nav-bar")
navToolbar.insertItem("smxtra-button", null, null, false);
document.persist("nav-bar", "currentset");
Still didn't persist.
Tried
Code: Select all
var currentset = document.getElementById("nav-bar").currentSet;
currentset=currentset + ",smxtra-button";
document.getElementById("nav-bar").setAttribute("currentset",currentset); //not needed I suppose
document.getElementById("nav-bar").currentSet = currentset;
document.persist("nav-bar","currentset");
This inserted and persisted, but screwed up firefox (address bar didn't work, about:config didn't work and probably some other stuff).
Any ideas?
-
- Posts: 4019
- Joined: November 16th, 2003, 3:05 am
- Location: Russia, Moscow
ok, Sephirot's variant was better, it should work. Try with a clean profile and if it doesn't work tell me what is in your localstore.rdf in profile (resource with uri chrome://browser/content/browser.xul#nav-bar)
edit: changed code
Code: Select all
var navbar = document.getElementById("nav-bar");
var newset = navbar.currentSet + ",your-button-id";
navbar.currentSet = newset;
navbar.setAttribute("currentset", newset );
document.persist("nav-bar", "currentset");
edit: changed code
- TheBaker
- Posts: 193
- Joined: October 20th, 2004, 9:20 am
Ok, I started a fresh profile, installed my extension, restarted. The button appeared on the toolbar like it should, but the still address bar wouldn't work (all the other buttons on the toolbar did, but the addressbar was blank and didn't change when i went to sites (via bookmarks, because the address bar wasn't working). It wouldn't allow me to type in and click go either. Which means I couldn't enter the URL you gave me. But you mentioned that it was called localstore.rdf, so I'm assuming you meant the file localstore.rdf that's in my profile directory, which contained:
Hope that's what you wanted.
Code: Select all
<?xml version="1.0"?>
<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<RDF:Description RDF:about="chrome://browser/content/bookmarks/bookmarksPanel.xul">
<NC:persist RDF:resource="chrome://browser/content/bookmarks/bookmarksPanel.xul#bookmarks-view"/>
</RDF:Description>
<RDF:Description RDF:about="chrome://browser/content/browser.xul#main-window"
width="994"
height="984"
screenX="4"
screenY="4"
sizemode="normal" />
<RDF:Description RDF:about="chrome://browser/content/browser.xul">
<NC:persist RDF:resource="chrome://browser/content/browser.xul#main-window"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-box"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-title"/>
<NC:persist RDF:resource="chrome://browser/content/browser.xul#nav-bar"/>
</RDF:Description>
<RDF:Description RDF:about="chrome://browser/content/browser.xul#sidebar-box"
sidebarcommand=""
width=""
src="" />
<RDF:Description RDF:about="chrome://browser/content/browser.xul#nav-bar"
currentset="back-button,forward-button,reload-button,stop-button,home-button,urlbar-container,go-container,search-container,smxtra-button" />
<RDF:Description RDF:about="chrome://browser/content/bookmarks/bookmarksPanel.xul#bookmarks-view"
colinfo=" col:Name?width=&hidden=&ordinal=1" />
<RDF:Description RDF:about="chrome://mozapps/content/extensions/extensions.xul?type=extensions">
<NC:persist RDF:resource="chrome://mozapps/content/extensions/extensions.xul?type=extensions#extensionsManager"/>
</RDF:Description>
<RDF:Description RDF:about="chrome://mozapps/content/extensions/extensions.xul?type=extensions#extensionsManager"
width="400"
height="300" />
</RDF:RDF>
Hope that's what you wanted.