dialog: Split out _setLabel function
This will be useful when adding more generic containers like MessageDialogContent. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/935
This commit is contained in:
parent
b3db8fc73f
commit
012dde3de9
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
const { Clutter, GObject, Pango, St } = imports.gi;
|
const { Clutter, GObject, Pango, St } = imports.gi;
|
||||||
|
|
||||||
|
function _setLabel(label, value) {
|
||||||
|
label.set({
|
||||||
|
text: value || '',
|
||||||
|
visible: value !== null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var Dialog = GObject.registerClass(
|
var Dialog = GObject.registerClass(
|
||||||
class Dialog extends St.Widget {
|
class Dialog extends St.Widget {
|
||||||
_init(parentActor, styleClass) {
|
_init(parentActor, styleClass) {
|
||||||
@ -185,18 +192,12 @@ var MessageDialogContent = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
set title(title) {
|
set title(title) {
|
||||||
this._setLabel(this._title, 'title', title);
|
_setLabel(this._title, title);
|
||||||
|
this.notify('title');
|
||||||
}
|
}
|
||||||
|
|
||||||
set description(description) {
|
set description(description) {
|
||||||
this._setLabel(this._description, 'description', description);
|
_setLabel(this._description, description);
|
||||||
}
|
this.notify('description');
|
||||||
|
|
||||||
_setLabel(label, prop, value) {
|
|
||||||
label.set({
|
|
||||||
text: value || '',
|
|
||||||
visible: value != null,
|
|
||||||
});
|
|
||||||
this.notify(prop);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user