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
This commit is contained in:
parent
76616dc98c
commit
6190d6c962
@ -328,6 +328,11 @@ StScrollBar StButton#vhandle:hover
|
|||||||
background-gradient-end: rgba(255, 255, 255, 0.2);
|
background-gradient-end: rgba(255, 255, 255, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.notification-icon-button:insensitive,
|
||||||
|
.notification-button:insensitive {
|
||||||
|
color: #9f9f9f;
|
||||||
|
}
|
||||||
|
|
||||||
/* Panel */
|
/* Panel */
|
||||||
|
|
||||||
#panel {
|
#panel {
|
||||||
|
@ -746,6 +746,7 @@ const Notification = new Lang.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let button = new St.Button({ can_focus: true });
|
let button = new St.Button({ can_focus: true });
|
||||||
|
button._actionId = id;
|
||||||
|
|
||||||
if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(id)) {
|
if (this._useActionIcons && Gtk.IconTheme.get_default().has_icon(id)) {
|
||||||
button.add_style_class_name('notification-icon-button');
|
button.add_style_class_name('notification-icon-button');
|
||||||
@ -765,6 +766,31 @@ const Notification = new Lang.Class({
|
|||||||
this.updated();
|
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) {
|
setUrgency: function(urgency) {
|
||||||
this.urgency = urgency;
|
this.urgency = urgency;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user