problems with tabbrowser.tabContainer module in a jetpack extension

22 views
Skip to first unread message

benson

unread,
Sep 8, 2010, 10:04:57 AM9/8/10
to mozilla-labs-jetpack
hello everyone,
i'm new to jetpack and firefox plugin development in general. i wrote
a simple jetpack-script which doesn't work as expected. i'm not sure,
if it's a jetpack problem or a firefox bug.

link to the script: http://pastebin.com/appaArfA

my script stores the old state of tabbrowser and if e.g. a tab is
closed, it searches for the index of the closed tab.
Problem:
i open 3 tabs and select tab2, afterwards i select tab0 and try to
close it but firefox won't let me close that tab. moreover it doesn't
print "found 0" to the command line, as i would expect.

firefox-version: 4.0b5
jetpack-sdk: 0.7 and git checkout (date: 8.9.2010) (i tried both)
Thanks a lot for your help.

cheers benson

Hernan Rodriguez Colmeiro

unread,
Sep 9, 2010, 10:52:41 AM9/9/10
to mozilla-la...@googlegroups.com
On Wed, Sep 8, 2010 at 11:04, benson <ben...@gmx.de> wrote:
> hello everyone,
> i'm new to jetpack and firefox plugin development in general. i wrote
> a simple jetpack-script which doesn't work as expected. i'm not sure,
> if it's a jetpack problem or a firefox bug.
>
> link to the script: http://pastebin.com/appaArfA
>

I didn't read the whole code in detail, but I think you should take a
look to the tab and tabbrowser APIs, that might be helpful:

* https://jetpack.mozillalabs.com/sdk/0.7/docs/#module/jetpack-core/tabs
* https://jetpack.mozillalabs.com/sdk/0.7/docs/#module/jetpack-core/tab-browser

> my script stores the old state of tabbrowser and if e.g. a tab is
> closed, it searches for the index of the closed tab.
> Problem:
> i open 3 tabs and select tab2, afterwards i select tab0 and try to
> close it but firefox won't let me close that tab. moreover it doesn't
> print "found 0" to the command line, as i would expect.
>

What is the purpose of you addon? Doesn't Firefox by default do what
you're trying to do?

Hernan

Benjamin Sackenreuter

unread,
Sep 9, 2010, 11:49:59 AM9/9/10
to mozilla-la...@googlegroups.com
On 09/09/10 16:52, Hernan Rodriguez Colmeiro wrote:
> On Wed, Sep 8, 2010 at 11:04, benson<ben...@gmx.de> wrote:
>> hello everyone,
>> i'm new to jetpack and firefox plugin development in general. i wrote
>> a simple jetpack-script which doesn't work as expected. i'm not sure,
>> if it's a jetpack problem or a firefox bug.
>>
>> link to the script: http://pastebin.com/appaArfA
>>
>
> I didn't read the whole code in detail, but I think you should take a
> look to the tab and tabbrowser APIs, that might be helpful:
>
> * https://jetpack.mozillalabs.com/sdk/0.7/docs/#module/jetpack-core/tabs
> * https://jetpack.mozillalabs.com/sdk/0.7/docs/#module/jetpack-core/tab-browser
>
One problem with that API is, that i don't get notified if a tab is moved (no onMove),
which is necessary for my addon.

>> my script stores the old state of tabbrowser and if e.g. a tab is
>> closed, it searches for the index of the closed tab.
>> Problem:
>> i open 3 tabs and select tab2, afterwards i select tab0 and try to
>> close it but firefox won't let me close that tab. moreover it doesn't
>> print "found 0" to the command line, as i would expect.
>>
>
> What is the purpose of you addon? Doesn't Firefox by default do what
> you're trying to do?
>

The purpose are updatable bookmarks for big websites.
I want to add a "Update" Button to the Firefox-GUI, which
sets the stored url of a bookmark to the currently opened url.

The "Update" button must only work, if the selected tab was loaded with a bookmarked
page before. After hitting the "Update" button, the previously loaded bookmark-url will be
updated to the present url of the selected tab.
This is usefully for substantial websites, where you want to proceed reading at the point, you stopped
last time.

Therefore i have to maintain a list, which consists of tabIndex as key and bookmarkID as
value. The list must be consistent even in case, a tab has been moved.
Have i overlooked an easy approach to track tabs?

cheers benson

Benjamin Sackenreuter

unread,
Sep 10, 2010, 9:18:33 AM9/10/10
to mozilla-la...@googlegroups.com
hi hernan,
i think i figured a way out, to keep track of the tabs.
by means of "tabbrowser.tabContainer.getIndexOfItem(event.target)"

anyway, thanks for your reply.
i already like the jetpack-sdk, it's great to try out code within
seconds.

ben

Hernan Rodriguez Colmeiro

unread,
Sep 10, 2010, 9:44:01 AM9/10/10
to mozilla-la...@googlegroups.com
On Fri, Sep 10, 2010 at 10:18, Benjamin Sackenreuter <ben...@gmx.de> wrote:
> i think i figured a way out, to keep track of the tabs.
> by means of "tabbrowser.tabContainer.getIndexOfItem(event.target)"
>

Great!

> anyway, thanks for your reply.
> i already like the jetpack-sdk, it's great to try out code within
> seconds.
>

Glad you liked it! Hope to see more feedback from you ;)

Hernán

Reply all
Reply to author
Forward
0 new messages