From dc86380f7c73736838d0771654fd314ba01b58f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 27 Feb 2019 16:24:25 +0100 Subject: [PATCH 1/7] lint: Remove unused exception https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- lint/eslintrc-polari.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lint/eslintrc-polari.json b/lint/eslintrc-polari.json index 0f13cf64..98f41994 100644 --- a/lint/eslintrc-polari.json +++ b/lint/eslintrc-polari.json @@ -20,7 +20,6 @@ 4, { "ignoredNodes": [ - "ArrayExpression > ObjectExpression", "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child", "ConditionalExpression" ], -- GitLab From 7433648045d0fc84b81f75822857738ece59d879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 28 Jul 2018 18:13:46 +0200 Subject: [PATCH 2/7] chatView: Fix up some weird indentation Use local variables to make the ternary expression align properly without exceeding the line limit. https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- src/chatView.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/chatView.js b/src/chatView.js index 6d9af07c..e32760a3 100644 --- a/src/chatView.js +++ b/src/chatView.js @@ -951,19 +951,17 @@ var ChatView = GObject.registerClass({ } _onMemberKicked(room, member, actor) { - let message = - actor ? _("%s has been kicked by %s").format(member.alias, - actor.alias) - : _("%s has been kicked").format(member.alias); - this._insertStatus(message, member.alias, 'left'); + let [kicked, kicker] = [member.alias, actor ? actor.alias : null]; + let msg = kicker ? _("%s has been kicked by %s").format(kicked, kicker) + : _("%s has been kicked").format(kicked); + this._insertStatus(msg, kicked, 'left'); } _onMemberBanned(room, member, actor) { - let message = - actor ? _("%s has been banned by %s").format(member.alias, - actor.alias) - : _("%s has been banned").format(member.alias); - this._insertStatus(message, member.alias, 'left'); + let [banned, banner] = [member.alias, actor ? actor.alias : null]; + let msg = banner ? _("%s has been banned by %s").format(banned, banner) + : _("%s has been banned").format(banned); + this._insertStatus(msg, banned, 'left'); } _onMemberJoined(room, member) { -- GitLab From 58caf67a0fe6ac65411e518ec3d5da7a3db3713f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 27 Feb 2019 15:58:22 +0100 Subject: [PATCH 3/7] style: Don't exempt ternary expressions from indent rule It turns out we can comply with gjs' coding style and still align the branches if line breaks are required, so do that to reduce diversion from the canonical GNOME style. https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- lint/eslintrc-legacy.json | 1 - lint/eslintrc-polari.json | 3 +-- src/accountsMonitor.js | 9 +++++---- src/chatView.js | 15 +++++++++------ src/connections.js | 6 ++++-- src/entryArea.js | 5 +++-- src/initialSetup.js | 4 ++-- src/joinDialog.js | 15 +++++++-------- src/networksManager.js | 3 +-- src/roomList.js | 4 ++-- src/roomManager.js | 4 ++-- src/serverRoomManager.js | 4 ++-- src/telepathyClient.js | 5 +++-- src/userTracker.js | 13 +++++++------ 14 files changed, 48 insertions(+), 43 deletions(-) diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json index ad2c560c..42b54fb3 100644 --- a/lint/eslintrc-legacy.json +++ b/lint/eslintrc-legacy.json @@ -5,7 +5,6 @@ 4, { "ignoredNodes": [ - "ConditionalExpression", "CallExpression > ArrowFunctionExpression", "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" ], diff --git a/lint/eslintrc-polari.json b/lint/eslintrc-polari.json index 98f41994..96af4639 100644 --- a/lint/eslintrc-polari.json +++ b/lint/eslintrc-polari.json @@ -20,8 +20,7 @@ 4, { "ignoredNodes": [ - "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child", - "ConditionalExpression" + "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" ], "MemberExpression": "off" } diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js index b45371f6..c572e144 100644 --- a/src/accountsMonitor.js +++ b/src/accountsMonitor.js @@ -124,8 +124,9 @@ var AccountsMonitor = class { }); account._visibleNotifyId = account.connect('notify::visible', () => { - this.emit(account.visible ? 'account-shown' - : 'account-hidden', account); + let signal = account.visible ? + 'account-shown' : 'account-hidden'; + this.emit(signal, account); this.emit('accounts-changed'); }); this._accounts.set(account.object_path, account); @@ -151,8 +152,8 @@ var AccountsMonitor = class { _accountEnabledChanged(am, account) { if (!this._accounts.has(account.object_path)) return; - this.emit(account.enabled ? 'account-enabled' - : 'account-disabled', account); + let signal = account.enabled ? 'account-enabled' : 'account-disabled'; + this.emit(signal, account); this.emit('accounts-changed'); } }; diff --git a/src/chatView.js b/src/chatView.js index e32760a3..eb378c23 100644 --- a/src/chatView.js +++ b/src/chatView.js @@ -913,8 +913,9 @@ var ChatView = GObject.registerClass({ this._channel = this._room.channel; - let nick = this._channel ? this._channel.connection.self_contact.alias - : this._room.account.nickname; + let nick = this._channel ? + this._channel.connection.self_contact.alias : + this._room.account.nickname; this._updateMaxNickChars(nick.length); if (!this._channel) @@ -952,15 +953,17 @@ var ChatView = GObject.registerClass({ _onMemberKicked(room, member, actor) { let [kicked, kicker] = [member.alias, actor ? actor.alias : null]; - let msg = kicker ? _("%s has been kicked by %s").format(kicked, kicker) - : _("%s has been kicked").format(kicked); + let msg = kicker ? + _("%s has been kicked by %s").format(kicked, kicker) : + _("%s has been kicked").format(kicked); this._insertStatus(msg, kicked, 'left'); } _onMemberBanned(room, member, actor) { let [banned, banner] = [member.alias, actor ? actor.alias : null]; - let msg = banner ? _("%s has been banned by %s").format(banned, banner) - : _("%s has been banned").format(banned); + let msg = banner ? + _("%s has been banned by %s").format(banned, banner) : + _("%s has been banned").format(banned); this._insertStatus(msg, banned, 'left'); } diff --git a/src/connections.js b/src/connections.js index ea4bea80..f7f71402 100644 --- a/src/connections.js +++ b/src/connections.js @@ -21,8 +21,10 @@ function getAccountParams(account) { params[p] = params[p].deep_unpack(); params['use-ssl'] = !!params['use-ssl']; - params['port'] = params['port'] || params['use-ssl'] ? DEFAULT_SSL_PORT - : DEFAULT_PORT; + + let defaultPort = params['use-ssl'] ? DEFAULT_SSL_PORT : DEFAULT_PORT; + params['port'] = params['port'] || defaultPort; + return params; } diff --git a/src/entryArea.js b/src/entryArea.js index 90973425..f22fbb55 100644 --- a/src/entryArea.js +++ b/src/entryArea.js @@ -474,8 +474,9 @@ var EntryArea = GObject.registerClass({ _updateNick() { let channel = this._room ? this._room.channel : null; - let nick = channel ? channel.connection.self_contact.alias - : this._room ? this._room.account.nickname : ''; + let nick = channel ? + channel.connection.self_contact.alias : + this._room ? this._room.account.nickname : ''; this._nickLabel.width_chars = Math.max(nick.length, this._maxNickChars); this._nickLabel.label = nick; diff --git a/src/initialSetup.js b/src/initialSetup.js index 2e1911f2..fd856d34 100644 --- a/src/initialSetup.js +++ b/src/initialSetup.js @@ -63,8 +63,8 @@ var InitialSetupWindow = GObject.registerClass({ _onNetworkAvailableChanged() { if (this._networkMonitor.network_available) - this._setPage(this._currentAccount ? SetupPage.ROOM - : SetupPage.CONNECTION); + this._setPage(this._currentAccount ? + SetupPage.ROOM : SetupPage.CONNECTION); else this._setPage(SetupPage.OFFLINE); } diff --git a/src/joinDialog.js b/src/joinDialog.js index ccc34dab..bd122de3 100644 --- a/src/joinDialog.js +++ b/src/joinDialog.js @@ -120,8 +120,8 @@ var JoinDialog = GObject.registerClass({ this._customToggle.connect('notify::active', () => { let isCustom = this._customToggle.active; - this._connectionStack.visible_child_name = isCustom ? 'custom' - : 'predefined'; + let childName = isCustom ? 'custom' : 'predefined'; + this._connectionStack.visible_child_name = childName; if (isCustom) { this._addButton.grab_default(); this._details.reset(); @@ -187,8 +187,8 @@ var JoinDialog = GObject.registerClass({ this._connectionCombo.append(names[i], names[i]); this._connectionCombo.sensitive = names.length > 1; - let activeRoom = this.transient_for ? this.transient_for.active_room - : null; + let activeRoom = this.transient_for ? + this.transient_for.active_room : null; let activeIndex = 0; if (activeRoom) activeIndex = Math.max(names.indexOf(activeRoom.account.display_name), 0); @@ -203,8 +203,8 @@ var JoinDialog = GObject.registerClass({ this._serverRoomList.can_join; this._joinButton.sensitive = sensitive; - this.set_default_response(sensitive ? Gtk.ResponseType.OK - : Gtk.ResponseType.NONE); + this.set_default_response(sensitive ? + Gtk.ResponseType.OK : Gtk.ResponseType.NONE); } get _page() { @@ -226,8 +226,7 @@ var JoinDialog = GObject.registerClass({ this._joinButton.visible = isMain; this._cancelButton.visible = isMain || isAccountsEmpty; this._backButton.visible = !(isMain || isAccountsEmpty); - this.title = isMain ? _("Join Chat Room") - : _("Add Network"); + this.title = isMain ? _("Join Chat Room") : _("Add Network"); this._mainStack.visible_child_name = isMain ? 'main' : 'connection'; this._updateCanJoin(); } diff --git a/src/networksManager.js b/src/networksManager.js index be3009c7..efa63408 100644 --- a/src/networksManager.js +++ b/src/networksManager.js @@ -93,8 +93,7 @@ var NetworksManager = class { getNetworkServers(id) { let network = this._lookupNetwork(id); let sslServers = network.servers.filter(s => s.ssl); - return sslServers.length > 0 ? sslServers - : network.servers.slice(); + return sslServers.length > 0 ? sslServers : network.servers.slice(); } getNetworkMatchTerms(id) { diff --git a/src/roomList.js b/src/roomList.js index b2c03e1c..22de6039 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -563,8 +563,8 @@ class RoomList extends Gtk.ListBox { let index = this._rowToRoomIndex(row.get_index()); this.select_row(row); - this._moveSelection(index == 0 ? Gtk.DirectionType.DOWN - : Gtk.DirectionType.UP); + this._moveSelection(index == 0 ? + Gtk.DirectionType.DOWN : Gtk.DirectionType.UP); let newSelected = this.get_selected_row(); if (newSelected != row) diff --git a/src/roomManager.js b/src/roomManager.js index 47ab5b2c..62145311 100644 --- a/src/roomManager.js +++ b/src/roomManager.js @@ -187,8 +187,8 @@ var RoomManager = class { ensureRoomForChannel(channel, time) { let accountPath = channel.connection.get_account().object_path; let targetContact = channel.target_contact; - let channelName = targetContact ? targetContact.alias - : channel.identifier; + let channelName = targetContact ? + targetContact.alias : channel.identifier; let [, handleType] = channel.get_handle(); let room = this._ensureRoom(accountPath, channelName, handleType, time); room.channel = channel; diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js index e6985cc9..592d345c 100644 --- a/src/serverRoomManager.js +++ b/src/serverRoomManager.js @@ -335,8 +335,8 @@ var ServerRoomList = GObject.registerClass({ [checked, name, count, sensitive]); store.move_before(iter, this._customRoomItem); - let maxTime = this._filterTerms.length > 0 ? MS_PER_FILTER_IDLE - : MS_PER_IDLE; + let maxTime = this._filterTerms.length > 0 ? + MS_PER_FILTER_IDLE : MS_PER_IDLE; // Limit time spent in idle to leave room for drawing etc. if (GLib.get_monotonic_time() - startTime > 1000 * maxTime) return GLib.SOURCE_CONTINUE; diff --git a/src/telepathyClient.js b/src/telepathyClient.js index 71b6bc8d..65497382 100644 --- a/src/telepathyClient.js +++ b/src/telepathyClient.js @@ -199,8 +199,9 @@ class TelepathyClient extends Tp.BaseClient { } _onNetworkChanged(mon, connected) { - let presence = connected ? Tp.ConnectionPresenceType.AVAILABLE - : Tp.ConnectionPresenceType.OFFLINE; + let presence = connected ? + Tp.ConnectionPresenceType.AVAILABLE : + Tp.ConnectionPresenceType.OFFLINE; debug(`Network changed to ${connected ? 'available' : 'unavailable'}`); this._accountsMonitor.visibleAccounts.forEach(a => { diff --git a/src/userTracker.js b/src/userTracker.js index 8548b5b1..c9328d7a 100644 --- a/src/userTracker.js +++ b/src/userTracker.js @@ -255,8 +255,9 @@ const UserTracker = GObject.registerClass({ let baseNick = Polari.util_get_basenick(nickName); let contacts = this._baseNickContacts.get(baseNick) || []; - return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE - : Tp.ConnectionPresenceType.AVAILABLE; + return contacts.length == 0 ? + Tp.ConnectionPresenceType.OFFLINE : + Tp.ConnectionPresenceType.AVAILABLE; } getNickRoomStatus(nickName, room) { @@ -265,8 +266,9 @@ const UserTracker = GObject.registerClass({ this._ensureRoomMappingForRoom(room); let contacts = this._getRoomContacts(room).get(baseNick) || []; - return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE - : Tp.ConnectionPresenceType.AVAILABLE; + return contacts.length == 0 ? + Tp.ConnectionPresenceType.OFFLINE : + Tp.ConnectionPresenceType.AVAILABLE; } lookupContact(nickName) { @@ -317,8 +319,7 @@ const UserTracker = GObject.registerClass({ _shouldNotifyNick(nickName) { let actionName = this._getNotifyActionNameInternal(nickName); let state = this._app.get_action_state(actionName); - return state ? state.get_boolean() - : false; + return state ? state.get_boolean() : false; } _setNotifyActionEnabled(nickName, enabled) { -- GitLab From 10c68a35096ca231a025bf6cae7103de1027886b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 28 Jul 2018 06:10:36 +0200 Subject: [PATCH 4/7] Switch switch indentation style Not my preferred style, but it's what gjs uses, which sort of sets the canonical GNOME javascript style ... https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- lint/eslintrc-legacy.json | 3 +- src/connections.js | 12 +- src/ircParser.js | 344 +++++++++++++++++++------------------- src/pasteManager.js | 30 ++-- src/roomList.js | 68 ++++---- src/tabCompletion.js | 22 +-- src/telepathyClient.js | 28 ++-- 7 files changed, 253 insertions(+), 254 deletions(-) diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json index 42b54fb3..e4b2fb0e 100644 --- a/lint/eslintrc-legacy.json +++ b/lint/eslintrc-legacy.json @@ -11,8 +11,7 @@ "CallExpression": { "arguments": "first" }, "ArrayExpression": "first", "ObjectExpression": "first", - "MemberExpression": "off", - "SwitchCase": 1 + "MemberExpression": "off" } ], "quotes": "off" diff --git a/src/connections.js b/src/connections.js index f7f71402..d5379a3a 100644 --- a/src/connections.js +++ b/src/connections.js @@ -529,12 +529,12 @@ var ConnectionProperties = GObject.registerClass({ return; switch (account.connection_error) { - case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REFUSED): - case Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR): - this._errorBox.show(); - this._errorLabel.label = _("Polari disconnected due to a network error. Please check if the address field is correct."); - this._details.setErrorHint(ErrorHint.SERVER); - break; + case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REFUSED): + case Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR): + this._errorBox.show(); + this._errorLabel.label = _("Polari disconnected due to a network error. Please check if the address field is correct."); + this._details.setErrorHint(ErrorHint.SERVER); + break; } } }); diff --git a/src/ircParser.js b/src/ircParser.js index ef55311d..4bf5b48f 100644 --- a/src/ircParser.js +++ b/src/ircParser.js @@ -74,203 +74,203 @@ var IrcParser = class { let cmd = argv.shift().toUpperCase(); let output = null; switch (cmd) { - case 'HELP': { - let command = argv.shift(); - if (command) - command = command.toUpperCase(); + case 'HELP': { + let command = argv.shift(); + if (command) + command = command.toUpperCase(); - retval = (command == null || knownCommands[command] != null); + retval = (command == null || knownCommands[command] != null); - if (!retval) //error - output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE)); - else if (command) - output = this._createFeedbackUsage(command); - else - output = this._createFeedbackGrid(_("Known commands:"), - Object.keys(knownCommands)); + if (!retval) //error + output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE)); + else if (command) + output = this._createFeedbackUsage(command); + else + output = this._createFeedbackGrid(_("Known commands:"), + Object.keys(knownCommands)); + break; + } + case 'INVITE': { + let nick = argv.shift(); + if (!nick) { + this._createFeedbackUsage(cmd); + retval = false; break; } - case 'INVITE': { - let nick = argv.shift(); - if (!nick) { - this._createFeedbackUsage(cmd); - retval = false; - break; - } - this._room.channel.connection.dup_contact_by_id_async(nick, [], - (c, res) => { - let contact; - try { - contact = c.dup_contact_by_id_finish(res); - } catch (e) { - logError(e, `Failed to get contact for ${nick}`); - return; - } - this._room.add_member(contact); - }); + this._room.channel.connection.dup_contact_by_id_async(nick, [], + (c, res) => { + let contact; + try { + contact = c.dup_contact_by_id_finish(res); + } catch (e) { + logError(e, `Failed to get contact for ${nick}`); + return; + } + this._room.add_member(contact); + }); + break; + } + case 'J': + case 'JOIN': { + let room = argv.shift(); + if (!room) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'J': - case 'JOIN': { - let room = argv.shift(); - if (!room) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - if (argv.length) - log(`Excess arguments to JOIN command: ${argv}`); + if (argv.length) + log(`Excess arguments to JOIN command: ${argv}`); - let account = this._room.account; - let app = Gio.Application.get_default(); - let action = app.lookup_action('join-room'); - action.activate(GLib.Variant.new('(ssu)', - [account.get_object_path(), - room, - Utils.getTpEventTime()])); + let account = this._room.account; + let app = Gio.Application.get_default(); + let action = app.lookup_action('join-room'); + action.activate(GLib.Variant.new('(ssu)', + [account.get_object_path(), + room, + Utils.getTpEventTime()])); + break; + } + case 'KICK': { + let nick = argv.shift(); + if (!nick) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'KICK': { - let nick = argv.shift(); - if (!nick) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - this._room.channel.connection.dup_contact_by_id_async(nick, [], - (c, res) => { - let contact; - try { - contact = c.dup_contact_by_id_finish(res); - } catch (e) { - logError(e, `Failed to get contact for ${nick}`); - return; - } - this._room.remove_member(contact); - }); + this._room.channel.connection.dup_contact_by_id_async(nick, [], + (c, res) => { + let contact; + try { + contact = c.dup_contact_by_id_finish(res); + } catch (e) { + logError(e, `Failed to get contact for ${nick}`); + return; + } + this._room.remove_member(contact); + }); + break; + } + case 'ME': { + if (!argv.length) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'ME': { - if (!argv.length) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - let action = stripCommand(text); - let type = Tp.ChannelTextMessageType.ACTION; - let message = Tp.ClientMessage.new_text(type, action); - this._sendMessage(message); + let action = stripCommand(text); + let type = Tp.ChannelTextMessageType.ACTION; + let message = Tp.ClientMessage.new_text(type, action); + this._sendMessage(message); + break; + } + case 'MSG': { + let nick = argv.shift(); + let message = argv.join(' '); + if (!nick || !message) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'MSG': { - let nick = argv.shift(); - let message = argv.join(' '); - if (!nick || !message) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - let account = this._room.account; + let account = this._room.account; - let app = Gio.Application.get_default(); - let action = app.lookup_action('message-user'); - action.activate(GLib.Variant.new('(sssu)', - [account.get_object_path(), - nick, - message, - Tp.USER_ACTION_TIME_NOT_USER_ACTION])); - break; - } - case 'NAMES': { - let channel = this._room.channel; - let members = channel.group_dup_members_contacts().map(m => m.alias); - output = this._createFeedbackGrid(_("Users on %s:").format(channel.identifier), - members); + let app = Gio.Application.get_default(); + let action = app.lookup_action('message-user'); + action.activate(GLib.Variant.new('(sssu)', + [account.get_object_path(), + nick, + message, + Tp.USER_ACTION_TIME_NOT_USER_ACTION])); + break; + } + case 'NAMES': { + let channel = this._room.channel; + let members = channel.group_dup_members_contacts().map(m => m.alias); + output = this._createFeedbackGrid(_("Users on %s:").format(channel.identifier), + members); + break; + } + case 'NICK': { + let nick = argv.shift(); + if (!nick) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'NICK': { - let nick = argv.shift(); - if (!nick) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - if (argv.length) - log(`Excess arguments to NICK command: ${argv}`); + if (argv.length) + log(`Excess arguments to NICK command: ${argv}`); - this._app.setAccountNick(this._room.account, nick); - break; - } - case 'PART': - case 'CLOSE': { - let room = null; - let name = argv[0]; - if (name) - room = this._roomManager.lookupRoomByName(name, this._room.account); - if (room) - argv.shift(); // first arg was a room name - else - room = this._room; + this._app.setAccountNick(this._room.account, nick); + break; + } + case 'PART': + case 'CLOSE': { + let room = null; + let name = argv[0]; + if (name) + room = this._roomManager.lookupRoomByName(name, this._room.account); + if (room) + argv.shift(); // first arg was a room name + else + room = this._room; - let app = Gio.Application.get_default(); - let action = app.lookup_action('leave-room'); - let param = GLib.Variant.new('(ss)', [room.id, argv.join(' ')]); - action.activate(param); + let app = Gio.Application.get_default(); + let action = app.lookup_action('leave-room'); + let param = GLib.Variant.new('(ss)', [room.id, argv.join(' ')]); + action.activate(param); + break; + } + case 'QUERY': { + let nick = argv.shift(); + if (!nick) { + output = this._createFeedbackUsage(cmd); + retval = false; break; } - case 'QUERY': { - let nick = argv.shift(); - if (!nick) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - let account = this._room.account; + let account = this._room.account; - let app = Gio.Application.get_default(); - let action = app.lookup_action('message-user'); - action.activate(GLib.Variant.new('(sssu)', - [account.get_object_path(), - nick, - '', - Utils.getTpEventTime()])); - break; - } - case 'QUIT': { - let presence = Tp.ConnectionPresenceType.OFFLINE; - let message = stripCommand(text); - this._room.account.request_presence_async(presence, 'offline', message, - (a, res) => { - try { - a.request_presence_finish(res); - } catch (e) { - logError(e, 'Failed to disconnect'); - } - }); - break; - } - case 'SAY': { - if (!argv.length) { - output = this._createFeedbackUsage(cmd); - retval = false; - break; - } - this._sendText(stripCommand(text)); - break; - } - case 'TOPIC': { - if (argv.length) - this._room.set_topic(stripCommand(text)); - else - output = this._createFeedbackLabel(this._room.topic || _("No topic set")); - break; - } - default: - output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE)); + let app = Gio.Application.get_default(); + let action = app.lookup_action('message-user'); + action.activate(GLib.Variant.new('(sssu)', + [account.get_object_path(), + nick, + '', + Utils.getTpEventTime()])); + break; + } + case 'QUIT': { + let presence = Tp.ConnectionPresenceType.OFFLINE; + let message = stripCommand(text); + this._room.account.request_presence_async(presence, 'offline', message, + (a, res) => { + try { + a.request_presence_finish(res); + } catch (e) { + logError(e, 'Failed to disconnect'); + } + }); + break; + } + case 'SAY': { + if (!argv.length) { + output = this._createFeedbackUsage(cmd); retval = false; break; + } + this._sendText(stripCommand(text)); + break; + } + case 'TOPIC': { + if (argv.length) + this._room.set_topic(stripCommand(text)); + else + output = this._createFeedbackLabel(this._room.topic || _("No topic set")); + break; + } + default: + output = this._createFeedbackLabel(_(UNKNOWN_COMMAND_MESSAGE)); + retval = false; + break; } if (output) diff --git a/src/pasteManager.js b/src/pasteManager.js index d22ee531..87f1c8c6 100644 --- a/src/pasteManager.js +++ b/src/pasteManager.js @@ -131,13 +131,13 @@ var DropTargetIface = GObject.registerClass({ let info = Polari.drag_dest_find_target(widget, context); switch (info) { - case DndTargetType.TEXT: - case DndTargetType.IMAGE: - case DndTargetType.URI_LIST: - Gdk.drag_status(context, Gdk.DragAction.COPY, time); - break; - default: - return Gdk.EVENT_PROPAGATE; + case DndTargetType.TEXT: + case DndTargetType.IMAGE: + case DndTargetType.URI_LIST: + Gdk.drag_status(context, Gdk.DragAction.COPY, time); + break; + default: + return Gdk.EVENT_PROPAGATE; } if (!this._dragHighlight) { @@ -172,14 +172,14 @@ var DropTargetIface = GObject.registerClass({ } else { let success = false; switch (info) { - case DndTargetType.TEXT: - this.emit('text-dropped', data.get_text()); - success = true; - break; - case DndTargetType.IMAGE: - this.emit('image-dropped', data.get_pixbuf()); - success = true; - break; + case DndTargetType.TEXT: + this.emit('text-dropped', data.get_text()); + success = true; + break; + case DndTargetType.IMAGE: + this.emit('image-dropped', data.get_pixbuf()); + success = true; + break; } Gtk.drag_finish(context, success, false, time); } diff --git a/src/roomList.js b/src/roomList.js index 22de6039..5e3635fb 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -380,46 +380,46 @@ var RoomListHeader = GObject.registerClass({ _getStatusLabel() { switch (this._getConnectionStatus()) { - case Tp.ConnectionStatus.CONNECTED: - return _("Connected"); - case Tp.ConnectionStatus.CONNECTING: - return _("Connecting…"); - case Tp.ConnectionStatus.DISCONNECTED: - return _("Offline"); - default: - return _("Unknown"); + case Tp.ConnectionStatus.CONNECTED: + return _("Connected"); + case Tp.ConnectionStatus.CONNECTING: + return _("Connecting…"); + case Tp.ConnectionStatus.DISCONNECTED: + return _("Offline"); + default: + return _("Unknown"); } } _getErrorLabel() { switch (this._account.connection_error) { - case Tp.error_get_dbus_name(Tp.Error.CERT_REVOKED): - case Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE): - case Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED): - case Tp.error_get_dbus_name(Tp.Error.CERT_INVALID): - case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_ERROR): - case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_PROVIDED): - case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_NOT_AVAILABLE): - case Tp.error_get_dbus_name(Tp.Error.CERT_UNTRUSTED): - case Tp.error_get_dbus_name(Tp.Error.CERT_EXPIRED): - case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_ACTIVATED): - case Tp.error_get_dbus_name(Tp.Error.CERT_HOSTNAME_MISMATCH): - case Tp.error_get_dbus_name(Tp.Error.CERT_FINGERPRINT_MISMATCH): - case Tp.error_get_dbus_name(Tp.Error.CERT_SELF_SIGNED): - return _("Could not connect to %s in a safe way.").format(this._account.display_name); - - case Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED): - return _("%s requires a password.").format(this._account.display_name); - - case Tp.error_get_dbus_name(Tp.Error.CONNECTION_FAILED): - case Tp.error_get_dbus_name(Tp.Error.CONNECTION_LOST): - case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REPLACED): - case Tp.error_get_dbus_name(Tp.Error.SERVICE_BUSY): - return _("Could not connect to %s. The server is busy.").format(this._account.display_name); - - default: - return _("Could not connect to %s.").format(this._account.display_name); + case Tp.error_get_dbus_name(Tp.Error.CERT_REVOKED): + case Tp.error_get_dbus_name(Tp.Error.CERT_INSECURE): + case Tp.error_get_dbus_name(Tp.Error.CERT_LIMIT_EXCEEDED): + case Tp.error_get_dbus_name(Tp.Error.CERT_INVALID): + case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_ERROR): + case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_PROVIDED): + case Tp.error_get_dbus_name(Tp.Error.ENCRYPTION_NOT_AVAILABLE): + case Tp.error_get_dbus_name(Tp.Error.CERT_UNTRUSTED): + case Tp.error_get_dbus_name(Tp.Error.CERT_EXPIRED): + case Tp.error_get_dbus_name(Tp.Error.CERT_NOT_ACTIVATED): + case Tp.error_get_dbus_name(Tp.Error.CERT_HOSTNAME_MISMATCH): + case Tp.error_get_dbus_name(Tp.Error.CERT_FINGERPRINT_MISMATCH): + case Tp.error_get_dbus_name(Tp.Error.CERT_SELF_SIGNED): + return _("Could not connect to %s in a safe way.").format(this._account.display_name); + + case Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED): + return _("%s requires a password.").format(this._account.display_name); + + case Tp.error_get_dbus_name(Tp.Error.CONNECTION_FAILED): + case Tp.error_get_dbus_name(Tp.Error.CONNECTION_LOST): + case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REPLACED): + case Tp.error_get_dbus_name(Tp.Error.SERVICE_BUSY): + return _("Could not connect to %s. The server is busy.").format(this._account.display_name); + + default: + return _("Could not connect to %s.").format(this._account.display_name); } } }); diff --git a/src/tabCompletion.js b/src/tabCompletion.js index 4edb4e93..56ab9536 100644 --- a/src/tabCompletion.js +++ b/src/tabCompletion.js @@ -129,17 +129,17 @@ var TabCompletion = class { } switch (keyval) { - case Gdk.KEY_Tab: - case Gdk.KEY_Down: - this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, 1); - return Gdk.EVENT_STOP; - case Gdk.KEY_ISO_Left_Tab: - case Gdk.KEY_Up: - this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, -1); - return Gdk.EVENT_STOP; - case Gdk.KEY_Escape: - this._cancel(); - return Gdk.EVENT_STOP; + case Gdk.KEY_Tab: + case Gdk.KEY_Down: + this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, 1); + return Gdk.EVENT_STOP; + case Gdk.KEY_ISO_Left_Tab: + case Gdk.KEY_Up: + this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, -1); + return Gdk.EVENT_STOP; + case Gdk.KEY_Escape: + this._cancel(); + return Gdk.EVENT_STOP; } if (Gdk.keyval_to_unicode(keyval) != 0) { diff --git a/src/telepathyClient.js b/src/telepathyClient.js index 65497382..625f7a94 100644 --- a/src/telepathyClient.js +++ b/src/telepathyClient.js @@ -74,20 +74,20 @@ class SASLAuthHandler { debug(`Auth status for server "${name}": ${statusString}`); switch (status) { - case SASLStatus.NOT_STARTED: - case SASLStatus.IN_PROGRESS: - case SASLStatus.CLIENT_ACCEPTED: - break; - - case SASLStatus.SERVER_SUCCEEDED: - this._proxy.AcceptSASLRemote(); - break; - - case SASLStatus.SUCCEEDED: - case SASLStatus.SERVER_FAILED: - case SASLStatus.CLIENT_FAILED: - this._channel.close_async(null); - break; + case SASLStatus.NOT_STARTED: + case SASLStatus.IN_PROGRESS: + case SASLStatus.CLIENT_ACCEPTED: + break; + + case SASLStatus.SERVER_SUCCEEDED: + this._proxy.AcceptSASLRemote(); + break; + + case SASLStatus.SUCCEEDED: + case SASLStatus.SERVER_FAILED: + case SASLStatus.CLIENT_FAILED: + this._channel.close_async(null); + break; } } -- GitLab From 75d9ae1cc5d2837049444b1d26aa592cf1c7d6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 28 Jul 2018 01:08:39 +0200 Subject: [PATCH 5/7] style: Use a consistent style for array literals Most array literals already use a four-space indent, except the ones in GObject metainfo and function parameters. Reindent those as well to make the style consistent and bring it closer to gjs' coding style. https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- lint/eslintrc-legacy.json | 1 - src/application.js | 7 ++++--- src/connections.js | 20 ++++++++++++-------- src/entryArea.js | 24 ++++++++++++++---------- src/initialSetup.js | 12 +++++++----- src/ircParser.js | 31 +++++++++++++++++-------------- src/joinDialog.js | 35 +++++++++++++++++++---------------- src/mainWindow.js | 18 ++++++++++-------- src/roomList.js | 32 ++++++++++++++++++++------------ src/serverRoomManager.js | 12 +++++++----- src/userList.js | 37 +++++++++++++++++++++---------------- src/userTracker.js | 9 +++++---- 12 files changed, 136 insertions(+), 102 deletions(-) diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json index e4b2fb0e..8b716511 100644 --- a/lint/eslintrc-legacy.json +++ b/lint/eslintrc-legacy.json @@ -9,7 +9,6 @@ "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" ], "CallExpression": { "arguments": "first" }, - "ArrayExpression": "first", "ObjectExpression": "first", "MemberExpression": "off" } diff --git a/src/application.js b/src/application.js index b1cdb39f..8e2c97c6 100644 --- a/src/application.js +++ b/src/application.js @@ -417,9 +417,10 @@ var Application = GObject.registerClass({ else this._createAccount(matchedId, server, port, a => { if (a) - joinAction.activate(new GLib.Variant('(ssu)', - [a.get_object_path(), - `#${room}`, time])); + joinAction.activate(new GLib.Variant('(ssu)', [ + a.get_object_path(), + `#${room}`, time + ])); }); }); } diff --git a/src/connections.js b/src/connections.js index d5379a3a..4dc4b14d 100644 --- a/src/connections.js +++ b/src/connections.js @@ -249,11 +249,13 @@ var ConnectionsList = GObject.registerClass({ var ConnectionDetails = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/connection-details.ui', - InternalChildren: ['nameEntry', - 'serverEntry', - 'nickEntry', - 'realnameEntry', - 'sslCheckbox'], + InternalChildren: [ + 'nameEntry', + 'serverEntry', + 'nickEntry', + 'realnameEntry', + 'sslCheckbox' + ], Properties: { 'can-confirm': GObject.ParamSpec.boolean('can-confirm', 'can-confirm', 'can-confirm', @@ -482,9 +484,11 @@ var ConnectionDetails = GObject.registerClass({ var ConnectionProperties = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/connection-properties.ui', - InternalChildren: ['details', - 'errorBox', - 'errorLabel'], + InternalChildren: [ + 'details', + 'errorBox', + 'errorLabel' + ] }, class ConnectionProperties extends Gtk.Dialog { _init(account) { /* Translators: %s is a connection name */ diff --git a/src/entryArea.js b/src/entryArea.js index f22fbb55..c8fab860 100644 --- a/src/entryArea.js +++ b/src/entryArea.js @@ -105,8 +105,10 @@ var ChatEntry = GObject.registerClass({ var NickPopover = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/nick-popover.ui', - InternalChildren: ['nickEntry', - 'changeButton'], + InternalChildren: [ + 'nickEntry', + 'changeButton' + ], Properties: { nick: GObject.ParamSpec.string('nick', 'nick', @@ -150,14 +152,16 @@ var NickPopover = GObject.registerClass({ var EntryArea = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/entry-area.ui', - InternalChildren: ['chatEntry', - 'nickButton', - 'nickLabel', - 'pasteBox', - 'confirmLabel', - 'uploadLabel', - 'cancelButton', - 'pasteButton'], + InternalChildren: [ + 'chatEntry', + 'nickButton', + 'nickLabel', + 'pasteBox', + 'confirmLabel', + 'uploadLabel', + 'cancelButton', + 'pasteButton' + ], Properties: { 'max-nick-chars': GObject.ParamSpec.uint('max-nick-chars', 'max-nick-chars', diff --git a/src/initialSetup.js b/src/initialSetup.js index fd856d34..bdc44058 100644 --- a/src/initialSetup.js +++ b/src/initialSetup.js @@ -12,11 +12,13 @@ const SetupPage = { var InitialSetupWindow = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/initial-setup-window.ui', - InternalChildren: ['contentStack', - 'connectionsList', - 'nextButton', - 'prevButton', - 'serverRoomList'], + InternalChildren: [ + 'contentStack', + 'connectionsList', + 'nextButton', + 'prevButton', + 'serverRoomList' + ] }, class InitialSetupWindow extends Gtk.Window { _init(params) { diff --git a/src/ircParser.js b/src/ircParser.js index 4bf5b48f..acaeeaef 100644 --- a/src/ircParser.js +++ b/src/ircParser.js @@ -124,10 +124,11 @@ var IrcParser = class { let account = this._room.account; let app = Gio.Application.get_default(); let action = app.lookup_action('join-room'); - action.activate(GLib.Variant.new('(ssu)', - [account.get_object_path(), - room, - Utils.getTpEventTime()])); + action.activate(GLib.Variant.new('(ssu)', [ + account.get_object_path(), + room, + Utils.getTpEventTime() + ])); break; } case 'KICK': { @@ -175,11 +176,12 @@ var IrcParser = class { let app = Gio.Application.get_default(); let action = app.lookup_action('message-user'); - action.activate(GLib.Variant.new('(sssu)', - [account.get_object_path(), - nick, - message, - Tp.USER_ACTION_TIME_NOT_USER_ACTION])); + action.activate(GLib.Variant.new('(sssu)', [ + account.get_object_path(), + nick, + message, + Tp.USER_ACTION_TIME_NOT_USER_ACTION + ])); break; } case 'NAMES': { @@ -231,11 +233,12 @@ var IrcParser = class { let app = Gio.Application.get_default(); let action = app.lookup_action('message-user'); - action.activate(GLib.Variant.new('(sssu)', - [account.get_object_path(), - nick, - '', - Utils.getTpEventTime()])); + action.activate(GLib.Variant.new('(sssu)', [ + account.get_object_path(), + nick, + '', + Utils.getTpEventTime() + ])); break; } case 'QUIT': { diff --git a/src/joinDialog.js b/src/joinDialog.js index bd122de3..18617753 100644 --- a/src/joinDialog.js +++ b/src/joinDialog.js @@ -12,18 +12,20 @@ const DialogPage = { var JoinDialog = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/join-room-dialog.ui', - InternalChildren: ['cancelButton', - 'joinButton', - 'mainStack', - 'connectionCombo', - 'connectionButton', - 'connectionStack', - 'filterEntry', - 'connectionsList', - 'serverRoomList', - 'details', - 'addButton', - 'customToggle'], + InternalChildren: [ + 'cancelButton', + 'joinButton', + 'mainStack', + 'connectionCombo', + 'connectionButton', + 'connectionStack', + 'filterEntry', + 'connectionsList', + 'serverRoomList', + 'details', + 'addButton', + 'customToggle' + ] }, class JoinDialog extends Gtk.Dialog { _init(params) { params['use-header-bar'] = 1; @@ -169,10 +171,11 @@ var JoinDialog = GObject.registerClass({ let app = Gio.Application.get_default(); let action = app.lookup_action('join-room'); - action.activate(GLib.Variant.new('(ssu)', - [account.get_object_path(), - room, - Utils.getTpEventTime()])); + action.activate(GLib.Variant.new('(ssu)', [ + account.get_object_path(), + room, + Utils.getTpEventTime() + ])); }); } diff --git a/src/mainWindow.js b/src/mainWindow.js index 4a627490..b319ba60 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -79,14 +79,16 @@ var FixedSizeFrame = GObject.registerClass({ var MainWindow = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/main-window.ui', - InternalChildren: ['titlebarRight', - 'titlebarLeft', - 'joinButton', - 'showUserListButton', - 'userListPopover', - 'roomListRevealer', - 'overlay', - 'roomStack'], + InternalChildren: [ + 'titlebarRight', + 'titlebarLeft', + 'joinButton', + 'showUserListButton', + 'userListPopover', + 'roomListRevealer', + 'overlay', + 'roomStack', + ], Properties: { subtitle: GObject.ParamSpec.string('subtitle', 'subtitle', diff --git a/src/roomList.js b/src/roomList.js index 5e3635fb..740d83be 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -17,7 +17,13 @@ function _onPopoverVisibleChanged(popover) { var RoomRow = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/room-list-row.ui', - InternalChildren: ['eventBox', 'icon', 'roomLabel', 'counter', 'eventStack'], + InternalChildren: [ + 'eventBox', + 'icon', + 'roomLabel', + 'counter', + 'eventStack' + ] }, class RoomRow extends Gtk.ListBoxRow { _init(room) { super._init({ name: `RoomRow ${room.display_name}` }); @@ -198,17 +204,19 @@ var RoomRow = GObject.registerClass({ var RoomListHeader = GObject.registerClass({ CssName: 'row', Template: 'resource:///org/gnome/Polari/ui/room-list-header.ui', - InternalChildren: ['label', - 'iconStack', - 'popoverStatus', - 'popoverTitle', - 'popoverPassword', - 'popoverConnect', - 'popoverDisconnect', - 'popoverReconnect', - 'popoverRemove', - 'popoverProperties', - 'spinner'], + InternalChildren: [ + 'label', + 'iconStack', + 'popoverStatus', + 'popoverTitle', + 'popoverPassword', + 'popoverConnect', + 'popoverDisconnect', + 'popoverReconnect', + 'popoverRemove', + 'popoverProperties', + 'spinner' + ] }, class RoomListHeader extends Gtk.MenuButton { _init(params) { this._account = params.account; diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js index 592d345c..17b2e368 100644 --- a/src/serverRoomManager.js +++ b/src/serverRoomManager.js @@ -108,11 +108,13 @@ function _strBaseEqual(str1, str2) { var ServerRoomList = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/server-room-list.ui', - InternalChildren: ['filterEntry', - 'list', - 'spinner', - 'store', - 'toggleRenderer'], + InternalChildren: [ + 'filterEntry', + 'list', + 'spinner', + 'store', + 'toggleRenderer' + ], Properties: { 'can-join': GObject.ParamSpec.boolean('can-join', 'can-join', 'can-join', diff --git a/src/userList.js b/src/userList.js index 293f40db..6b5903f3 100644 --- a/src/userList.js +++ b/src/userList.js @@ -94,13 +94,15 @@ class UserListPopover extends Gtk.Popover { var UserDetails = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/user-details.ui', - InternalChildren: ['spinnerBox', - 'spinner', - 'detailsGrid', - 'fullnameLabel', - 'lastLabel', - 'notificationLabel', - 'messageButton'], + InternalChildren: [ + 'spinnerBox', + 'spinner', + 'detailsGrid', + 'fullnameLabel', + 'lastLabel', + 'notificationLabel', + 'messageButton' + ], Properties: { 'expanded': GObject.ParamSpec.boolean('expanded', 'expanded', 'expanded', @@ -293,11 +295,12 @@ var UserDetails = GObject.registerClass({ let app = Gio.Application.get_default(); let action = app.lookup_action('message-user'); let time = Gtk.get_current_event().get_time(); - action.activate(GLib.Variant.new('(sssu)', - [account.get_object_path(), - this._user.alias, - '', - time])); + action.activate(GLib.Variant.new('(sssu)', [ + account.get_object_path(), + this._user.alias, + '', + time + ])); } _updateButtonVisibility() { @@ -319,10 +322,12 @@ var UserDetails = GObject.registerClass({ var UserPopover = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/user-popover.ui', - InternalChildren: ['nickLabel', - 'statusLabel', - 'notifyButton', - 'userDetails'], + InternalChildren: [ + 'nickLabel', + 'statusLabel', + 'notifyButton', + 'userDetails' + ] }, class UserPopover extends Gtk.Popover { _init(params) { this._room = params.room; diff --git a/src/userTracker.js b/src/userTracker.js index c9328d7a..1381fe27 100644 --- a/src/userTracker.js +++ b/src/userTracker.js @@ -307,10 +307,11 @@ const UserTracker = GObject.registerClass({ notification.set_title(_("User is online")); notification.set_body(_("User %s is now online.").format(member.alias)); - let param = GLib.Variant.new('(ssu)', - [this._account.get_object_path(), - room.channel_name, - Utils.getTpEventTime()]); + let param = GLib.Variant.new('(ssu)', [ + this._account.get_object_path(), + room.channel_name, + Utils.getTpEventTime() + ]); notification.set_default_action_and_target('app.join-room', param); this._app.send_notification(this._getNotifyActionNameInternal(member.alias), notification); -- GitLab From 02ee3858b5cc4e14c00992a0abda91ab6b7f1597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 28 Jul 2018 01:08:39 +0200 Subject: [PATCH 6/7] style: Change indentation style of object literals Instead of keeping the first property on the same line as the opening brace and aligning the properties, use a four-space indent. This brings us closer to gjs' coding style, and as a bonus helps keeping lines in the soft 80 character limit. https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- src/accountsMonitor.js | 16 ++++-- src/appNotifications.js | 52 +++++++++++------ src/application.js | 30 ++++++---- src/chatView.js | 83 ++++++++++++++++----------- src/connections.js | 118 +++++++++++++++++++++++---------------- src/entryArea.js | 15 +++-- src/joinDialog.js | 8 ++- src/main.js | 18 +++--- src/mainWindow.js | 6 +- src/pasteManager.js | 2 +- src/roomList.js | 12 ++-- src/roomManager.js | 8 ++- src/roomStack.js | 66 ++++++++++++++-------- src/serverRoomManager.js | 12 ++-- src/tabCompletion.js | 20 ++++--- src/telepathyClient.js | 20 ++++--- src/userList.js | 98 +++++++++++++++++++------------- src/userTracker.js | 16 ++++-- src/utils.js | 8 ++- 19 files changed, 375 insertions(+), 233 deletions(-) diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js index c572e144..51652007 100644 --- a/src/accountsMonitor.js +++ b/src/accountsMonitor.js @@ -55,8 +55,10 @@ var AccountsMonitor = class { return settings; let path = `/org/gnome/Polari/Accounts/${account.get_path_suffix()}/`; - settings = new Gio.Settings({ schema_id: 'org.gnome.Polari.Account', - path: path }); + settings = new Gio.Settings({ + schema_id: 'org.gnome.Polari.Account', + path: path + }); this._accountSettings.set(accountPath, settings); return settings; } @@ -162,10 +164,12 @@ Signals.addSignalMethods(AccountsMonitor.prototype); const ClientFactory = GObject.registerClass( class ClientFactory extends Polari.ClientFactory { vfunc_create_account(objectPath) { - return new PolariAccount({ factory: this, - dbus_daemon: this.dbus_daemon, - bus_name: Tp.ACCOUNT_MANAGER_BUS_NAME, - object_path: objectPath }); + return new PolariAccount({ + factory: this, + dbus_daemon: this.dbus_daemon, + bus_name: Tp.ACCOUNT_MANAGER_BUS_NAME, + object_path: objectPath + }); } }); diff --git a/src/appNotifications.js b/src/appNotifications.js index 259c8bca..188ab567 100644 --- a/src/appNotifications.js +++ b/src/appNotifications.js @@ -12,8 +12,10 @@ class AppNotification extends Gtk.Revealer { if (this.constructor.name == 'AppNotification') throw new Error('Cannot instantiate abstract class AppNotification'); - super._init({ reveal_child: true, - transition_type: Gtk.RevealerTransitionType.SLIDE_DOWN }); + super._init({ + reveal_child: true, + transition_type: Gtk.RevealerTransitionType.SLIDE_DOWN + }); this.connect('notify::child-revealed', this._onChildRevealed.bind(this)); } @@ -40,8 +42,11 @@ class MessageNotification extends AppNotification { if (iconName) this._box.add(new Gtk.Image({ icon_name: iconName })); - this._box.add(new Gtk.Label({ label: label, hexpand: true, - ellipsize: Pango.EllipsizeMode.END })); + this._box.add(new Gtk.Label({ + label: label, + hexpand: true, + ellipsize: Pango.EllipsizeMode.END + })); let closeButton = new Gtk.Button({ relief: Gtk.ReliefStyle.NONE }); closeButton.image = new Gtk.Image({ icon_name: 'window-close-symbolic' }); @@ -66,7 +71,10 @@ class MessageNotification extends AppNotification { }); var UndoNotification = GObject.registerClass({ - Signals: { closed: {}, undo: {} } + Signals: { + closed: {}, + undo: {} + } }, class UndoNotification extends MessageNotification { _init(label) { super._init(label); @@ -109,10 +117,12 @@ class SimpleOutput extends CommandOutputNotification { _init(text) { super._init(); - let label = new Gtk.Label({ label: text, - vexpand: true, - visible: true, - wrap: true }); + let label = new Gtk.Label({ + label: text, + vexpand: true, + visible: true, + wrap: true + }); this.add(label); this.show_all(); } @@ -127,9 +137,11 @@ class GridOutput extends CommandOutputNotification { let numCols = Math.min(numItems, 4); let numRows = Math.floor(numItems / numCols) + numItems % numCols; - let grid = new Gtk.Grid({ column_homogeneous: true, - row_spacing: 6, - column_spacing: 18 }); + let grid = new Gtk.Grid({ + column_homogeneous: true, + row_spacing: 6, + column_spacing: 18 + }); grid.attach(new Gtk.Label({ label: header }), 0, 0, numCols, 1); let row = 1; @@ -151,14 +163,18 @@ class GridOutput extends CommandOutputNotification { var NotificationQueue = GObject.registerClass( class NotificationQueue extends Gtk.Frame { _init() { - super._init({ valign: Gtk.Align.START, - halign: Gtk.Align.CENTER, - margin_start: 24, margin_end: 24, - no_show_all: true }); + super._init({ + valign: Gtk.Align.START, + halign: Gtk.Align.CENTER, + margin_start: 24, margin_end: 24, + no_show_all: true + }); this.get_style_context().add_class('app-notification'); - this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL, - row_spacing: 6, visible: true }); + this._grid = new Gtk.Grid({ + orientation: Gtk.Orientation.VERTICAL, + row_spacing: 6, visible: true + }); this.add(this._grid); } diff --git a/src/application.js b/src/application.js index 8e2c97c6..fb57d6d4 100644 --- a/src/application.js +++ b/src/application.js @@ -20,12 +20,16 @@ const MAX_RETRIES = 3; const IRC_SCHEMA_REGEX = /^(irc?:\/\/)([\da-z.-]+):?(\d+)?\/(?:%23)?([\w.+-]+)/i; var Application = GObject.registerClass({ - Signals: { 'prepare-shutdown': {}, - 'room-focus-changed': {} }, + Signals: { + 'prepare-shutdown': {}, + 'room-focus-changed': {} + } }, class Application extends Gtk.Application { _init() { - super._init({ application_id: 'org.gnome.Polari', - flags: Gio.ApplicationFlags.HANDLES_OPEN }); + super._init({ + application_id: 'org.gnome.Polari', + flags: Gio.ApplicationFlags.HANDLES_OPEN + }); GLib.set_prgname('polari'); this._retryData = new Map(); @@ -457,10 +461,12 @@ var Application = GObject.registerClass({ name = server; } - let req = new Tp.AccountRequest({ account_manager: Tp.AccountManager.dup(), - connection_manager: 'idle', - protocol: 'irc', - display_name: name }); + let req = new Tp.AccountRequest({ + account_manager: Tp.AccountManager.dup(), + connection_manager: 'idle', + protocol: 'irc', + display_name: name + }); req.set_enabled(true); if (id) @@ -650,9 +656,11 @@ var Application = GObject.registerClass({ return false; debug(`Retrying with ${server.address}:${server.port}`); - let params = { server: new GLib.Variant('s', server.address), - port: new GLib.Variant('u', server.port), - 'use-ssl': new GLib.Variant('b', server.ssl) }; + let params = { + server: new GLib.Variant('s', server.address), + port: new GLib.Variant('u', server.port), + 'use-ssl': new GLib.Variant('b', server.ssl) + }; this._retryWithParams(account, new GLib.Variant('a{sv}', params)); return true; } diff --git a/src/chatView.js b/src/chatView.js index eb378c23..40bdec27 100644 --- a/src/chatView.js +++ b/src/chatView.js @@ -147,9 +147,9 @@ const ButtonTag = GObject.registerClass({ false) }, Signals: { - 'clicked': { }, - 'popup-menu': { } - }, + 'clicked': {}, + 'popup-menu': {} + } }, class ButtonTag extends Gtk.TextTag { _init(params) { this._hover = false; @@ -185,9 +185,11 @@ const ButtonTag = GObject.registerClass({ if (this._gesture) return; - this._gesture = new Gtk.GestureMultiPress({ widget, - button: 0, - exclusive: true }); + this._gesture = new Gtk.GestureMultiPress({ + widget, + button: 0, + exclusive: true + }); this._gesture.connect('pressed', (gesture, nPress) => { if (!this._hover || nPress > 1) @@ -291,9 +293,11 @@ var ChatView = GObject.registerClass({ this.get_style_context().add_class('polari-chat-view'); - this._view = new TextView({ editable: false, cursor_visible: false, - wrap_mode: Gtk.WrapMode.WORD_CHAR, - right_margin: MARGIN }); + this._view = new TextView({ + editable: false, cursor_visible: false, + wrap_mode: Gtk.WrapMode.WORD_CHAR, + right_margin: MARGIN + }); this._view.add_events(Gdk.EventMask.LEAVE_NOTIFY_MASK | Gdk.EventMask.ENTER_NOTIFY_MASK); this.add(this._view); @@ -350,9 +354,10 @@ var ChatView = GObject.registerClass({ this._updateMaxNickChars(this._room.account.nickname.length); let isRoom = room.type == Tp.HandleType.ROOM; - let target = new Tpl.Entity({ type: isRoom ? Tpl.EntityType.ROOM - : Tpl.EntityType.CONTACT, - identifier: room.channel_name }); + let target = new Tpl.Entity({ + type: isRoom ? Tpl.EntityType.ROOM : Tpl.EntityType.CONTACT, + identifier: room.channel_name + }); let logManager = Tpl.LogManager.dup_singleton(); this._logWalker = logManager.walk_filtered_events(room.account, target, @@ -461,10 +466,12 @@ var ChatView = GObject.registerClass({ let desaturatedNickColor = (this._activeNickColor.red + this._activeNickColor.blue + this._activeNickColor.green) / 3; - this._inactiveNickColor = new Gdk.RGBA ({ red: desaturatedNickColor, - green: desaturatedNickColor, - blue: desaturatedNickColor, - alpha: 1.0 }); + this._inactiveNickColor = new Gdk.RGBA({ + red: desaturatedNickColor, + green: desaturatedNickColor, + blue: desaturatedNickColor, + alpha: 1.0 + }); if (this._activeNickColor.equal(this._inactiveNickColor)) this._inactiveNickColor.alpha = 0.5; @@ -550,17 +557,21 @@ var ChatView = GObject.registerClass({ if (source instanceof Tp.Message) { let [text] = source.to_text(); let [id, valid] = source.get_pending_message_id(); - return { nick: source.sender.alias, - text: text, - timestamp: source.get_sent_timestamp() || - source.get_received_timestamp(), - messageType: source.get_message_type(), - pendingId: valid ? id : undefined }; + return { + nick: source.sender.alias, + text: text, + timestamp: source.get_sent_timestamp() || + source.get_received_timestamp(), + messageType: source.get_message_type(), + pendingId: valid ? id : undefined + }; } else if (source instanceof Tpl.Event) { - return { nick: source.sender.alias, - text: source.message, - timestamp: source.timestamp, - messageType: source.get_message_type() }; + return { + nick: source.sender.alias, + text: source.message, + timestamp: source.timestamp, + messageType: source.get_message_type() + }; } throw new Error(`Cannot create message from source ${source}`); @@ -813,8 +824,10 @@ var ChatView = GObject.registerClass({ } _showLoadingIndicator() { - let indicator = new Gtk.Image({ icon_name: 'content-loading-symbolic', - visible: true }); + let indicator = new Gtk.Image({ + icon_name: 'content-loading-symbolic', + visible: true + }); indicator.get_style_context().add_class('dim-label'); let buffer = this._view.buffer; @@ -1251,8 +1264,10 @@ var ChatView = GObject.registerClass({ } tags.push(nickTag); - let hoverTag = new HoverFilterTag({ filtered_tag: nickTag, - hover_opacity: 0.8 }); + let hoverTag = new HoverFilterTag({ + filtered_tag: nickTag, + hover_opacity: 0.8 + }); buffer.get_tag_table().add(hoverTag); tags.push(hoverTag); @@ -1357,9 +1372,11 @@ var ChatView = GObject.registerClass({ let actualNickName = view.get_buffer().get_slice(start, end, false); if (!tag._popover) - tag._popover = new 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/connections.js b/src/connections.js index 4dc4b14d..f6b21c09 100644 --- a/src/connections.js +++ b/src/connections.js @@ -50,10 +50,12 @@ class ConnectionRow extends Gtk.ListBoxRow { box.add(new Gtk.Label({ label: name, halign: Gtk.Align.START })); - let insensitiveDesc = new Gtk.Label({ label: _("Already added"), - hexpand: true, - no_show_all: true, - halign: Gtk.Align.END }); + let insensitiveDesc = new Gtk.Label({ + label: _("Already added"), + hexpand: true, + no_show_all: true, + halign: Gtk.Align.END + }); box.add(insensitiveDesc); this.show_all(); @@ -77,8 +79,10 @@ var ConnectionsList = GObject.registerClass({ GObject.ParamFlags.CONSTRUCT_ONLY, false) }, - Signals: { 'account-created': { param_types: [Tp.Account.$gtype] }, - 'account-selected': {} } + Signals: { + 'account-created': { param_types: [Tp.Account.$gtype] }, + 'account-selected': {} + } }, class ConnectionsList extends Gtk.ScrolledWindow { _init(params) { this._favoritesOnly = false; @@ -98,15 +102,21 @@ var ConnectionsList = GObject.registerClass({ this._list.set_header_func(this._updateHeader.bind(this)); this._list.set_sort_func(this._sort.bind(this)); - let placeholder = new Gtk.Box({ halign: Gtk.Align.CENTER, - valign: Gtk.Align.CENTER, - orientation: Gtk.Orientation.VERTICAL, - visible: true }); - placeholder.add(new Gtk.Image({ icon_name: 'edit-find-symbolic', - pixel_size: 115, - visible: true })); - placeholder.add(new Gtk.Label({ label: _("No results."), - visible: true })); + let placeholder = new Gtk.Box({ + halign: Gtk.Align.CENTER, + valign: Gtk.Align.CENTER, + orientation: Gtk.Orientation.VERTICAL, + visible: true + }); + placeholder.add(new Gtk.Image({ + icon_name: 'edit-find-symbolic', + pixel_size: 115, + visible: true + })); + placeholder.add(new Gtk.Label({ + label: _("No results."), + visible: true + })); placeholder.get_style_context().add_class('dim-label'); @@ -194,19 +204,22 @@ var ConnectionsList = GObject.registerClass({ return; let sensitive = !usedNetworks.includes(network.id); - this._rows.set(network.id, - new ConnectionRow({ id: network.id, - sensitive: sensitive })); + this._rows.set(network.id, new ConnectionRow({ + id: network.id, + sensitive: sensitive + })); this._list.add(this._rows.get(network.id)); }); } _onRowActivated(list, row) { let name = this._networksManager.getNetworkName(row.id); - let req = new Tp.AccountRequest({ account_manager: Tp.AccountManager.dup(), - connection_manager: 'idle', - protocol: 'irc', - display_name: name }); + let req = new Tp.AccountRequest({ + account_manager: Tp.AccountManager.dup(), + connection_manager: 'idle', + protocol: 'irc', + display_name: name + }); req.set_service(row.id); req.set_enabled(true); @@ -256,17 +269,21 @@ var ConnectionDetails = GObject.registerClass({ 'realnameEntry', 'sslCheckbox' ], - Properties: { 'can-confirm': GObject.ParamSpec.boolean('can-confirm', - 'can-confirm', - 'can-confirm', - GObject.ParamFlags.READABLE, - false), - 'has-serivce': GObject.ParamSpec.boolean('has-service', - 'has-service', - 'has-service', - GObject.ParamFlags.READABLE, - false) }, - Signals: { 'account-created': { param_types: [Tp.Account.$gtype] } }, + Properties: { + 'can-confirm': GObject.ParamSpec.boolean('can-confirm', + 'can-confirm', + 'can-confirm', + GObject.ParamFlags.READABLE, + false), + 'has-serivce': GObject.ParamSpec.boolean('has-service', + 'has-service', + 'has-service', + GObject.ParamFlags.READABLE, + false) + }, + Signals: { + 'account-created': { param_types: [Tp.Account.$gtype] } + } }, class ConnectionDetails extends Gtk.Grid { _init(params) { this._networksManager = NetworksManager.getDefault(); @@ -297,10 +314,12 @@ var ConnectionDetails = GObject.registerClass({ realnameStore.set_column_types([GObject.TYPE_STRING]); realnameStore.insert_with_valuesv(-1, [0], [GLib.get_real_name()]); - let completion = new Gtk.EntryCompletion({ model: realnameStore, - text_column: 0, - inline_completion: true, - popup_completion: false }); + let completion = new Gtk.EntryCompletion({ + model: realnameStore, + text_column: 0, + inline_completion: true, + popup_completion: false + }); this._realnameEntry.set_completion(completion); this.reset(); @@ -429,10 +448,12 @@ var ConnectionDetails = GObject.registerClass({ _createAccount() { let params = this._getParams(); let accountManager = Tp.AccountManager.dup(); - let req = new Tp.AccountRequest({ account_manager: accountManager, - connection_manager: 'idle', - protocol: 'irc', - display_name: params.name }); + let req = new Tp.AccountRequest({ + account_manager: accountManager, + connection_manager: 'idle', + protocol: 'irc', + display_name: params.name + }); req.set_enabled(true); let [details] = this._detailsFromParams(params, {}); @@ -464,9 +485,11 @@ var ConnectionDetails = GObject.registerClass({ } _detailsFromParams(params, oldDetails) { - let details = { account: GLib.Variant.new('s', params.account), - username: GLib.Variant.new('s', params.account), - server: GLib.Variant.new('s', params.server) }; + let details = { + account: GLib.Variant.new('s', params.account), + username: GLib.Variant.new('s', params.account), + server: GLib.Variant.new('s', params.server) + }; if (params.port) details.port = GLib.Variant.new('u', params.port); @@ -492,9 +515,10 @@ var ConnectionProperties = GObject.registerClass({ }, class ConnectionProperties extends Gtk.Dialog { _init(account) { /* Translators: %s is a connection name */ - let title = _("“%s” Properties").format(account.display_name); - super._init({ title: title, - use_header_bar: 1 }); + super._init({ + title: _("“%s” Properties").format(account.display_name), + use_header_bar: 1 + }); this._details.account = account; diff --git a/src/entryArea.js b/src/entryArea.js index c8fab860..fd7a7139 100644 --- a/src/entryArea.js +++ b/src/entryArea.js @@ -18,10 +18,11 @@ var ChatEntry = GObject.registerClass({ Properties: { 'can-drop': GObject.ParamSpec.override('can-drop', DropTargetIface), }, - Signals: { 'text-pasted': { param_types: [GObject.TYPE_STRING, - GObject.TYPE_INT] }, - 'image-pasted': { param_types: [GdkPixbuf.Pixbuf.$gtype] }, - 'file-pasted': { param_types: [Gio.File.$gtype] } }, + Signals: { + 'text-pasted': { param_types: [GObject.TYPE_STRING, GObject.TYPE_INT] }, + 'image-pasted': { param_types: [GdkPixbuf.Pixbuf.$gtype] }, + 'file-pasted': { param_types: [Gio.File.$gtype] } + } }, class ChatEntry extends Gtk.Entry { static get _checker() { if (!this.__checker) @@ -116,7 +117,9 @@ var NickPopover = GObject.registerClass({ GObject.ParamFlags.READWRITE, '') }, - Signals: { 'nick-changed': {} } + Signals: { + 'nick-changed': {} + } }, class NickPopover extends Gtk.Popover { _init() { this._nick = ''; @@ -168,7 +171,7 @@ var EntryArea = GObject.registerClass({ 'max-nick-chars', GObject.ParamFlags.WRITABLE, 0, GLib.MAXUINT32, 0) - }, + } }, class EntryArea extends Gtk.Stack { static get _nickPopover() { if (!this.__nickPopover) diff --git a/src/joinDialog.js b/src/joinDialog.js index 18617753..a72e08f6 100644 --- a/src/joinDialog.js +++ b/src/joinDialog.js @@ -33,9 +33,11 @@ var JoinDialog = GObject.registerClass({ // TODO: Is there really no way to do this in the template? let icon = new Gtk.Image({ icon_name: 'go-previous-symbolic' }); - this._backButton = new Gtk.Button({ image: icon, - valign: Gtk.Align.CENTER, - focus_on_click: false }); + this._backButton = new Gtk.Button({ + image: icon, + valign: Gtk.Align.CENTER, + focus_on_click: false + }); this.get_header_bar().pack_start(this._backButton); let accelGroup = new Gtk.AccelGroup(); diff --git a/src/main.js b/src/main.js index 1af80987..2d2e9c19 100755 --- a/src/main.js +++ b/src/main.js @@ -4,14 +4,16 @@ pkg.initFormat(); pkg.initGettext(); window.ngettext = imports.gettext.ngettext; -pkg.require({ 'GdkPixbuf': '2.0', - 'GObject': '2.0', - 'Pango': '1.0', - 'PangoCairo': '1.0', - 'Secret': '1', - 'Soup': '2.4', - 'TelepathyGLib': '0.12', - 'TelepathyLogger': '0.2' }); +pkg.require({ + 'GdkPixbuf': '2.0', + 'GObject': '2.0', + 'Pango': '1.0', + 'PangoCairo': '1.0', + 'Secret': '1', + 'Soup': '2.4', + 'TelepathyGLib': '0.12', + 'TelepathyLogger': '0.2' +}); pkg.requireSymbol('Gio', '2.0', 'Application.send_notification'); pkg.requireSymbol('GLib', '2.0', 'log_variant'); pkg.requireSymbol('Gspell', '1', 'Entry'); diff --git a/src/mainWindow.js b/src/mainWindow.js index b319ba60..632f6929 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -23,7 +23,7 @@ var FixedSizeFrame = GObject.registerClass({ 'width', GObject.ParamFlags.READWRITE, -1, GLib.MAXINT32, -1) - }, + } }, class FixedSizeFrame extends Gtk.Frame { _init(params) { this._height = -1; @@ -106,7 +106,9 @@ var MainWindow = GObject.registerClass({ GObject.ParamFlags.READWRITE, Polari.Room.$gtype) }, - Signals: { 'active-room-state-changed': {} }, + Signals: { + 'active-room-state-changed': {} + } }, class MainWindow extends Gtk.ApplicationWindow { _init(params) { this._subtitle = ''; diff --git a/src/pasteManager.js b/src/pasteManager.js index 87f1c8c6..63d31aae 100644 --- a/src/pasteManager.js +++ b/src/pasteManager.js @@ -82,7 +82,7 @@ var DropTargetIface = GObject.registerClass({ 'text-dropped': { param_types: [GObject.TYPE_STRING] }, 'image-dropped': { param_types: [GdkPixbuf.Pixbuf.$gtype] }, 'file-dropped': { param_types: [Gio.File.$gtype] } - }, + } }, class DropTargetIface extends GObject.Interface { addTargets(widget) { this._dragHighlight = false; diff --git a/src/roomList.js b/src/roomList.js index 740d83be..4cf6669d 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -26,7 +26,9 @@ var RoomRow = GObject.registerClass({ ] }, class RoomRow extends Gtk.ListBoxRow { _init(room) { - super._init({ name: `RoomRow ${room.display_name}` }); + super._init({ + name: `RoomRow ${room.display_name}` + }); this._room = room; this._popover = null; @@ -587,9 +589,11 @@ class RoomList extends Gtk.ListBox { if (this._placeholders.has(account)) return; - let placeholder = new Gtk.ListBoxRow({ selectable: false, - activatable: false, - no_show_all: true }); + let placeholder = new Gtk.ListBoxRow({ + selectable: false, + activatable: false, + no_show_all: true + }); placeholder.account = account; this._placeholders.set(account, placeholder); diff --git a/src/roomManager.js b/src/roomManager.js index 62145311..79d3729c 100644 --- a/src/roomManager.js +++ b/src/roomManager.js @@ -170,9 +170,11 @@ var RoomManager = class { let id = Polari.create_room_id(account, channelName, type); let room = this._rooms.get(id); if (!room) { - room = new Polari.Room({ account: account, - channel_name: channelName, - type: type }); + room = new Polari.Room({ + account: account, + channel_name: channelName, + type: type + }); this._rooms.set(room.id, room); this.emit('room-added', room); } diff --git a/src/roomStack.js b/src/roomStack.js index 2fa9e1bc..b3d15227 100644 --- a/src/roomStack.js +++ b/src/roomStack.js @@ -14,7 +14,7 @@ var RoomStack = GObject.registerClass({ 'entry-area-height', GObject.ParamFlags.READABLE, 0, GLib.MAXUINT32, 0) - }, + } }, class RoomStack extends Gtk.Stack { _init(params) { super._init(params); @@ -119,26 +119,32 @@ class SavePasswordConfirmationBar extends Gtk.Revealer { this.add(this._infoBar); let target = new GLib.Variant('o', this._room.account.object_path); - let button = new Gtk.Button({ label: _("_Save Password"), - use_underline: true, - action_name: 'app.save-identify-password', - action_target: target }); + let button = new Gtk.Button({ + label: _("_Save Password"), + use_underline: true, + action_name: 'app.save-identify-password', + action_target: target + }); this._infoBar.add_action_widget(button, Gtk.ResponseType.ACCEPT); let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); this._infoBar.get_content_area().add(box); let title = _("Should the password be saved?"); - this._titleLabel = new Gtk.Label({ halign: Gtk.Align.START, - valign: Gtk.Align.CENTER, - wrap: true }); + this._titleLabel = new Gtk.Label({ + halign: Gtk.Align.START, + valign: Gtk.Align.CENTER, + wrap: true + }); this._titleLabel.set_markup(`${title}`); box.add(this._titleLabel); let accountName = this._room.account.display_name; let text = _("Identification will happen automatically the next time you connect to %s").format(accountName); - this._subtitleLabel = new Gtk.Label({ label: text, - ellipsize: Pango.EllipsizeMode.END }); + this._subtitleLabel = new Gtk.Label({ + label: text, + ellipsize: Pango.EllipsizeMode.END + }); box.add(this._subtitleLabel); this._infoBar.show_all(); @@ -156,27 +162,39 @@ class ChatPlaceholder extends Gtk.Overlay { _init(sizeGroup) { this._accountsMonitor = AccountsMonitor.getDefault(); - let image = new Gtk.Image({ icon_name: 'org.gnome.Polari-symbolic', - pixel_size: 96, halign: Gtk.Align.END, - margin_end: 14 }); + let image = new Gtk.Image({ + icon_name: 'org.gnome.Polari-symbolic', + pixel_size: 96, halign: Gtk.Align.END, + margin_end: 14 + }); - let title = new Gtk.Label({ use_markup: true, halign: Gtk.Align.START, - margin_start: 14 }); + let title = new Gtk.Label({ + use_markup: true, + halign: Gtk.Align.START, + margin_start: 14 + }); title.label = `${_("Polari")}`; title.get_style_context().add_class('polari-background-title'); - let description = new Gtk.Label({ label: _("Join a room using the + button."), - halign: Gtk.Align.CENTER, wrap: true, - margin_top: 24, use_markup: true }); + let description = new Gtk.Label({ + label: _("Join a room using the + button."), + halign: Gtk.Align.CENTER, wrap: true, + margin_top: 24, use_markup: true + }); description.get_style_context().add_class('polari-background-description'); let inputPlaceholder = new Gtk.Box({ valign: Gtk.Align.END }); sizeGroup.add_widget(inputPlaceholder); super._init(); - let grid = new Gtk.Grid({ column_homogeneous: true, can_focus: false, - column_spacing: 18, hexpand: true, vexpand: true, - valign: Gtk.Align.CENTER }); + let grid = new Gtk.Grid({ + column_homogeneous: true, + can_focus: false, + column_spacing: 18, + hexpand: true, + vexpand: true, + valign: Gtk.Align.CENTER + }); grid.get_style_context().add_class('polari-background'); grid.attach(image, 0, 0, 1, 1); grid.attach(title, 1, 0, 1, 1); @@ -201,8 +219,10 @@ class RoomView extends Gtk.Overlay { this._view = new ChatView(room); box.add(this._view); - this._entryArea = new EntryArea({ room: room, - sensitive: false }); + this._entryArea = new EntryArea({ + room: room, + sensitive: false + }); box.add(this._entryArea); this._view.bind_property('max-nick-chars', diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js index 17b2e368..51ba8870 100644 --- a/src/serverRoomManager.js +++ b/src/serverRoomManager.js @@ -115,11 +115,13 @@ var ServerRoomList = GObject.registerClass({ 'store', 'toggleRenderer' ], - Properties: { 'can-join': GObject.ParamSpec.boolean('can-join', - 'can-join', - 'can-join', - GObject.ParamFlags.READABLE, - false) }, + Properties: { + 'can-join': GObject.ParamSpec.boolean('can-join', + 'can-join', + 'can-join', + GObject.ParamFlags.READABLE, + false) + } }, class ServerRoomList extends Gtk.Box { _init(params) { this._account = null; diff --git a/src/tabCompletion.js b/src/tabCompletion.js index 56ab9536..437e809b 100644 --- a/src/tabCompletion.js +++ b/src/tabCompletion.js @@ -41,10 +41,12 @@ var TabCompletion = class { let row = new Gtk.ListBoxRow(); row._text = `/${commands[i]}`; row._casefoldedText = row._text.toLowerCase(); - row.add(new Gtk.Label({ label: row._text, - halign: Gtk.Align.START, - margin_start: 6, - margin_end: 6 })); + row.add(new Gtk.Label({ + label: row._text, + halign: Gtk.Align.START, + margin_start: 6, + margin_end: 6 + })); this._list.add(row); } } @@ -94,10 +96,12 @@ var TabCompletion = class { row = new Gtk.ListBoxRow(); row._text = nick; row._casefoldedText = row._text.toLowerCase(); - row.add(new Gtk.Label({ label: row._text, - halign: Gtk.Align.START, - margin_start: 6, - margin_end: 6 })); + row.add(new Gtk.Label({ + label: row._text, + halign: Gtk.Align.START, + margin_start: 6, + margin_end: 6 + })); widgetMap.set(nick, row); } } diff --git a/src/telepathyClient.js b/src/telepathyClient.js index 625f7a94..da13f566 100644 --- a/src/telepathyClient.js +++ b/src/telepathyClient.js @@ -471,15 +471,19 @@ class TelepathyClient extends Tp.BaseClient { _processRequest(context, connection, channels, processChannel) { if (connection.protocol_name != 'irc') { let message = 'Not implementing non-IRC protocols'; - context.fail(new Tp.Error({ code: Tp.Error.NOT_IMPLEMENTED, - message: message })); + context.fail(new Tp.Error({ + code: Tp.Error.NOT_IMPLEMENTED, + message: message + })); return; } if (this._isAuthChannel(channels[0]) && channels.length > 1) { let message = 'Only one authentication channel per connection allowed'; - context.fail(new Tp.Error({ code: Tp.Error.INVALID_ARGUMENT, - message: message })); + context.fail(new Tp.Error({ + code: Tp.Error.INVALID_ARGUMENT, + message: message + })); return; } @@ -545,9 +549,11 @@ class TelepathyClient extends Tp.BaseClient { notification.set_title(summary); notification.set_body(body); - let params = [room.account.object_path, - room.channel_name, - Utils.getTpEventTime()]; + let params = [ + room.account.object_path, + room.channel_name, + Utils.getTpEventTime() + ]; let actionName, paramFormat; if (room.type == Tp.HandleType.ROOM) { diff --git a/src/userList.js b/src/userList.js index 6b5903f3..20b43dd9 100644 --- a/src/userList.js +++ b/src/userList.js @@ -35,8 +35,10 @@ class UserListPopover extends Gtk.Popover { } _createWidget() { - this._box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, - spacing: 6 }); + this._box = new Gtk.Box({ + orientation: Gtk.Orientation.VERTICAL, + spacing: 6 + }); this.add(this._box); this._revealer = new Gtk.Revealer(); @@ -45,7 +47,9 @@ class UserListPopover extends Gtk.Popover { this._userListBin = new Gtk.Frame({ shadow_type: Gtk.ShadowType.NONE }); this._box.add(this._userListBin); - this._entry = new Gtk.SearchEntry({ primary_icon_name: 'avatar-default-symbolic' }); + this._entry = new Gtk.SearchEntry({ + primary_icon_name: 'avatar-default-symbolic' + }); this._entry.connect('search-changed', this._updateFilter.bind(this)); this._revealer.add(this._entry); @@ -103,16 +107,18 @@ var UserDetails = GObject.registerClass({ 'notificationLabel', 'messageButton' ], - Properties: { 'expanded': GObject.ParamSpec.boolean('expanded', - 'expanded', - 'expanded', - READWRITE, - false), - 'notifications-enabled': GObject.ParamSpec.boolean('notifications-enabled', - 'notifications-enabled', - 'notifications-enabled', - READWRITE, - false) }, + Properties: { + 'expanded': GObject.ParamSpec.boolean('expanded', + 'expanded', + 'expanded', + READWRITE, + false), + 'notifications-enabled': GObject.ParamSpec.boolean('notifications-enabled', + 'notifications-enabled', + 'notifications-enabled', + READWRITE, + false) + } }, class UserDetails extends Gtk.Frame { _init(params = {}) { let user = params.user; @@ -465,19 +471,25 @@ class UserListRow extends Gtk.ListBoxRow { let vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); this.add(vbox); - let hbox = new Gtk.Box({ margin_end: 12, - margin_start: 4, - margin_top: 4, - margin_bottom: 4, - spacing: 4 }); - this._arrow = new Gtk.Arrow({ arrow_type: Gtk.ArrowType.RIGHT, - no_show_all: true }); - this._label = new Gtk.Label({ label: this._user.alias, - halign: Gtk.Align.START, - hexpand: true, - use_markup: true, - ellipsize: Pango.EllipsizeMode.END, - max_width_chars: MAX_USERS_WIDTH_CHARS }); + let hbox = new Gtk.Box({ + margin_end: 12, + margin_start: 4, + margin_top: 4, + margin_bottom: 4, + spacing: 4 + }); + this._arrow = new Gtk.Arrow({ + arrow_type: Gtk.ArrowType.RIGHT, + no_show_all: true + }); + this._label = new Gtk.Label({ + label: this._user.alias, + halign: Gtk.Align.START, + hexpand: true, + use_markup: true, + ellipsize: Pango.EllipsizeMode.END, + max_width_chars: MAX_USERS_WIDTH_CHARS + }); hbox.add(this._label); hbox.add(this._arrow); vbox.add(hbox); @@ -545,23 +557,31 @@ class UserListRow extends Gtk.ListBoxRow { var UserList = GObject.registerClass( class UserList extends Gtk.ScrolledWindow { _init(room) { - super._init({ hexpand: true, - shadow_type: Gtk.ShadowType.ETCHED_IN, - hscrollbar_policy: Gtk.PolicyType.NEVER, - propagate_natural_width: true }); + super._init({ + hexpand: true, + shadow_type: Gtk.ShadowType.ETCHED_IN, + hscrollbar_policy: Gtk.PolicyType.NEVER, + propagate_natural_width: true + }); this._list = new Gtk.ListBox({ vexpand: true }); this.add(this._list); - let placeholder = new Gtk.Box({ halign: Gtk.Align.CENTER, - valign: Gtk.Align.CENTER, - orientation: Gtk.Orientation.VERTICAL, - visible: true }); - placeholder.add(new Gtk.Image({ icon_name: 'edit-find-symbolic', - pixel_size: 64, - visible: true })); - placeholder.add(new Gtk.Label({ label: _("No results"), - visible: true })); + let placeholder = new Gtk.Box({ + halign: Gtk.Align.CENTER, + valign: Gtk.Align.CENTER, + orientation: Gtk.Orientation.VERTICAL, + visible: true + }); + placeholder.add(new Gtk.Image({ + icon_name: 'edit-find-symbolic', + pixel_size: 64, + visible: true + })); + placeholder.add(new Gtk.Label({ + label: _("No results"), + visible: true + })); placeholder.get_style_context().add_class('dim-label'); diff --git a/src/userTracker.js b/src/userTracker.js index 1381fe27..43a6a7f4 100644 --- a/src/userTracker.js +++ b/src/userTracker.js @@ -154,9 +154,11 @@ const UserTracker = GObject.registerClass({ _ensureRoomMappingForRoom(room) { if (this._roomData.has(room)) return; - this._roomData.set(room, { contactMapping: new Map(), - handlerMapping: new Map(), - roomSignals: [] }); + this._roomData.set(room, { + contactMapping: new Map(), + handlerMapping: new Map(), + roomSignals: [] + }); } _onMemberRenamed(room, oldMember, newMember) { @@ -344,9 +346,11 @@ const UserTracker = GObject.registerClass({ let enabled = status == Tp.ConnectionPresenceType.OFFLINE; let state = new GLib.Variant('b', false); - let action = new Gio.SimpleAction({ name: name, - enabled: enabled, - state: state }); + let action = new Gio.SimpleAction({ + name: name, + enabled: enabled, + state: state + }); action.connect('notify::enabled', () => { if (!action.enabled) diff --git a/src/utils.js b/src/utils.js index 50f43960..52cdbb65 100644 --- a/src/utils.js +++ b/src/utils.js @@ -167,9 +167,11 @@ function findUrls(str) { function findChannels(str, server) { let res = [], match; while ((match = _channelRegexp.exec(str))) - res.push({ url: `irc://${server}/${match[2]}`, - name: `#${match[2]}`, - pos: match.index + match[1].length }); + res.push({ + url: `irc://${server}/${match[2]}`, + name: `#${match[2]}`, + pos: match.index + match[1].length + }); return res; } -- GitLab From cb596b357c71a085981a87d8ae8852f378ae2984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 28 Jul 2018 19:13:35 +0200 Subject: [PATCH 7/7] style: Use single-quotes for translated strings The coding style of using double quotes for translatable strings and single quotes otherwise is unnecessarily complex and cannot be enforced with an eslint rule. Simply use single quotes consistently for all strings. https://gitlab.gnome.org/GNOME/polari/merge_requests/93 --- lint/eslintrc-legacy.json | 3 +-- src/appNotifications.js | 2 +- src/application.js | 18 +++++++------- src/chatView.js | 50 +++++++++++++++++++-------------------- src/connections.js | 8 +++---- src/entryArea.js | 20 ++++++++-------- src/initialSetup.js | 4 ++-- src/ircParser.js | 38 ++++++++++++++--------------- src/joinDialog.js | 2 +- src/mainWindow.js | 4 ++-- src/roomList.js | 24 +++++++++---------- src/roomStack.js | 10 ++++---- src/telepathyClient.js | 8 +++---- src/userList.js | 32 ++++++++++++------------- src/userTracker.js | 4 ++-- src/utils.js | 6 ++--- 16 files changed, 116 insertions(+), 117 deletions(-) diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json index 8b716511..7f5a479d 100644 --- a/lint/eslintrc-legacy.json +++ b/lint/eslintrc-legacy.json @@ -12,7 +12,6 @@ "ObjectExpression": "first", "MemberExpression": "off" } - ], - "quotes": "off" + ] } } diff --git a/src/appNotifications.js b/src/appNotifications.js index 188ab567..0039a36d 100644 --- a/src/appNotifications.js +++ b/src/appNotifications.js @@ -84,7 +84,7 @@ var UndoNotification = GObject.registerClass({ this.connect('destroy', () => { this.close(); }); - this.addButton(_("Undo"), () => { this._undo = true; }); + this.addButton(_('Undo'), () => { this._undo = true; }); } close() { diff --git a/src/application.js b/src/application.js index fb57d6d4..2b3e5791 100644 --- a/src/application.js +++ b/src/application.js @@ -40,18 +40,18 @@ var Application = GObject.registerClass({ this.add_main_option('start-client', 0, GLib.OptionFlags.NONE, GLib.OptionArg.NONE, - _("Start Telepathy client"), null); + _('Start Telepathy client'), null); // Only included for --help output, the actual option is handled // from C before handling over control to JS this.add_main_option('debugger', 'd', GLib.OptionFlags.NONE, GLib.OptionArg.NONE, - _("Start in debug mode"), null); + _('Start in debug mode'), null); this.add_main_option('test-instance', 0, GLib.OptionFlags.NONE, GLib.OptionArg.NONE, - _("Allow running alongside another instance"), null); + _('Allow running alongside another instance'), null); this.add_main_option('version', 0, GLib.OptionFlags.NONE, GLib.OptionArg.NONE, - _("Print version and exit"), null); + _('Print version and exit'), null); this.connect('handle-local-options', (o, dict) => { let v = dict.lookup_value('test-instance', null); if (v && v.get_boolean()) @@ -436,7 +436,7 @@ var Application = GObject.registerClass({ [,, server, port, room] = uri.match(IRC_SCHEMA_REGEX); success = true; } catch (e) { - let label = _("Failed to open link"); + let label = _('Failed to open link'); let n = new AppNotifications.MessageNotification(label, 'dialog-error-symbolic'); this.notificationQueue.addNotification(n); @@ -727,7 +727,7 @@ var Application = GObject.registerClass({ account.set_enabled_finish(res); account.visible = false; - let label = _("%s removed.").format(account.display_name); + let label = _('%s removed.').format(account.display_name); let n = new AppNotifications.UndoNotification(label); this.notificationQueue.addNotification(n); @@ -802,13 +802,13 @@ var Application = GObject.registerClass({ 'Lapo Calamandrei ', 'Tobias Bernard ' ], - translator_credits: _("translator-credits"), - comments: _("An Internet Relay Chat Client for GNOME"), + translator_credits: _('translator-credits'), + comments: _('An Internet Relay Chat Client for GNOME'), copyright: 'Copyright © 2013-2018 The Polari authors', license_type: Gtk.License.GPL_2_0, logo_icon_name: 'org.gnome.Polari', version: pkg.version, - website_label: _("Learn more about Polari"), + website_label: _('Learn more about Polari'), website: 'https://wiki.gnome.org/Apps/Polari', transient_for: this.active_window, diff --git a/src/chatView.js b/src/chatView.js index 40bdec27..59d9df60 100644 --- a/src/chatView.js +++ b/src/chatView.js @@ -134,7 +134,7 @@ class TextView extends Gtk.TextView { _updateLayout() { this._layout = this.create_pango_layout(null); - this._layout.set_markup(`${_("New Messages")}`, -1); + this._layout.set_markup(`${_('New Messages')}`, -1); } }); @@ -776,13 +776,13 @@ var ChatView = GObject.registerClass({ _showUrlContextMenu(url) { let menu = new Gtk.Menu(); - let item = new Gtk.MenuItem({ label: _("Open Link") }); + let item = new Gtk.MenuItem({ label: _('Open Link') }); item.connect('activate', () => { Utils.openURL(url, Gtk.get_current_event_time()); }); menu.append(item); - item = new Gtk.MenuItem({ label: _("Copy Link Address") }); + item = new Gtk.MenuItem({ label: _('Copy Link Address') }); item.connect('activate', () => { let clipboard = Gtk.Clipboard.get_default(item.get_display()); clipboard.set_text(url, -1); @@ -953,12 +953,12 @@ var ChatView = GObject.registerClass({ } _onMemberRenamed(room, oldMember, newMember) { - let text = _("%s is now known as %s").format(oldMember.alias, newMember.alias); + let text = _('%s is now known as %s').format(oldMember.alias, newMember.alias); this._insertStatus(text, oldMember.alias, 'renamed'); } _onMemberDisconnected(room, member, message) { - let text = _("%s has disconnected").format(member.alias); + let text = _('%s has disconnected').format(member.alias); if (message) text += ` (${message})`; this._insertStatus(text, member.alias, 'left'); @@ -967,26 +967,26 @@ var ChatView = GObject.registerClass({ _onMemberKicked(room, member, actor) { let [kicked, kicker] = [member.alias, actor ? actor.alias : null]; let msg = kicker ? - _("%s has been kicked by %s").format(kicked, kicker) : - _("%s has been kicked").format(kicked); + _('%s has been kicked by %s').format(kicked, kicker) : + _('%s has been kicked').format(kicked); this._insertStatus(msg, kicked, 'left'); } _onMemberBanned(room, member, actor) { let [banned, banner] = [member.alias, actor ? actor.alias : null]; let msg = banner ? - _("%s has been banned by %s").format(banned, banner) : - _("%s has been banned").format(banned); + _('%s has been banned by %s').format(banned, banner) : + _('%s has been banned').format(banned); this._insertStatus(msg, banned, 'left'); } _onMemberJoined(room, member) { - let text = _("%s joined").format(member.alias); + let text = _('%s joined').format(member.alias); this._insertStatus(text, member.alias, 'joined'); } _onMemberLeft(room, member, message) { - let text = _("%s left").format(member.alias); + let text = _('%s left').format(member.alias); if (message) text += ` (${message})`; @@ -1079,11 +1079,11 @@ var ChatView = GObject.registerClass({ let stats = []; if (this._statusCount.joined > 0) - stats.push(ngettext("%d user joined", - "%d users joined", this._statusCount.joined).format(this._statusCount.joined)); + stats.push(ngettext('%d user joined', + '%d users joined', this._statusCount.joined).format(this._statusCount.joined)); if (this._statusCount.left > 0) - stats.push(ngettext("%d user left", - "%d users left", this._statusCount.left).format(this._statusCount.left)); + stats.push(ngettext('%d user left', + '%d users left', this._statusCount.left).format(this._statusCount.left)); // TODO: How do we update the arrow direction when text direction change? let iter = buffer.get_iter_at_mark(headerMark); let tags = [this._lookupTag('status'), headerTag]; @@ -1149,56 +1149,56 @@ var ChatView = GObject.registerClass({ if (clockFormat == '24h' || !hasAmPm) { if (daysAgo < 1) { // today /* Translators: Time in 24h format */ - format = _("%H\u2236%M"); + format = _('%H\u2236%M'); } else if (daysAgo < 2) { // yesterday /* Translators: this is the word "Yesterday" followed by a time string in 24h format. i.e. "Yesterday, 14:30" */ // xgettext:no-c-format - format = _("Yesterday, %H\u2236%M"); + format = _('Yesterday, %H\u2236%M'); } else if (daysAgo < 7) { // this week /* Translators: this is the week day name followed by a time string in 24h format. i.e. "Monday, 14:30" */ // xgettext:no-c-format - format = _("%A, %H\u2236%M"); + format = _('%A, %H\u2236%M'); } else if (date.get_year() == now.get_year()) { // this year /* Translators: this is the month name and day number followed by a time string in 24h format. i.e. "May 25, 14:30" */ // xgettext:no-c-format - format = _("%B %d, %H\u2236%M"); + format = _('%B %d, %H\u2236%M'); } else { // before this year /* Translators: this is the month name, day number, year number followed by a time string in 24h format. i.e. "May 25 2012, 14:30" */ // xgettext:no-c-format - format = _("%B %d %Y, %H\u2236%M"); + format = _('%B %d %Y, %H\u2236%M'); } } else { if (daysAgo < 1) { // today /* Translators: Time in 12h format */ - format = _("%l\u2236%M %p"); + format = _('%l\u2236%M %p'); } else if (daysAgo < 2) { // yesterday /* Translators: this is the word "Yesterday" followed by a time string in 12h format. i.e. "Yesterday, 2:30 pm" */ // xgettext:no-c-format - format = _("Yesterday, %l\u2236%M %p"); + format = _('Yesterday, %l\u2236%M %p'); } else if (daysAgo < 7) { // this week /* Translators: this is the week day name followed by a time string in 12h format. i.e. "Monday, 2:30 pm" */ // xgettext:no-c-format - format = _("%A, %l\u2236%M %p"); + format = _('%A, %l\u2236%M %p'); } else if (date.get_year() == now.get_year()) { // this year /* Translators: this is the month name and day number followed by a time string in 12h format. i.e. "May 25, 2:30 pm" */ // xgettext:no-c-format - format = _("%B %d, %l\u2236%M %p"); + format = _('%B %d, %l\u2236%M %p'); } else { // before this year /* Translators: this is the month name, day number, year number followed by a time string in 12h format. i.e. "May 25 2012, 2:30 pm"*/ // xgettext:no-c-format - format = _("%B %d %Y, %l\u2236%M %p"); + format = _('%B %d %Y, %l\u2236%M %p'); } } diff --git a/src/connections.js b/src/connections.js index f6b21c09..b2174946 100644 --- a/src/connections.js +++ b/src/connections.js @@ -51,7 +51,7 @@ class ConnectionRow extends Gtk.ListBoxRow { box.add(new Gtk.Label({ label: name, halign: Gtk.Align.START })); let insensitiveDesc = new Gtk.Label({ - label: _("Already added"), + label: _('Already added'), hexpand: true, no_show_all: true, halign: Gtk.Align.END @@ -114,7 +114,7 @@ var ConnectionsList = GObject.registerClass({ visible: true })); placeholder.add(new Gtk.Label({ - label: _("No results."), + label: _('No results.'), visible: true })); @@ -516,7 +516,7 @@ var ConnectionProperties = GObject.registerClass({ _init(account) { /* Translators: %s is a connection name */ super._init({ - title: _("“%s” Properties").format(account.display_name), + title: _('“%s” Properties').format(account.display_name), use_header_bar: 1 }); @@ -560,7 +560,7 @@ var ConnectionProperties = GObject.registerClass({ case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REFUSED): case Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR): this._errorBox.show(); - this._errorLabel.label = _("Polari disconnected due to a network error. Please check if the address field is correct."); + this._errorLabel.label = _('Polari disconnected due to a network error. Please check if the address field is correct.'); this._details.setErrorHint(ErrorHint.SERVER); break; } diff --git a/src/entryArea.js b/src/entryArea.js index fd7a7139..5d225feb 100644 --- a/src/entryArea.js +++ b/src/entryArea.js @@ -369,19 +369,19 @@ var EntryArea = GObject.registerClass({ pasteText(text, nLines) { this._confirmLabel.label = - ngettext("Paste %s line of text to public paste service?", - "Paste %s lines of text to public paste service?", + ngettext('Paste %s line of text to public paste service?', + 'Paste %s lines of text to public paste service?', nLines).format(nLines); this._uploadLabel.label = - ngettext("Uploading %s line of text to public paste service…", - "Uploading %s lines of text to public paste service…", + ngettext('Uploading %s line of text to public paste service…', + 'Uploading %s lines of text to public paste service…', nLines).format(nLines); this._setPasteContent(text); } pasteImage(pixbuf) { - this._confirmLabel.label = _("Upload image to public paste service?"); - this._uploadLabel.label = _("Uploading image to public paste service…"); + this._confirmLabel.label = _('Upload image to public paste service?'); + this._uploadLabel.label = _('Uploading image to public paste service…'); this._setPasteContent(pixbuf); } @@ -402,9 +402,9 @@ var EntryArea = GObject.registerClass({ let name = fileInfo.get_display_name(); /* Translators: %s is a filename */ - this._confirmLabel.label = _("Upload “%s” to public paste service?").format(name); + this._confirmLabel.label = _('Upload “%s” to public paste service?').format(name); /* Translators: %s is a filename */ - this._uploadLabel.label = _("Uploading “%s” to public paste service…").format(name); + this._uploadLabel.label = _('Uploading “%s” to public paste service…').format(name); this._setPasteContent(file); } @@ -413,9 +413,9 @@ var EntryArea = GObject.registerClass({ let nick = this._room.channel.connection.self_contact.alias; if (this._room.type == Tp.HandleType.ROOM) /* translators: %s is a nick, #%s a channel */ - title = _("%s in #%s").format(nick, this._room.display_name); + title = _('%s in #%s').format(nick, this._room.display_name); else - title = _("Paste from %s").format(nick); + title = _('Paste from %s').format(nick); let app = Gio.Application.get_default(); try { diff --git a/src/initialSetup.js b/src/initialSetup.js index bdc44058..45df25d3 100644 --- a/src/initialSetup.js +++ b/src/initialSetup.js @@ -81,8 +81,8 @@ var InitialSetupWindow = GObject.registerClass({ let isLastPage = page == SetupPage.ROOM; - this._prevButton.label = isLastPage ? _("_Back") : _("_Cancel"); - this._nextButton.label = isLastPage ? _("_Done") : _("_Next"); + this._prevButton.label = isLastPage ? _('_Back') : _('_Cancel'); + this._nextButton.label = isLastPage ? _('_Done') : _('_Next'); let context = this._nextButton.get_style_context(); if (isLastPage) diff --git a/src/ircParser.js b/src/ircParser.js index acaeeaef..4212472c 100644 --- a/src/ircParser.js +++ b/src/ircParser.js @@ -20,23 +20,23 @@ var knownCommands = { WHOIS: N_("/WHOIS — requests information on "), */ - CLOSE: N_("/CLOSE [] [] — closes , by default the current one"), - HELP: N_("/HELP [] — displays help for , or a list of available commands"), - INVITE: N_("/INVITE [] — invites to , or the current one"), - JOIN: N_("/JOIN — joins "), - KICK: N_("/KICK — kicks from current channel"), - ME: N_("/ME — sends to the current channel"), - MSG: N_("/MSG [] — sends a private message to "), - NAMES: N_("/NAMES — lists users on the current channel"), - NICK: N_("/NICK — sets your nick to "), - PART: N_("/PART [] [] — leaves , by default the current one"), - QUERY: N_("/QUERY — opens a private conversation with "), - QUIT: N_("/QUIT [] — disconnects from the current server"), - SAY: N_("/SAY — sends to the current room/contact"), - TOPIC: N_("/TOPIC — sets the topic to , or shows the current one"), + CLOSE: N_('/CLOSE [] [] — closes , by default the current one'), + HELP: N_('/HELP [] — displays help for , or a list of available commands'), + INVITE: N_('/INVITE [] — invites to , or the current one'), + JOIN: N_('/JOIN — joins '), + KICK: N_('/KICK — kicks from current channel'), + ME: N_('/ME — sends to the current channel'), + MSG: N_('/MSG [] — sends a private message to '), + NAMES: N_('/NAMES — lists users on the current channel'), + NICK: N_('/NICK — sets your nick to '), + PART: N_('/PART [] [] — leaves , by default the current one'), + QUERY: N_('/QUERY — opens a private conversation with '), + QUIT: N_('/QUIT [] — disconnects from the current server'), + SAY: N_('/SAY — sends to the current room/contact'), + TOPIC: N_('/TOPIC — sets the topic to , or shows the current one'), }; const UNKNOWN_COMMAND_MESSAGE = - N_("Unknown command — try /HELP for a list of available commands"); + N_('Unknown command — try /HELP for a list of available commands'); var IrcParser = class { constructor(room) { @@ -50,7 +50,7 @@ var IrcParser = class { } _createFeedbackUsage(cmd) { - return this._createFeedbackLabel(_("Usage: %s").format(_(knownCommands[cmd]))); + return this._createFeedbackLabel(_('Usage: %s').format(_(knownCommands[cmd]))); } _createFeedbackGrid(header, items) { @@ -86,7 +86,7 @@ var IrcParser = class { else if (command) output = this._createFeedbackUsage(command); else - output = this._createFeedbackGrid(_("Known commands:"), + output = this._createFeedbackGrid(_('Known commands:'), Object.keys(knownCommands)); break; } @@ -187,7 +187,7 @@ var IrcParser = class { case 'NAMES': { let channel = this._room.channel; let members = channel.group_dup_members_contacts().map(m => m.alias); - output = this._createFeedbackGrid(_("Users on %s:").format(channel.identifier), + output = this._createFeedbackGrid(_('Users on %s:').format(channel.identifier), members); break; } @@ -267,7 +267,7 @@ var IrcParser = class { if (argv.length) this._room.set_topic(stripCommand(text)); else - output = this._createFeedbackLabel(this._room.topic || _("No topic set")); + output = this._createFeedbackLabel(this._room.topic || _('No topic set')); break; } default: diff --git a/src/joinDialog.js b/src/joinDialog.js index a72e08f6..3fd796f5 100644 --- a/src/joinDialog.js +++ b/src/joinDialog.js @@ -231,7 +231,7 @@ var JoinDialog = GObject.registerClass({ this._joinButton.visible = isMain; this._cancelButton.visible = isMain || isAccountsEmpty; this._backButton.visible = !(isMain || isAccountsEmpty); - this.title = isMain ? _("Join Chat Room") : _("Add Network"); + this.title = isMain ? _('Join Chat Room') : _('Add Network'); this._mainStack.visible_child_name = isMain ? 'main' : 'connection'; this._updateCanJoin(); } diff --git a/src/mainWindow.js b/src/mainWindow.js index 632f6929..f3206574 100644 --- a/src/mainWindow.js +++ b/src/mainWindow.js @@ -358,8 +358,8 @@ var MainWindow = GObject.registerClass({ this._room.channel.has_interface(Tp.IFACE_CHANNEL_INTERFACE_GROUP)) numMembers = this._room.channel.group_dup_members_contacts().length; - let accessibleName = ngettext("%d user", - "%d users", numMembers).format(numMembers); + let accessibleName = ngettext('%d user', + '%d users', numMembers).format(numMembers); this._showUserListButton.get_accessible().set_name(accessibleName); this._showUserListButton.label = `${numMembers}`; } diff --git a/src/roomList.js b/src/roomList.js index 4cf6669d..2b9670f1 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -190,7 +190,7 @@ var RoomRow = GObject.registerClass({ if (!this._popover) { let menu = new Gio.Menu(); let isRoom = this._room.type == Tp.HandleType.ROOM; - menu.append(isRoom ? _("Leave chatroom") : _("End conversation"), + menu.append(isRoom ? _('Leave chatroom') : _('End conversation'), `app.leave-room(("${this._room.id}", ""))`); this._popover = Gtk.Popover.new_from_model(this, menu); @@ -296,7 +296,7 @@ var RoomListHeader = GObject.registerClass({ if (parent) parent.invalidate_sort(); - let accessibleName = _("Network %s has an error").format(this._account.display_name); + let accessibleName = _('Network %s has an error').format(this._account.display_name); this.get_accessible().set_name(accessibleName); } @@ -367,14 +367,14 @@ var RoomListHeader = GObject.registerClass({ /* Translators: This is an account name followed by a server address, e.g. "GNOME (irc.gnome.org)" */ - let fullTitle = _("%s (%s)").format(accountName, server); + let fullTitle = _('%s (%s)').format(accountName, server); this._popoverTitle.label = (accountName == server) ? accountName : fullTitle; this._popoverStatus.label = `${this._getStatusLabel()}<${'/'}sup>`; } else { let styleContext = this._popoverStatus.get_style_context(); styleContext.remove_class('dim-label'); - this._popoverTitle.label = `${_("Connection Problem")}<${'/'}b>`; + this._popoverTitle.label = `${_('Connection Problem')}<${'/'}b>`; this._popoverStatus.label = this._getErrorLabel(); } } @@ -391,13 +391,13 @@ var RoomListHeader = GObject.registerClass({ _getStatusLabel() { switch (this._getConnectionStatus()) { case Tp.ConnectionStatus.CONNECTED: - return _("Connected"); + return _('Connected'); case Tp.ConnectionStatus.CONNECTING: - return _("Connecting…"); + return _('Connecting…'); case Tp.ConnectionStatus.DISCONNECTED: - return _("Offline"); + return _('Offline'); default: - return _("Unknown"); + return _('Unknown'); } } @@ -417,19 +417,19 @@ var RoomListHeader = GObject.registerClass({ case Tp.error_get_dbus_name(Tp.Error.CERT_HOSTNAME_MISMATCH): case Tp.error_get_dbus_name(Tp.Error.CERT_FINGERPRINT_MISMATCH): case Tp.error_get_dbus_name(Tp.Error.CERT_SELF_SIGNED): - return _("Could not connect to %s in a safe way.").format(this._account.display_name); + return _('Could not connect to %s in a safe way.').format(this._account.display_name); case Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED): - return _("%s requires a password.").format(this._account.display_name); + return _('%s requires a password.').format(this._account.display_name); case Tp.error_get_dbus_name(Tp.Error.CONNECTION_FAILED): case Tp.error_get_dbus_name(Tp.Error.CONNECTION_LOST): case Tp.error_get_dbus_name(Tp.Error.CONNECTION_REPLACED): case Tp.error_get_dbus_name(Tp.Error.SERVICE_BUSY): - return _("Could not connect to %s. The server is busy.").format(this._account.display_name); + return _('Could not connect to %s. The server is busy.').format(this._account.display_name); default: - return _("Could not connect to %s.").format(this._account.display_name); + return _('Could not connect to %s.').format(this._account.display_name); } } }); diff --git a/src/roomStack.js b/src/roomStack.js index b3d15227..e58023b4 100644 --- a/src/roomStack.js +++ b/src/roomStack.js @@ -120,7 +120,7 @@ class SavePasswordConfirmationBar extends Gtk.Revealer { let target = new GLib.Variant('o', this._room.account.object_path); let button = new Gtk.Button({ - label: _("_Save Password"), + label: _('_Save Password'), use_underline: true, action_name: 'app.save-identify-password', action_target: target @@ -130,7 +130,7 @@ class SavePasswordConfirmationBar extends Gtk.Revealer { let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); this._infoBar.get_content_area().add(box); - let title = _("Should the password be saved?"); + let title = _('Should the password be saved?'); this._titleLabel = new Gtk.Label({ halign: Gtk.Align.START, valign: Gtk.Align.CENTER, @@ -140,7 +140,7 @@ class SavePasswordConfirmationBar extends Gtk.Revealer { box.add(this._titleLabel); let accountName = this._room.account.display_name; - let text = _("Identification will happen automatically the next time you connect to %s").format(accountName); + let text = _('Identification will happen automatically the next time you connect to %s').format(accountName); this._subtitleLabel = new Gtk.Label({ label: text, ellipsize: Pango.EllipsizeMode.END @@ -173,11 +173,11 @@ class ChatPlaceholder extends Gtk.Overlay { halign: Gtk.Align.START, margin_start: 14 }); - title.label = `${_("Polari")}`; + title.label = `${_('Polari')}`; title.get_style_context().add_class('polari-background-title'); let description = new Gtk.Label({ - label: _("Join a room using the + button."), + label: _('Join a room using the + button.'), halign: Gtk.Align.CENTER, wrap: true, margin_top: 24, use_markup: true }); diff --git a/src/telepathyClient.js b/src/telepathyClient.js index da13f566..8d11fb40 100644 --- a/src/telepathyClient.js +++ b/src/telepathyClient.js @@ -408,7 +408,7 @@ class TelepathyClient extends Tp.BaseClient { }); let reason = Tp.ChannelGroupChangeReason.NONE; - message = message || _("Good Bye"); + message = message || _('Good Bye'); room.channel.leave_async(reason, message, (c, res) => { try { c.leave_finish(res); @@ -588,11 +588,11 @@ class TelepathyClient extends Tp.BaseClient { let accountName = room.account.display_name; /* Translators: Those are a botname and an accountName, e.g. "Save NickServ password for GNOME" */ - let summary = _("Save %s password for %s?").format(data.botname, accountName); - let text = _("Identification will happen automatically the next time you connect to %s").format(accountName); + let summary = _('Save %s password for %s?').format(data.botname, accountName); + let text = _('Identification will happen automatically the next time you connect to %s').format(accountName); let notification = this._createNotification(room, summary, text); - notification.add_button_with_target(_("Save"), 'app.save-identify-password', + notification.add_button_with_target(_('Save'), 'app.save-identify-password', new GLib.Variant('o', accountPath)); this._app.send_notification(this._getIdentifyNotificationID(accountPath), notification); diff --git a/src/userList.js b/src/userList.js index 20b43dd9..47c4257d 100644 --- a/src/userList.js +++ b/src/userList.js @@ -234,32 +234,32 @@ var UserDetails = GObject.registerClass({ _formatLast(seconds) { if (seconds < 60) - return ngettext("%d second ago", - "%d seconds ago", seconds).format(seconds); + return ngettext('%d second ago', + '%d seconds ago', seconds).format(seconds); let minutes = seconds / 60; if (minutes < 60) - return ngettext("%d minute ago", - "%d minutes ago", minutes).format(minutes); + return ngettext('%d minute ago', + '%d minutes ago', minutes).format(minutes); let hours = minutes / 60; if (hours < 24) - return ngettext("%d hour ago", - "%d hours ago", hours).format(hours); + return ngettext('%d hour ago', + '%d hours ago', hours).format(hours); let days = hours / 24; if (days < 7) - return ngettext("%d day ago", - "%d days ago", days).format(days); + return ngettext('%d day ago', + '%d days ago', days).format(days); let weeks = days / 7; if (days < 30) - return ngettext("%d week ago", - "%d weeks ago", weeks).format(weeks); + return ngettext('%d week ago', + '%d weeks ago', weeks).format(weeks); let months = days / 30; - return ngettext("%d month ago", - "%d months ago", months).format(months); + return ngettext('%d month ago', + '%d months ago', months).format(months); } _onContactInfoReady() { @@ -419,11 +419,11 @@ var UserPopover = GObject.registerClass({ let label; if (status != roomStatus) - label = _("Available in another room."); + label = _('Available in another room.'); else if (status == Tp.ConnectionPresenceType.AVAILABLE) - label = _("Online"); + label = _('Online'); else - label = _("Offline"); + label = _('Offline'); this._statusLabel.label = label; this._nickLabel.sensitive = (status == Tp.ConnectionPresenceType.AVAILABLE); @@ -579,7 +579,7 @@ class UserList extends Gtk.ScrolledWindow { visible: true })); placeholder.add(new Gtk.Label({ - label: _("No results"), + label: _('No results'), visible: true })); diff --git a/src/userTracker.js b/src/userTracker.js index 43a6a7f4..a77e5ce8 100644 --- a/src/userTracker.js +++ b/src/userTracker.js @@ -306,8 +306,8 @@ const UserTracker = GObject.registerClass({ _notifyNickAvailable (member, room) { let notification = new Gio.Notification(); - notification.set_title(_("User is online")); - notification.set_body(_("User %s is now online.").format(member.alias)); + notification.set_title(_('User is online')); + notification.set_body(_('User %s is now online.').format(member.alias)); let param = GLib.Variant.new('(ssu)', [ this._account.get_object_path(), diff --git a/src/utils.js b/src/utils.js index 52cdbb65..75da4660 100644 --- a/src/utils.js +++ b/src/utils.js @@ -103,12 +103,12 @@ function getTpEventTime() { } function storeAccountPassword(account, password, callback) { - let label = _("Polari server password for %s").format(account.display_name); + let label = _('Polari server password for %s').format(account.display_name); _storePassword(SECRET_SCHEMA_ACCOUNT, label, account, password, callback); } function storeIdentifyPassword(account, password, callback) { - let label = _("Polari NickServ password for %s").format(account.display_name); + let label = _('Polari NickServ password for %s').format(account.display_name); _storePassword(SECRET_SCHEMA_IDENTIFY, label, account, password, callback); } @@ -183,7 +183,7 @@ function openURL(url, timestamp) { else Gtk.show_uri (Gdk.Screen.get_default(), url, timestamp); } catch (e) { - let n = new AppNotifications.SimpleOutput(_("Failed to open link")); + let n = new AppNotifications.SimpleOutput(_('Failed to open link')); app.notificationQueue.addNotification(n); debug(`Failed to open ${url}: ${e.message}`); } -- GitLab