-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 726560 - Add support of Panorama group name (FF10+) for titlebar customization #19
Changes from 1 commit
a14ef5f
bcdc712
57e2da6
7dbf770
e52f841
91017e7
5f86f3d
2b7bfbf
2853a69
0b1787c
630b02e
5e5edaf
e11907e
3c7f334
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ repository: ['mozilla-central','mozilla-aurora'], | |
|
||
storedTitle: document.documentElement.getAttribute("titlemodifier"), | ||
|
||
LAST_SESSION_GROUP_NAME_IDENTIFIER: "nightlytt-last-session-group-name", | ||
_lastSessionGroupName: "", | ||
|
||
get defaultTitle() { | ||
var tabbrowser = document.getElementById("content"); | ||
return tabbrowser.getWindowTitleForBrowser(tabbrowser.mCurrentBrowser); | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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? |
||
|
||
|
||
// 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 = window.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) { | ||
groupItem = activeTabItem.parent; | ||
} | ||
|
||
// groupItem may still be null, if the active tab is an orphan. | ||
return groupItem ? groupItem.getTitle() : ""; | ||
}, | ||
|
||
init: function() | ||
{ | ||
var brandbundle = document.getElementById("bundle_brand"); | ||
|
@@ -66,6 +95,24 @@ init: function() | |
|
||
tabbrowser.updateTitlebar = nightly.updateTitlebar; | ||
tabbrowser.addEventListener("DOMTitleChanged", nightly.updateTitlebar, false); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If I move these lines some line below, into the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still not clear. :) Are You talking about L#44, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
// Listening to Bug 659591 (landed in FF7) - instead "domwindowclosed" (see Bug 655269), | ||
// 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 | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the ternary operator here. It makes it kinda hard to read. Also please better align those rows. |
||
}, | ||
|
||
openURL: function(url) | ||
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind starting to use JSdoc comments? http://code.google.com/p/jsdoc-toolkit/w/list |
||
saveActiveGroupName: function NightlyTT_saveActiveGroupName(win) { | ||
let groupName = nightlyApp.activeTabGroupName; | ||
Cc["@mozilla.org/browser/sessionstore;1"] | ||
.getService(Ci.nsISessionStore) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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? |
||
.setWindowValue( | ||
win, | ||
nightlyApp.LAST_SESSION_GROUP_NAME_IDENTIFIER, | ||
groupName | ||
); | ||
}, | ||
|
||
setCustomTitle: function(title) | ||
{ | ||
document.getElementById("content").ownerDocument.title = title; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tabGroupTitle? |
||
profile: null, | ||
toolkit: "cairo", | ||
flags: "" | ||
|
@@ -107,6 +108,10 @@ showAlert: function(id, args) { | |
|
||
init: function() { | ||
window.removeEventListener("load", nightly.init, false); | ||
setTimeout(nightly.initLazy,800); | ||
}, | ||
|
||
initLazy: function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
var prefs = Components.classes["@mozilla.org/preferences-service;1"] | ||
.getService(Components.interfaces.nsIPrefService); | ||
nightly.preferences = prefs.getBranch("nightly.") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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'. |
||
variable.Profile.description=Current Profile | ||
variable.Toolkit.description=Graphics Toolkit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ttaubert - would you mind checking the code if it's getting the group title the correct way?