[sushi/wip/cosimoc/no-clutter: 36/50] Clean up gi imports
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi/wip/cosimoc/no-clutter: 36/50] Clean up gi imports
- Date: Mon, 17 Jun 2019 18:35:38 +0000 (UTC)
commit 344e8709dedf917d8c7e248b54f54359e502e733
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sat Jun 15 12:18:54 2019 -0700
Clean up gi imports
Use the destructuring assignment to make this much simpler.
src/js/ui/application.js | 5 +----
src/js/ui/fallbackRenderer.js | 5 +----
src/js/ui/main.js | 3 ++-
src/js/ui/mainWindow.js | 9 ++-------
src/js/ui/mimeHandler.js | 4 ++--
src/js/ui/renderer.js | 3 ++-
src/js/ui/utils.js | 5 +----
src/js/viewers/audio.js | 6 +-----
src/js/viewers/evince.js | 13 +++++--------
src/js/viewers/font.js | 6 ++----
src/js/viewers/html.js | 7 ++-----
src/js/viewers/image.js | 6 +-----
src/js/viewers/text.js | 8 ++------
13 files changed, 24 insertions(+), 56 deletions(-)
---
diff --git a/src/js/ui/application.js b/src/js/ui/application.js
index be566db..c3f057b 100644
--- a/src/js/ui/application.js
+++ b/src/js/ui/application.js
@@ -23,10 +23,7 @@
*
*/
-const Gdk = imports.gi.Gdk;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const Gtk = imports.gi.Gtk;
+const {Gdk, Gio, GLib, Gtk} = imports.gi;
const Lang = imports.lang;
const MainWindow = imports.ui.mainWindow;
diff --git a/src/js/ui/fallbackRenderer.js b/src/js/ui/fallbackRenderer.js
index 7cb0524..d59e745 100644
--- a/src/js/ui/fallbackRenderer.js
+++ b/src/js/ui/fallbackRenderer.js
@@ -23,10 +23,7 @@
*
*/
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
-const Pango = imports.gi.Pango;
-const Sushi = imports.gi.Sushi;
+const {Gio, Gtk, Pango, Sushi} = imports.gi;
const Gettext = imports.gettext.domain('sushi');
const _ = Gettext.gettext;
diff --git a/src/js/ui/main.js b/src/js/ui/main.js
index 1a974f8..c77189f 100644
--- a/src/js/ui/main.js
+++ b/src/js/ui/main.js
@@ -25,9 +25,10 @@
imports.gi.versions.GdkX11 = '3.0';
imports.gi.versions.Gtk = '3.0';
+const {GLib} = imports.gi;
+
const Format = imports.format;
const Gettext = imports.gettext;
-const GLib = imports.gi.GLib;
const Application = imports.ui.application;
const Path = imports.util.path;
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index e4e47c8..ceb5b7a 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -23,15 +23,10 @@
*
*/
-const Gdk = imports.gi.Gdk;
-const GdkX11 = imports.gi.GdkX11;
-const Gio = imports.gi.Gio;
-const GLib = imports.gi.GLib;
-const Gtk = imports.gi.Gtk;
+const {Gdk, Gio, GLib, Gtk, Sushi} = imports.gi;
+
const Lang = imports.lang;
const Mainloop = imports.mainloop;
-const Pango = imports.gi.Pango;
-const Sushi = imports.gi.Sushi;
const Constants = imports.util.constants;
const MimeHandler = imports.ui.mimeHandler;
diff --git a/src/js/ui/mimeHandler.js b/src/js/ui/mimeHandler.js
index ba7578a..c3bad7a 100644
--- a/src/js/ui/mimeHandler.js
+++ b/src/js/ui/mimeHandler.js
@@ -23,9 +23,9 @@
*
*/
-const FallbackRenderer = imports.ui.fallbackRenderer;
+const {Gio} = imports.gi;
-const Gio = imports.gi.Gio;
+const FallbackRenderer = imports.ui.fallbackRenderer;
let _mimeHandler = null;
diff --git a/src/js/ui/renderer.js b/src/js/ui/renderer.js
index 5ba3f94..7407d74 100644
--- a/src/js/ui/renderer.js
+++ b/src/js/ui/renderer.js
@@ -1,4 +1,5 @@
-const Gtk = imports.gi.Gtk;
+const {Gtk} = imports.gi;
+
const Lang = imports.lang;
var ResizePolicy = {
diff --git a/src/js/ui/utils.js b/src/js/ui/utils.js
index 6e88fa3..6bf7153 100644
--- a/src/js/ui/utils.js
+++ b/src/js/ui/utils.js
@@ -23,10 +23,7 @@
*
*/
-const Gdk = imports.gi.Gdk;
-const Gtk = imports.gi.Gtk;
-
-const Lang = imports.lang;
+const {Gtk} = imports.gi;
function getScaledSize(baseSize, allocSize, upscale) {
let allocW = allocSize[0];
diff --git a/src/js/viewers/audio.js b/src/js/viewers/audio.js
index 10e490a..4f6f028 100644
--- a/src/js/viewers/audio.js
+++ b/src/js/viewers/audio.js
@@ -23,11 +23,7 @@
*
*/
-const GdkPixbuf = imports.gi.GdkPixbuf;
-const Gio = imports.gi.Gio;
-const Gst = imports.gi.Gst;
-const Gtk = imports.gi.Gtk;
-const Sushi = imports.gi.Sushi;
+const {GdkPixbuf, Gio, Gst, Gtk, Sushi} = imports.gi;
const Gettext = imports.gettext.domain('sushi');
const _ = Gettext.gettext;
diff --git a/src/js/viewers/evince.js b/src/js/viewers/evince.js
index 8ecedaa..8f7184a 100644
--- a/src/js/viewers/evince.js
+++ b/src/js/viewers/evince.js
@@ -23,10 +23,7 @@
*
*/
-const EvDoc = imports.gi.EvinceDocument;
-const EvView = imports.gi.EvinceView;
-const Gtk = imports.gi.Gtk;
-const Sushi = imports.gi.Sushi;
+const {EvinceDocument, EvinceView, Gtk, Sushi} = imports.gi;
const Gettext = imports.gettext.domain('sushi');
const _ = Gettext.gettext;
@@ -56,7 +53,7 @@ const EvinceRenderer = new Lang.Class({
this._pdfLoader.connect('notify::document', this._onDocumentLoaded.bind(this));
this._pdfLoader.uri = file.get_uri();
- this._view = EvView.View.new();
+ this._view = EvinceView.View.new();
this._view.show();
this.add(this._view);
@@ -74,8 +71,8 @@ const EvinceRenderer = new Lang.Class({
},
_onDocumentLoaded : function(pdfLoader) {
- this._model = EvView.DocumentModel.new_with_document(pdfLoader.document);
- this._model.set_sizing_mode(EvView.SizingMode.FIT_WIDTH);
+ this._model = EvinceView.DocumentModel.new_with_document(pdfLoader.document);
+ this._model.set_sizing_mode(EvinceView.SizingMode.FIT_WIDTH);
this._model.set_continuous(true);
this._model.connect('page-changed', this._updatePageLabel.bind(this));
@@ -118,7 +115,7 @@ const EvinceRenderer = new Lang.Class({
let handler = new MimeHandler.MimeHandler();
-EvDoc.init();
+EvinceDocument.init();
let mimeTypes = Sushi.query_supported_document_types();
handler.registerMimeTypes(mimeTypes, EvinceRenderer);
diff --git a/src/js/viewers/font.js b/src/js/viewers/font.js
index 2ffdaac..01109d4 100644
--- a/src/js/viewers/font.js
+++ b/src/js/viewers/font.js
@@ -23,14 +23,12 @@
*
*/
-const MimeHandler = imports.ui.mimeHandler;
+const {Gtk, GLib, Sushi} = imports.gi;
const Lang = imports.lang;
-const Gtk = imports.gi.Gtk;
-const GLib = imports.gi.GLib;
+const MimeHandler = imports.ui.mimeHandler;
const Renderer = imports.ui.renderer;
-const Sushi = imports.gi.Sushi;
const FontRenderer = new Lang.Class({
Name: 'FontRenderer',
diff --git a/src/js/viewers/html.js b/src/js/viewers/html.js
index c6cebc4..9cab7a9 100644
--- a/src/js/viewers/html.js
+++ b/src/js/viewers/html.js
@@ -23,11 +23,8 @@
*
*/
-const Gtk = imports.gi.Gtk;
-const GLib = imports.gi.GLib;
+const {Gtk, GLib, Sushi, WebKit2} = imports.gi;
const Lang = imports.lang;
-const Sushi = imports.gi.Sushi;
-const WebKit = imports.gi.WebKit2;
const MimeHandler = imports.ui.mimeHandler;
const Renderer = imports.ui.renderer;
@@ -35,7 +32,7 @@ const Utils = imports.ui.utils;
const HTMLRenderer = new Lang.Class({
Name: 'HTMLRenderer',
- Extends: WebKit.WebView,
+ Extends: WebKit2.WebView,
_init : function(file, mainWindow) {
this.parent();
diff --git a/src/js/viewers/image.js b/src/js/viewers/image.js
index 6ba8f17..63422e1 100644
--- a/src/js/viewers/image.js
+++ b/src/js/viewers/image.js
@@ -25,11 +25,7 @@
imports.gi.versions.Gdk = '3.0';
imports.gi.versions.Gtk = '3.0';
-const Gdk = imports.gi.Gdk;
-const GdkPixbuf = imports.gi.GdkPixbuf;
-const GLib = imports.gi.GLib;
-const GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
+const {Gdk, GdkPixbuf, GLib, GObject, Gtk} = imports.gi;
const Gettext = imports.gettext.domain('sushi');
const _ = Gettext.gettext;
diff --git a/src/js/viewers/text.js b/src/js/viewers/text.js
index 15aaa4d..ffb8c0f 100644
--- a/src/js/viewers/text.js
+++ b/src/js/viewers/text.js
@@ -25,13 +25,9 @@
imports.gi.versions.GtkSource = '4';
-const Gdk = imports.gi.Gdk;
-const Gtk = imports.gi.Gtk;
-const GLib = imports.gi.GLib;
-const GtkSource = imports.gi.GtkSource;
-const Gio = imports.gi.Gio;
+const {Gdk, Gio, GLib, Gtk, GtkSource, Sushi} = imports.gi;
+
const Lang = imports.lang;
-const Sushi = imports.gi.Sushi;
const MimeHandler = imports.ui.mimeHandler;
const Renderer = imports.ui.renderer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]