[polari] roomStack: Expose :view-height to window
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomStack: Expose :view-height to window
- Date: Fri, 3 Sep 2021 09:45:13 +0000 (UTC)
commit 19d9d0f21c0617308ca8bb969d11833a02fb25eb
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Aug 23 23:52:46 2021 +0200
roomStack: Expose :view-height to window
This allows the main window to just forward the property, instead of
using the ::size-allocate signal to compute it itself.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/225>
src/mainWindow.js | 17 +++--------------
src/roomStack.js | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index a7c3d539..8e529256 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -142,15 +142,8 @@ export default GObject.registerClass({
if (GLib.get_application_name().toLowerCase().includes('snapshot'))
this.get_style_context().add_class('snapshot');
- this._viewHeight = this._calculateViewHeight();
- this._roomStack.connect('size-allocate', () => {
- let oldViewHeight = this._viewHeight;
- let newViewHeight = this._calculateViewHeight();
- if (oldViewHeight !== newViewHeight) {
- this._viewHeight = newViewHeight;
- this.notify('view-height');
- }
- });
+ this._roomStack.connect('notify::view-height',
+ () => this.notify('view-height'));
// command output notifications should not pop up over
// the input area, but appear to emerge from it, so
@@ -227,13 +220,9 @@ export default GObject.registerClass({
return this._subtitle.length > 0;
}
- _calculateViewHeight() {
- return this._roomStack.get_allocated_height() - this._roomStack.entry_area_height;
- }
-
// eslint-disable-next-line camelcase
get view_height() {
- return this._viewHeight;
+ return this._roomStack.view_height;
}
_onAccountsReachableChanged() {
diff --git a/src/roomStack.js b/src/roomStack.js
index 872f752a..4d29be70 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -16,6 +16,10 @@ export default GObject.registerClass({
'entry-area-height', 'entry-area-height', 'entry-area-height',
GObject.ParamFlags.READABLE,
0, GLib.MAXUINT32, 0),
+ 'view-height': GObject.ParamSpec.uint(
+ 'view-height', 'view-height', 'view-height',
+ GObject.ParamFlags.READABLE,
+ 0, GLib.MAXUINT32, 0),
},
}, class RoomStack extends Gtk.Stack {
_init(params) {
@@ -35,6 +39,7 @@ export default GObject.registerClass({
this.add_named(new ChatPlaceholder(this._sizeGroup), 'placeholder');
this._entryAreaHeight = 0;
+ this._viewHeight = 0;
this.connect('destroy', () => {
this._roomManager.disconnect(this._roomAddedId);
@@ -64,6 +69,12 @@ export default GObject.registerClass({
this._entryAreaHeight = entryHeight;
this.notify('entry-area-height');
}
+
+ const viewHeight = this.get_allocated_height() - entryHeight;
+ if (this._viewHeight !== viewHeight) {
+ this._viewHeight = viewHeight;
+ this.notify('view-height');
+ }
}
// eslint-disable-next-line camelcase
@@ -71,6 +82,11 @@ export default GObject.registerClass({
return this._entryAreaHeight;
}
+ // eslint-disable-next-line camelcase
+ get view_height() {
+ return this._viewHeight;
+ }
+
_addView(id, view) {
this._rooms.set(id, view);
this.add_named(view, id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]