cleanup: Avoid unnecessary braces

Our coding style has always been to avoid braces when all blocks
are single-lines.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/805
This commit is contained in:
Florian Müllner 2019-08-20 02:51:42 +02:00 committed by Georges Basile Stavracas Neto
parent 69f63dc94f
commit 67ea424525
38 changed files with 136 additions and 201 deletions

View File

@ -78,11 +78,10 @@ var AuthPrompt = GObject.registerClass({
this.connect('next', () => { this.connect('next', () => {
this.updateSensitivity(false); this.updateSensitivity(false);
this.startSpinning(); this.startSpinning();
if (this._queryingService) { if (this._queryingService)
this._userVerifier.answerQuery(this._queryingService, this._entry.text); this._userVerifier.answerQuery(this._queryingService, this._entry.text);
} else { else
this._preemptiveAnswer = this._entry.text; this._preemptiveAnswer = this._entry.text;
}
}); });
this.connect('destroy', this._onDestroy.bind(this)); this.connect('destroy', this._onDestroy.bind(this));
@ -525,9 +524,9 @@ var AuthPrompt = GObject.registerClass({
} }
cancel() { cancel() {
if (this.verificationStatus == AuthPromptStatus.VERIFICATION_SUCCEEDED) { if (this.verificationStatus == AuthPromptStatus.VERIFICATION_SUCCEEDED)
return; return;
}
this.reset(); this.reset();
this.emit('cancelled'); this.emit('cancelled');
} }

View File

@ -112,13 +112,12 @@ var Batch = class extends Task {
for (let i = 0; i < tasks.length; i++) { for (let i = 0; i < tasks.length; i++) {
let task; let task;
if (tasks[i] instanceof Task) { if (tasks[i] instanceof Task)
task = tasks[i]; task = tasks[i];
} else if (typeof tasks[i] == 'function') { else if (typeof tasks[i] == 'function')
task = new Task(scope, tasks[i]); task = new Task(scope, tasks[i]);
} else { else
throw new Error('Batch tasks must be functions or Task, Hold or Batch objects'); throw new Error('Batch tasks must be functions or Task, Hold or Batch objects');
}
this.tasks.push(task); this.tasks.push(task);
} }
@ -129,9 +128,8 @@ var Batch = class extends Task {
} }
runTask() { runTask() {
if (!(this._currentTaskIndex in this.tasks)) { if (!(this._currentTaskIndex in this.tasks))
return null; return null;
}
return this.tasks[this._currentTaskIndex].run(); return this.tasks[this._currentTaskIndex].run();
} }
@ -179,9 +177,8 @@ var ConcurrentBatch = class extends Batch {
process() { process() {
let hold = this.runTask(); let hold = this.runTask();
if (hold) { if (hold)
this.hold.acquireUntilAfter(hold); this.hold.acquireUntilAfter(hold);
}
// Regardless of the state of the just run task, // Regardless of the state of the just run task,
// fire off the next one, so all the tasks can run // fire off the next one, so all the tasks can run

View File

@ -702,9 +702,8 @@ var LoginDialog = GObject.registerClass({
} }
// Finally hand out the allocations // Finally hand out the allocations
if (bannerAllocation) { if (bannerAllocation)
this._bannerView.allocate(bannerAllocation, flags); this._bannerView.allocate(bannerAllocation, flags);
}
if (authPromptAllocation) if (authPromptAllocation)
this._authPrompt.allocate(authPromptAllocation, flags); this._authPrompt.allocate(authPromptAllocation, flags);
@ -820,9 +819,9 @@ var LoginDialog = GObject.registerClass({
_resetGreeterProxy() { _resetGreeterProxy() {
if (GLib.getenv('GDM_GREETER_TEST') != '1') { if (GLib.getenv('GDM_GREETER_TEST') != '1') {
if (this._greeter) { if (this._greeter)
this._greeter.run_dispose(); this._greeter.run_dispose();
}
this._greeter = this._gdmClient.get_greeter_sync(null); this._greeter = this._gdmClient.get_greeter_sync(null);
this._defaultSessionChangedId = this._greeter.connect('default-session-name-changed', this._defaultSessionChangedId = this._greeter.connect('default-session-name-changed',
@ -1039,9 +1038,8 @@ var LoginDialog = GObject.registerClass({
() => { () => {
// If we're just starting out, start on the right item. // If we're just starting out, start on the right item.
if (!this._userManager.is_loaded) { if (!this._userManager.is_loaded)
this._userList.jumpToItem(loginItem); this._userList.jumpToItem(loginItem);
}
}, },
() => { () => {
@ -1092,9 +1090,8 @@ var LoginDialog = GObject.registerClass({
// Restart timed login on user interaction // Restart timed login on user interaction
global.stage.connect('captured-event', (actor, event) => { global.stage.connect('captured-event', (actor, event) => {
if (event.type() == Clutter.EventType.KEY_PRESS || if (event.type() == Clutter.EventType.KEY_PRESS ||
event.type() == Clutter.EventType.BUTTON_PRESS) { event.type() == Clutter.EventType.BUTTON_PRESS)
this._startTimedLogin(userName, seconds); this._startTimedLogin(userName, seconds);
}
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
}); });
@ -1201,9 +1198,8 @@ var LoginDialog = GObject.registerClass({
let users = this._userManager.list_users(); let users = this._userManager.list_users();
for (let i = 0; i < users.length; i++) { for (let i = 0; i < users.length; i++)
this._userList.addUser(users[i]); this._userList.addUser(users[i]);
}
this._updateDisableUserList(); this._updateDisableUserList();

View File

@ -571,9 +571,8 @@ var ShellUserVerifier = class {
// if the password service fails, then cancel everything. // if the password service fails, then cancel everything.
// But if, e.g., fingerprint fails, still give // But if, e.g., fingerprint fails, still give
// password authentication a chance to succeed // password authentication a chance to succeed
if (this.serviceIsForeground(serviceName)) { if (this.serviceIsForeground(serviceName))
this._verificationFailed(true); this._verificationFailed(true);
} }
}
}; };
Signals.addSignalMethods(ShellUserVerifier.prototype); Signals.addSignalMethods(ShellUserVerifier.prototype);

View File

@ -82,11 +82,11 @@ var HistoryManager = class {
_onEntryKeyPress(entry, event) { _onEntryKeyPress(entry, event) {
let symbol = event.get_key_symbol(); let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Up) { if (symbol == Clutter.KEY_Up)
return this._setPrevItem(entry.get_text()); return this._setPrevItem(entry.get_text());
} else if (symbol == Clutter.KEY_Down) { else if (symbol == Clutter.KEY_Down)
return this._setNextItem(entry.get_text()); return this._setNextItem(entry.get_text());
}
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }

View File

@ -11,9 +11,8 @@ function getCompletions(text, commandHeader, globalCompletionList) {
let methods = []; let methods = [];
let expr_, base; let expr_, base;
let attrHead = ''; let attrHead = '';
if (globalCompletionList == null) { if (globalCompletionList == null)
globalCompletionList = []; globalCompletionList = [];
}
let offset = getExpressionOffset(text, text.length - 1); let offset = getExpressionOffset(text, text.length - 1);
if (offset >= 0) { if (offset >= 0) {
@ -59,20 +58,18 @@ function isStopChar(c) {
function findMatchingQuote(expr, offset) { function findMatchingQuote(expr, offset) {
let quoteChar = expr.charAt(offset); let quoteChar = expr.charAt(offset);
for (let i = offset - 1; i >= 0; --i) { for (let i = offset - 1; i >= 0; --i) {
if (expr.charAt(i) == quoteChar && expr.charAt(i - 1) != '\\') { if (expr.charAt(i) == quoteChar && expr.charAt(i - 1) != '\\')
return i; return i;
} }
}
return -1; return -1;
} }
// Given the ending position of a regex, find where it starts // Given the ending position of a regex, find where it starts
function findMatchingSlash(expr, offset) { function findMatchingSlash(expr, offset) {
for (let i = offset - 1; i >= 0; --i) { for (let i = offset - 1; i >= 0; --i) {
if (expr.charAt(i) == '/' && expr.charAt(i - 1) != '\\') { if (expr.charAt(i) == '/' && expr.charAt(i - 1) != '\\')
return i; return i;
} }
}
return -1; return -1;
} }
@ -117,13 +114,11 @@ function getExpressionOffset(expr, offset) {
while (offset >= 0) { while (offset >= 0) {
let currChar = expr.charAt(offset); let currChar = expr.charAt(offset);
if (isStopChar(currChar)) { if (isStopChar(currChar))
return offset + 1; return offset + 1;
}
if (currChar.match(/[)\]]/)) { if (currChar.match(/[)\]]/))
offset = findMatchingBrace(expr, offset); offset = findMatchingBrace(expr, offset);
}
--offset; --offset;
} }
@ -140,9 +135,9 @@ function isValidPropertyName(w) {
// To get all properties (enumerable and not), we need to walk // To get all properties (enumerable and not), we need to walk
// the prototype chain ourselves // the prototype chain ourselves
function getAllProps(obj) { function getAllProps(obj) {
if (obj === null || obj === undefined) { if (obj === null || obj === undefined)
return []; return [];
}
return Object.getOwnPropertyNames(obj).concat( getAllProps(Object.getPrototypeOf(obj)) ); return Object.getOwnPropertyNames(obj).concat( getAllProps(Object.getPrototypeOf(obj)) );
} }

View File

@ -192,9 +192,8 @@ var ObjectManager = class {
_onNameAppeared() { _onNameAppeared() {
this._managerProxy.GetManagedObjectsRemote((result, error) => { this._managerProxy.GetManagedObjectsRemote((result, error) => {
if (!result) { if (!result) {
if (error) { if (error)
logError(error, `could not get remote objects for service ${this._serviceName} path ${this._managerPath}`); logError(error, `could not get remote objects for service ${this._serviceName} path ${this._managerPath}`);
}
this._tryToCompleteLoad(); this._tryToCompleteLoad();
return; return;

View File

@ -72,12 +72,11 @@ var SmartcardManager = class {
if ('IsInserted' in properties.deep_unpack()) { if ('IsInserted' in properties.deep_unpack()) {
this._updateToken(token); this._updateToken(token);
if (token.IsInserted) { if (token.IsInserted)
this.emit('smartcard-inserted', token); this.emit('smartcard-inserted', token);
} else { else
this.emit('smartcard-removed', token); this.emit('smartcard-removed', token);
} }
}
}); });
// Emit a smartcard-inserted at startup if it's already plugged in // Emit a smartcard-inserted at startup if it's already plugged in

View File

@ -174,11 +174,10 @@ function script_applicationsShowDone(time) {
} }
function script_afterShowHide(_time) { function script_afterShowHide(_time) {
if (overviewShowCount == 1) { if (overviewShowCount == 1)
METRICS.usedAfterOverview.value = mallocUsedSize; METRICS.usedAfterOverview.value = mallocUsedSize;
} else { else
METRICS.leakedAfterOverview.value = mallocUsedSize - METRICS.usedAfterOverview.value; METRICS.leakedAfterOverview.value = mallocUsedSize - METRICS.usedAfterOverview.value;
}
} }
function malloc_usedSize(time, bytes) { function malloc_usedSize(time, bytes) {

View File

@ -722,9 +722,9 @@ class AppSwitcher extends SwitcherPopup.SwitcherList {
_setIconSize() { _setIconSize() {
let j = 0; let j = 0;
while (this._items.length > 1 && this._items[j].style_class != 'item-box') { while (this._items.length > 1 && this._items[j].style_class != 'item-box')
j++; j++;
}
let themeNode = this._items[j].get_theme_node(); let themeNode = this._items[j].get_theme_node();
this._list.ensure_style(); this._list.ensure_style();

View File

@ -110,10 +110,9 @@ function _findBestFolderName(apps) {
// If a category is present in all apps, its counter will // If a category is present in all apps, its counter will
// reach appInfos.length // reach appInfos.length
if (category.length > 0 && if (category.length > 0 &&
categoryCounter[category] == appInfos.length) { categoryCounter[category] == appInfos.length)
categories.push(category); categories.push(category);
} }
}
return categories; return categories;
}, commonCategories); }, commonCategories);
@ -764,9 +763,8 @@ var AllView = GObject.registerClass({
// Within the grid boundaries, or already animating // Within the grid boundaries, or already animating
if (dragEvent.y > gridY && dragEvent.y < gridBottom || if (dragEvent.y > gridY && dragEvent.y < gridBottom ||
this._adjustment.get_transition('value') != null) { this._adjustment.get_transition('value') != null)
return; return;
}
// Moving above the grid // Moving above the grid
let currentY = this._adjustment.value; let currentY = this._adjustment.value;
@ -777,10 +775,9 @@ var AllView = GObject.registerClass({
// Moving below the grid // Moving below the grid
let maxY = this._adjustment.upper - this._adjustment.page_size; let maxY = this._adjustment.upper - this._adjustment.page_size;
if (dragEvent.y >= gridBottom && currentY < maxY) { if (dragEvent.y >= gridBottom && currentY < maxY)
this.goToPage(this._grid.currentPage + 1); this.goToPage(this._grid.currentPage + 1);
} }
}
_onDragBegin() { _onDragBegin() {
this._dragMonitor = { this._dragMonitor = {
@ -2257,12 +2254,11 @@ var AppIcon = GObject.registerClass({
} }
activateWindow(metaWindow) { activateWindow(metaWindow) {
if (metaWindow) { if (metaWindow)
Main.activateWindow(metaWindow); Main.activateWindow(metaWindow);
} else { else
Main.overview.hide(); Main.overview.hide();
} }
}
_onMenuPoppedDown() { _onMenuPoppedDown() {
this.sync_hover(); this.sync_hover();

View File

@ -269,9 +269,9 @@ var Background = GObject.registerClass({
let i; let i;
let keys = Object.keys(this._fileWatches); let keys = Object.keys(this._fileWatches);
for (i = 0; i < keys.length; i++) { for (i = 0; i < keys.length; i++)
this._cache.disconnect(this._fileWatches[keys[i]]); this._cache.disconnect(this._fileWatches[keys[i]]);
}
this._fileWatches = null; this._fileWatches = null;
if (this._timezoneChangedId != 0) if (this._timezoneChangedId != 0)

View File

@ -247,12 +247,11 @@ var BoxPointer = GObject.registerClass({
let [absX, absY] = this.get_transformed_position(); let [absX, absY] = this.get_transformed_position();
if (this._arrowSide == St.Side.TOP || if (this._arrowSide == St.Side.TOP ||
this._arrowSide == St.Side.BOTTOM) { this._arrowSide == St.Side.BOTTOM)
this._arrowOrigin = sourceX - absX + sourceWidth / 2; this._arrowOrigin = sourceX - absX + sourceWidth / 2;
} else { else
this._arrowOrigin = sourceY - absY + sourceHeight / 2; this._arrowOrigin = sourceY - absY + sourceHeight / 2;
} }
}
let borderWidth = themeNode.get_length('-arrow-border-width'); let borderWidth = themeNode.get_length('-arrow-border-width');
let base = themeNode.get_length('-arrow-base'); let base = themeNode.get_length('-arrow-base');
@ -266,20 +265,19 @@ var BoxPointer = GObject.registerClass({
let [width, height] = area.get_surface_size(); let [width, height] = area.get_surface_size();
let [boxWidth, boxHeight] = [width, height]; let [boxWidth, boxHeight] = [width, height];
if (this._arrowSide == St.Side.TOP || this._arrowSide == St.Side.BOTTOM) { if (this._arrowSide == St.Side.TOP || this._arrowSide == St.Side.BOTTOM)
boxHeight -= rise; boxHeight -= rise;
} else { else
boxWidth -= rise; boxWidth -= rise;
}
let cr = area.get_context(); let cr = area.get_context();
// Translate so that box goes from 0,0 to boxWidth,boxHeight, // Translate so that box goes from 0,0 to boxWidth,boxHeight,
// with the arrow poking out of that // with the arrow poking out of that
if (this._arrowSide == St.Side.TOP) { if (this._arrowSide == St.Side.TOP)
cr.translate(0, rise); cr.translate(0, rise);
} else if (this._arrowSide == St.Side.LEFT) { else if (this._arrowSide == St.Side.LEFT)
cr.translate(rise, 0); cr.translate(rise, 0);
}
let [x1, y1] = [halfBorder, halfBorder]; let [x1, y1] = [halfBorder, halfBorder];
let [x2, y2] = [boxWidth - halfBorder, boxHeight - halfBorder]; let [x2, y2] = [boxWidth - halfBorder, boxHeight - halfBorder];

View File

@ -326,10 +326,9 @@ class DBusEventSource extends EventSourceBase {
for (let n = 0; n < this._events.length; n++) { for (let n = 0; n < this._events.length; n++) {
let event = this._events[n]; let event = this._events[n];
if (_dateIntervalsOverlap (event.date, event.end, begin, end)) { if (_dateIntervalsOverlap(event.date, event.end, begin, end))
result.push(event); result.push(event);
} }
}
result.sort((event1, event2) => { result.sort((event1, event2) => {
// sort events by end time on ending day // sort events by end time on ending day
let d1 = event1.date < begin && event1.end <= end ? event1.end : event1.date; let d1 = event1.date < begin && event1.end <= end ? event1.end : event1.date;

View File

@ -58,9 +58,8 @@ var AutomountManager = class {
_InhibitorsChanged(_object, _senderName, [_inhibitor]) { _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT, this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
(result, error) => { (result, error) => {
if (!error) { if (!error)
this._inhibited = result[0]; this._inhibited = result[0];
}
}); });
} }

View File

@ -245,11 +245,10 @@ var AutorunDispatcher = class {
let success = false; let success = false;
let app = null; let app = null;
if (setting == AutorunSetting.RUN) { if (setting == AutorunSetting.RUN)
app = Gio.app_info_get_default_for_type(contentTypes[0], false); app = Gio.app_info_get_default_for_type(contentTypes[0], false);
} else if (setting == AutorunSetting.FILES) { else if (setting == AutorunSetting.FILES)
app = Gio.app_info_get_default_for_type('inode/directory', false); app = Gio.app_info_get_default_for_type('inode/directory', false);
}
if (app) if (app)
success = startAppForMount(app, mount); success = startAppForMount(app, mount);

View File

@ -349,12 +349,11 @@ class ChatSource extends MessageTray.Source {
getIcon() { getIcon() {
let file = this._contact.get_avatar_file(); let file = this._contact.get_avatar_file();
if (file) { if (file)
return new Gio.FileIcon({ file: file }); return new Gio.FileIcon({ file: file });
} else { else
return new Gio.ThemedIcon({ name: 'avatar-default' }); return new Gio.ThemedIcon({ name: 'avatar-default' });
} }
}
getSecondaryIcon() { getSecondaryIcon() {
let iconName; let iconName;

View File

@ -16,11 +16,10 @@ var DASH_ITEM_LABEL_HIDE_TIME = 100;
var DASH_ITEM_HOVER_TIMEOUT = 300; var DASH_ITEM_HOVER_TIMEOUT = 300;
function getAppFromSource(source) { function getAppFromSource(source) {
if (source instanceof AppDisplay.AppIcon) { if (source instanceof AppDisplay.AppIcon)
return source.app; return source.app;
} else { else
return null; return null;
}
} }
var DashIcon = GObject.registerClass( var DashIcon = GObject.registerClass(
@ -755,9 +754,8 @@ var Dash = GObject.registerClass({
if (!this._shownInitially) if (!this._shownInitially)
this._shownInitially = true; this._shownInitially = true;
for (let i = 0; i < addedItems.length; i++) { for (let i = 0; i < addedItems.length; i++)
addedItems[i].item.show(animate); addedItems[i].item.show(animate);
}
// Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=692744 // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=692744
// Without it, StBoxLayout may use a stale size cache // Without it, StBoxLayout may use a stale size cache
@ -865,9 +863,8 @@ var Dash = GObject.registerClass({
let app = getAppFromSource(source); let app = getAppFromSource(source);
// Don't allow favoriting of transient apps // Don't allow favoriting of transient apps
if (app == null || app.is_window_backed()) { if (app == null || app.is_window_backed())
return false; return false;
}
if (!global.settings.is_writable('favorite-apps')) if (!global.settings.is_writable('favorite-apps'))
return false; return false;

View File

@ -635,11 +635,11 @@ class DateMenuButton extends PanelMenu.Button {
_sessionUpdated() { _sessionUpdated() {
let eventSource; let eventSource;
let showEvents = Main.sessionMode.showCalendarEvents; let showEvents = Main.sessionMode.showCalendarEvents;
if (showEvents) { if (showEvents)
eventSource = this._getEventSource(); eventSource = this._getEventSource();
} else { else
eventSource = new Calendar.EmptyEventSource(); eventSource = new Calendar.EmptyEventSource();
}
this._setEventSource(eventSource); this._setEventSource(eventSource);
// Displays are not actually expected to launch Settings when activated // Displays are not actually expected to launch Settings when activated

View File

@ -258,11 +258,11 @@ var _Draggable = class _Draggable {
} else if (event.type() == Clutter.EventType.MOTION || } else if (event.type() == Clutter.EventType.MOTION ||
(event.type() == Clutter.EventType.TOUCH_UPDATE && (event.type() == Clutter.EventType.TOUCH_UPDATE &&
global.display.is_pointer_emulating_sequence(event.get_event_sequence()))) { global.display.is_pointer_emulating_sequence(event.get_event_sequence()))) {
if (this._dragActor && this._dragState == DragState.DRAGGING) { if (this._dragActor && this._dragState == DragState.DRAGGING)
return this._updateDragPosition(event); return this._updateDragPosition(event);
} else if (this._dragActor == null && this._dragState != DragState.CANCELLED) { else if (this._dragActor == null && this._dragState != DragState.CANCELLED)
return this._maybeStartDrag(event); return this._maybeStartDrag(event);
}
// We intercept KEY_PRESS event so that we can process Esc key press to cancel // We intercept KEY_PRESS event so that we can process Esc key press to cancel
// dragging and ignore all other key presses. // dragging and ignore all other key presses.
} else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragState == DragState.DRAGGING) { } else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragState == DragState.DRAGGING) {

View File

@ -200,9 +200,8 @@ var ExtensionManager = class {
createExtensionObject(uuid, dir, type) { createExtensionObject(uuid, dir, type) {
let metadataFile = dir.get_child('metadata.json'); let metadataFile = dir.get_child('metadata.json');
if (!metadataFile.query_exists(null)) { if (!metadataFile.query_exists(null))
throw new Error('Missing metadata.json'); throw new Error('Missing metadata.json');
}
let metadataContents, success_; let metadataContents, success_;
try { try {
@ -222,14 +221,12 @@ var ExtensionManager = class {
let requiredProperties = ['uuid', 'name', 'description', 'shell-version']; let requiredProperties = ['uuid', 'name', 'description', 'shell-version'];
for (let i = 0; i < requiredProperties.length; i++) { for (let i = 0; i < requiredProperties.length; i++) {
let prop = requiredProperties[i]; let prop = requiredProperties[i];
if (!meta[prop]) { if (!meta[prop])
throw new Error(`missing "${prop}" property in metadata.json`); throw new Error(`missing "${prop}" property in metadata.json`);
} }
}
if (uuid != meta.uuid) { if (uuid != meta.uuid)
throw new Error(`uuid "${meta.uuid}" from metadata.json does not match directory name "${uuid}"`); throw new Error(`uuid "${meta.uuid}" from metadata.json does not match directory name "${uuid}"`);
}
let extension = { let extension = {
metadata: meta, metadata: meta,

View File

@ -815,9 +815,9 @@ var IconGrid = GObject.registerClass({
this._updateIconSizesLaterId = 0; this._updateIconSizesLaterId = 0;
let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, this._vItemSize); let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, this._vItemSize);
let newIconSize = Math.floor(ICON_SIZE * scale); let newIconSize = Math.floor(ICON_SIZE * scale);
for (let i in this._items) { for (let i in this._items)
this._items[i].icon.setIconSize(newIconSize); this._items[i].icon.setIconSize(newIconSize);
}
return GLib.SOURCE_REMOVE; return GLib.SOURCE_REMOVE;
} }
}); });
@ -879,9 +879,9 @@ var PaginatedIconGrid = GObject.registerClass({
children[i].show(); children[i].show();
columnIndex++; columnIndex++;
if (columnIndex == nColumns) { if (columnIndex == nColumns)
columnIndex = 0; columnIndex = 0;
}
if (columnIndex == 0) { if (columnIndex == 0) {
y += this._getVItemSize() + spacing; y += this._getVItemSize() + spacing;
if ((i + 1) % this._childrenPerPage == 0) if ((i + 1) % this._childrenPerPage == 0)

View File

@ -311,9 +311,8 @@ var Key = GObject.registerClass({
_press(key) { _press(key) {
this.emit('activated'); this.emit('activated');
if (key != this.key || this._extended_keys.length == 0) { if (key != this.key || this._extended_keys.length == 0)
this.emit('pressed', this._getKeyval(key), key); this.emit('pressed', this._getKeyval(key), key);
}
if (key == this.key) { if (key == this.key) {
this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,

View File

@ -54,9 +54,9 @@ var AutoComplete = class AutoComplete {
} }
_processCompletionRequest(event) { _processCompletionRequest(event) {
if (event.completions.length == 0) { if (event.completions.length == 0)
return; return;
}
// Unique match = go ahead and complete; multiple matches + single tab = complete the common starting string; // Unique match = go ahead and complete; multiple matches + single tab = complete the common starting string;
// multiple matches + double tab = emit a suggest event with all possible options // multiple matches + double tab = emit a suggest event with all possible options
if (event.completions.length == 1) { if (event.completions.length == 1) {
@ -78,10 +78,10 @@ var AutoComplete = class AutoComplete {
_entryKeyPressEvent(actor, event) { _entryKeyPressEvent(actor, event) {
let cursorPos = this._entry.clutter_text.get_cursor_position(); let cursorPos = this._entry.clutter_text.get_cursor_position();
let text = this._entry.get_text(); let text = this._entry.get_text();
if (cursorPos != -1) { if (cursorPos != -1)
text = text.slice(0, cursorPos); text = text.slice(0, cursorPos);
}
if (event.get_key_symbol() === Clutter.KEY_Tab) { if (event.get_key_symbol() == Clutter.KEY_Tab) {
let [completions, attrHead] = JsParse.getCompletions(text, commandHeader, AUTO_COMPLETE_GLOBAL_KEYWORDS); let [completions, attrHead] = JsParse.getCompletions(text, commandHeader, AUTO_COMPLETE_GLOBAL_KEYWORDS);
let currTime = global.get_current_time(); let currTime = global.get_current_time();
if ((currTime - this._lastTabTime) < AUTO_COMPLETE_DOUBLE_TAB_DELAY) { if ((currTime - this._lastTabTime) < AUTO_COMPLETE_DOUBLE_TAB_DELAY) {
@ -224,18 +224,16 @@ var Notebook = GObject.registerClass({
nextTab() { nextTab() {
let nextIndex = this._selectedIndex; let nextIndex = this._selectedIndex;
if (nextIndex < this._tabs.length - 1) { if (nextIndex < this._tabs.length - 1)
++nextIndex; ++nextIndex;
}
this.selectIndex(nextIndex); this.selectIndex(nextIndex);
} }
prevTab() { prevTab() {
let prevIndex = this._selectedIndex; let prevIndex = this._selectedIndex;
if (prevIndex > 0) { if (prevIndex > 0)
--prevIndex; --prevIndex;
}
this.selectIndex(prevIndex); this.selectIndex(prevIndex);
} }
@ -412,9 +410,8 @@ class ObjInspector extends St.ScrollView {
hbox.add(button); hbox.add(button);
if (typeof obj == typeof {}) { if (typeof obj == typeof {}) {
let properties = []; let properties = [];
for (let propName in obj) { for (let propName in obj)
properties.push(propName); properties.push(propName);
}
properties.sort(); properties.sort();
for (let i = 0; i < properties.length; i++) { for (let i = 0; i < properties.length; i++) {
@ -1096,22 +1093,20 @@ class LookingGlass extends St.BoxLayout {
// Handle key events which are relevant for all tabs of the LookingGlass // Handle key events which are relevant for all tabs of the LookingGlass
vfunc_key_press_event(keyPressEvent) { vfunc_key_press_event(keyPressEvent) {
let symbol = keyPressEvent.keyval; let symbol = keyPressEvent.keyval;
if (symbol === Clutter.KEY_Escape) { if (symbol == Clutter.KEY_Escape) {
if (this._objInspector.visible) { if (this._objInspector.visible)
this._objInspector.close(); this._objInspector.close();
} else { else
this.close(); this.close();
}
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }
// Ctrl+PgUp and Ctrl+PgDown switches tabs in the notebook view // Ctrl+PgUp and Ctrl+PgDown switches tabs in the notebook view
if (keyPressEvent.modifier_state & Clutter.ModifierType.CONTROL_MASK) { if (keyPressEvent.modifier_state & Clutter.ModifierType.CONTROL_MASK) {
if (symbol == Clutter.KEY_Page_Up) { if (symbol == Clutter.KEY_Page_Up)
this._notebook.prevTab(); this._notebook.prevTab();
} else if (symbol == Clutter.KEY_Page_Down) { else if (symbol == Clutter.KEY_Page_Down)
this._notebook.nextTab(); this._notebook.nextTab();
} }
}
return Clutter.EVENT_PROPAGATE; return Clutter.EVENT_PROPAGATE;
} }

View File

@ -623,10 +623,9 @@ var Magnifier = class Magnifier {
_updateLensMode() { _updateLensMode() {
// Applies only to the first zoom region. // Applies only to the first zoom region.
if (this._zoomRegions.length) { if (this._zoomRegions.length)
this._zoomRegions[0].setLensMode(this._settings.get_boolean(LENS_MODE_KEY)); this._zoomRegions[0].setLensMode(this._settings.get_boolean(LENS_MODE_KEY));
} }
}
_updateClampMode() { _updateClampMode() {
// Applies only to the first zoom region. // Applies only to the first zoom region.
@ -1182,10 +1181,9 @@ var ZoomRegion = class ZoomRegion {
// If the crossHairs is not already within a larger container, add it // If the crossHairs is not already within a larger container, add it
// to this zoom region. Otherwise, add a clone. // to this zoom region. Otherwise, add a clone.
if (crossHairs && this.isActive()) { if (crossHairs && this.isActive())
this._crossHairsActor = crossHairs.addToZoomRegion(this, this._mouseActor); this._crossHairsActor = crossHairs.addToZoomRegion(this, this._mouseActor);
} }
}
/** /**
* setInvertLightness: * setInvertLightness:
@ -1448,13 +1446,12 @@ var ZoomRegion = class ZoomRegion {
let xMouse = this._magnifier.xMouse; let xMouse = this._magnifier.xMouse;
let yMouse = this._magnifier.yMouse; let yMouse = this._magnifier.yMouse;
if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.PROPORTIONAL) { if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.PROPORTIONAL)
return this._centerFromPointProportional(xMouse, yMouse); return this._centerFromPointProportional(xMouse, yMouse);
} else if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.PUSH) { else if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.PUSH)
return this._centerFromPointPush(xMouse, yMouse); return this._centerFromPointPush(xMouse, yMouse);
} else if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.CENTERED) { else if (this._mouseTrackingMode == GDesktopEnums.MagnifierMouseTrackingMode.CENTERED)
return this._centerFromPointCentered(xMouse, yMouse); return this._centerFromPointCentered(xMouse, yMouse);
}
return null; // Should never be hit return null; // Should never be hit
} }

View File

@ -248,12 +248,12 @@ function _initializeUI() {
} }
layoutManager.connect('startup-complete', () => { layoutManager.connect('startup-complete', () => {
if (actionMode == Shell.ActionMode.NONE) { if (actionMode == Shell.ActionMode.NONE)
actionMode = Shell.ActionMode.NORMAL; actionMode = Shell.ActionMode.NORMAL;
}
if (screenShield) { if (screenShield)
screenShield.lockIfWasLocked(); screenShield.lockIfWasLocked();
}
if (sessionMode.currentMode != 'gdm' && if (sessionMode.currentMode != 'gdm' &&
sessionMode.currentMode != 'initial-setup') { sessionMode.currentMode != 'initial-setup') {
GLib.log_structured(LOG_DOMAIN, GLib.LogLevelFlags.LEVEL_MESSAGE, { GLib.log_structured(LOG_DOMAIN, GLib.LogLevelFlags.LEVEL_MESSAGE, {
@ -573,16 +573,16 @@ function popModal(actor, timestamp) {
} }
function createLookingGlass() { function createLookingGlass() {
if (lookingGlass == null) { if (lookingGlass == null)
lookingGlass = new LookingGlass.LookingGlass(); lookingGlass = new LookingGlass.LookingGlass();
}
return lookingGlass; return lookingGlass;
} }
function openRunDialog() { function openRunDialog() {
if (runDialog == null) { if (runDialog == null)
runDialog = new RunDialog.RunDialog(); runDialog = new RunDialog.RunDialog();
}
runDialog.open(); runDialog.open();
} }

View File

@ -856,12 +856,11 @@ var Source = GObject.registerClass({
notification.acknowledged = false; notification.acknowledged = false;
this.pushNotification(notification); this.pushNotification(notification);
if (this.policy.showBanners || notification.urgency == Urgency.CRITICAL) { if (this.policy.showBanners || notification.urgency == Urgency.CRITICAL)
this.emit('notification-show', notification); this.emit('notification-show', notification);
} else { else
notification.playSound(); notification.playSound();
} }
}
notify(propName) { notify(propName) {
if (propName instanceof Notification) { if (propName instanceof Notification) {

View File

@ -179,11 +179,10 @@ class SlidingControl extends St.Widget {
let translation = this._getTranslation(); let translation = this._getTranslation();
let shouldShow = (this._getSlide() > 0); let shouldShow = (this._getSlide() > 0);
if (shouldShow) { if (shouldShow)
translationStart = translation; translationStart = translation;
} else { else
translationEnd = translation; translationEnd = translation;
}
if (this.layout.translation_x == translationEnd) if (this.layout.translation_x == translationEnd)
return; return;

View File

@ -708,16 +708,15 @@ class AggregateMenu extends PanelMenu.Button {
this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' }); this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' });
this.add_child(this._indicators); this.add_child(this._indicators);
if (Config.HAVE_NETWORKMANAGER) { if (Config.HAVE_NETWORKMANAGER)
this._network = new imports.ui.status.network.NMApplet(); this._network = new imports.ui.status.network.NMApplet();
} else { else
this._network = null; this._network = null;
}
if (Config.HAVE_BLUETOOTH) { if (Config.HAVE_BLUETOOTH)
this._bluetooth = new imports.ui.status.bluetooth.Indicator(); this._bluetooth = new imports.ui.status.bluetooth.Indicator();
} else { else
this._bluetooth = null; this._bluetooth = null;
}
this._remoteAccess = new imports.ui.status.remoteAccess.RemoteAccessApplet(); this._remoteAccess = new imports.ui.status.remoteAccess.RemoteAccessApplet();
this._power = new imports.ui.status.power.Indicator(); this._power = new imports.ui.status.power.Indicator();
@ -734,12 +733,10 @@ class AggregateMenu extends PanelMenu.Button {
this._indicators.add_child(this._screencast); this._indicators.add_child(this._screencast);
this._indicators.add_child(this._location); this._indicators.add_child(this._location);
this._indicators.add_child(this._nightLight); this._indicators.add_child(this._nightLight);
if (this._network) { if (this._network)
this._indicators.add_child(this._network); this._indicators.add_child(this._network);
} if (this._bluetooth)
if (this._bluetooth) {
this._indicators.add_child(this._bluetooth); this._indicators.add_child(this._bluetooth);
}
this._indicators.add_child(this._remoteAccess); this._indicators.add_child(this._remoteAccess);
this._indicators.add_child(this._rfkill); this._indicators.add_child(this._rfkill);
this._indicators.add_child(this._volume); this._indicators.add_child(this._volume);
@ -749,12 +746,12 @@ class AggregateMenu extends PanelMenu.Button {
this.menu.addMenuItem(this._volume.menu); this.menu.addMenuItem(this._volume.menu);
this.menu.addMenuItem(this._brightness.menu); this.menu.addMenuItem(this._brightness.menu);
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
if (this._network) { if (this._network)
this.menu.addMenuItem(this._network.menu); this.menu.addMenuItem(this._network.menu);
}
if (this._bluetooth) { if (this._bluetooth)
this.menu.addMenuItem(this._bluetooth.menu); this.menu.addMenuItem(this._bluetooth.menu);
}
this.menu.addMenuItem(this._remoteAccess.menu); this.menu.addMenuItem(this._remoteAccess.menu);
this.menu.addMenuItem(this._location.menu); this.menu.addMenuItem(this._location.menu);
this.menu.addMenuItem(this._rfkill.menu); this.menu.addMenuItem(this._rfkill.menu);

View File

@ -175,12 +175,11 @@ class RunDialog extends ModalDialog.ModalDialog {
} }
_getCompletion(text) { _getCompletion(text) {
if (text.includes('/')) { if (text.includes('/'))
return this._pathCompleter.get_completion_suffix(text); return this._pathCompleter.get_completion_suffix(text);
} else { else
return this._getCommandCompletion(text); return this._getCommandCompletion(text);
} }
}
_run(input, inTerminal) { _run(input, inTerminal) {
let command = input; let command = input;

View File

@ -123,10 +123,9 @@ var NotificationsBox = GObject.registerClass({
} }
let items = this._sources.entries(); let items = this._sources.entries();
for (let [source, obj] of items) { for (let [source, obj] of items)
this._removeSource(source, obj); this._removeSource(source, obj);
} }
}
_updateVisibility() { _updateVisibility() {
this._notificationBox.visible = this._notificationBox.visible =
@ -205,11 +204,10 @@ var NotificationsBox = GObject.registerClass({
} }
_showSource(source, obj, box) { _showSource(source, obj, box) {
if (obj.detailed) { if (obj.detailed)
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box); [obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
} else { else
[obj.titleLabel, obj.countLabel] = this._makeNotificationSource(source, box); [obj.titleLabel, obj.countLabel] = this._makeNotificationSource(source, box);
}
box.visible = obj.visible && (source.unseenCount > 0); box.visible = obj.visible && (source.unseenCount > 0);
} }
@ -704,9 +702,8 @@ var ScreenShield = class {
this._lockScreenScrollCounter += delta; this._lockScreenScrollCounter += delta;
// 7 standard scrolls to lift up // 7 standard scrolls to lift up
if (this._lockScreenScrollCounter > 35) { if (this._lockScreenScrollCounter > 35)
this._liftShield(true, 0); this._liftShield(true, 0);
}
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} }

View File

@ -87,9 +87,8 @@ class ListSearchResult extends SearchResult {
// An icon for, or thumbnail of, content // An icon for, or thumbnail of, content
let icon = this.metaInfo['createIcon'](this.ICON_SIZE); let icon = this.metaInfo['createIcon'](this.ICON_SIZE);
if (icon) { if (icon)
titleBox.add(icon); titleBox.add(icon);
}
let title = new St.Label({ let title = new St.Label({
text: this.metaInfo['name'], text: this.metaInfo['name'],
@ -689,13 +688,12 @@ var SearchResultsView = GObject.registerClass({
this._statusBin.visible = !haveResults; this._statusBin.visible = !haveResults;
if (!haveResults) { if (!haveResults) {
if (this.searchInProgress) { if (this.searchInProgress)
this._statusText.set_text(_("Searching…")); this._statusText.set_text(_("Searching…"));
} else { else
this._statusText.set_text(_("No results.")); this._statusText.set_text(_("No results."));
} }
} }
}
_updateResults(provider, results) { _updateResults(provider, results) {
let terms = this._terms; let terms = this._terms;

View File

@ -362,9 +362,8 @@ var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
if the reason is no secrets, as that indicates the user if the reason is no secrets, as that indicates the user
cancelled the agent dialog */ cancelled the agent dialog */
if (newstate == NM.DeviceState.FAILED && if (newstate == NM.DeviceState.FAILED &&
reason != NM.DeviceStateReason.NO_SECRETS) { reason != NM.DeviceStateReason.NO_SECRETS)
this.emit('activation-failed', reason); this.emit('activation-failed', reason);
}
this._sync(); this._sync();
} }
@ -1053,9 +1052,8 @@ class NMWirelessDialog extends ModalDialog.ModalDialog {
_checkConnections(network, accessPoint) { _checkConnections(network, accessPoint) {
this._connections.forEach(connection => { this._connections.forEach(connection => {
if (accessPoint.connection_valid(connection) && if (accessPoint.connection_valid(connection) &&
!network.connections.includes(connection)) { !network.connections.includes(connection))
network.connections.push(connection); network.connections.push(connection);
}
}); });
} }
@ -1241,9 +1239,8 @@ var NMDeviceWireless = class {
if the reason is no secrets, as that indicates the user if the reason is no secrets, as that indicates the user
cancelled the agent dialog */ cancelled the agent dialog */
if (newstate == NM.DeviceState.FAILED && if (newstate == NM.DeviceState.FAILED &&
reason != NM.DeviceStateReason.NO_SECRETS) { reason != NM.DeviceStateReason.NO_SECRETS)
this.emit('activation-failed', reason); this.emit('activation-failed', reason);
}
this._sync(); this._sync();
} }
@ -1511,9 +1508,9 @@ var NMVpnSection = class extends NMConnectionSection {
setActiveConnections(vpnConnections) { setActiveConnections(vpnConnections) {
let connections = this._connectionItems.values(); let connections = this._connectionItems.values();
for (let item of connections) { for (let item of connections)
item.setActiveConnection(null); item.setActiveConnection(null);
}
vpnConnections.forEach(a => { vpnConnections.forEach(a => {
if (a.connection) { if (a.connection) {
let item = this._connectionItems.get(a.connection.get_uuid()); let item = this._connectionItems.get(a.connection.get_uuid());

View File

@ -59,9 +59,8 @@ var StreamSlider = class {
} }
set stream(stream) { set stream(stream) {
if (this._stream) { if (this._stream)
this._disconnectStream(this._stream); this._disconnectStream(this._stream);
}
this._stream = stream; this._stream = stream;

View File

@ -85,11 +85,10 @@ var ShowOverviewAction = GObject.registerClass({
for (let i = 0; i < this.get_n_current_points(); i++) { for (let i = 0; i < this.get_n_current_points(); i++) {
let x, y; let x, y;
if (motion == true) { if (motion == true)
[x, y] = this.get_motion_coords(i); [x, y] = this.get_motion_coords(i);
} else { else
[x, y] = this.get_press_coords(i); [x, y] = this.get_press_coords(i);
}
if (i == 0) { if (i == 0) {
minX = maxX = x; minX = maxX = x;

View File

@ -1023,9 +1023,8 @@ var WindowManager = class {
this._gsdWacomProxy = new GsdWacomProxy(Gio.DBus.session, GSD_WACOM_BUS_NAME, this._gsdWacomProxy = new GsdWacomProxy(Gio.DBus.session, GSD_WACOM_BUS_NAME,
GSD_WACOM_OBJECT_PATH, GSD_WACOM_OBJECT_PATH,
(proxy, error) => { (proxy, error) => {
if (error) { if (error)
log(error.message); log(error.message);
}
}); });
global.display.connect('pad-mode-switch', (display, pad, group, mode) => { global.display.connect('pad-mode-switch', (display, pad, group, mode) => {
@ -1170,10 +1169,9 @@ var WindowManager = class {
_lookupIndex(windows, metaWindow) { _lookupIndex(windows, metaWindow) {
for (let i = 0; i < windows.length; i++) { for (let i = 0; i < windows.length; i++) {
if (windows[i].metaWindow == metaWindow) { if (windows[i].metaWindow == metaWindow)
return i; return i;
} }
}
return -1; return -1;
} }

View File

@ -1588,16 +1588,14 @@ class Workspace extends St.Widget {
} }
_windowEnteredMonitor(metaDisplay, monitorIndex, metaWin) { _windowEnteredMonitor(metaDisplay, monitorIndex, metaWin) {
if (monitorIndex == this.monitorIndex) { if (monitorIndex == this.monitorIndex)
this._doAddWindow(metaWin); this._doAddWindow(metaWin);
} }
}
_windowLeftMonitor(metaDisplay, monitorIndex, metaWin) { _windowLeftMonitor(metaDisplay, monitorIndex, metaWin) {
if (monitorIndex == this.monitorIndex) { if (monitorIndex == this.monitorIndex)
this._doRemoveWindow(metaWin); this._doRemoveWindow(metaWin);
} }
}
// check for maximized windows on the workspace // check for maximized windows on the workspace
hasMaximizedWindows() { hasMaximizedWindows() {

View File

@ -293,10 +293,9 @@ var WorkspaceThumbnail = GObject.registerClass({
this._allWindows.push(windows[i].meta_window); this._allWindows.push(windows[i].meta_window);
this._minimizedChangedIds.push(minimizedChangedId); this._minimizedChangedIds.push(minimizedChangedId);
if (this._isMyWindow(windows[i]) && this._isOverviewWindow(windows[i])) { if (this._isMyWindow(windows[i]) && this._isOverviewWindow(windows[i]))
this._addWindowClone(windows[i]); this._addWindowClone(windows[i]);
} }
}
// Track window changes // Track window changes
this._windowAddedId = this.metaWorkspace.connect('window-added', this._windowAddedId = this.metaWorkspace.connect('window-added',
@ -450,16 +449,14 @@ var WorkspaceThumbnail = GObject.registerClass({
} }
_windowEnteredMonitor(metaDisplay, monitorIndex, metaWin) { _windowEnteredMonitor(metaDisplay, monitorIndex, metaWin) {
if (monitorIndex == this.monitorIndex) { if (monitorIndex == this.monitorIndex)
this._doAddWindow(metaWin); this._doAddWindow(metaWin);
} }
}
_windowLeftMonitor(metaDisplay, monitorIndex, metaWin) { _windowLeftMonitor(metaDisplay, monitorIndex, metaWin) {
if (monitorIndex == this.monitorIndex) { if (monitorIndex == this.monitorIndex)
this._doRemoveWindow(metaWin); this._doRemoveWindow(metaWin);
} }
}
_updateMinimized(metaWin) { _updateMinimized(metaWin) {
if (metaWin.minimized) if (metaWin.minimized)