calendar: Use binding for clearButton visibility

When the calendar PlaceHolder is visible, the ClearButton shouldn't
be. Instead of setting the visibility explicitly, we can use a property
binding.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/700
This commit is contained in:
Marco Trevisan (Treviño) 2019-08-31 20:43:05 +02:00 committed by Florian Müllner
parent 8656102182
commit 27da3ed1fe

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported Calendar, CalendarMessageList */ /* exported Calendar, CalendarMessageList */
const { Clutter, Gio, GLib, Shell, St } = imports.gi; const { Clutter, Gio, GLib, GObject, Shell, St } = imports.gi;
const Signals = imports.signals; const Signals = imports.signals;
const Main = imports.ui.main; const Main = imports.ui.main;
@ -1075,6 +1075,10 @@ var CalendarMessageList = class CalendarMessageList {
}); });
box.add_actor(this._clearButton); box.add_actor(this._clearButton);
this._placeholder.actor.bind_property('visible',
this._clearButton, 'visible',
GObject.BindingFlags.INVERT_BOOLEAN);
this._sectionList = new St.BoxLayout({ style_class: 'message-list-sections', this._sectionList = new St.BoxLayout({ style_class: 'message-list-sections',
vertical: true, vertical: true,
y_expand: true, y_expand: true,
@ -1145,7 +1149,6 @@ var CalendarMessageList = class CalendarMessageList {
let empty = sections.every(s => s.empty || !s.actor.visible); let empty = sections.every(s => s.empty || !s.actor.visible);
this._placeholder.actor.visible = empty; this._placeholder.actor.visible = empty;
this._clearButton.visible = !empty;
let canClear = sections.some(s => s.canClear && s.actor.visible); let canClear = sections.some(s => s.canClear && s.actor.visible);
this._clearButton.reactive = canClear; this._clearButton.reactive = canClear;