[polari/wip/fmuellner/cleanups: 8/11] cleanup: Import classes directly where it makes sense
- From: Gitlab Administrative User <gitlab src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/cleanups: 8/11] cleanup: Import classes directly where it makes sense
- Date: Fri, 10 Nov 2017 02:35:05 +0000 (UTC)
commit 75015307c1bb4cebc815dc280632e581d025b610
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Nov 10 02:02:45 2017 +0100
cleanup: Import classes directly where it makes sense
Most of the time we only use a single class from an imported module;
destructuring allows us to import the class directly in that case
and save us some repetitive typing.
src/application.js | 18 +++++++++---------
src/chatView.js | 16 ++++++++--------
src/entryArea.js | 20 ++++++++++----------
src/main.js | 4 ++--
src/mainWindow.js | 4 ++--
src/roomStack.js | 10 +++++-----
6 files changed, 36 insertions(+), 36 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 452b31e..f91e5bd 100644
--- a/src/application.js
+++ b/src/application.js
@@ -10,13 +10,13 @@ const Tp = imports.gi.TelepathyGLib;
const AccountsMonitor = imports.accountsMonitor;
const AppNotifications = imports.appNotifications;
const Connections = imports.connections;
-const InitialSetup = imports.initialSetup;
-const MainWindow = imports.mainWindow;
+const {InitialSetupWindow} = imports.initialSetup;
+const {MainWindow} = imports.mainWindow;
const NetworksManager = imports.networksManager;
-const PasteManager = imports.pasteManager;
+const {PasteManager} = imports.pasteManager;
const RoomManager = imports.roomManager;
const ServerRoomManager = imports.serverRoomManager;
-const TelepathyClient = imports.telepathyClient;
+const {TelepathyClient} = imports.telepathyClient;
const UserTracker = imports.userTracker;
const Utils = imports.utils;
@@ -263,7 +263,7 @@ var Application = GObject.registerClass({
});
});
- this.pasteManager = new PasteManager.PasteManager();
+ this.pasteManager = new PasteManager();
this.notificationQueue = new AppNotifications.NotificationQueue();
this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
@@ -285,14 +285,14 @@ var Application = GObject.registerClass({
if (!this.active_window) {
if (this._needsInitialSetup()) {
- let setupDialog = new InitialSetup.InitialSetupWindow({ application: this });
+ let setupDialog = new InitialSetupWindow({ application: this });
this._windowRemovedId = this.connect('window-removed', () => {
this.disconnect(this._windowRemovedId);
this._windowRemovedId = 0;
this.activate();
});
} else {
- let window = new MainWindow.MainWindow({ application: this });
+ let window = new MainWindow({ application: this });
window.connect('destroy', () => {
if (this._settings.get_boolean('run-in-background'))
return;
@@ -311,7 +311,7 @@ var Application = GObject.registerClass({
vfunc_window_added(window) {
super.vfunc_window_added(window);
- if (!(window instanceof MainWindow.MainWindow))
+ if (!(window instanceof MainWindow))
return;
let action = this.lookup_action('leave-current-room');
@@ -722,7 +722,7 @@ var Application = GObject.registerClass({
account_manager: this._accountsMonitor.accountManager,
uniquify_name: false
};
- this._telepathyClient = new TelepathyClient.TelepathyClient(params);
+ this._telepathyClient = new TelepathyClient(params);
}
_onShowHelp() {
diff --git a/src/chatView.js b/src/chatView.js
index 1cc521a..4a1956a 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -11,8 +11,8 @@ const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
const Tpl = imports.gi.TelepathyLogger;
-const PasteManager = imports.pasteManager;
-const UserList = imports.userList;
+const {DropTargetIface} = imports.pasteManager;
+const {UserPopover} = imports.userList;
const UserTracker = imports.userTracker;
const Utils = imports.utils;
@@ -285,9 +285,9 @@ var HoverFilterTag = GObject.registerClass({
});
var ChatView = GObject.registerClass({
- Implements: [PasteManager.DropTargetIface],
+ Implements: [DropTargetIface],
Properties: {
- 'can-drop': GObject.ParamSpec.override('can-drop', PasteManager.DropTargetIface),
+ 'can-drop': GObject.ParamSpec.override('can-drop', DropTargetIface),
'max-nick-chars': GObject.ParamSpec.uint('max-nick-chars',
'max-nick-chars',
'max-nick-chars',
@@ -377,7 +377,7 @@ var ChatView = GObject.registerClass({
this._autoscroll = true;
this._app = Gio.Application.get_default();
- PasteManager.DropTargetIface.addTargets(this, this._view);
+ DropTargetIface.addTargets(this, this._view);
this._app.connect('room-focus-changed',
Lang.bind(this, this._checkMessages));
@@ -1359,9 +1359,9 @@ var ChatView = GObject.registerClass({
let actualNickName = view.get_buffer().get_slice(start, end, false);
if (!tag._popover)
- tag._popover = new UserList.UserPopover({ relative_to: this._view,
- userTracker: this._userTracker,
- room: this._room });
+ tag._popover = new UserPopover({ relative_to: this._view,
+ userTracker: this._userTracker,
+ room: this._room });
tag._popover.nickname = actualNickName;
diff --git a/src/entryArea.js b/src/entryArea.js
index c8535e7..b583459 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -10,10 +10,10 @@ const Mainloop = imports.mainloop;
const Tp = imports.gi.TelepathyGLib;
const ChatView = imports.chatView;
-const EmojiPicker = imports.emojiPicker;
-const IrcParser = imports.ircParser;
-const PasteManager = imports.pasteManager;
-const TabCompletion = imports.tabCompletion;
+const {DropTargetIface} = imports.pasteManager;
+const {EmojiPicker} = imports.emojiPicker;
+const {IrcParser} = imports.ircParser;
+const {TabCompletion} = imports.tabCompletion;
const MAX_NICK_UPDATE_TIME = 5; /* s */
const MAX_LINES = 5;
@@ -23,9 +23,9 @@ let _emojiPicker = null;
let _nickPopover = null;
var ChatEntry = GObject.registerClass({
- Implements: [PasteManager.DropTargetIface],
+ Implements: [DropTargetIface],
Properties: {
- 'can-drop': GObject.ParamSpec.override('can-drop', PasteManager.DropTargetIface),
+ 'can-drop': GObject.ParamSpec.override('can-drop', DropTargetIface),
},
Signals: { 'text-pasted': { param_types: [GObject.TYPE_STRING,
GObject.TYPE_INT] },
@@ -35,7 +35,7 @@ var ChatEntry = GObject.registerClass({
_init(params) {
super._init(params);
- PasteManager.DropTargetIface.addTargets(this, this);
+ DropTargetIface.addTargets(this, this);
this._emojiPickedId = 0;
@@ -67,7 +67,7 @@ var ChatEntry = GObject.registerClass({
return;
if (!_emojiPicker)
- _emojiPicker = new EmojiPicker.EmojiPicker();
+ _emojiPicker = new EmojiPicker();
if (!this._emojiPickedId)
this._emojiPickedId = _emojiPicker.connect('emoji-picked',
@@ -204,7 +204,7 @@ var EntryArea = GObject.registerClass({
this._room = params.room;
delete params.room;
- this._ircParser = new IrcParser.IrcParser(this._room);
+ this._ircParser = new IrcParser(this._room);
this._maxNickChars = ChatView.MAX_NICK_CHARS;
this._nickChangedId = 0;
@@ -301,7 +301,7 @@ var EntryArea = GObject.registerClass({
if (!this._room)
return;
- this._completion = new TabCompletion.TabCompletion(this._chatEntry);
+ this._completion = new TabCompletion(this._chatEntry);
this._membersChangedId =
this._room.connect('members-changed',
Lang.bind(this, this._updateCompletions));
diff --git a/src/main.js b/src/main.js
index f80b3f1..4e64275 100755
--- a/src/main.js
+++ b/src/main.js
@@ -17,7 +17,7 @@ pkg.requireSymbol('Gtk', '3.0', 'ScrolledWindow.propagate_natural_width');
const GLib = imports.gi.GLib;
-const Application = imports.application;
+const {Application} = imports.application;
var LOG_DOMAIN = 'Polari';
@@ -49,7 +49,7 @@ function main(args) {
if (GLib.log_writer_is_journald(2))
GLib.setenv('G_MESSAGES_DEBUG', LOG_DOMAIN, false);
- let application = new Application.Application();
+ let application = new Application();
if (GLib.getenv('POLARI_PERSIST'))
application.hold();
return application.run(args);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 54e49e4..8ca80be 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -9,7 +9,7 @@ const Polari = imports.gi.Polari;
const Tp = imports.gi.TelepathyGLib;
const AccountsMonitor = imports.accountsMonitor;
-const JoinDialog = imports.joinDialog;
+const {JoinDialog} = imports.joinDialog;
const RoomList = imports.roomList; // used in template
const RoomManager = imports.roomManager;
const RoomStack = imports.roomStack; // used in template
@@ -363,7 +363,7 @@ var MainWindow = GObject.registerClass({
}
showJoinRoomDialog() {
- let dialog = new JoinDialog.JoinDialog({ transient_for: this });
+ let dialog = new JoinDialog({ transient_for: this });
dialog.show();
}
diff --git a/src/roomStack.js b/src/roomStack.js
index a9fb078..af3e9c1 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -7,8 +7,8 @@ const Pango = imports.gi.Pango;
const Tp = imports.gi.TelepathyGLib;
const AccountsMonitor = imports.accountsMonitor;
-const ChatView = imports.chatView;
-const EntryArea = imports.entryArea;
+const {ChatView} = imports.chatView;
+const {EntryArea} = imports.entryArea;
const RoomManager = imports.roomManager;
var RoomStack = GObject.registerClass({
@@ -196,11 +196,11 @@ class RoomView extends Gtk.Overlay {
if (room.type == Tp.HandleType.CONTACT)
this.add_overlay(new SavePasswordConfirmationBar(room));
- this._view = new ChatView.ChatView(room);
+ this._view = new ChatView(room);
box.add(this._view);
- this._entryArea = new EntryArea.EntryArea({ room: room,
- sensitive: false });
+ this._entryArea = new EntryArea({ room: room,
+ sensitive: false });
box.add(this._entryArea);
this._view.bind_property('max-nick-chars',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]