[polari] mainWindow: Own in-app notification queues
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] mainWindow: Own in-app notification queues
- Date: Fri, 3 Sep 2021 19:02:15 +0000 (UTC)
commit 62fbe17ed0d0d270e47bba94fcc0c47e4bb5cfcb
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Sep 3 20:30:23 2021 +0200
mainWindow: Own in-app notification queues
Currently the queues are owned by the application, and the main
windows "borrows" them for its lifetime. That's unnecessarily
awful, so stop doing that.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/229>
src/application.js | 6 ++----
src/ircParser.js | 2 +-
src/mainWindow.js | 29 ++++++++++++++++++++++-------
src/utils.js | 2 +-
4 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index a720c05e..dbb43f8a 100644
--- a/src/application.js
+++ b/src/application.js
@@ -388,8 +388,6 @@ export default GObject.registerClass({
});
this.pasteManager = new PasteManager();
- this.notificationQueue = new AppNotifications.NotificationQueue();
- this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
let provider = new Gtk.CssProvider();
let uri = 'resource:///org/gnome/Polari/css/application.css';
@@ -502,7 +500,7 @@ export default GObject.registerClass({
let label = _('Failed to open link');
let n = new AppNotifications.MessageNotification(
label, 'dialog-error-symbolic');
- this.notificationQueue.addNotification(n);
+ this.active_window?.queueNotification(n);
}
return [success, server, port, room];
@@ -771,7 +769,7 @@ export default GObject.registerClass({
const label = vprintf(_('%s removed.'), account.display_name);
const n = new AppNotifications.UndoNotification(label);
- this.notificationQueue.addNotification(n);
+ this?.active_window.queueNotification(n);
n.connect('closed', async () => {
await account.remove_async(); // TODO: Check for errors
diff --git a/src/ircParser.js b/src/ircParser.js
index 276e2f0b..6fb70ddf 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -295,7 +295,7 @@ export default class IrcParser {
}
if (output)
- this._app.commandOutputQueue.addNotification(output);
+ this._app.active_window?.queueCommandOutput(output);
return retval;
}
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 00cc761c..f7aa438f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -7,6 +7,7 @@ import Polari from 'gi://Polari';
import Tp from 'gi://TelepathyGLib';
import AccountsMonitor from './accountsMonitor.js';
+import * as AppNotifications from './appNotifications.js';
import JoinDialog from './joinDialog.js';
import RoomList_ from './roomList.js'; // used in template
import RoomManager from './roomManager.js';
@@ -135,10 +136,13 @@ export default GObject.registerClass({
this._isMaximized = false;
this._isFullscreen = false;
- let app = this.application;
- this._overlay.add_overlay(app.notificationQueue);
- this._overlay.add_overlay(app.commandOutputQueue);
+ this._notificationQueue = new AppNotifications.NotificationQueue();
+ this._commandOutputQueue = new AppNotifications.CommandOutputQueue();
+ this._overlay.add_overlay(this._notificationQueue);
+ this._overlay.add_overlay(this._commandOutputQueue);
+
+ const app = this.application;
if (app.isTestInstance)
this.add_css_class('test-instance');
if (GLib.get_application_name().toLowerCase().includes('snapshot'))
@@ -151,7 +155,7 @@ export default GObject.registerClass({
// the input area, but appear to emerge from it, so
// set up an appropriate margin
this._roomStack.bind_property('entry-area-height',
- app.commandOutputQueue, 'margin-bottom',
+ this._commandOutputQueue, 'margin-bottom',
GObject.BindingFlags.SYNC_CREATE);
// Make sure user-list button is at least as wide as icon buttons
@@ -227,6 +231,20 @@ export default GObject.registerClass({
return this._roomStack.view_height;
}
+ /**
+ * @param {AppNotification} n - a notification
+ */
+ queueNotification(n) {
+ this._notificationQueue.addNotification(n);
+ }
+
+ /**
+ * @param {AppNotification} n - a notification
+ */
+ queueCommandOutput(n) {
+ this._commandOutputQueue.addNotification(n);
+ }
+
_onAccountsReachableChanged() {
let accounts = this._accountsMonitor.visibleAccounts;
this._offlineInfoBar.revealed =
@@ -270,9 +288,6 @@ export default GObject.registerClass({
this._roomManager.disconnect(this._roomsLoadedId);
this._roomManager.disconnect(this._roomRemovedId);
-
- this._overlay.remove(this.application.notificationQueue);
- this._overlay.remove(this.application.commandOutputQueue);
}
_onAccountsChanged() {
diff --git a/src/utils.js b/src/utils.js
index b046d645..99d7368b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -317,7 +317,7 @@ export function openURL(url) {
Gtk.show_uri_full_finish(app.active_window, res);
} catch (e) {
let n = new AppNotification(_('Failed to open link'));
- app.notificationQueue.addNotification(n);
+ app.active_window?.queueNotification(n);
console.debug(`Failed to open ${url}: %o`, e);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]