[gnome-shell] messageTray: Allow to make notification buttons insensitive
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] messageTray: Allow to make notification buttons insensitive
- Date: Fri, 18 May 2012 15:41:54 +0000 (UTC)
commit 6190d6c962ca4df2675789e29672e74e5c55fa32
Author: Florian MÃllner <fmuellner gnome org>
Date: Thu May 17 21:05:36 2012 +0200
messageTray: Allow to make notification buttons insensitive
The availability of a notification action may depend on conditions,
so add a method to control the sensitivity of buttons which have
been added with addButton().
https://bugzilla.gnome.org/show_bug.cgi?id=651251
data/theme/gnome-shell.css | 5 +++++
js/ui/messageTray.js | 26 ++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css
index 259be26..a229653 100644
--- a/data/theme/gnome-shell.css
+++ b/data/theme/gnome-shell.css
@@ -328,6 +328,11 @@ StScrollBar StButton#vhandle:hover
background-gradient-end: rgba(255, 255, 255, 0.2);
}
+.notification-icon-button:insensitive,
+.notification-button:insensitive {
+ color: #9f9f9f;
+}
+
/* Panel */
#panel {
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index c7e3410..a5bd472 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -746,6 +746,7 @@ const Notification = new Lang.Class({
}
let button = new St.Button({ can_focus: true });
+ button._actionId = id;
if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(id)) {
button.add_style_class_name('notification-icon-button');
@@ -765,6 +766,31 @@ const Notification = new Lang.Class({
this.updated();
},
+ // setButtonSensitive:
+ // @id: the action ID
+ // @sensitive: whether the button should be sensitive
+ //
+ // If the notification contains a button with action ID @id,
+ // its sensitivity will be set to @sensitive. Insensitive
+ // buttons cannot be clicked.
+ setButtonSensitive: function(id, sensitive) {
+ if (!this._buttonBox)
+ return;
+
+ let button = this._buttonBox.get_children().filter(function(b) {
+ return b._actionId == id;
+ })[0];
+
+ if (!button || button.reactive == sensitive)
+ return;
+
+ button.reactive = sensitive;
+ if (sensitive)
+ button.remove_style_pseudo_class('insensitive');
+ else
+ button.add_style_pseudo_class('insensitive');
+ },
+
setUrgency: function(urgency) {
this.urgency = urgency;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]