Bug 594704 - add better notification setup for Fx4, r=gavin, a=blocking

--HG--
extra : rebase_source : 0b4a83f7bb87626d54ff8b1b7d87166373c39d0f
This commit is contained in:
Philipp von Weitershausen 2010-09-10 13:47:57 -04:00
Родитель f65fde1511
Коммит 14674eb816
5 изменённых файлов: 44 добавлений и 77 удалений

Просмотреть файл

@ -67,7 +67,7 @@ let gSyncUI = {
// If this is a browser window?
if (gBrowser) {
obs.push("weave:notification:added", "weave:notification:removed");
obs.push("weave:notification:added");
}
let self = this;
@ -82,9 +82,29 @@ let gSyncUI = {
popup.addEventListener("popupshowing", function() {
self.alltabsPopupShowing();
}, true);
if (Weave.Notifications.notifications.length)
this.initNotifications();
}
this.updateUI();
},
initNotifications: function SUI_initNotifications() {
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let notificationbox = document.createElementNS(XULNS, "notificationbox");
notificationbox.id = "sync-notifications";
notificationbox.setAttribute("flex", "1");
let bottombox = document.getElementById("browser-bottombox");
let statusbar = document.getElementById("status-bar");
bottombox.insertBefore(notificationbox, statusbar);
// Force a style flush to ensure that our binding is attached.
notificationbox.clientTop;
// notificationbox will listen to observers from now on.
Services.obs.removeObserver(this, "weave:notification:added");
},
_wasDelayed: false,
@ -237,36 +257,6 @@ let gSyncUI = {
Weave.Notifications.replaceTitle(notification);
},
onNotificationAdded: function SUI_onNotificationAdded() {
if (!gBrowser)
return;
let notificationsButton = document.getElementById("sync-notifications-button");
notificationsButton.hidden = false;
let notification = Weave.Notifications.notifications.reduce(function(prev, cur) {
return prev.priority > cur.priority ? prev : cur;
});
let image = notification.priority >= Weave.Notifications.PRIORITY_WARNING ?
"chrome://global/skin/icons/warning-16.png" :
"chrome://global/skin/icons/information-16.png";
notificationsButton.image = image;
notificationsButton.label = notification.title;
},
onNotificationRemoved: function SUI_onNotificationRemoved() {
if (!gBrowser)
return;
if (Weave.Notifications.notifications.length == 0) {
document.getElementById("sync-notifications-button").hidden = true;
}
else {
// Display remaining notifications
this.onNotificationAdded();
}
},
// Commands
doLogin: function SUI_doLogin() {
Weave.Service.login();
@ -434,10 +424,7 @@ let gSyncUI = {
this.initUI();
break;
case "weave:notification:added":
this.onNotificationAdded();
break;
case "weave:notification:removed":
this.onNotificationRemoved();
this.initNotifications();
break;
}
},

Просмотреть файл

@ -318,13 +318,14 @@ window[chromehidden~="toolbar"] toolbar:not(.toolbar-primary):not(.chromeclass-m
min-width: 1px;
}
/* Sync statusbar UI */
%ifdef MOZ_SERVICES_SYNC
#sync-notifications-box {
/* Sync notification UI */
#sync-notifications {
-moz-binding: url("chrome://browser/content/syncNotification.xml#notificationbox");
overflow-y: visible !important;
}
#sync-notifications-box notification {
#sync-notifications notification {
-moz-binding: url("chrome://browser/content/syncNotification.xml#notification");
}
%endif

Просмотреть файл

@ -2768,6 +2768,13 @@ var PrintPreviewListener = {
this._chromeState.findOpen = gFindBarInitialized && !gFindBar.hidden;
if (gFindBarInitialized)
gFindBar.close();
this._chromeState.syncNotificationsOpen = false;
var syncNotifications = document.getElementById("sync-notifications");
if (syncNotifications) {
this._chromeState.syncNotificationsOpen = !syncNotifications.notificationsHidden;
syncNotifications.notificationsHidden = true;
}
},
_showChrome: function () {
if (this._chromeState.notificationsOpen)
@ -2778,6 +2785,9 @@ var PrintPreviewListener = {
if (this._chromeState.findOpen)
gFindBar.open();
if (this._chromeState.syncNotificationsOpen)
document.getElementById("sync-notifications").notificationsHidden = false;
}
}

Просмотреть файл

@ -1308,16 +1308,6 @@
<statusbarpanel id="security-button" class="statusbarpanel-iconic"
hidden="true"
onclick="if (event.button == 0 &amp;&amp; event.detail == 1) displaySecurityInfo();"/>
#ifdef MOZ_SERVICES_SYNC
<statusbarpanel id="sync-notifications-button"
class="statusbarpanel-iconic-text"
hidden="true"
popup="sync-notifications-panel">
</statusbarpanel>
<panel id="sync-notifications-panel" position="before_end">
<notificationbox id="sync-notifications-box"/>
</panel>
#endif
<statusbarpanel id="page-report-button" type="menu"
class="statusbarpanel-menu-iconic"
hidden="true"

Просмотреть файл

@ -91,32 +91,17 @@
break;
}
}
// If the user has just closed the last notification, close the panel.
// FIXME: this is not quite right, because it might not have been
// the user that caused weave:notification:removed to get called.
// We need to differentiate between "notification removed" and "user
// closed the notification" and only close the panel if it was
// the user who closed the last notification. Maybe we should make
// the notification's close method handle closing the panel,
// but should the notification box or its notifications really know
// they are located inside the panel?
var panel = document.getElementById("sync-notifications-panel");
if (panel.state == "open" &&
Notifications.notifications.length == 0)
panel.hidePopup();
]]></body>
</method>
<method name="_appendNotification">
<parameter name="notification"/>
<body><![CDATA[
var node = this.appendNotification(notification.title,
notification.description,
var node = this.appendNotification(notification.description,
notification.title,
notification.iconURL,
notification.priority,
notification.buttons);
node.className = notification.constructor.name;
node.notification = notification;
]]></body>
</method>
@ -126,23 +111,17 @@
<binding id="notification" extends="chrome://global/content/bindings/notification.xml#notification">
<content>
<xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type" align="start">
<xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image" style="padding: 3px;"/>
<xul:vbox flex="1">
<xul:hbox anonid="details" align="center" flex="1">
<xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
<xul:spacer flex="1"/>
</xul:hbox>
<xul:description xbl:inherits="xbl:text=value"/>
<xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
<xul:hbox anonid="details" align="center" flex="1">
<xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
<xul:description anonid="messageText" class="messageText" xbl:inherits="xbl:text=label"/>
<!-- The children are the buttons defined by the notification. -->
<xul:hbox oncommand="document.getBindingParent(this)._doButtonCommand(event);">
<xul:spacer flex="1"/>
<children/>
</xul:hbox>
</xul:vbox>
<xul:spacer flex="1"/>
<xul:spacer flex="1"/>
</xul:hbox>
<xul:toolbarbutton ondblclick="event.stopPropagation();"
class="messageCloseButton tabbable"
xbl:inherits="hidden=hideclose"