messageList: Allow disabling automatic resizing of ScaleLayout
For notification grouping we don't always want to resize the message container when adding or removing a message. This adds the option so it can be disabled when not wanted. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3012>
This commit is contained in:

committed by
Marge Bot

parent
b4c74ee168
commit
95c21bbb19
@ -148,14 +148,31 @@ class URLHighlighter extends St.Label {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ScaleLayout = GObject.registerClass(
|
const ScaleLayout = GObject.registerClass({
|
||||||
class ScaleLayout extends Clutter.BinLayout {
|
Properties: {
|
||||||
_init(params) {
|
'scaling-enabled': GObject.ParamSpec.boolean(
|
||||||
this._container = null;
|
'scaling-enabled', null, null,
|
||||||
super._init(params);
|
GObject.ParamFlags.READWRITE,
|
||||||
|
true),
|
||||||
|
},
|
||||||
|
}, class ScaleLayout extends Clutter.BinLayout {
|
||||||
|
_container = null;
|
||||||
|
_scalingEnabled = true;
|
||||||
|
|
||||||
|
get scalingEnabled() {
|
||||||
|
return this._scalingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
_connectContainer(container) {
|
set scalingEnabled(value) {
|
||||||
|
if (this._scalingEnabled === value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._scalingEnabled = value;
|
||||||
|
this.notify('scaling-enabled');
|
||||||
|
this.layout_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
vfunc_set_container(container) {
|
||||||
if (this._container === container)
|
if (this._container === container)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -171,23 +188,29 @@ class ScaleLayout extends Clutter.BinLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
vfunc_get_preferred_width(container, forHeight) {
|
vfunc_get_preferred_width(container, forHeight) {
|
||||||
this._connectContainer(container);
|
const [min, nat] = super.vfunc_get_preferred_width(container, forHeight);
|
||||||
|
|
||||||
let [min, nat] = super.vfunc_get_preferred_width(container, forHeight);
|
if (this._scalingEnabled) {
|
||||||
return [
|
return [
|
||||||
Math.floor(min * container.scale_x),
|
Math.floor(min * container.scale_x),
|
||||||
Math.floor(nat * container.scale_x),
|
Math.floor(nat * container.scale_x),
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
return [min, nat];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_get_preferred_height(container, forWidth) {
|
vfunc_get_preferred_height(container, forWidth) {
|
||||||
this._connectContainer(container);
|
const [min, nat] = super.vfunc_get_preferred_height(container, forWidth);
|
||||||
|
|
||||||
let [min, nat] = super.vfunc_get_preferred_height(container, forWidth);
|
if (this._scalingEnabled) {
|
||||||
return [
|
return [
|
||||||
Math.floor(min * container.scale_y),
|
Math.floor(min * container.scale_y),
|
||||||
Math.floor(nat * container.scale_y),
|
Math.floor(nat * container.scale_y),
|
||||||
];
|
];
|
||||||
|
} else {
|
||||||
|
return [min, nat];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user