From d116fa8d4ad4fe93647f8fd6144febf48c3dfba0 Mon Sep 17 00:00:00 2001 From: "Utilu.com" Date: Wed, 31 Aug 2016 22:58:37 +0200 Subject: [PATCH 1/2] Added customize title bar options * Increased the size of the Customize Title bar window * Optimized the order of the Customize Title bar Variables * Added Customize Title bar Variable Application Title and Version * Added Customize Title bar Variable Application Display Version * Added Customize Title bar Variable Application Version Pretty * Added Customize Title bar Variable Application Update Channel * Added Customize Title bar Variable Application Update Channel Pretty (Release, ESR, beta, Aurora, Nighty, Default) * Added Customize Title bar Variable Application Beta Revision (only filled when applicable), fixing #204 * Added Customize Title bar Variable Application Version and Channel * Removed Gecko Build Identifier, since it used PlatformBuildID, just like XUL Platform Build Identifier * Removed Gecko Version, since it used PlatformVersion, just like XUL Platform Version --- extension/chrome/content/nightly.js | 68 ++++++++++++++++--- .../chrome/content/titlebar/customize.js | 31 +++++---- .../chrome/locale/en-US/variables.properties | 23 ++++--- extension/chrome/skin/titlebar/titlebar.css | 4 +- 4 files changed, 94 insertions(+), 32 deletions(-) diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index f6c54b1..4c07967 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -15,20 +15,36 @@ variables: { return this._appInfo; }, + get titleversion() { return this.tabtitle + ' - ' + this.vendor + ' ' + this.name + ' ' + this.versionchannel + ' (' + this.appbuildid + ')'; }, + get defaulttitle() { return nightlyApp.defaultTitle; }, + get tabtitle() { return nightlyApp.tabTitle; }, get appid() this.appInfo.ID, + brandname: null, get vendor() { // Fix for vendor not being set in Mozilla Thunderbird return this.appInfo.name == "Thunderbird" && this.appInfo.vendor == "" ? "Mozilla" : this.appInfo.vendor; }, get name() this.appInfo.name, get version() this.appInfo.version, - get appbuildid() this.appInfo.appBuildID, - get platformbuildid() this.appInfo.platformBuildID, + get versionpretty() { return nightly.makeVersionPretty(this.version); }, + get displayversion() { + var ver = this.version; + try { + // The import is only required in Mozilla Thunderbird + Components.utils.import("resource://gre/modules/AppConstants.jsm"); + if (AppConstants.MOZ_APP_VERSION_DISPLAY) { ver = AppConstants.MOZ_APP_VERSION_DISPLAY; } + } + catch (e) {} + return ver; + }, + get channel() { return nightly.updateChannel(); }, + get channelpretty() { return nightly.updateChannelPretty(); }, + get betarevision() { return nightly.betaRevision(this.version, this.displayversion); }, + get versionchannel() { return nightly.versionAndChannel(this.version, this.displayversion); }, get platformversion() this.appInfo.platformVersion, - get geckobuildid() this.appInfo.platformBuildID, - get geckoversion() this.appInfo.platformVersion, + get platformbuildid() this.appInfo.platformBuildID, + get appbuildid() this.appInfo.appBuildID, get changeset() { return nightly.getChangeset(); }, - brandname: null, get useragent() navigator.userAgent, get locale() { var registry = Components.classes["@mozilla.org/chrome/chrome-registry;1"] @@ -38,11 +54,9 @@ variables: { get os() this.appInfo.OS, get processor() this.appInfo.XPCOMABI.split("-")[0], get compiler() this.appInfo.XPCOMABI.split(/-(.*)$/)[1], - get defaulttitle() { return nightlyApp.defaultTitle; }, - get tabscount() { return nightlyApp.tabsCount; }, - get tabtitle() { return nightlyApp.tabTitle; }, - profile: null, toolkit: "cairo", + profile: null, + get tabscount() { return nightlyApp.tabsCount; }, flags: "" }, @@ -259,6 +273,42 @@ parseHTML: function(url, callback) { frame.contentDocument.location.href = url; }, +makeVersionPretty: function(ver) { + ver = ver.replace('0a2','0.0.0'); + ver = ver.replace('0a1','0.0.0'); + while (ver.match(new RegExp('\\.','g')).length < 3) { ver += '.0'; } + return ver; +}, +updateChannel: function() { + return Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService).getBranch("app.update.").getCharPref("channel"); +}, +updateChannelPretty: function() { + var channel = nightly.updateChannel(); + if (channel == 'release') { channel = 'Release' } + else if (channel == 'esr') { channel = 'ESR' } + else if (channel == 'beta') { channel = 'beta' } + else if (channel == 'aurora') { channel = 'Aurora' } + else if (channel == 'nightly') { channel = 'Nighty' } + else if (channel == 'default') { channel = 'Default' } + else channel = ''; + return channel; +}, +betaRevision: function(ver, displayversion) { + var beta = displayversion.replace(ver + 'b',''); + if (beta == displayversion) { beta = ''; }; + return beta; +}, +versionAndChannel: function(ver, displayversion) { + var channel = nightly.updateChannelPretty(); + var beta = nightly.betaRevision(ver, displayversion); + if (channel == 'Release' || channel == 'Default') { channel = ''; } + if (channel == 'beta' && beta != '') { channel += ' ' + beta; } + ver = nightly.makeVersionPretty(ver); + if (channel != '') { ver += ' ' + channel; } + return ver; +}, + pastebinAboutSupport: function() { nightly.parseHTML("about:support", function(doc) { var contents = doc.getElementById("contents"); diff --git a/extension/chrome/content/titlebar/customize.js b/extension/chrome/content/titlebar/customize.js index 3b49db2..1cb3e33 100644 --- a/extension/chrome/content/titlebar/customize.js +++ b/extension/chrome/content/titlebar/customize.js @@ -83,26 +83,33 @@ init: function(aEvent) paneTitle.bundle=document.getElementById("variablesBundle"); - paneTitle.addVariable("AppBuildID"); + paneTitle.addVariable("TitleVersion"); + paneTitle.addVariable("DefaultTitle"); + paneTitle.addVariable("TabTitle"); paneTitle.addVariable("AppID"); paneTitle.addVariable("BrandName"); + paneTitle.addVariable("Vendor"); + paneTitle.addVariable("Name"); + paneTitle.addVariable("Version"); + paneTitle.addVariable("VersionPretty"); + paneTitle.addVariable("DisplayVersion"); + paneTitle.addVariable("Channel"); + paneTitle.addVariable("ChannelPretty"); + paneTitle.addVariable("BetaRevision"); + paneTitle.addVariable("VersionChannel"); + paneTitle.addVariable("PlatformVersion"); + paneTitle.addVariable("PlatformBuildID"); + paneTitle.addVariable("AppBuildID"); paneTitle.addVariable("Changeset"); - paneTitle.addVariable("Compiler"); - paneTitle.addVariable("DefaultTitle"); - paneTitle.addVariable("GeckoVersion"); + paneTitle.addVariable("UserAgent"); paneTitle.addVariable("Locale"); - paneTitle.addVariable("Name"); paneTitle.addVariable("OS"); - paneTitle.addVariable("PlatformBuildID"); - paneTitle.addVariable("PlatformVersion"); paneTitle.addVariable("Processor"); + paneTitle.addVariable("Compiler"); + paneTitle.addVariable("Toolkit"); paneTitle.addVariable("Profile"); paneTitle.addVariable("TabsCount"); - paneTitle.addVariable("TabTitle"); - paneTitle.addVariable("Toolkit"); - paneTitle.addVariable("UserAgent"); - paneTitle.addVariable("Vendor"); - paneTitle.addVariable("Version"); + paneTitle.setupTree(); }, diff --git a/extension/chrome/locale/en-US/variables.properties b/extension/chrome/locale/en-US/variables.properties index 57d4d01..c055382 100644 --- a/extension/chrome/locale/en-US/variables.properties +++ b/extension/chrome/locale/en-US/variables.properties @@ -2,24 +2,29 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # +variable.TitleVersion.description=Application Title and Version +variable.DefaultTitle.description=Default Application Title +variable.TabTitle.description=Current Tab's Title variable.AppID.description=Application Identifier +variable.BrandName.description=Application Brand Name variable.Vendor.description=Application Vendor variable.Name.description=Application Name variable.Version.description=Application Version +variable.VersionPretty.description=Application Version Pretty +variable.DisplayVersion.description=Application Display Version +variable.Channel.description=Application Update Channel +variable.ChannelPretty.description=Application Update Channel Pretty +variable.BetaRevision.description=Application Beta Revision +variable.VersionChannel.description=Application Version and Channel +variable.PlatformVersion.description=XUL Platform Version +variable.PlatformBuildID.description=XUL Platform Build Identifier variable.AppBuildID.description=Application Build Identifier variable.Changeset.description=Built from that changeset -variable.PlatformBuildID.description=XUL Platform Build Identifier -variable.PlatformVersion.description=XUL Platform Version -variable.GeckoBuildID.description=Gecko Build Identifier -variable.GeckoVersion.description=Gecko Version -variable.BrandName.description=Application Brand Name variable.UserAgent.description=User Agent String variable.Locale.description=Current Locale variable.OS.description=Compilation OS variable.Processor.description=Compilation Processor variable.Compiler.description=Compiler -variable.DefaultTitle.description=Default Application Title -variable.TabTitle.description=Current Tab's Title -variable.Profile.description=Current Profile variable.Toolkit.description=Graphics Toolkit -variable.TabsCount.description=Count of visible tabs +variable.Profile.description=Current Profile +variable.TabsCount.description=Number of visible tabs diff --git a/extension/chrome/skin/titlebar/titlebar.css b/extension/chrome/skin/titlebar/titlebar.css index 2491978..b0a3093 100644 --- a/extension/chrome/skin/titlebar/titlebar.css +++ b/extension/chrome/skin/titlebar/titlebar.css @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #variableTree { - height: 17em; + height: 23em; } #NightlyTesterOptions { - width: 42.75em; + width: 56em; } From 62bc0d3100768e67b4937a013efa0644e78e36cc Mon Sep 17 00:00:00 2001 From: "Utilu.com" Date: Thu, 8 Sep 2016 12:41:43 +0200 Subject: [PATCH 2/2] Short way to get app.update.channel + beta version * Used the short way to get app.update.channel * Changed beta revision to beta version --- extension/chrome/content/nightly.js | 9 ++++----- extension/chrome/content/titlebar/customize.js | 2 +- extension/chrome/locale/en-US/variables.properties | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/extension/chrome/content/nightly.js b/extension/chrome/content/nightly.js index 4c07967..9e85816 100644 --- a/extension/chrome/content/nightly.js +++ b/extension/chrome/content/nightly.js @@ -39,7 +39,7 @@ variables: { }, get channel() { return nightly.updateChannel(); }, get channelpretty() { return nightly.updateChannelPretty(); }, - get betarevision() { return nightly.betaRevision(this.version, this.displayversion); }, + get betaversion() { return nightly.betaVersion(this.version, this.displayversion); }, get versionchannel() { return nightly.versionAndChannel(this.version, this.displayversion); }, get platformversion() this.appInfo.platformVersion, get platformbuildid() this.appInfo.platformBuildID, @@ -280,8 +280,7 @@ makeVersionPretty: function(ver) { return ver; }, updateChannel: function() { - return Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService).getBranch("app.update.").getCharPref("channel"); + return Services.prefs.getCharPref("app.update.channel"); }, updateChannelPretty: function() { var channel = nightly.updateChannel(); @@ -294,14 +293,14 @@ updateChannelPretty: function() { else channel = ''; return channel; }, -betaRevision: function(ver, displayversion) { +betaVersion: function(ver, displayversion) { var beta = displayversion.replace(ver + 'b',''); if (beta == displayversion) { beta = ''; }; return beta; }, versionAndChannel: function(ver, displayversion) { var channel = nightly.updateChannelPretty(); - var beta = nightly.betaRevision(ver, displayversion); + var beta = nightly.betaVersion(ver, displayversion); if (channel == 'Release' || channel == 'Default') { channel = ''; } if (channel == 'beta' && beta != '') { channel += ' ' + beta; } ver = nightly.makeVersionPretty(ver); diff --git a/extension/chrome/content/titlebar/customize.js b/extension/chrome/content/titlebar/customize.js index 1cb3e33..a3d76ac 100644 --- a/extension/chrome/content/titlebar/customize.js +++ b/extension/chrome/content/titlebar/customize.js @@ -95,7 +95,7 @@ init: function(aEvent) paneTitle.addVariable("DisplayVersion"); paneTitle.addVariable("Channel"); paneTitle.addVariable("ChannelPretty"); - paneTitle.addVariable("BetaRevision"); + paneTitle.addVariable("BetaVersion"); paneTitle.addVariable("VersionChannel"); paneTitle.addVariable("PlatformVersion"); paneTitle.addVariable("PlatformBuildID"); diff --git a/extension/chrome/locale/en-US/variables.properties b/extension/chrome/locale/en-US/variables.properties index c055382..35e4fed 100644 --- a/extension/chrome/locale/en-US/variables.properties +++ b/extension/chrome/locale/en-US/variables.properties @@ -14,7 +14,7 @@ variable.VersionPretty.description=Application Version Pretty variable.DisplayVersion.description=Application Display Version variable.Channel.description=Application Update Channel variable.ChannelPretty.description=Application Update Channel Pretty -variable.BetaRevision.description=Application Beta Revision +variable.BetaVersion.description=Application Beta Version variable.VersionChannel.description=Application Version and Channel variable.PlatformVersion.description=XUL Platform Version variable.PlatformBuildID.description=XUL Platform Build Identifier