Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug 726560 - Add support of Panorama group name (FF10+) for titlebar customization #19

Open
wants to merge 14 commits into from

4 participants

@xabolcs
Owner

Hi!

This is the pull request that contains the patch from Bug 726560.

Before reviewing the diff, please read Comment 4 and 5 in Bugzilla!

@xabolcs
Owner

Rebased to top of reorg merge.

extension/chrome/locale/en-US/variables.properties
@@ -52,5 +52,6 @@ variable.Processor.description=Compilation Processor
variable.Compiler.description=Compiler
variable.DefaultTitle.description=Default Application Title
variable.TabTitle.description=Current Tab's Title
+variable.ActiveTabGroupName.description=Active TabView group name - may be empty in rare cases
@whimboo Owner
whimboo added a note

Please reduce the variable to 'TabGroup' so we stay in sync with 'TabTitle' and others. Also please kill the last part of the description content and use 'Tab Group' instead of 'TabView', e.g. 'Current Tab Group'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/nightly.js
@@ -107,6 +108,10 @@ showAlert: function(id, args) {
init: function() {
window.removeEventListener("load", nightly.init, false);
+ setTimeout(nightly.initLazy,800);
+},
+
+initLazy: function() {
@whimboo Owner
whimboo added a note

Would you mind moving this out to another pull request? I'm not yet, if this will cause side-effects by lazily loading / executing some of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/nightly.js
@@ -69,6 +69,7 @@ variables: {
get compiler() this.appInfo.XPCOMABI.split("-")[1],
get defaulttitle() { return nightlyApp.defaultTitle; },
get tabtitle() { return nightlyApp.tabTitle; },
+ get activetabgroupname() { return nightlyApp.activeTabGroupName || null; },
@whimboo Owner
whimboo added a note

tabGroupTitle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/browser.js
@@ -51,6 +54,32 @@ get tabTitle() {
return tabbrowser.mCurrentBrowser.contentTitle;
},
+get activeTabGroupName() {
+ // TabView isn't implemented or initialized
+ if (!TabView || !TabView._window)
+ return nightlyApp._lastSessionGroupName;
@whimboo Owner
whimboo added a note

What happens if no tab group exists anymore? Would we carry around the last name forever? Or is there at least one group in any case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/browser.js
@@ -51,6 +54,32 @@ get tabTitle() {
return tabbrowser.mCurrentBrowser.contentTitle;
},
+get activeTabGroupName() {
@whimboo Owner
whimboo added a note

@ttaubert - would you mind checking the code if it's getting the group title the correct way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/browser.js
((6 lines not shown))
+ // to store active group's name for showing at next startup
+ window.addEventListener("SSWindowClosing", function NightlyTT_onWindowClosing() {
+ window.removeEventListener("SSWindowClosing", NightlyTT_onWindowClosing, false);
+ nightlyApp.saveActiveGroupName(window);
+ }, false);
+
+ // grab the last used group title
+ // use TabView's property if we are before Bug 682996 (landed in FF10)
+ nightlyApp._lastSessionGroupName = (TabView && TabView._lastSessionGroupName)
+ ? TabView._lastSessionGroupName
+ : Cc["@mozilla.org/browser/sessionstore;1"]
+ .getService(Ci.nsISessionStore)
+ .getWindowValue(
+ window,
+ nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER
+ );
@whimboo Owner
whimboo added a note

Please remove the ternary operator here. It makes it kinda hard to read. Also please better align those rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/browser.js
@@ -87,6 +134,19 @@ openNotification: function(id, message, label, accessKey, callback) {
message, "urlbar", action, null, options);
},
+// Function: saveActiveGroupName
+// Saves the active group's name for the given window.
@whimboo Owner
whimboo added a note

Would you mind starting to use JSdoc comments? http://code.google.com/p/jsdoc-toolkit/w/list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/chrome/content/browser.js
@@ -87,6 +134,19 @@ openNotification: function(id, message, label, accessKey, callback) {
message, "urlbar", action, null, options);
},
+// Function: saveActiveGroupName
+// Saves the active group's name for the given window.
+saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) {
+ let groupName = nightlyApp.activeTabGroupName;
+ Cc["@mozilla.org/browser/sessionstore;1"]
+ .getService(Ci.nsISessionStore)
@whimboo Owner
whimboo added a note

Can you please get a reference to this service once and store it globally. When will those values be deleted from the session store file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xabolcs
Owner

Assigned some of @whimboo's review comments.

Unaddressed:

What happens if no tab group exists anymore?

Nothing special. ${TabGroup} will be empty.

Would we carry around the last name forever? Or is there at least one group in any case?

If we thinking about it strictly, then yes, we would carry that forever. But as I said above, if
user changes TabGroup (open / close / rename a group) then ${TabGroup} will follow the last active group.

As I see, in FF11, there will be always a TabGroup. Could somebody provide it's Bugzilla number?

In FF4.2a1pre user is able to close all the groups and leave tabs alone. The tab bar would contain only one tab in that case, if user exits from the TabView.

When will those values be deleted from the session store file?

I don't know sessionStore. IMHO if we don't save the value at shutdown, it wouldn't be saved, which is an implicit delete.
Should I discard empty nightlyApp.tabGroupTitle values? In other words: should I test it's emptiness before save?

Can you please get a reference to this service once and store it globally.

I introduced some other getService() in these v2 commits.
So in which global would you ask to store the reference? In nightly or in (browser.js') nightlyApp? Or just in window? ;)
Anyway, could we defer this after the landing of #6? Importing Services.jsm would be enough then, wouldn't be?

Please consider that I would like to fold these commits before pull!
Please give me a day or two to make it clean after r+!

@whimboo
Owner

I know it's a bit harder for you but I would love it if we could keep up with the conversation at the right places and don't combine all in a single reply. It's hard to follow-up on changes and questions.

Here some answers and questions:

  • Have you tested that we correctly handle the TabGroup name across windows? Each window has its own set of groups
  • Not sure of a bug which has changed the behavior of a default group. But that happened a while ago
  • Re: sessionstore. It should already have the name of the group included per default. Can't we simply retrieve it?
  • We could defer the Services issue for now, that's fine with me
extension/chrome/content/browser.js
((9 lines not shown))
+ nightlyApp.saveActiveGroupName(window);
+ }, false);
+
+ // grab the last used group title
+ // use TabView's property if we are before Bug 682996 (landed in FF10)
+ if (TabView && TabView._lastSessionGroupName)
+ {
+ nightlyApp._lastSessionGroupName = TabView._lastSessionGroupName;
+ }
+ else
+ {
+ Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService).addObserver({
+ observe: function NightlyTT_Restore() {
+ Cc["@mozilla.org/observer-service;1"]
+ .getService(Ci.nsIObserverService).removeObserver(this, "sessionstore-windows-restored");
@whimboo Owner
whimboo added a note

Please don't call getService twice here but cache it locally right before:

var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService)
obs.addObserver(...);

Same applies to the SessionStore service below.

@xabolcs Owner
xabolcs added a note
  • Have you tested that we correctly handle the TabGroup name across windows? Each window has its own set of groups

Not tested before, but a quick test shows something: only the registering window's TabGroup title is restored.
Because I don't iterate through all the windows. :)

But I don't sure about the need of removeObserver. And related: how to take care Private Browsing...?

@whimboo Owner
whimboo added a note

Any observer we register we have to remove.

@xabolcs Owner
xabolcs added a note

Any observer we register we have to remove.

Yes, this is obvious. But when to remove?
On startup of the observer code? On application shutdown? On entering PB mode .... :)

@whimboo Owner
whimboo added a note

It depends on when the code gets called. If it's during the startup phase then we can do it on shutdown. Otherwise it has to be done before possible references get invalid.

@xabolcs Owner
xabolcs added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xabolcs
Owner

Thank You for the answers and the questions!

extension/chrome/content/browser.js
@@ -66,6 +95,37 @@ init: function()
tabbrowser.updateTitlebar = nightly.updateTitlebar;
tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false);
+
@xabolcs Owner
xabolcs added a note
  • Re: sessionstore. It should already have the name of the group included per default. Can't we simply retrieve it?

If I move these lines some line below, into the if ... else then getting and setting of tabGroupTitle would be in sync.
After that I wouldn't understand Your question.
Would You mind to write some details about Your question? Because I don't really know why are You asking that.

@whimboo Owner
whimboo added a note

The question was about our own sessionstore entry for NTT. Per default the sessionstore.js file will contain the list of all the windows, tabs, and groups. So if we would query the session store service we probably could retrieve the last active group on startup, whereby we wouldn't have to store our own property.

@xabolcs Owner
xabolcs added a note

Still not clear. :)

Are You talking about L#44, LAST_SESSION_GROUP_NAME_IDENTIFIER: "nightlytt-last-session-group-name", ?
I wouldn't like to collide TabView's property if we are before Bug 682996. In that case I plan simply use TabView's stuff, and do not save / restore ours.

@whimboo Owner
whimboo added a note

I don't think that we should care about code before bug 682996 has been fixed. It was fixed for Firefox 10 which we still support on the ESR branch. Releases before we do not support anymore. 3.6.x is an exception but will also be dropped soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo
Owner

I don't think this enhancement its worth delaying 3.2.2. Lets push it to 3.2.3.

@xabolcs
Owner

Sorry @whimboo, but I couldn't keep this status update in the diffs.

Updated pull (with a debug "build"):

  • refactored TabGroup support to JS Code module, due it's size
  • not addressed "simply retrive"
  • checked against multiple windows
  • unable to address Private Browsing (with multiple windows)

Could somebody help me?
STR:

  1. start Firefox (recommended with -console)
  2. open a new window
  3. name all your groups
  4. start Private Browsing
  5. browse a little
  6. stop Private Browing
  7. note that the other (background) windows won't get their TabGroup
  8. initialize their TabView: click on "Group your tabs", "move to group"
  9. examine log messages

I'm going to investigate the "simple retrive". (See comment: #19 (comment) )

@xabolcs
Owner
  • unable to address Private Browsing (with multiple windows)

Reason seems to be: SessionStore likes only startup and shutdown.
Isn't reliable to store title's when entering PB. :(
Are there any other way to store and load titles in case of PB?

@xabolcs
Owner

Updated pull (with a debug "build"):

In summary: TabGroup feature is complete except Private Browsing compatibility.

EDIT:
It's worth to test TabView's own implementation about this in FF 9!

@whimboo
Owner

Re: private browsing, we could observe the transition events and react accordingly. Those are independent from the session restore notifications.

@xabolcs
Owner

Updated pull:

  • addressed "simply retrieve" (See comment: #19 (comment) )
  • which resolves the Private Browing / History incompatibility
@xabolcs xabolcs commented on the diff
extension/modules/tabGroupTitle.jsm
((39 lines not shown))
+function getTabGroupTitle(win) {
+ let nightlyApp = win.nightlyApp;
+ let TabView = win.TabView;
+
+ // TabView isn't implemented
+ if (!("TabView" in win))
+ return "";
+
+ // If we are before Bug 682996,
+ // use TabView's own implementation except it is null
+ if (typeof(TabView.getActiveGroupName) === "function")
+ return TabView.getActiveGroupName() || "";
+
+ // TabView isn't initialized
+ if (!TabView._window) {
+ return getActiveGroupName(win);
@xabolcs Owner
xabolcs added a note

If there is no legal way to modify active group and / or active group's title then caching the result of getActiveGroupName() would be nice.
In other words: if the (TabView._window == null) implies that group items are immutable then caching the result of getActiveGroupName() is allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xabolcs xabolcs commented on the diff
extension/chrome/content/browser.js
@@ -66,6 +72,11 @@ init: function()
tabbrowser.updateTitlebar = nightly.updateTitlebar;
tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false);
+
+ try { // import tabGroupTitle functionality for titlebar customization
+ Components.utils.import("resource://nightly/tabGroupTitle.jsm", nightlyApp);
+ }
+ catch(e) { Components.utils.reportError(e); }
@xabolcs Owner
xabolcs added a note

Not sure, that error report is needed. IMHO it's enough to fail silently.

@whimboo Owner
whimboo added a note

Why do we have to put this into try/catch? The file will always be available and this import should never fail. If it does it would be fatal, and the failure should really bubble up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
extension/modules/tabGroupTitle.jsm
((30 lines not shown))
+
+/**
+ * Calculates Tab Group's title for nightlyApp
+ * @param {nsIDOMWindow} win A window which contains nightly.
+ *
+ * In Gecko 1.x title is set to "Undefined" as in other Apps
+ * Before FF10 title is managed by TabView
+ * After that we manages the title: SessionStore to load and save, borrowed code to generate
+ */
+function getTabGroupTitle(win) {
+ let nightlyApp = win.nightlyApp;
+ let TabView = win.TabView;
+
+ // TabView isn't implemented
+ if (!("TabView" in win))
+ return "";
@xabolcs Owner
xabolcs added a note

Fixed locally: just return;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xabolcs
Owner

Should test against Private Browsing Windows too!

EDIT:
Nothing special, it just runs another instance of Firefox with -no-remote -private -P private.

@whimboo
Owner

Moving to 3.4 because it's not that necessary to get out to our user base.

@whimboo
Owner

I think that this should wait until 3.4. It's more important to get out the compatibility changes to our user base.

@jwir3

Is this going to land? It would be really nice to have!

@xabolcs
Owner

jwir3: all the reviewer guys are busy, so not really. :(

@jwir3

xabolcs:

In the meantime, then, have you considered developing your own plugin for this and distributing it separately? If we can't get it into NTT, then there doesn't seem to be any reason not to push it from a 3rd party perspective.

@xabolcs
Owner

jwir:
hmmm, You're right.
There are a Nighly Tester Tools Resurrection named thread on MozillaZine.
Some months ago I posted there an unofficial release of NTT 3.4pre.

So I will update that soon, and would pack another one which has got this feature too.

@xabolcs
Owner

jwir3: see comment on MozillaZine! I made it for You! :)

@tonymec
Owner

FWIW: on 26 Sep. three's been an update on https://github.com/mozilla/nightlytt

Nothing yet at AMO since 2 May.

@whimboo
Owner

In https://bugzilla.mozilla.org/show_bug.cgi?id=836758 the panorama feature will be removed from Firefox. It will become an extension. So I don't believe that this pull is helpful anymore.

@xabolcs
Owner

You are wrong, IMHO. Do you use tab groups?

I believe it could be very useful.
See @jwir3's comment in this pull, and the others in the original Bug 682996!
And please note, this pull (in it's current status - last commit is almost a year old) supports Fx4 ... Fx21!
Did you check NTT's statistics on AMO by Application?

Of course, you are right, this pull needs update if Bug 836758 lands.
That's why I filed issue #118.

@xabolcs
Owner

Btw try build + addon + this pull works as expected.
No update needed. :)

So I really don't know why did you think that this pull isn't helpful anymore.

@whimboo
Owner

Please run the current version of this pull without the panorama ad-on installed. Does it break NTT?

Also how many people will still use panorama when it has been removed from Firefox core? There is a real low number as given on bug 836758, and this would also apply to users of NTT. You might want to start a survey on mozillazine if you want to figure that out. If there are only a few people why should we maintain such a feature in NTT which also relies on another add-on? Please keep that in mind.

@xabolcs
Owner

Please run the current version of this pull without the panorama ad-on installed. Does it break NTT?

It works like you run with Fx 3.6. See below:

// TabView isn't implemented
if (!("TabView" in win))
  return;

It will show "Undefined".

If there are only a few people why should we maintain such a feature in NTT which also relies on another add-on? Please keep that in mind.

I happily do the maintenance work.

@whimboo
Owner

In this case I'm fine with it. But shouldn't we move out this code into its own sub module? Given that it's not supported by default it's distracting to see when we are working on the code around it.

@xabolcs
Owner

Sad but true: this is still open :(
Unticking from v3.6.

@whimboo whimboo commented on the diff
extension/chrome/content/browser.js
@@ -51,6 +51,14 @@ get tabTitle() {
return tabbrowser.mCurrentBrowser.contentTitle;
},
+get tabGroupTitle() {
+ try
+ {
+ return nightlyApp.getTabGroupTitle(window);
+ }
+ catch (e) { }
@whimboo Owner
whimboo added a note

I don't see where ´getTabGroupTitle´ throws an exception. Can you please explain that? If we silently catch that, we might already want to do that in that method.

@tonymec Owner
tonymec added a note

Is getTabGroupTitle defined in SeaMonkey? AFAIK, there are no tab groups there at all (yet). Or do we never come here in SeaMonkey (however braindead the user's actions)?

@xabolcs Owner
xabolcs added a note

As you can see, nightlyApp.getTabGroupTitle() is only defined in browser.js === Firefox.
Therefore the current implementation needs the try ... catch. (Of course it could be improved, to avoid try ... catch)
BTW, only Firefox supports TabGroups (but the dev guys are going to extract it to an addon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo whimboo commented on the diff
extension/modules/tabGroupTitle.jsm
@@ -0,0 +1,75 @@
+var EXPORTED_SYMBOLS = ["getTabGroupTitle"];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const GROUP_DATA_IDENTIFIER = "tabview-group";
+
+let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+
+
+/**
+ * Simply retrieves the active tabgroup's title from SessionStore
+ */
+function getActiveGroupName(win) {
+ let data = "", groupTitle = "";
@whimboo Owner
whimboo added a note

nit: please put those on separate lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo whimboo commented on the diff
extension/modules/tabGroupTitle.jsm
((2 lines not shown))
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const GROUP_DATA_IDENTIFIER = "tabview-group";
+
+let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+
+
+/**
+ * Simply retrieves the active tabgroup's title from SessionStore
+ */
+function getActiveGroupName(win) {
+ let data = "", groupTitle = "";
+ try {
+ data = sstore.getWindowValue(win, win.TabView.GROUPS_IDENTIFIER);
@whimboo Owner
whimboo added a note

Why don't you make use of ´GROUP_DATA_IDENTIFIER´ here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo whimboo commented on the diff
extension/modules/tabGroupTitle.jsm
((9 lines not shown))
+
+
+/**
+ * Simply retrieves the active tabgroup's title from SessionStore
+ */
+function getActiveGroupName(win) {
+ let data = "", groupTitle = "";
+ try {
+ data = sstore.getWindowValue(win, win.TabView.GROUPS_IDENTIFIER);
+ if (data) {
+ let parsedData = {};
+ parsedData = JSON.parse(data);
+ let activeGroupId = parsedData.activeGroupId;
+ data = sstore.getWindowValue(win, GROUP_DATA_IDENTIFIER);
+ parsedData = JSON.parse(data);
+ groupTitle = parsedData[activeGroupId].title;
@whimboo Owner
whimboo added a note

Would you mind to add a comment what this code is doing, and why you have to parse twice? That would help a lot. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo whimboo commented on the diff
extension/modules/tabGroupTitle.jsm
((54 lines not shown))
+ return getActiveGroupName(win);
+ }
+
+ // We get the active group this way, instead of querying
+ // GroupItems.getActiveGroupItem() because the tabSelect event
+ // will not have happened by the time the browser tries to
+ // update the title.
+ let groupItem = null;
+ let activeTab = win.gBrowser.selectedTab;
+ let activeTabItem = activeTab._tabViewTabItem;
+
+ if (activeTab.pinned) {
+ // It's an app tab, so it won't have a .tabItem. However, its .parent
+ // will already be set as the active group.
+ groupItem = TabView._window.GroupItems.getActiveGroupItem();
+ } else if (activeTabItem) {
@whimboo Owner
whimboo added a note

nit: I would not recommend to use the hanging style. Lets move the ´else´ and ´catch´ statements into their own line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@whimboo
Owner

With the updates made, can we get a new XPI so users (on mozillazine?) could test it?

@xabolcs
Owner

With the updates made, can we get a new XPI so users (on mozillazine?) could test it?

Hi!
Thank you for the review!

Sadly, I don't have enough time on this, so I'm unable to address your comments soon. :(
Which implies this pull won't merged before v3.6 release date.
But what is delayed may come later. :)

@xabolcs xabolcs referenced this pull request from a commit in xabolcs/nightlytt
@xabolcs xabolcs Merge pull #19 - Tab groups b0b5072
@xabolcs xabolcs commented on the diff
extension/chrome/locale/en-US/variables.properties
@@ -52,5 +52,6 @@ variable.Processor.description=Compilation Processor
variable.Compiler.description=Compiler
variable.DefaultTitle.description=Default Application Title
variable.TabTitle.description=Current Tab's Title
+variable.TabGroup.description=Current Tab Group
@xabolcs Owner
xabolcs added a note

As you know, we have zh-CN locale too. Please merge from master!

Missing translation entity

Warning: Localizations must include a translated copy of each entity from each file in the reference locale. The required files may vary from target application to target application.

Missing Entities: variable.PlatformChangeset.description, variable.TabGroup.description
chrome/locale/zh-CN//chrome/locale/zh-CN/variables.properties

@whimboo Owner
whimboo added a note

Please do the merge yourself and ensure that all is included. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
13 extension/chrome/content/browser.js
@@ -18,6 +18,14 @@ get tabTitle() {
return tabbrowser.mCurrentBrowser.contentTitle;
},
+get tabGroupTitle() {
+ try
+ {
+ return nightlyApp.getTabGroupTitle(window);
+ }
+ catch (e) { }
@whimboo Owner
whimboo added a note

I don't see where ´getTabGroupTitle´ throws an exception. Can you please explain that? If we silently catch that, we might already want to do that in that method.

@tonymec Owner
tonymec added a note

Is getTabGroupTitle defined in SeaMonkey? AFAIK, there are no tab groups there at all (yet). Or do we never come here in SeaMonkey (however braindead the user's actions)?

@xabolcs Owner
xabolcs added a note

As you can see, nightlyApp.getTabGroupTitle() is only defined in browser.js === Firefox.
Therefore the current implementation needs the try ... catch. (Of course it could be improved, to avoid try ... catch)
BTW, only Firefox supports TabGroups (but the dev guys are going to extract it to an addon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+},
+
init: function()
{
var brandbundle = document.getElementById("bundle_brand");
@@ -33,6 +41,11 @@ init: function()
tabbrowser.updateTitlebar = nightly.updateTitlebar;
tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false);
+
+ try { // import tabGroupTitle functionality for titlebar customization
+ Components.utils.import("resource://nightly/tabGroupTitle.jsm", nightlyApp);
+ }
+ catch(e) { Components.utils.reportError(e); }
@xabolcs Owner
xabolcs added a note

Not sure, that error report is needed. IMHO it's enough to fail silently.

@whimboo Owner
whimboo added a note

Why do we have to put this into try/catch? The file will always be available and this import should never fail. If it does it would be fatal, and the failure should really bubble up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
},
openURL: function(url)
View
1  extension/chrome/content/nightly.js
@@ -37,6 +37,7 @@ variables: {
get compiler() this.appInfo.XPCOMABI.split("-")[1],
get defaulttitle() { return nightlyApp.defaultTitle; },
get tabtitle() { return nightlyApp.tabTitle; },
+ get tabgroup() { return nightlyApp.tabGroupTitle; },
profile: null,
toolkit: "cairo",
flags: ""
View
1  extension/chrome/content/titlebar/customize.js
@@ -85,6 +85,7 @@ init: function(aEvent)
paneTitle.addVariable("DefaultTitle");
paneTitle.addVariable("TabTitle");
+ paneTitle.addVariable("TabGroup");
paneTitle.addVariable("AppID");
paneTitle.addVariable("Vendor");
paneTitle.addVariable("Name");
View
1  extension/chrome/locale/en-US/variables.properties
@@ -20,5 +20,6 @@ variable.Processor.description=Compilation Processor
variable.Compiler.description=Compiler
variable.DefaultTitle.description=Default Application Title
variable.TabTitle.description=Current Tab's Title
+variable.TabGroup.description=Current Tab Group
@xabolcs Owner
xabolcs added a note

As you know, we have zh-CN locale too. Please merge from master!

Missing translation entity

Warning: Localizations must include a translated copy of each entity from each file in the reference locale. The required files may vary from target application to target application.

Missing Entities: variable.PlatformChangeset.description, variable.TabGroup.description
chrome/locale/zh-CN//chrome/locale/zh-CN/variables.properties

@whimboo Owner
whimboo added a note

Please do the merge yourself and ensure that all is included. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
variable.Profile.description=Current Profile
variable.Toolkit.description=Graphics Toolkit
View
75 extension/modules/tabGroupTitle.jsm
@@ -0,0 +1,75 @@
+var EXPORTED_SYMBOLS = ["getTabGroupTitle"];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const GROUP_DATA_IDENTIFIER = "tabview-group";
+
+let sstore = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
+
+
+/**
+ * Simply retrieves the active tabgroup's title from SessionStore
+ */
+function getActiveGroupName(win) {
+ let data = "", groupTitle = "";
@whimboo Owner
whimboo added a note

nit: please put those on separate lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ try {
+ data = sstore.getWindowValue(win, win.TabView.GROUPS_IDENTIFIER);
@whimboo Owner
whimboo added a note

Why don't you make use of ´GROUP_DATA_IDENTIFIER´ here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (data) {
+ let parsedData = {};
+ parsedData = JSON.parse(data);
+ let activeGroupId = parsedData.activeGroupId;
+ data = sstore.getWindowValue(win, GROUP_DATA_IDENTIFIER);
+ parsedData = JSON.parse(data);
+ groupTitle = parsedData[activeGroupId].title;
@whimboo Owner
whimboo added a note

Would you mind to add a comment what this code is doing, and why you have to parse twice? That would help a lot. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+ } catch (e) { }
+
+ return groupTitle;
+}
+
+/**
+ * Calculates Tab Group's title for nightlyApp
+ * @param {nsIDOMWindow} win A window which contains nightly.
+ *
+ * In Gecko 1.x title is set to "Undefined" as in other Apps
+ * Before FF10 title is managed by TabView
+ * After that we manages the title: using SessionStore and other borrowed code to generate
+ */
+function getTabGroupTitle(win) {
+ let nightlyApp = win.nightlyApp;
+ let TabView = win.TabView;
+
+ // TabView isn't implemented
+ if (!("TabView" in win))
+ return;
+
+ // If we are before Bug 682996,
+ // use TabView's own implementation except it is null
+ if (typeof(TabView.getActiveGroupName) === "function")
+ return TabView.getActiveGroupName() || "";
+
+ // TabView isn't initialized
+ if (!TabView._window) {
+ return getActiveGroupName(win);
@xabolcs Owner
xabolcs added a note

If there is no legal way to modify active group and / or active group's title then caching the result of getActiveGroupName() would be nice.
In other words: if the (TabView._window == null) implies that group items are immutable then caching the result of getActiveGroupName() is allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ }
+
+ // We get the active group this way, instead of querying
+ // GroupItems.getActiveGroupItem() because the tabSelect event
+ // will not have happened by the time the browser tries to
+ // update the title.
+ let groupItem = null;
+ let activeTab = win.gBrowser.selectedTab;
+ let activeTabItem = activeTab._tabViewTabItem;
+
+ if (activeTab.pinned) {
+ // It's an app tab, so it won't have a .tabItem. However, its .parent
+ // will already be set as the active group.
+ groupItem = TabView._window.GroupItems.getActiveGroupItem();
+ } else if (activeTabItem) {
@whimboo Owner
whimboo added a note

nit: I would not recommend to use the hanging style. Lets move the ´else´ and ´catch´ statements into their own line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ groupItem = activeTabItem.parent;
+ }
+
+ // groupItem may still be null, if the active tab is an orphan.
+ return groupItem ? groupItem.getTitle() : "";
+}
Something went wrong with that request. Please try again.