From 1e4a847565ff0d38cf9bef65bbd353c51588469b Mon Sep 17 00:00:00 2001 From: abakkk Date: Fri, 19 Jun 2020 01:35:25 +0200 Subject: [PATCH] replace Mainloop by GLib --- draw.js | 14 +++++++------- prefs.js | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/draw.js b/draw.js index 8cbda75..d20859b 100644 --- a/draw.js +++ b/draw.js @@ -28,7 +28,6 @@ const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const Gtk = imports.gi.Gtk; const Lang = imports.lang; -const Mainloop = imports.mainloop; const PangoMatrix = imports.gi.Pango.Matrix; const Shell = imports.gi.Shell; const St = imports.gi.St; @@ -52,6 +51,7 @@ const GS_VERSION = Config.PACKAGE_VERSION; const CAIRO_DEBUG_EXTENDS = false; const SVG_DEBUG_EXTENDS = false; const SVG_DEBUG_SUPERPOSES_CAIRO = false; +const TEXT_CURSOR_TIME = 600; // ms const ICON_DIR = Me.dir.get_child('data').get_child('icons'); const FILL_ICON_PATH = ICON_DIR.get_child('fill-symbolic.svg').get_path(); @@ -683,7 +683,7 @@ var DrawingArea = new Lang.Class({ _stopTextCursorTimeout: function() { if (this.textCursorTimeoutId) { - Mainloop.source_remove(this.textCursorTimeoutId); + GLib.source_remove(this.textCursorTimeoutId); this.textCursorTimeoutId = null; } this.textHasCursor = false; @@ -691,7 +691,7 @@ var DrawingArea = new Lang.Class({ _updateTextCursorTimeout: function() { this._stopTextCursorTimeout(); - this.textCursorTimeoutId = Mainloop.timeout_add(600, () => { + this.textCursorTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, TEXT_CURSOR_TIME, () => { this.textHasCursor = !this.textHasCursor; this._redisplay(); return GLib.SOURCE_CONTINUE; @@ -2106,7 +2106,7 @@ const DrawingMenu = new Lang.Class({ item.menu.close(); }; - Mainloop.timeout_add(0, () => { + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { for (let i in obj) { let text; if (targetProperty == 'currentFontFamilyId') @@ -2148,7 +2148,7 @@ const DrawingMenu = new Lang.Class({ item.menu.close(); }; - Mainloop.timeout_add(0, () => { + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { for (let i = 1; i < this.area.colors.length; i++) { let text = this.area.colors[i].to_string(); let iCaptured = i; @@ -2191,7 +2191,7 @@ const DrawingMenu = new Lang.Class({ item.menu.close(); }; - Mainloop.timeout_add(0, () => { + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { this._populateOpenDrawingSubMenu(); // small trick to prevent the menu from "jumping" on first opening item.menu.open(); @@ -2244,7 +2244,7 @@ const DrawingMenu = new Lang.Class({ item.menu.close(); }; - Mainloop.timeout_add(0, () => { + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { this._populateSaveDrawingSubMenu(); // small trick to prevent the menu from "jumping" on first opening item.menu.open(); diff --git a/prefs.js b/prefs.js index 1ac439c..b342cc2 100644 --- a/prefs.js +++ b/prefs.js @@ -20,10 +20,10 @@ * along with this program. If not, see . */ +const GLib = imports.gi.GLib; const GObject = imports.gi.GObject; const Gtk = imports.gi.Gtk; const Lang = imports.lang; -const Mainloop = imports.mainloop; const Config = imports.misc.config; const ExtensionUtils = imports.misc.extensionUtils; @@ -114,7 +114,7 @@ function init() { function buildPrefsWidget() { let topStack = new TopStack(); let switcher = new Gtk.StackSwitcher({halign: Gtk.Align.CENTER, visible: true, stack: topStack}); - Mainloop.timeout_add(0, () => { + GLib.idle_add(GLib.PRIORITY_DEFAULT, () => { let window = topStack.get_toplevel(); window.resize(720,500); let headerBar = window.get_titlebar();