Port message tray sources and notifications to class framework

Third step in the class framework port, now it's the turn of
MessageTray.Source and MessageTray.Notification, as well as
the various implementations around the shell.

https://bugzilla.gnome.org/show_bug.cgi?id=664436
This commit is contained in:
Giovanni Campagna 2011-11-20 16:12:02 +01:00
parent 566bdb50c2
commit b356aa8e3b
9 changed files with 162 additions and 254 deletions

View File

@ -261,15 +261,12 @@ AutorunManager.prototype = {
},
}
function AutorunResidentSource() {
this._init();
}
AutorunResidentSource.prototype = {
__proto__: MessageTray.Source.prototype,
const AutorunResidentSource = new Lang.Class({
Name: 'AutorunResidentSource',
Extends: MessageTray.Source,
_init: function() {
MessageTray.Source.prototype._init.call(this, _("Removable Devices"));
this.parent(_("Removable Devices"));
this._mounts = [];
@ -324,19 +321,14 @@ AutorunResidentSource.prototype = {
icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE });
}
}
});
function AutorunResidentNotification(source) {
this._init(source);
}
AutorunResidentNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const AutorunResidentNotification = new Lang.Class({
Name: 'AutorunResidentNotification',
Extends: MessageTray.Notification,
_init: function(source) {
MessageTray.Notification.prototype._init.call(this, source,
source.title, null,
{ customContent: true });
this.parent(source, source.title, null, { customContent: true });
// set the notification as resident
this.setResident(true);
@ -410,7 +402,7 @@ AutorunResidentNotification.prototype = {
return item;
},
}
});
function AutorunTransientDispatcher() {
this._init();
@ -509,15 +501,12 @@ AutorunTransientDispatcher.prototype = {
}
}
function AutorunTransientSource(mount, apps) {
this._init(mount, apps);
}
AutorunTransientSource.prototype = {
__proto__: MessageTray.Source.prototype,
const AutorunTransientSource = new Lang.Class({
Name: 'AutorunTransientSource',
Extends: MessageTray.Source,
_init: function(mount, apps) {
MessageTray.Source.prototype._init.call(this, mount.get_name());
this.parent(mount.get_name());
this.mount = mount;
this.apps = apps;
@ -534,19 +523,14 @@ AutorunTransientSource.prototype = {
return new St.Icon({ gicon: this.mount.get_icon(),
icon_size: this.ICON_SIZE });
}
}
});
function AutorunTransientNotification(source) {
this._init(source);
}
AutorunTransientNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const AutorunTransientNotification = new Lang.Class({
Name: 'AutorunTransientNotification',
Extends: MessageTray.Notification,
_init: function(source) {
MessageTray.Notification.prototype._init.call(this, source,
source.title, null,
{ customContent: true });
this.parent(source, source.title, null, { customContent: true });
this._box = new St.BoxLayout({ style_class: 'hotplug-transient-box',
vertical: true });
@ -621,5 +605,5 @@ AutorunTransientNotification.prototype = {
return button;
}
}
});

View File

@ -535,16 +535,13 @@ Keyboard.prototype = {
};
DBus.conformExport(Keyboard.prototype, CaribouKeyboardIface);
function KeyboardSource() {
this._init.apply(this, arguments);
}
KeyboardSource.prototype = {
__proto__: MessageTray.Source.prototype,
const KeyboardSource = new Lang.Class({
Name: 'KeyboardSource',
Extends: MessageTray.Source,
_init: function(keyboard) {
this.parent(_("Keyboard"));
this._keyboard = keyboard;
MessageTray.Source.prototype._init.call(this, _("Keyboard"));
this._setSummaryIcon(this.createNotificationIcon());
},
@ -567,4 +564,4 @@ KeyboardSource.prototype = {
open: function() {
this._keyboard.show();
}
};
});

View File

@ -408,11 +408,9 @@ Signals.addSignalMethods(FocusGrabber.prototype);
// the content and the action area of the notification will be cleared.
// The content area is also always cleared if 'customContent' is false
// because it might contain the @banner that didn't fit in the banner mode.
function Notification(source, title, banner, params) {
this._init(source, title, banner, params);
}
const Notification = new Lang.Class({
Name: 'Notification',
Notification.prototype = {
IMAGE_SIZE: 125,
_init: function(source, title, banner, params) {
@ -953,14 +951,12 @@ Notification.prototype = {
this.actor.destroy();
this.actor._delegate = null;
}
};
});
Signals.addSignalMethods(Notification.prototype);
function Source(title) {
this._init(title);
}
const Source = new Lang.Class({
Name: 'MessageTraySource',
Source.prototype = {
ICON_SIZE: 24,
_init: function(title) {
@ -1142,7 +1138,7 @@ Source.prototype = {
_lastNotificationRemoved: function() {
this.destroy();
}
};
});
Signals.addSignalMethods(Source.prototype);
function SummaryItem(source) {
@ -2428,15 +2424,12 @@ MessageTray.prototype = {
}
};
function SystemNotificationSource() {
this._init();
}
SystemNotificationSource.prototype = {
__proto__: Source.prototype,
const SystemNotificationSource = new Lang.Class({
Name: 'SystemNotificationSource',
Extends: Source,
_init: function() {
Source.prototype._init.call(this, _("System Information"));
this.parent(_("System Information"));
this._setSummaryIcon(this.createNotificationIcon());
},
@ -2450,4 +2443,4 @@ SystemNotificationSource.prototype = {
open: function() {
this.destroy();
}
};
});

View File

@ -476,15 +476,12 @@ NotificationDaemon.prototype = {
}
};
function Source(title, pid, sender) {
this._init(title, pid, sender);
}
Source.prototype = {
__proto__: MessageTray.Source.prototype,
const Source = new Lang.Class({
Name: 'NotificationDaemonSource',
Extends: MessageTray.Source,
_init: function(title, pid, sender) {
MessageTray.Source.prototype._init.call(this, title);
this.parent(title);
this._pid = pid;
if (sender)
@ -606,6 +603,6 @@ Source.prototype = {
this._nameWatcherId = 0;
}
MessageTray.Source.prototype.destroy.call(this);
this.parent();
}
};
});

View File

@ -239,16 +239,13 @@ ShellMountQuestionDialog.prototype = {
}
Signals.addSignalMethods(ShellMountQuestionDialog.prototype);
function ShellMountPasswordSource(message, icon, reaskPassword) {
this._init(message, icon, reaskPassword);
}
ShellMountPasswordSource.prototype = {
__proto__: MessageTray.Source.prototype,
const ShellMountPasswordSource = new Lang.Class({
Name: 'ShellMountPasswordSource',
Extends: MessageTray.Source,
_init: function(message, icon, reaskPassword) {
let strings = message.split('\n');
MessageTray.Source.prototype._init.call(this, strings[0]);
this.parent(strings[0]);
this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
@ -256,21 +253,15 @@ ShellMountPasswordSource.prototype = {
Main.messageTray.add(this);
this.notify(this._notification);
},
}
});
Signals.addSignalMethods(ShellMountPasswordSource.prototype);
function ShellMountPasswordNotification(source, strings, icon, reaskPassword) {
this._init(source, strings, icon, reaskPassword);
}
ShellMountPasswordNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const ShellMountPasswordNotification = new Lang.Class({
Name: 'ShellMountPasswordNotification',
Extends: MessageTray.Notification,
_init: function(source, strings, icon, reaskPassword) {
MessageTray.Notification.prototype._init.call(this, source,
strings[0], null,
{ customContent: true,
icon: icon });
this.parent(source, strings[0], null, { customContent: true, icon: icon });
// set the notification to transient and urgent, so that it
// expands out
@ -305,7 +296,7 @@ ShellMountPasswordNotification.prototype = {
this.source.emit('password-ready', text);
}
}
});
function ShellProcessesDialog(icon) {
this._init(icon);

View File

@ -334,15 +334,12 @@ const Indicator = new Lang.Class({
}
});
function Source() {
this._init.apply(this, arguments);
}
Source.prototype = {
__proto__: MessageTray.Source.prototype,
const Source = new Lang.Class({
Name: 'BluetoothSource',
Extends: MessageTray.Source,
_init: function() {
MessageTray.Source.prototype._init.call(this, _("Bluetooth"));
this.parent(_("Bluetooth"));
this._setSummaryIcon(this.createNotificationIcon());
},
@ -364,18 +361,14 @@ Source.prototype = {
icon_type: St.IconType.SYMBOLIC,
icon_size: this.ICON_SIZE });
}
}
});
function AuthNotification() {
this._init.apply(this, arguments);
}
AuthNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const AuthNotification = new Lang.Class({
Name: 'AuthNotification',
Extends: MessageTray.Notification,
_init: function(source, applet, device_path, name, long_name, uuid) {
MessageTray.Notification.prototype._init.call(this,
source,
this.parent(source,
_("Bluetooth"),
_("Authorization request from %s").format(name),
{ customContent: true });
@ -404,18 +397,14 @@ AuthNotification.prototype = {
this.destroy();
}));
}
}
});
function ConfirmNotification() {
this._init.apply(this, arguments);
}
ConfirmNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const ConfirmNotification = new Lang.Class({
Name: 'ConfirmNotification',
Extends: MessageTray.Notification,
_init: function(source, applet, device_path, name, long_name, pin) {
MessageTray.Notification.prototype._init.call(this,
source,
this.parent(source,
_("Bluetooth"),
_("Pairing confirmation for %s").format(name),
{ customContent: true });
@ -437,18 +426,14 @@ ConfirmNotification.prototype = {
this.destroy();
}));
}
}
});
function PinNotification() {
this._init.apply(this, arguments);
}
PinNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const PinNotification = new Lang.Class({
Name: 'PinNotification',
Extends: MessageTray.Notification,
_init: function(source, applet, device_path, name, long_name, numeric) {
MessageTray.Notification.prototype._init.call(this,
source,
this.parent(source,
_("Bluetooth"),
_("Pairing request for %s").format(name),
{ customContent: true });
@ -503,4 +488,4 @@ PinNotification.prototype = {
MessageTray.Notification.prototype.grabFocus.call(this, lockTray);
global.stage.set_key_focus(this._entry);
}
}
});

View File

@ -2121,15 +2121,12 @@ const NMApplet = new Lang.Class({
}
});
function NMMessageTraySource() {
this._init();
}
NMMessageTraySource.prototype = {
__proto__: MessageTray.Source.prototype,
const NMMessageTraySource = new Lang.Class({
Name: 'NMMessageTraySource',
Extends: MessageTray.Source,
_init: function() {
MessageTray.Source.prototype._init.call(this, _("Network Manager"));
this.parent(_("Network Manager"));
let icon = new St.Icon({ icon_name: 'network-transmit-receive',
icon_type: St.IconType.SYMBOLIC,
@ -2137,4 +2134,4 @@ NMMessageTraySource.prototype = {
});
this._setSummaryIcon(icon);
}
};
});

View File

@ -481,15 +481,12 @@ Client.prototype = {
}
};
function ChatSource(account, conn, channel, contact, client) {
this._init(account, conn, channel, contact, client);
}
ChatSource.prototype = {
__proto__: MessageTray.Source.prototype,
const ChatSource = new Lang.Class({
Name: 'ChatSource',
Extends: MessageTray.Source,
_init: function(account, conn, channel, contact, client) {
MessageTray.Source.prototype._init.call(this, contact.get_alias());
this.parent(contact.get_alias());
this.isChat = true;
@ -798,17 +795,14 @@ ChatSource.prototype = {
this._shouldAck = false;
}
};
});
function ChatNotification(source) {
this._init(source);
}
ChatNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const ChatNotification = new Lang.Class({
Name: 'ChatNotification',
Extends: MessageTray.Notification,
_init: function(source) {
MessageTray.Notification.prototype._init.call(this, source, source.title, null, { customContent: true });
this.parent(source, source.title, null, { customContent: true });
this.setResident(true);
this._responseEntry = new St.Entry({ style_class: 'chat-response',
@ -1091,17 +1085,14 @@ ChatNotification.prototype = {
this.source.setChatState(Tp.ChannelChatState.ACTIVE);
}
}
};
});
function ApproverSource(dispatchOp, text, gicon) {
this._init(dispatchOp, text, gicon);
}
ApproverSource.prototype = {
__proto__: MessageTray.Source.prototype,
const ApproverSource = new Lang.Class({
Name: 'ApproverSource',
Extends: MessageTray.Source,
_init: function(dispatchOp, text, gicon) {
MessageTray.Source.prototype._init.call(this, text);
this.parent(text);
this._gicon = gicon;
this._setSummaryIcon(this.createNotificationIcon());
@ -1130,18 +1121,14 @@ ApproverSource.prototype = {
icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE });
}
}
});
function RoomInviteNotification(source, dispatchOp, channel, inviter) {
this._init(source, dispatchOp, channel, inviter);
}
RoomInviteNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const RoomInviteNotification = new Lang.Class({
Name: 'RoomInviteNotification',
Extends: MessageTray.Notification,
_init: function(source, dispatchOp, channel, inviter) {
MessageTray.Notification.prototype._init.call(this,
source,
this.parent(source,
/* translators: argument is a room name like
* room@jabber.org for example. */
_("Invitation to %s").format(channel.get_identifier()),
@ -1173,15 +1160,12 @@ RoomInviteNotification.prototype = {
this.destroy();
}));
}
};
});
// Audio Video
function AudioVideoNotification(source, dispatchOp, channel, contact, isVideo) {
this._init(source, dispatchOp, channel, contact, isVideo);
}
AudioVideoNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const AudioVideoNotification = new Lang.Class({
Name: 'AudioVideoNotification',
Extends: MessageTray.Notification,
_init: function(source, dispatchOp, channel, contact, isVideo) {
let title = '';
@ -1193,11 +1177,7 @@ AudioVideoNotification.prototype = {
/* translators: argument is a contact name like Alice for example. */
title = _("Call from %s").format(contact.get_alias());
MessageTray.Notification.prototype._init.call(this,
source,
title,
null,
{ customContent: true });
this.parent(this, source, title, null, { customContent: true });
this.setResident(true);
this.addButton('reject', _("Reject"));
@ -1220,18 +1200,15 @@ AudioVideoNotification.prototype = {
this.destroy();
}));
}
};
});
// File Transfer
function FileTransferNotification(source, dispatchOp, channel, contact) {
this._init(source, dispatchOp, channel, contact);
}
FileTransferNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const FileTransferNotification = new Lang.Class({
Name: 'FileTransferNotification',
Extends: MessageTray.Notification,
_init: function(source, dispatchOp, channel, contact) {
MessageTray.Notification.prototype._init.call(this,
this.parent(this,
source,
/* To translators: The first parameter is
* the contact's alias and the second one is the
@ -1263,18 +1240,15 @@ FileTransferNotification.prototype = {
this.destroy();
}));
}
};
});
// A notification source that can embed multiple notifications
function MultiNotificationSource(title, icon) {
this._init(title, icon);
}
MultiNotificationSource.prototype = {
__proto__: MessageTray.Source.prototype,
const MultiNotificationSource = new Lang.Class({
Name: 'MultiNotificationSource',
Extends: MessageTray.Source,
_init: function(title, icon) {
MessageTray.Source.prototype._init.call(this, title);
this.parent(title);
this._icon = icon;
this._setSummaryIcon(this.createNotificationIcon());
@ -1282,7 +1256,7 @@ MultiNotificationSource.prototype = {
},
notify: function(notification) {
MessageTray.Source.prototype.notify.call(this, notification);
this.parent(notification);
this._nbNotifications += 1;
@ -1300,18 +1274,15 @@ MultiNotificationSource.prototype = {
icon_type: St.IconType.FULLCOLOR,
icon_size: this.ICON_SIZE });
}
};
});
// Subscription request
function SubscriptionRequestNotification(source, contact) {
this._init(source, contact);
}
SubscriptionRequestNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const SubscriptionRequestNotification = new Lang.Class({
Name: 'SubscriptionRequestNotification',
Extends: MessageTray.Notification,
_init: function(source, contact) {
MessageTray.Notification.prototype._init.call(this, source,
this.parent(this, source,
/* To translators: The parameter is the contact's alias */
_("%s would like permission to see when you are online").format(contact.get_alias()),
null, { customContent: true });
@ -1388,7 +1359,7 @@ SubscriptionRequestNotification.prototype = {
this._invalidatedId = 0;
}
MessageTray.Notification.prototype.destroy.call(this);
this.parent();
},
_subscriptionStatesChangedCb: function(contact, subscribe, publish, msg) {
@ -1397,12 +1368,7 @@ SubscriptionRequestNotification.prototype = {
if (publish != Tp.SubscriptionState.ASK)
this.destroy();
}
};
function AccountNotification(source, account, connectionError) {
this._init(source, account, connectionError);
}
});
// Messages from empathy/libempathy/empathy-utils.c
// create_errors_to_message_hash()
@ -1457,11 +1423,12 @@ _connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE)]
_connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED)]
= _("The length of the server certificate, or the depth of the server certificate chain, exceed the limits imposed by the cryptography library");
AccountNotification.prototype = {
__proto__: MessageTray.Notification.prototype,
const AccountNotification = new Lang.Class({
Name: 'AccountNotification',
Extends: MessageTray.Notification,
_init: function(source, account, connectionError) {
MessageTray.Notification.prototype._init.call(this, source,
this.parent(source,
/* translators: argument is the account name, like
* name@jabber.org for example. */
_("Connection to %s failed").format(account.get_display_name()),
@ -1541,6 +1508,6 @@ AccountNotification.prototype = {
this._connectionStatusId = 0;
}
MessageTray.Notification.prototype.destroy.call(this);
this.parent();
}
};
});

View File

@ -45,15 +45,12 @@ WindowAttentionHandler.prototype = {
}
};
function Source(app, window) {
this._init(app, window);
}
Source.prototype = {
__proto__ : MessageTray.Source.prototype,
const Source = new Lang.Class({
Name: 'WindowAttentionSource',
Extends: MessageTray.Source,
_init: function(app, window) {
MessageTray.Source.prototype._init.call(this, app.get_name());
this.parent(app.get_name());
this._window = window;
this._app = app;
this._setSummaryIcon(this.createNotificationIcon());
@ -81,4 +78,4 @@ Source.prototype = {
Main.activateWindow(this._window);
this.destroy();
}
};
});