[polari] cleanup: Stop using Mainloop



commit c823dda9d54305013884e150adad5d6193a41e53
Author: Daronion <stefanosdimos 98 gmail com>
Date:   Tue Feb 26 20:49:19 2019 +0200

    cleanup: Stop using Mainloop
    
    Port Mainloop functions to the GLib recommended functions.
    
    https://gitlab.gnome.org/GNOME/polari/issues/68

 src/appNotifications.js  | 10 +++++-----
 src/chatView.js          |  7 +++----
 src/entryArea.js         |  3 +--
 src/mainWindow.js        |  3 +--
 src/roomList.js          |  7 +++----
 src/serverRoomManager.js |  5 ++---
 src/userList.js          |  3 +--
 7 files changed, 16 insertions(+), 22 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 059ccc8..259c8bc 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -1,8 +1,7 @@
 /* exported MessageNotification UndoNotification NotificationQueue
             SimpleOutput GridOutput CommandOutputQueue */
 
-const { GObject, Gtk, Pango } = imports.gi;
-const Mainloop = imports.mainloop;
+const { GLib, GObject, Gtk, Pango } = imports.gi;
 
 const TIMEOUT = 7;
 const COMMAND_OUTPUT_REVEAL_TIME = 3;
@@ -34,7 +33,7 @@ class MessageNotification extends AppNotification {
     _init(label, iconName) {
         super._init();
 
-        Mainloop.timeout_add_seconds(TIMEOUT, this.close.bind(this));
+        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, TIMEOUT, this.close.bind(this));
 
         this._box = new Gtk.Box({ spacing: 12 });
 
@@ -99,8 +98,9 @@ class CommandOutputNotification extends AppNotification {
         super._init();
 
         this.transition_type = Gtk.RevealerTransitionType.SLIDE_UP;
-        Mainloop.timeout_add_seconds(COMMAND_OUTPUT_REVEAL_TIME,
-                                     this.close.bind(this));
+        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT,
+                                 COMMAND_OUTPUT_REVEAL_TIME,
+                                 this.close.bind(this));
     }
 });
 
diff --git a/src/chatView.js b/src/chatView.js
index c4fb0b7..6d9af07 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -4,7 +4,6 @@ const {
     Gdk, Gio, GLib, GObject, Gtk, Pango, PangoCairo, Polari,
     TelepathyGLib: Tp, TelepathyLogger: Tpl
 } = imports.gi;
-const Mainloop = imports.mainloop;
 
 const { DropTargetIface } = imports.pasteManager;
 const { UserPopover } = imports.userList;
@@ -524,7 +523,7 @@ var ChatView = GObject.registerClass({
         this._roomFocusChangedId = 0;
 
         if (this._backlogTimeoutId)
-            Mainloop.source_remove(this._backlogTimeoutId);
+            GLib.source_remove(this._backlogTimeoutId);
         this._backlogTimeoutId = 0;
 
         if (this._nickStatusChangedId)
@@ -727,7 +726,7 @@ var ChatView = GObject.registerClass({
 
         this._fetchingBacklog = true;
         this._showLoadingIndicator();
-        this._backlogTimeoutId = Mainloop.timeout_add(500, () => {
+        this._backlogTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
             this._logWalker.get_events_async(NUM_LOG_EVENTS,
                                              this._onLogEventsReady.bind(this));
             this._backlogTimeoutId = 0;
@@ -740,7 +739,7 @@ var ChatView = GObject.registerClass({
         if (this._valueChangedId)
             return;
 
-        this._valueChangedId = Mainloop.timeout_add(SCROLL_TIMEOUT, () => {
+        this._valueChangedId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCROLL_TIMEOUT, () => {
             this._checkMessages();
             this._valueChangedId = 0;
             return GLib.SOURCE_REMOVE;
diff --git a/src/entryArea.js b/src/entryArea.js
index 95a2135..9097342 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -3,7 +3,6 @@
 const {
     Gdk, GdkPixbuf, Gio, GLib, GObject, Gspell, Gtk, TelepathyGLib: Tp
 } = imports.gi;
-const Mainloop = imports.mainloop;
 
 const ChatView = imports.chatView;
 const { DropTargetIface } = imports.pasteManager;
@@ -467,7 +466,7 @@ var EntryArea = GObject.registerClass({
         //
         // (set_aliases() would do what we want, but it's not
         // introspected)
-        Mainloop.timeout_add_seconds(MAX_NICK_UPDATE_TIME, () => {
+        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, MAX_NICK_UPDATE_TIME, () => {
             this._updateNick();
             return GLib.SOURCE_REMOVE;
         });
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 6c9f2ab..4a62749 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -1,7 +1,6 @@
 /* exported MainWindow FixedSizeFrame RoomList RoomStack UserList */
 
 const { Gdk, Gio, GLib, GObject, Gtk, Polari, TelepathyGLib: Tp } = imports.gi;
-const Mainloop = imports.mainloop;
 
 const { AccountsMonitor } = imports.accountsMonitor;
 const { JoinDialog } = imports.joinDialog;
@@ -147,7 +146,7 @@ var MainWindow = GObject.registerClass({
         // Make sure user-list button is at least as wide as icon buttons
         this._joinButton.connect('size-allocate', (w, rect) => {
             let width = rect.width;
-            Mainloop.idle_add(() => {
+            GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
                 this._showUserListButton.width_request = width;
                 return GLib.SOURCE_REMOVE;
             });
diff --git a/src/roomList.js b/src/roomList.js
index 40429d0..b2c03e1 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -1,7 +1,6 @@
 /* exported RoomList RoomListHeader RoomRow */
 
 const { Gdk, Gio, GLib, GObject, Gtk, TelepathyGLib: Tp } = imports.gi;
-const Mainloop = imports.mainloop;
 
 const { AccountsMonitor } = imports.accountsMonitor;
 const { RoomManager } = imports.roomManager;
@@ -63,7 +62,7 @@ var RoomRow = GObject.registerClass({
             if (connectionStatusChangedId)
                 this.account.disconnect(connectionStatusChangedId);
             if (this._connectingTimeoutId)
-                Mainloop.source_remove(this._connectingTimeoutId);
+                GLib.source_remove(this._connectingTimeoutId);
             this._connectingTimeoutId = 0;
         });
 
@@ -116,7 +115,7 @@ var RoomRow = GObject.registerClass({
         let status = this._getConnectionStatus();
         // Show loading indicator if joining a room takes more than 3 seconds
         if (status == Tp.ConnectionStatus.CONNECTED && !this._room.channel)
-            this._connectingTimeoutId = Mainloop.timeout_add_seconds(3, () => {
+            this._connectingTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 3, () => {
                 this._connectingTimeoutId = 0;
 
                 if (this._room.channel)
@@ -330,7 +329,7 @@ var RoomListHeader = GObject.registerClass({
         if (isError && this._spinner.active) {
             let spinnerTime = GLib.get_monotonic_time() - this._spinnerActivationTime;
             if (spinnerTime < MIN_SPINNER_TIME) {
-                Mainloop.timeout_add((MIN_SPINNER_TIME - spinnerTime) / 1000, () => {
+                GLib.timeout_add(GLib.PRIORITY_DEFAULT, (MIN_SPINNER_TIME - spinnerTime) / 1000, () => {
                     this._onConnectionStatusChanged();
                     return GLib.SOURCE_REMOVE;
                 });
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 2513b30..e6985cc 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -1,7 +1,6 @@
 /* exported ServerRoomManager ServerRoomList */
 
 const { Gdk, GLib, GObject, Gtk, TelepathyGLib: Tp } = imports.gi;
-const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 
 const { AccountsMonitor } = imports.accountsMonitor;
@@ -290,7 +289,7 @@ var ServerRoomList = GObject.registerClass({
         this._clearList();
 
         if (this._idleId)
-            Mainloop.source_remove(this._idleId);
+            GLib.source_remove(this._idleId);
 
         if (!account)
             return;
@@ -309,7 +308,7 @@ var ServerRoomList = GObject.registerClass({
 
         let roomManager = RoomManager.getDefault();
 
-        this._idleId = Mainloop.idle_add(() => {
+        this._idleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
             let customName = this._store.get_value(this._customRoomItem,
                                                    RoomListColumn.NAME);
             let store = this._store;
diff --git a/src/userList.js b/src/userList.js
index 7bcdd6d..293f40d 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -3,7 +3,6 @@
 const {
     Gio, GLib, GObject, Gtk, Pango, Polari, TelepathyGLib: Tp
 } = imports.gi;
-const Mainloop = imports.mainloop;
 
 const READWRITE = GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE;
 
@@ -623,7 +622,7 @@ class UserList extends Gtk.ScrolledWindow {
         if (this._updateHeightId != 0)
             return;
 
-        this._updateHeightId = Mainloop.idle_add(() => {
+        this._updateHeightId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
             let topRow = this._list.get_row_at_y(this.vadjustment.value);
             let membersShown = Math.min(this.numRows, MAX_USERS_SHOWN);
             // topRow is unset when all rows are hidden due to filtering,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]