[gnome-maps/wip/mlundblad/es6-modules: 18/24] mainWindow: Stop using imports.mainloop




commit 3dc51a6dece75ee65d901963f8ea615b3a1ecd0c
Author: Marcus Lundblad <ml dfupdate se>
Date:   Thu May 26 14:40:18 2022 +0200

    mainWindow: Stop using imports.mainloop
    
    Replace usage of Mainloop.idle_add() and .source_remove()
    with the corresponding methods from GLib.

 src/mainWindow.js | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d28843be..4c17b407 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -28,7 +28,6 @@ import GObject from 'gi://GObject';
 import Gdk from 'gi://Gdk';
 import Gio from 'gi://Gio';
 import Gtk from 'gi://Gtk';
-const Mainloop = imports.mainloop;
 
 import {Application} from './application.js';
 import {ContextMenu} from './contextMenu.js';
@@ -270,7 +269,7 @@ export class MainWindow extends Gtk.ApplicationWindow {
         this._mapView.view.connect('button-press-event', () => {
             // Can not call something that will generate clutter events
             // from a clutter event-handler. So use an idle.
-            Mainloop.idle_add(() => this._mapView.grab_focus());
+            GLib.idle_add(null, () => this._mapView.grab_focus());
         });
 
         /*
@@ -417,11 +416,11 @@ export class MainWindow extends Gtk.ApplicationWindow {
 
     _onConfigureEvent(widget, event) {
         if (this._configureId !== 0) {
-            Mainloop.source_remove(this._configureId);
+            GLib.source_remove(this._configureId);
             this._configureId = 0;
         }
 
-        this._configureId = Mainloop.timeout_add(_CONFIGURE_ID_TIMEOUT, () => {
+        this._configureId = GLib.timeout_add(null, _CONFIGURE_ID_TIMEOUT, () => {
             this._saveWindowGeometry();
             this._configureId = 0;
             return false;
@@ -442,7 +441,7 @@ export class MainWindow extends Gtk.ApplicationWindow {
     _quit() {
         // remove configure event handler if still there
         if (this._configureId !== 0) {
-            Mainloop.source_remove(this._configureId);
+            GLib.source_remove(this._configureId);
             this._configureId = 0;
         }
 


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