diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json index ad2c560ca17dc2a1d335f09c559318decb23b47d..7f5a479d835ada64711e64ef83b1025421d03598 100644 --- a/lint/eslintrc-legacy.json +++ b/lint/eslintrc-legacy.json @@ -5,17 +5,13 @@ 4, { "ignoredNodes": [ - "ConditionalExpression", "CallExpression > ArrowFunctionExpression", "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" ], "CallExpression": { "arguments": "first" }, - "ArrayExpression": "first", "ObjectExpression": "first", - "MemberExpression": "off", - "SwitchCase": 1 + "MemberExpression": "off" } - ], - "quotes": "off" + ] } } diff --git a/lint/eslintrc-polari.json b/lint/eslintrc-polari.json index 0f13cf648091d92c11cc0607a4f66eeb369f2e6f..96af4639d97b317bdc20a06b8d77bf27727a16ca 100644 --- a/lint/eslintrc-polari.json +++ b/lint/eslintrc-polari.json @@ -20,9 +20,7 @@ 4, { "ignoredNodes": [ - "ArrayExpression > ObjectExpression", - "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 b45371f6abf1ee2d2e399e76e5bfc874cfe15779..51652007c314f1fa2790ac38a4a0ef7d800e4687 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; } @@ -124,8 +126,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 +154,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'); } }; @@ -161,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 259c8bca306b109604c1555433113607cf9b4375..0039a36dcf2851ba01f1e3a6d983f2220dffb9a9 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); @@ -76,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() { @@ -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 b1cdb39fad49f515a441e0e9342573f245a7846f..2b3e57910c8db310b1dc64d9d0c144c47a994fc4 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(); @@ -36,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()) @@ -417,9 +421,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 + ])); }); }); } @@ -431,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); @@ -456,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) @@ -649,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; } @@ -718,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); @@ -793,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 6d9af07cd4361db6a0fdb7d2fc86842b020cdcf2..59d9df60a8825f367f6a25affbde99dc37b8ef61 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); } }); @@ -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}`); @@ -765,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); @@ -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; @@ -913,8 +926,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) @@ -939,40 +953,40 @@ 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'); } _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) { - 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})`; @@ -1065,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]; @@ -1135,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'); } } @@ -1250,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); @@ -1356,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 ea4bea800559076f566252585188a4c57658b903..b2174946ac2ff2b9bee0dd566297f346c3257c43 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; } @@ -48,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(); @@ -75,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; @@ -96,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'); @@ -192,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); @@ -247,22 +262,28 @@ var ConnectionsList = GObject.registerClass({ var ConnectionDetails = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/connection-details.ui', - InternalChildren: ['nameEntry', - 'serverEntry', - 'nickEntry', - '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] } }, + InternalChildren: [ + 'nameEntry', + 'serverEntry', + 'nickEntry', + '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] } + } }, class ConnectionDetails extends Gtk.Grid { _init(params) { this._networksManager = NetworksManager.getDefault(); @@ -293,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(); @@ -425,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, {}); @@ -460,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); @@ -480,15 +507,18 @@ 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 */ - 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; @@ -527,12 +557,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/entryArea.js b/src/entryArea.js index 90973425e6116745fac2676c54cfc87f6b1a4b13..5d225feb10ed4cc2732485c60df9e9179419f514 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) @@ -105,8 +106,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', @@ -114,7 +117,9 @@ var NickPopover = GObject.registerClass({ GObject.ParamFlags.READWRITE, '') }, - Signals: { 'nick-changed': {} } + Signals: { + 'nick-changed': {} + } }, class NickPopover extends Gtk.Popover { _init() { this._nick = ''; @@ -150,21 +155,23 @@ 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', 'max-nick-chars', GObject.ParamFlags.WRITABLE, 0, GLib.MAXUINT32, 0) - }, + } }, class EntryArea extends Gtk.Stack { static get _nickPopover() { if (!this.__nickPopover) @@ -362,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); } @@ -395,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); } @@ -406,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 { @@ -474,8 +481,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 2e1911f2d90fe81d2a4d767bb4d6ec6bd3319eba..45df25d3f218c8de465493a47e706094dd1f59c0 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) { @@ -63,8 +65,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); } @@ -79,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 ef55311d944ec5c200d94419d6e65356aff416dc..4212472c71b097a89a618e8724824b8bf1736fa8 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) { @@ -74,203 +74,206 @@ 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/joinDialog.js b/src/joinDialog.js index ccc34dabfe80435f054cca4ed6a90721b60c4d28..3fd796f50b7b108bf3a59d676e8dcc396a0651c2 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; @@ -31,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(); @@ -120,8 +124,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(); @@ -169,10 +173,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() + ])); }); } @@ -187,8 +192,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 +208,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 +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/main.js b/src/main.js index 1af8098729fd785ab981fbf02ee3d06f1437fbe3..2d2e9c19b95aa3d8317c02d1b1f28d714beb33af 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 4a62749076156e7f3634763dc2c603f5f627a50d..f3206574edde878db2a81f25490e171a6e402458 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; @@ -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', @@ -104,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 = ''; @@ -354,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/networksManager.js b/src/networksManager.js index be3009c78879624b1522b9a100e033f28d5f1178..efa634088a673d5a13dcb7a68ea9c8875a8f48b1 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/pasteManager.js b/src/pasteManager.js index d22ee531f2fed7678b2a5835a6f8a216f83e6351..63d31aae3140f838af0e750ba8d8035ce3174da3 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; @@ -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 b2c03e1c44ea818a1815609d6190c3c64d7e06e9..2b9670f199173c65d4487b59ad820d0be1e193dd 100644 --- a/src/roomList.js +++ b/src/roomList.js @@ -17,10 +17,18 @@ 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}` }); + super._init({ + name: `RoomRow ${room.display_name}` + }); this._room = room; this._popover = null; @@ -182,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); @@ -198,17 +206,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; @@ -286,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); } @@ -357,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(); } } @@ -380,46 +390,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); } } }); @@ -563,8 +573,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) @@ -579,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 47ab5b2cba34a7045a05082fdd2749a30ec0b325..79d3729cc0d41a496579c19432d67c619d3a6690 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); } @@ -187,8 +189,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/roomStack.js b/src/roomStack.js index 2fa9e1bc1967586d756bf23ab918b02299aa7ded..e58023b41a9d655a7d016c346d78ee508d850eb7 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 }); + let title = _('Should the password be saved?'); + 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 }); + 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 + }); 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 }); - title.label = `${_("Polari")}`; + 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 e6985cc957f440e8bb197db4214edd75dc451cb8..51ba88708824ebf7f749a9de81e33652e59b7f96 100644 --- a/src/serverRoomManager.js +++ b/src/serverRoomManager.js @@ -108,16 +108,20 @@ function _strBaseEqual(str1, str2) { var ServerRoomList = GObject.registerClass({ Template: 'resource:///org/gnome/Polari/ui/server-room-list.ui', - InternalChildren: ['filterEntry', - 'list', - 'spinner', - 'store', - 'toggleRenderer'], - Properties: { 'can-join': GObject.ParamSpec.boolean('can-join', - 'can-join', - 'can-join', - GObject.ParamFlags.READABLE, - false) }, + InternalChildren: [ + 'filterEntry', + 'list', + 'spinner', + 'store', + 'toggleRenderer' + ], + 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; @@ -335,8 +339,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/tabCompletion.js b/src/tabCompletion.js index 4edb4e93c47e5a8010fcbf8bca1f3dc80ede9cc6..437e809bd8e430c32870a0edb53faea6f55b7e77 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); } } @@ -129,17 +133,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 71b6bc8d9daa0e500a91b767f3960dc34f1d1f6a..8d11fb40cd5f9c135147c92ef5410229357f1d2a 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; } } @@ -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 => { @@ -407,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); @@ -470,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; } @@ -544,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) { @@ -581,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 293f40db6af0162193dcfb847913836e402710d9..47c4257d76992387dda39b517963793b1493f1e0 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); @@ -94,23 +98,27 @@ 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'], - Properties: { 'expanded': GObject.ParamSpec.boolean('expanded', - 'expanded', - 'expanded', - READWRITE, - false), - 'notifications-enabled': GObject.ParamSpec.boolean('notifications-enabled', - 'notifications-enabled', - 'notifications-enabled', - READWRITE, - false) }, + InternalChildren: [ + 'spinnerBox', + 'spinner', + 'detailsGrid', + 'fullnameLabel', + 'lastLabel', + '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) + } }, class UserDetails extends Gtk.Frame { _init(params = {}) { let user = params.user; @@ -226,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() { @@ -293,11 +301,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 +328,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; @@ -408,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); @@ -460,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); @@ -540,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 8548b5b1d5f6cfb02ae4bb1b577ae3589c1a2acc..a77e5ce8569d3f6674686037324d80b6f5827dc5 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) { @@ -255,8 +257,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 +268,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) { @@ -302,13 +306,14 @@ 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)); - - let param = GLib.Variant.new('(ssu)', - [this._account.get_object_path(), - room.channel_name, - Utils.getTpEventTime()]); + 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() + ]); notification.set_default_action_and_target('app.join-room', param); this._app.send_notification(this._getNotifyActionNameInternal(member.alias), notification); @@ -317,8 +322,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) { @@ -342,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 50f43960ce5a3ac9d77571eda513315f46df1a6e..75da4660c06ff9ae6015094eedd55173b95e2035 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); } @@ -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; } @@ -181,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}`); }