shell-info: Use transient notifications
According to the designers, system notifications should be transient; so now that transient notifications are supported properly, make use of it instead of using a timeout to remove the associated source.
This commit is contained in:
parent
22f4aabadf
commit
eef194c3aa
@ -28,7 +28,6 @@ const ANIMATION_TIME = 0.25;
|
||||
// We split the screen vertically between the dash and the view selector.
|
||||
const DASH_SPLIT_FRACTION = 0.1;
|
||||
|
||||
const SHELL_INFO_HIDE_TIMEOUT = 10;
|
||||
|
||||
function Source() {
|
||||
this._init();
|
||||
@ -61,14 +60,10 @@ function ShellInfo() {
|
||||
ShellInfo.prototype = {
|
||||
_init: function() {
|
||||
this._source = null;
|
||||
this._timeoutId = 0;
|
||||
this._undoCallback = null;
|
||||
},
|
||||
|
||||
_onUndoClicked: function() {
|
||||
Mainloop.source_remove(this._timeoutId);
|
||||
this._timeoutId = 0;
|
||||
|
||||
if (this._undoCallback)
|
||||
this._undoCallback();
|
||||
this._undoCallback = null;
|
||||
@ -77,20 +72,7 @@ ShellInfo.prototype = {
|
||||
this._source.destroy();
|
||||
},
|
||||
|
||||
_onTimeout: function() {
|
||||
this._timeoutId = 0;
|
||||
if (this._source)
|
||||
this._source.destroy();
|
||||
return false;
|
||||
},
|
||||
|
||||
setMessage: function(text, undoCallback, undoLabel) {
|
||||
if (this._timeoutId)
|
||||
Mainloop.source_remove(this._timeoutId);
|
||||
|
||||
this._timeoutId = Mainloop.timeout_add_seconds(SHELL_INFO_HIDE_TIMEOUT,
|
||||
Lang.bind(this, this._onTimeout));
|
||||
|
||||
if (this._source == null) {
|
||||
this._source = new Source();
|
||||
this._source.connect('destroy', Lang.bind(this,
|
||||
@ -106,6 +88,8 @@ ShellInfo.prototype = {
|
||||
else
|
||||
notification.update(text, null, { clear: true });
|
||||
|
||||
notification.setTransient(true);
|
||||
|
||||
this._undoCallback = undoCallback;
|
||||
if (undoCallback) {
|
||||
notification.addButton('system-undo',
|
||||
|
Loading…
Reference in New Issue
Block a user