js: Use SOURCE_CONTINUE/SOURCE_REMOVE constants in source functions

With support for boolean constants in g-i, we can finally use the
more readable constants instead of true/false.

https://bugzilla.gnome.org/show_bug.cgi?id=719567
This commit is contained in:
Florian Müllner 2013-11-29 01:45:39 +01:00
parent fee2a07e08
commit 751a3f0e94
30 changed files with 78 additions and 47 deletions

View File

@ -644,7 +644,7 @@ const LoginDialog = new Lang.Class({
onComplete: function() {
Mainloop.idle_add(Lang.bind(this, function() {
this._greeter.call_start_session_when_ready_sync(serviceName, true, null);
return false;
return GLib.SOURCE_REMOVE;
}));
},
onCompleteScope: this });
@ -699,6 +699,7 @@ const LoginDialog = new Lang.Class({
function() {
this._timedLoginAnimationTime -= _TIMED_LOGIN_IDLE_THRESHOLD;
hold.release();
return GLib.SOURCE_REMOVE;
});
return hold;
},

View File

@ -250,6 +250,7 @@ const ShellUserVerifier = new Lang.Class({
Lang.bind(this, function() {
this._messageQueueTimeoutId = 0;
this._queueMessageTimeout();
return GLib.SOURCE_REMOVE;
}));
},

View File

@ -2,6 +2,7 @@
const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -312,7 +313,7 @@ const AppSwitcherPopup = new Lang.Class({
this._createThumbnails();
this._thumbnailTimeoutId = 0;
this._thumbnailsFocused = false;
return false;
return GLib.SOURCE_REMOVE;
},
_destroyThumbnails : function() {
@ -547,7 +548,7 @@ const AppSwitcher = new Lang.Class({
Lang.bind(this, function () {
this._enterItem(index);
this._mouseTimeOutId = 0;
return false;
return GLib.SOURCE_REMOVE;
}));
} else
this._itemEntered(index);

View File

@ -1,5 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const St = imports.gi.St;
@ -59,7 +60,7 @@ const Animation = new Lang.Class({
_update: function() {
this._showFrame(this._frame + 1);
return true;
return GLib.SOURCE_CONTINUE;
},
_animationsLoaded: function() {

View File

@ -1370,7 +1370,7 @@ const AppIcon = new Lang.Class({
Lang.bind(this, function() {
this._menuTimeoutId = 0;
this.popupMenu();
return false;
return GLib.SOURCE_REMOVE;
}));
} else if (button == 3) {
this.popupMenu();

View File

@ -262,6 +262,7 @@ const BackgroundCache = new Lang.Class({
if (params.onLoaded) {
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
params.onLoaded(this._animation);
return GLib.SOURCE_REMOVE;
}));
}
}
@ -276,6 +277,7 @@ const BackgroundCache = new Lang.Class({
if (params.onLoaded) {
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
params.onLoaded(this._animation);
return GLib.SOURCE_REMOVE;
}));
}
}));
@ -375,7 +377,7 @@ const Background = new Lang.Class({
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
this.emit('loaded');
return false;
return GLib.SOURCE_REMOVE;
}));
},
@ -517,7 +519,7 @@ const Background = new Lang.Class({
Lang.bind(this, function() {
this._updateAnimationTimeoutId = 0;
this._updateAnimation();
return false;
return GLib.SOURCE_REMOVE;
}));
},

View File

@ -77,7 +77,7 @@ const AutomountManager = new Lang.Class({
}));
this._mountAllId = 0;
return false;
return GLib.SOURCE_REMOVE;
},
_onDriveConnected: function() {
@ -236,7 +236,7 @@ const AutomountManager = new Lang.Class({
_allowAutorunExpire: function(volume) {
Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, function() {
volume.allowAutorun = false;
return false;
return GLib.SOURCE_REMOVE;
});
}
});

View File

@ -675,7 +675,7 @@ const ChatSource = new Lang.Class({
this._notifyTimeoutId = 0;
return false;
return GLib.SOURCE_REMOVE;
},
// This is called for both messages we send from
@ -975,7 +975,7 @@ const ChatNotification = new Lang.Class({
this._filterMessages();
return false;
return GLib.SOURCE_REMOVE;
},
appendAliasChange: function(oldAlias, newAlias) {
@ -1013,7 +1013,7 @@ const ChatNotification = new Lang.Class({
this.source.setChatState(Tp.ChannelChatState.PAUSED);
return false;
return GLib.SOURCE_REMOVE;
},
_onEntryChanged: function() {

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Signals = imports.signals;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
@ -577,7 +578,7 @@ const Dash = new Lang.Class({
this._labelShowing = true;
item.showLabel();
this._showLabelTimeoutId = 0;
return false;
return GLib.SOURCE_REMOVE;
}));
if (this._resetHoverTimeoutId > 0) {
Mainloop.source_remove(this._resetHoverTimeoutId);
@ -594,7 +595,7 @@ const Dash = new Lang.Class({
Lang.bind(this, function() {
this._labelShowing = false;
this._resetHoverTimeoutId = 0;
return false;
return GLib.SOURCE_REMOVE;
}));
}
}

View File

@ -362,7 +362,7 @@ const _Draggable = new Lang.Class({
let result = motionFunc(dragEvent);
if (result != DragMotionResult.CONTINUE) {
global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
return false;
return GLib.SOURCE_REMOVE;
}
}
}
@ -380,13 +380,13 @@ const _Draggable = new Lang.Class({
0);
if (result != DragMotionResult.CONTINUE) {
global.screen.set_cursor(DRAG_CURSOR_MAP[result]);
return false;
return GLib.SOURCE_REMOVE;
}
}
target = target.get_parent();
}
global.screen.set_cursor(Meta.Cursor.DND_IN_DRAG);
return false;
return GLib.SOURCE_REMOVE;
},
_queueUpdateDragHover: function() {

View File

@ -411,7 +411,7 @@ const EndSessionDialog = new Lang.Class({
this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
if (this._secondsLeft > 0) {
this._sync();
return true;
return GLib.SOURCE_CONTINUE;
}
let dialogContent = DialogContent[this._type];
@ -419,7 +419,7 @@ const EndSessionDialog = new Lang.Class({
this._confirm(button.signal);
this._timerId = 0;
return false;
return GLib.SOURCE_REMOVE;
}));
},

View File

@ -252,7 +252,10 @@ const Keyboard = new Lang.Class({
if (!this._showIdleId)
this._showIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE,
Lang.bind(this, function() { this.Show(time); }));
Lang.bind(this, function() {
this.Show(time);
return GLib.SOURCE_REMOVE;
}));
},
_createLayersForGroup: function (gname) {
@ -479,6 +482,7 @@ const Keyboard = new Lang.Class({
Lang.bind(this, function() {
this._clearKeyboardRestTimer();
this._show(monitor);
return GLib.SOURCE_REMOVE;
}));
},
@ -504,6 +508,7 @@ const Keyboard = new Lang.Class({
Lang.bind(this, function() {
this._clearKeyboardRestTimer();
this._hide();
return GLib.SOURCE_REMOVE;
}));
},

View File

@ -622,7 +622,7 @@ const LayoutManager = new Lang.Class({
// when the system is bogged down
GLib.idle_add(GLib.PRIORITY_LOW, Lang.bind(this, function() {
this._startupAnimation();
return false;
return GLib.SOURCE_REMOVE;
}));
},
@ -1039,7 +1039,7 @@ const LayoutManager = new Lang.Class({
workspace.set_builtin_struts(struts);
}
return false;
return GLib.SOURCE_REMOVE;
}
});
Signals.addSignalMethods(LayoutManager.prototype);

View File

@ -841,6 +841,7 @@ const LookingGlass = new Lang.Class({
this._timeoutId = Mainloop.timeout_add(500, Lang.bind(this, function () {
gcIcon.icon_name = 'gnome-fs-trash-full';
Mainloop.source_remove(this._timeoutId);
return GLib.SOURCE_REMOVE;
}));
}));

View File

@ -609,7 +609,7 @@ function queueDeferredWork(workId) {
_deferredTimeoutId = Mainloop.timeout_add_seconds(DEFERRED_TIMEOUT_SECONDS, function () {
_runAllDeferredWork();
_deferredTimeoutId = 0;
return false;
return GLib.SOURCE_REMOVE;
});
}
}

View File

@ -1988,23 +1988,23 @@ const MessageTray = new Lang.Class({
this._trayDwellTimeoutId = 0;
if (Main.layoutManager.bottomMonitor.inFullscreen)
return false;
return GLib.SOURCE_REMOVE;
// We don't want to open the tray when a modal dialog
// is up, so we check the modal count for that. When we are in the
// overview we have to take the overview's modal push into account
if (Main.modalCount > (Main.overview.visible ? 1 : 0))
return false;
return GLib.SOURCE_REMOVE;
// If the user interacted with the focus window since we started the tray
// dwell (by clicking or typing), don't activate the message tray
let focusWindow = global.display.focus_window;
let currentUserTime = focusWindow ? focusWindow.user_time : 0;
if (currentUserTime != this._trayDwellUserTime)
return false;
return GLib.SOURCE_REMOVE;
this.openTray();
return false;
return GLib.SOURCE_REMOVE;
},
_onNotificationKeyRelease: function(actor, event) {
@ -2334,7 +2334,7 @@ const MessageTray = new Lang.Class({
this._updateNotificationTimeout(0);
this._updateState();
}
return false;
return GLib.SOURCE_REMOVE;
},
_escapeTray: function() {
@ -2667,7 +2667,7 @@ const MessageTray = new Lang.Class({
this._lastSeenMouseX = x;
this._lastSeenMouseY = y;
return false;
return GLib.SOURCE_REMOVE;
},
_hideNotification: function(animate) {

View File

@ -247,7 +247,7 @@ const FdoNotificationDaemon = new Lang.Class({
Mainloop.idle_add(Lang.bind(this,
function () {
this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
return false;
return GLib.SOURCE_REMOVE;
}));
return invocation.return_value(GLib.Variant.new('(u)', [id]));
}

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const St = imports.gi.St;
const Lang = imports.lang;
@ -173,6 +174,7 @@ const OsdWindow = new Lang.Class({
Meta.enable_unredirect_for_screen(global.screen);
})
});
return GLib.SOURCE_REMOVE;
},
_reset: function() {

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Meta = imports.gi.Meta;
const Mainloop = imports.mainloop;
@ -369,7 +370,7 @@ const Overview = new Lang.Class({
this._windowSwitchTimestamp);
this.hide();
this._lastHoveredWindow = null;
return false;
return GLib.SOURCE_REMOVE;
}));
}

View File

@ -628,6 +628,7 @@ const ActivitiesButton = new Lang.Class({
Mainloop.source_remove(this._xdndTimeOut);
this._xdndTimeOut = 0;
return GLib.SOURCE_REMOVE;
}
});

View File

@ -1,5 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -110,7 +111,7 @@ const PointerWatcher = new Lang.Class({
_onTimeout: function() {
this._updatePointer();
return true;
return GLib.SOURCE_CONTINUE;
},
_updatePointer: function() {

View File

@ -752,7 +752,7 @@ const ScreenShield = new Lang.Class({
});
}
return true;
return GLib.SOURCE_CONTINUE;
},
_onDragBegin: function() {
@ -848,7 +848,7 @@ const ScreenShield = new Lang.Class({
Lang.bind(this, function() {
this._lockTimeoutId = 0;
this.lock(false);
return false;
return GLib.SOURCE_REMOVE;
}));
}
@ -1110,6 +1110,7 @@ const ScreenShield = new Lang.Class({
Mainloop.timeout_add(1000 * MANUAL_FADE_TIME, Lang.bind(this, function() {
this._activateFade(this._shortLightbox, MANUAL_FADE_TIME);
return GLib.SOURCE_REMOVE;
}));
} else {
if (params.fadeToBlack)

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
@ -41,7 +42,7 @@ function sleep(milliseconds) {
Mainloop.timeout_add(milliseconds, function() {
if (cb)
cb();
return false;
return GLib.SOURCE_REMOVE;
});
return function(callback) {

View File

@ -2,6 +2,7 @@
const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const St = imports.gi.St;
@ -94,7 +95,7 @@ const ATIndicator = new Lang.Class({
this.actor.visible = alwaysShow || items.some(function(f) { return !!f.state; });
return false;
return GLib.SOURCE_REMOVE;
},
_queueSyncMenuVisibility: function() {

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@ -163,6 +164,7 @@ const SwitcherPopup = new Lang.Class({
Main.osdWindow.cancel();
this.actor.opacity = 255;
this._initialDelayTimeoutId = 0;
return GLib.SOURCE_REMOVE;
}));
return true;
},
@ -251,6 +253,7 @@ const SwitcherPopup = new Lang.Class({
_mouseTimedOut: function() {
this._motionTimeoutId = 0;
this.mouseActive = true;
return GLib.SOURCE_REMOVE;
},
_popModal: function() {

View File

@ -2,6 +2,7 @@
const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -461,6 +462,8 @@ const ViewSelector = new Lang.Class({
this._searchResults.setTerms(terms);
this._showPage(this._searchPage);
return GLib.SOURCE_REMOVE;
},
getActivePage: function() {

View File

@ -106,11 +106,11 @@ const DisplayChangeDialog = new Lang.Class({
/* mutter already takes care of failing at timeout */
this._timeoutId = 0;
this.close();
return false;
return GLib.SOURCE_REMOVE;
}
this._descriptionLabel.text = this._formatCountDown();
return true;
return GLib.SOURCE_CONTINUE;
},
_onFailure: function() {
@ -278,7 +278,7 @@ const WorkspaceTracker = new Lang.Class({
workspace._keepAliveId = Mainloop.timeout_add(duration, Lang.bind(this, function() {
workspace._keepAliveId = 0;
this._queueCheckWorkspaces();
return false;
return GLib.SOURCE_REMOVE;
}));
},
@ -290,7 +290,7 @@ const WorkspaceTracker = new Lang.Class({
workspace._lastRemovedWindow = null;
this._queueCheckWorkspaces();
}
return false;
return GLib.SOURCE_REMOVE;
}));
},

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -472,7 +473,7 @@ const WindowOverlay = new Lang.Class({
Mainloop.idle_add(Lang.bind(this,
function() {
this._windowClone.emit('selected');
return false;
return GLib.SOURCE_REMOVE;
}));
}
},
@ -554,7 +555,7 @@ const WindowOverlay = new Lang.Class({
!this.closeButton.has_pointer)
this._animateInvisible();
return false;
return GLib.SOURCE_REMOVE;
},
hideCloseButton: function() {
@ -1222,18 +1223,18 @@ const Workspace = new Lang.Class({
// store current cursor position
this._cursorX = x;
this._cursorY = y;
return true;
return GLib.SOURCE_CONTINUE;
}
let actorUnderPointer = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
for (let i = 0; i < this._windows.length; i++) {
if (this._windows[i].actor == actorUnderPointer)
return true;
return GLib.SOURCE_CONTINUE;
}
this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
this._repositionWindowsId = 0;
return false;
return GLib.SOURCE_REMOVE;
},
_doRemoveWindow : function(metaWin) {
@ -1308,7 +1309,7 @@ const Workspace = new Lang.Class({
metaWin.get_compositor_private() &&
metaWin.get_workspace() == this.metaWorkspace)
this._doAddWindow(metaWin);
return false;
return GLib.SOURCE_REMOVE;
}));
return;
}

View File

@ -1,6 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -156,6 +157,7 @@ const WorkspaceSwitcherPopup = new Lang.Class({
onComplete: function() { this.destroy(); },
onCompleteScope: this
});
return GLib.SOURCE_REMOVE;
},
destroy: function() {

View File

@ -2,6 +2,7 @@
const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Meta = imports.gi.Meta;
@ -325,7 +326,7 @@ const WorkspaceThumbnail = new Lang.Class({
metaWin.get_compositor_private() &&
metaWin.get_workspace() == this.metaWorkspace)
this._doAddWindow(metaWin);
return false;
return GLib.SOURCE_REMOVE;
}));
return;
}