calendar: Update notification icons handling

parent c7ed8e1f
......@@ -33,7 +33,7 @@
padding: $base_padding;
// icon container
.message-icon-bin {
.message-icon {
padding: ($base_padding * 2) 0 ($base_padding * 2) ($base_padding * 2);
&:rtl {
......@@ -100,6 +100,10 @@
.message-body {
color: darken($fg_color, 10%);
}
.message-avatar {
padding: $base_padding ($base_padding * 2);
}
}
// URLs in messages
......
......@@ -15,7 +15,6 @@ const { loadInterfaceXML } = imports.misc.fileUtils;
var MSECS_IN_DAY = 24 * 60 * 60 * 1000;
var SHOW_WEEKDATE_KEY = 'show-weekdate';
var MESSAGE_ICON_SIZE = -1; // pick up from CSS
var DEFAULT_EXPAND_LINES = 6;
var NC_ = (context, str) => '%s\u0004%s'.format(context, str);
......@@ -827,26 +826,29 @@ class NotificationMessage extends MessageList.Message {
let hbox = new St.BoxLayout();
vbox.add_actor(hbox);
this._iconBin = new St.Bin({
style_class: 'message-icon-bin',
this._sourceIcon = new St.Icon({
style_class: 'message-icon',
y_align: Clutter.ActorAlign.CENTER,
visible: false,
gicon: this.notification.source.getIcon(),
icon_size: 16,
});
hbox.add_actor(this._iconBin);
hbox.add_actor(this._sourceIcon);
let contentBox = new St.BoxLayout({
const contentBox = new St.BoxLayout({ x_expand: true });
vbox.add_child(contentBox);
const primaryContentBox = new St.BoxLayout({
style_class: 'message-content',
vertical: true,
x_expand: true,
});
vbox.add_actor(contentBox);
contentBox.add_child(primaryContentBox);
let headerBox = new St.BoxLayout({
style_class: 'message-header',
x_expand: true,
});
hbox.add_actor(headerBox);
headerBox.add_actor(this._iconBin);
this._header = new St.Label({
text: notification.source.title,
......@@ -855,7 +857,7 @@ class NotificationMessage extends MessageList.Message {
headerBox.add_actor(this._header);
let titleBox = new St.BoxLayout();
contentBox.add_actor(titleBox);
primaryContentBox.add_child(titleBox);
this.titleLabel = new St.Label({ style_class: 'message-title' });
this.setTitle(notification.title);
......@@ -888,7 +890,7 @@ class NotificationMessage extends MessageList.Message {
this._bodyStack = new St.Widget({ x_expand: true });
this._bodyStack.layout_manager = new LabelExpanderLayout();
contentBox.add_actor(this._bodyStack);
primaryContentBox.add_child(this._bodyStack);
this.bodyLabel = new MessageList.URLHighlighter('', false, this._useBodyMarkup);
this.bodyLabel.add_style_class_name('message-body');
......@@ -902,7 +904,18 @@ class NotificationMessage extends MessageList.Message {
this.setUseBodyMarkup(notification.bannerBodyMarkup);
this.setIcon(this._getIcon());
if (this.notification.gicon) {
this._icon = new St.Icon({
style_class: 'message-avatar',
y_align: Clutter.ActorAlign.CENTER,
gicon: this.notification.gicon,
x_expand: false,
icon_size: 32,
visible: !this.notification.gicon.equal(this.notification.source.getIcon()),
});
contentBox.add_child(this._icon);
}
this.connect('close', () => {
this._closed = true;
......@@ -945,19 +958,8 @@ class NotificationMessage extends MessageList.Message {
this._closeButton.reactive = visible;
}
_getIcon() {
if (this.notification.gicon) {
return new St.Icon({
gicon: this.notification.gicon,
icon_size: MESSAGE_ICON_SIZE,
});
} else {
return this.notification.source.createIcon(MESSAGE_ICON_SIZE);
}
}
_onUpdated(n, _clear) {
this.setIcon(this._getIcon());
this.notification.source.getIcon();
this.setTitle(n.title);
this.setBody(n.bannerBodyText);
this.setUseBodyMarkup(n.bannerBodyMarkup);
......
......@@ -451,6 +451,12 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
super.setTitle(title);
}
getIcon() {
return this.app && this.app.app_info
? this.app.app_info.get_icon()
: new Gio.ThemedIcon({ name: 'application-x-executable' });
}
open() {
this.openApp();
this.destroyNonResidentNotifications();
......@@ -601,6 +607,12 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
return this._app.create_icon_texture(size);
}
getIcon() {
return this._app.app_info
? this._app.app_info.get_icon()
: new Gio.ThemedIcon({ name: 'application-x-executable' });
}
_createPolicy() {
return new MessageTray.NotificationApplicationPolicy(this._appId);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment