[Pkg-mozext-commits] [tabmixplus] 12/44: Notify the user when TabView is missing and the restored session contains groups

David Prévot taffit at moszumanska.debian.org
Fri Mar 18 20:57:14 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 97769586a83331ad866b8d5edbdd2a72152ccd98
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sun Feb 21 14:37:15 2016 +0200

    Notify the user when TabView is missing and the restored session contains groups
---
 chrome/content/minit/tabView.js                |  6 +--
 chrome/content/session/session.js              | 74 ++++++++++++++++++++++++--
 chrome/locale/en-US/session-manager.properties |  5 ++
 3 files changed, 75 insertions(+), 10 deletions(-)

diff --git a/chrome/content/minit/tabView.js b/chrome/content/minit/tabView.js
index 4125390..1163aff 100644
--- a/chrome/content/minit/tabView.js
+++ b/chrome/content/minit/tabView.js
@@ -197,17 +197,13 @@
 
   // aWindow: rdfNodeWindow to read from
   TabmixSessionManager._setWindowStateBusy = function SM__setWindowStateBusy(aWindow) {
-    TabmixSvc.SessionStore._setWindowStateBusy(window);
+    this._beforeRestore(aWindow);
     if (!this.tabViewInstalled) {
       return;
     }
 
     TMP_SessionStore.initService();
     this._getSessionTabviewData(aWindow);
-
-    // save group count before we start the restore
-    var parsedData = TabmixSessionData.getWindowValue(window, "tabview-groups", true);
-    this._groupCount = parsedData.totalNumber || 1;
     this._updateUIpageBounds = false;
   };
 
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index b9339a5..3bad554 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -3807,14 +3807,78 @@ TabmixSessionManager = {
     return TMP_TabView.installed;
   },
 
-  notifyAboutMissingTabView: function() {
-    // TODO: notify the user when TabView is missing and the restored session
-    // contains groups
+  notifyAboutMissingTabView: function(showNotification) {
+    // show notification when Tabview is missing and the session have hidden tabs
+    if (showNotification || !this.tabViewInstalled) {
+      let hiddenTabs = gBrowser.tabs.length > gBrowser.visibleTabs.length;
+      if (this._groupCount > 1 && hiddenTabs) {
+        this.missingTabViewNotification();
+      }
+    }
   },
 
-  // we override these functions when TabView exist
-  _setWindowStateBusy: function() {
+  missingTabViewNotification: function(backup = "") {
+    let string = s => TabmixSvc.getSMString("sm.tabview." + s);
+
+    // If there's already an existing notification bar, don't do anything.
+    let notificationBox = document.getElementById("high-priority-global-notificationbox") ||
+                          document.getElementById("global-notificationbox");
+    let notification = notificationBox.getNotificationWithValue("tabmix-missing-tabview");
+    if (notification) {
+      if (notification.tabmixSavedBackup) {
+        notification.label += " " + string("hiddengroups");
+        delete notification.tabmixSavedBackup;
+      }
+      return;
+    }
+
+    let message = backup || string("hiddengroups");
+    let buttons = [{
+      label: string("install.label"),
+      accessKey: string("install.accesskey"),
+      callback: function() {
+        let link = TabmixSvc.isPaleMoon ?
+            "http://www.palemoon.org/tabgroups.shtml" :
+            "https://addons.mozilla.org/en-US/firefox/addon/tab-groups-panorama/";
+        openUILinkIn(link, "tab");
+      }
+    }];
+
+    if (!TabmixSvc.isPaleMoon) {
+      buttons.push({
+        label: string("removed.learnMore.label"),
+        accessKey: string("removed.learnMore.accesskey"),
+        callback: function() {
+          openUILinkIn("https://support.mozilla.org/kb/tab-groups-removal#w_tab-groups-replacement-add-ons", "tab");
+        }
+      });
+
+      message = string("removed") + " " + message;
+    }
+
+    notification = notificationBox.appendNotification(
+      message,
+      "tabmix-missing-tabview",
+      "chrome://tabmixplus/skin/tmpsmall.png",
+      notificationBox.PRIORITY_WARNING_MEDIUM,
+      buttons
+    );
+    if (backup) {
+      notification.tabmixSavedBackup = true;
+    }
+  },
+
+  _beforeRestore: function(rdfNodeWindow) {
     TabmixSvc.SessionStore._setWindowStateBusy(window);
+    // save group count before we start the restore
+    let data = this.getLiteralValue(rdfNodeWindow, "tabview-groups", "{}");
+    let parsedData = TabmixSvc.JSON.parse(data);
+    this._groupCount = parsedData.totalNumber || 1;
+  },
+
+  // we override these functions when TabView exist
+  _setWindowStateBusy: function(rdfNodeWindow) {
+    this._beforeRestore(rdfNodeWindow);
   },
 
   _setWindowStateReady: function(aOverwriteTabs, showNotification) {
diff --git a/chrome/locale/en-US/session-manager.properties b/chrome/locale/en-US/session-manager.properties
index 5f825c6..43d1f97 100644
--- a/chrome/locale/en-US/session-manager.properties
+++ b/chrome/locale/en-US/session-manager.properties
@@ -105,3 +105,8 @@ sm.extension.convert.selectfile=Select session.rdf file to convert
 sm.extension.convert.rdffiles=RDF Files
 sm.extension.convert.sessionfiles=Session Files
 sm.tabview.hiddengroups=More tabs restored into hidden groups.
+sm.tabview.removed=The Tab Groups (Panorama) feature was removed from Firefox.
+sm.tabview.removed.learnMore.label=Learn More
+sm.tabview.removed.learnMore.accesskey=L
+sm.tabview.install.label=Install Tab Groups extension
+sm.tabview.install.accesskey=I

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list