[gnome-shell/wip/gtk-notification: 30/40] messageTray: Remove useActionIcons feature
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/gtk-notification: 30/40] messageTray: Remove useActionIcons feature
- Date: Mon, 21 Oct 2013 17:17:38 +0000 (UTC)
commit 5f081b8f8d5c474ef68cda5d5dec464c6c26ebcb
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sun Oct 13 23:13:31 2013 -0400
messageTray: Remove useActionIcons feature
This can be put in the legacy notification daemon with the new
addButtonFull API, to create icon names for actions.
https://bugzilla.gnome.org/show_bug.cgi?id=710137
js/ui/messageTray.js | 19 +++----------------
js/ui/notificationDaemon.js | 24 ++++++++++++++++++++----
2 files changed, 23 insertions(+), 20 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 9e6e5c0..2e1780a 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -503,7 +503,6 @@ const Notification = new Lang.Class({
this.focused = false;
this.acknowledged = false;
this._destroyed = false;
- this._useActionIcons = false;
this._customContent = false;
this.bannerBodyText = null;
this.bannerBodyMarkup = false;
@@ -866,17 +865,9 @@ const Notification = new Lang.Class({
// If the button is clicked, the notification will emit the
// %action-invoked signal with @id as a parameter
addAction: function(id, label) {
- let button = new St.Button({ can_focus: true });
-
- let iconName = strHasSuffix(id, '-symbolic') ? id : id + '-symbolic';
- if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(iconName)) {
- button.add_style_class_name('notification-icon-button');
- button.child = new St.Icon({ icon_name: iconName });
- } else {
- button.add_style_class_name('notification-button');
- button.label = label;
- }
-
+ let button = new St.Button({ style_class: 'notification-button',
+ label: label,
+ can_focus: true });
return this.addButton(id, button);
},
@@ -896,10 +887,6 @@ const Notification = new Lang.Class({
this.forFeedback = forFeedback;
},
- setUseActionIcons: function(useIcons) {
- this._useActionIcons = useIcons;
- },
-
_styleChanged: function() {
this._spacing = this._table.get_theme_node().get_length('spacing-columns');
},
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 55d98a9..8410aed 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -351,6 +351,19 @@ const NotificationDaemon = new Lang.Class({
return invocation.return_value(GLib.Variant.new('(u)', [id]));
},
+ _makeButton: function(id, label, useActionIcons) {
+ let button = new St.Button({ can_focus: true });
+ let iconName = strHasSuffix(id, '-symbolic') ? id : id + '-symbolic';
+ if (useActionIcons && Gtk.IconTheme.get_default().has_icon(iconName)) {
+ button.add_style_class_name('notification-icon-button');
+ button.child = new St.Icon({ icon_name: iconName });
+ } else {
+ button.add_style_class_name('notification-button');
+ button.label = label;
+ }
+ return button;
+ },
+
_notifyForSource: function(source, ndata) {
let [id, icon, summary, body, actions, hints, notification] =
[ndata.id, ndata.icon, ndata.summary, ndata.body,
@@ -414,15 +427,18 @@ const NotificationDaemon = new Lang.Class({
notification.setImage(image);
if (actions.length) {
- notification.setUseActionIcons(hints['action-icons'] == true);
+ let useActionIcons = (hints['action-icons'] == true);
+
for (let i = 0; i < actions.length - 1; i += 2) {
- if (actions[i] == 'default')
+ let [actionId, label] = [actions[i], actions[i+1]];
+ if (actionId == 'default') {
notification.connect('clicked', Lang.bind(this,
function() {
this._emitActionInvoked(ndata.id, "default");
}));
- else
- notification.addAction(actions[i], actions[i + 1]);
+ } else {
+ notification.addButton(actionId, this._makeButton(id, label, useActionIcons));
+ }
}
}
switch (hints.urgency) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]