MozillaZine

Rebuilding TBE's featureset with other plugins

Talk about add-ons and extension development.
Paradox52525

User avatar
 
Posts: 1219
Joined: April 23rd, 2003, 9:13 am
Location: Middle of nowhere

Post Posted January 23rd, 2004, 10:06 pm

Well MozFBRH isn't really a TBE replacement in any sense, it's an enhancement for the navigation toolbar buttons, it's primary purpose is to allow you to middle click the navbar buttons (Back, Forward, Reload, Home, Go) to open them in new tabs. The only relation it has to TBE is that I based some of my code (mostly the session history copy stuff) on functions from TBE. I was trying to decifer TBE's ability to move tabs because I wanted to have MozFBRH open new tabs from the back button to the left of the current tab, and tabs opened from the forward button to the right of the current tab (which it currently can do, but it actually calls functions in TBE, so it only works if TBE is installed as well). If you still want to check it out I just released a new version: http://forums.mozillazine.org/viewtopic.php?t=46146

The thing that really gets me about moving tabs around is this: Tabs have an "ordinal" attribute by default, and you can reorder them by changing this attribute. However, without TBE installed, this attribute is BLANK. I found that if I manually assign ordinal numbers to each tab, and then change those ordinal numbers, I can move tabs around (with some difficulty) but using that method completely breaks TBE compatibility (because TBE also assigns ordinals to tabs). There was a topic awhile back about which TBE features should make it into the Firebird core, and of course people suggested just about everything, but what I really think should be built in is some of the simpler backend stuff that would make tab management easier for extension authors. I mean why doesn't Firebird have a MoveTab() function like TBE's built in? How hard would that be to add? Why is it that tabs have an oridinal attribute by default but it's never assigned a value? Wouldn't it make more sense to give tabs oridinal numbers from left to right so they can be moved around by changing the ordinal, and then maybe adding an UpdateTabIndex() or something of the like that would reorder the tab index to match the ordinal numbers? From what I've seen in the TBE code, a lot of it is just doing stuff like that, creating ways to manage tabs because there aren't any in the core already. If more tab management functionality were moved into the core, that alone would make it possible to significantly downsize TBE and probably speed it up a great deal. Anyway, forgive my ranting.

Also on a sidenote, wasn't someone going through TBE and trying to slim down/ decrypt TBE awhile back? I'd be interested to see if they've made any progress.

TychoQuad
 
Posts: 1263
Joined: December 11th, 2002, 12:30 am
Location: Australia

Post Posted January 23rd, 2004, 11:26 pm

Yeah, I learnt what MozFBRH does, and to be perfectly honest, there isn't much in there for me.

You mention it is possible, but breaks TBE... but isn't the point of this thread that I don't want to use TBE anymore? I would really like an extension which would manage the movement of tabs. Currently my only use for miniT is the ability to drag n drop tabs (moving them, or copying their address elsewhere) and i would happily exchange that extension for one that could do this, but also allow me to customize their appearance. (in my case, to the right of the current tab) I found browsing like this to be far superior than any other method. Of course, I would welcome such a feature in miniT as well.

As I have said before, seperate extensions for certain funcions i would welcome with open arms. While I believe it's Toolbar Enhancement's job to remove the tab close button, (and place it on the customize pallatte) I believe a function like Undo close tab would be better off in a seperate extension. There are always featues that blur the lines though, like what extension would you add the "open bookmarks in new tabs" function? it's not important enough for it's own, and doesn't really belong anywhere exept in an all in one.

rue
 
Posts: 673
Joined: June 10th, 2003, 2:20 pm

Post Posted January 24th, 2004, 2:26 am

Tycho:
Assuming you're running the latest moz/fb, evaluating this line in your javascript-console should make "New tabs open right of Current". If you're running an older browser, I've made a version for that, too.
.
The effect is temporary, for current-windows only:
    rue wrote:var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator); var enumerator = windowMediator.getEnumerator("navigator:browser"); while (enumerator.hasMoreElements()) { win = enumerator.getNext(); win.setTimeout('getBrowser().addTab = function addTab(aURI, aReferrerURI, aCharset) { if (!this.mTabbedMode) this.enterTabbedMode(); var t = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "tab"); var blank = (aURI == "about:blank"); if (blank) t.setAttribute("label", this.mStringBundle.getString("tabs.untitled")); else t.setAttribute("label", aURI); t.setAttribute("crop", "end"); t.maxWidth = 250; t.minWidth = 30; t.width = 0; t.setAttribute("flex", "100"); t.setAttribute("validate", "never"); t.setAttribute("onerror", "this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute(\'image\')); this.removeAttribute(\'image\');"); var nextTab = this.mTabContainer.selectedItem.nextSibling; (nextTab) ? this.mTabContainer.insertBefore(t, nextTab) : this.mTabContainer.appendChild(t); var b = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "browser"); b.setAttribute("type", "content"); b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu")); b.setAttribute("tooltip", this.getAttribute("contenttooltip")); var nextBrowser = this.mPanelContainer.selectedPanel.nextSibling; (nextBrowser) ? this.mPanelContainer.insertBefore(b, nextBrowser) : this.mPanelContainer.appendChild(b); b.addEventListener("DOMTitleChanged", this.onTitleChanged, false); if (this.mStrip.collapsed) this.setStripVisibilityTo(true); this.mPrefs.setBoolPref("browser.tabs.forceHide", false); var position = this.mTabContainer.selectedIndex +1; var tabListener = this.mTabProgressListener(t, b, blank); const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"].createInstance(Components.interfaces.nsIWebProgress); filter.addProgressListener(tabListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); b.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL); this.mTabListeners.splice(position, 0, tabListener); this.mTabFilters.splice(position, 0, filter); if (!blank) { b.userTypedValue = aURI; b.loadURI(aURI, aReferrerURI, aCharset); } return t; }', 0); }

TychoQuad
 
Posts: 1263
Joined: December 11th, 2002, 12:30 am
Location: Australia

Post Posted January 24th, 2004, 6:29 pm

Thanks rue, it appears to work, but it does cause problems. Created tabs are totally ignored when scrolling through tabs, and it's not a good idea to close unaffected tabs, because my tab bar dissapeared even though i have it set to not hide when there is a single tab.

rue
 
Posts: 673
Joined: June 10th, 2003, 2:20 pm

Post Posted January 24th, 2004, 6:52 pm

Tycho:
yea- it's just proof-of-concept. Rather than redefine the whole function -- a bad idea, since it changed through a number of builds -- I'll export the original code to string and only adjust the relevant lines. I had some problems with string-escaping earlier and had to put it aside. But, I should have something shortly.
.
When you say "scrolling through tabs", you mean with miniT?

chuonthis
 
Posts: 519
Joined: July 23rd, 2003, 10:17 am

Post Posted January 24th, 2004, 7:10 pm

All I need is an extension for tabgroups (which seems really hard due to Paradox's comments) and I will have all of TBE's features via other extensions.
chuonthis extensions: [fx] BookKey 0.0.1, OpenBook 2.0.1.1, Update Bookmark 0.0.5.1 [tb] Buttons! 0.5.3.2, DeleteJunk 0.3.2, Flipping the Thunderbird 0.0.0.1, Folderpane 0.0.5, NNWODC 0.2.3

TychoQuad
 
Posts: 1263
Joined: December 11th, 2002, 12:30 am
Location: Australia

Post Posted January 24th, 2004, 7:39 pm

rue wrote:When you say "scrolling through tabs", you mean with miniT?


No, I mean the default way with Ctrl-Tab and Ctrl-Shift-Tab, but since their the same function, it would give the same result. That reminds me actually, Would it be possible to overwrite the default function and have it send a switch tab function the same way miniT does, only using the keys? There's a very irritating bug which i can reproduce* but everyone ignores because of lack of use.


*Switching tabs using the keyboard shortcuts doesn't work when the tab is trying to load content, but hasn't recieved any yet. If you try to switch tabs to/from a tab which is about to begin loading content, it will either crash the browser, or lock it up with 100% proc usage.

ehume

User avatar
 
Posts: 6743
Joined: November 17th, 2002, 12:33 pm
Location: Princeton, NJ, USA

Post Posted January 24th, 2004, 8:11 pm

Thank you, Torisugari, for explaining TBE. A tabbrowser hooked onto Moz or FB as an extension. Finally, I understand. Thank you.
Firefox: Sic transit gloria mundi.

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted January 25th, 2004, 5:03 am

TychoQuad wrote:
rue wrote:When you say "scrolling through tabs", you mean with miniT?

No, I mean the default way with Ctrl-Tab and Ctrl-Shift-Tab[...]

Note that if miniT is enabled that wouldn't work either...

TychoQuad
 
Posts: 1263
Joined: December 11th, 2002, 12:30 am
Location: Australia

Post Posted January 25th, 2004, 5:28 am

dorando wrote:
TychoQuad wrote:
rue wrote:When you say "scrolling through tabs", you mean with miniT?

No, I mean the default way with Ctrl-Tab and Ctrl-Shift-Tab[...]

Note that if miniT is enabled that wouldn't work either...


Not true. I constantly use the hotkeys when miniT is enabled. That's the problem, or not...

I want to use the hotkeys, but i also want them to be bugfree like scrolling the tabs with the mousewheel is.

Jeff_pony
Moderator

User avatar
 
Posts: 8790
Joined: January 5th, 2003, 12:38 pm
Location: (.uk)

Post Posted January 25th, 2004, 11:08 am

TychoQuad wrote:I have found that the gain in speed I get from switching off TBE is not great enough to justify the loss of features, nor the strong compatibility that TBE has with itself compared to these extensions. Not to mention a bug I had which i blamed on TBE turns out to be a problem in Firebird. I will try these 3 again with a fresh profile at a later date, but for now, I'm disabling these extensions, and re-enabling TBE.

Removing TBE for me is not about features its about preventing crashes and Java script bugs... If only a lite version was released...
Please PM the mod team when you see a rule infraction
Life State:: McLovin it
Camino v2.1 (pre)

IGAU
 
Posts: 831
Joined: November 18th, 2003, 2:25 pm

Post Posted January 25th, 2004, 11:36 am

My only thoughts on why we should have alternatives to TBE really relate to the fact that I dont use many of it's features, but it has a couple of tiny things that I would like to use without the need for all the rest. TBE is a good extension, my only real critisism is that I dont need all of it!

rue
 
Posts: 673
Joined: June 10th, 2003, 2:20 pm

Post Posted January 25th, 2004, 1:06 pm

Tycho:
This one should be near-universal. Paste into the javascript-console to make "New tabs open right of Current". If your browser's not compatible, you'll be told:
    rue wrote:var searchArray = new Array();var replaceArray = new Array();searchArray[0] = /this\.mTabContainer\.appendChild\(t\)\;/;searchArray[1] = /this\.mPanelContainer\.appendChild\(b\)\;/;searchArray[2] = /var position ?\= ?this\.mTabContainer\.childNodes\.length ?\- ?1\;/;searchArray[3] = /this\.mTabListeners\[position\] ?\= ?tabListener\;/;searchArray[4] = /this\.mTabFilters\[position\] ?\= ?filter\;/;replaceArray[0] = "var nextTab = this.mTabContainer.selectedItem.nextSibling; (nextTab) ? this.mTabContainer.insertBefore(t, nextTab) : this.mTabContainer.appendChild(t);";replaceArray[1] = "var nextBrowser = this.mPanelContainer.selectedPanel.nextSibling; (nextBrowser) ? this.mPanelContainer.insertBefore(b, nextBrowser) : this.mPanelContainer.appendChild(b);";replaceArray[2] = "var position = this.mTabContainer.selectedIndex +1;";replaceArray[3] = "this.mTabListeners.splice(position, 0, tabListener);";replaceArray[4] = "this.mTabFilters.splice(position, 0, filter);";var miniTSearch = /this\.mTabs\[position\] ?\= ?t\;/;var miniTReplace = "this.mTabs.splice(position, 0, t);";var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);var enumerator = windowMediator.getEnumerator("navigator:browser");var searchSuccess = true;while (enumerator.hasMoreElements() && searchSuccess) { win = enumerator.getNext(); win.setTimeout( function() { function editAddTab() { var functionStringCurrent = win.getBrowser().addTab.toString(); var functionStringOrig = (win.getBrowser().addTabOrig) ? win.getBrowser().addTabOrig.toString() : functionStringCurrent; functionString = new String(functionStringOrig); win.setTimeout("getBrowser().addTabOrig = "+new String(functionStringOrig), 0); for (var i = 0, matched = 0 ; i < searchArray.length ; i++) { matched += searchArray[i].test(functionString); functionString = functionString.replace(searchArray[i], replaceArray[i]); } functionString = functionString.replace(miniTSearch, miniTReplace); searchSuccess = (matched == searchArray.length); if (searchSuccess) win.setTimeout("getBrowser().addTab = "+new String(functionString), 0); else alert("Sorry: nothing was changed. \n\nYour browser's addTab-function didn't match the expected code."); } editAddTab(); if (searchSuccess) alert("New tabs will open right of Current."); } , 0); }
[updated for miniT]
Last edited by rue on January 26th, 2004, 5:07 pm, edited 2 times in total.

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted January 25th, 2004, 2:48 pm

You should be able to simplify
Code: Select all
var nextTab = this.mTabContainer.selectedItem.nextSibling; (nextTab) ? this.mTabContainer.insertBefore(t, nextTab) : this.mTabContainer.appendChild(t);
to
Code: Select all
this.mTabContainer.insertBefore(t, this.mTabContainer.selectedItem.nextSibling);

at least it worked for me... (same goes for mPanelContainer)

rue
 
Posts: 673
Joined: June 10th, 2003, 2:20 pm

Post Posted January 25th, 2004, 5:19 pm

dorando:
Yea- actually an earlier version made further use of those next.. items. Even more: I played overkill on the nested function, initially attempting to migrate its scope to each window.
.
The whole point was to come up with something you could integrate into miniT. To that end, all you need are the two arrays, using setTimeout or eval to parse the edited function-string back into a function.

Return to Extension Development


Who is online

Users browsing this forum: Google Adsense [Bot] and 3 guests