[polari] Use constant return values in source/event handlers
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] Use constant return values in source/event handlers
- Date: Wed, 2 Apr 2014 14:02:41 +0000 (UTC)
commit b06665f27b740ae8259e1b31ca940703d5ce2e56
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Apr 2 15:56:39 2014 +0200
Use constant return values in source/event handlers
Constants like G_SOURCE_REMOVE or GDK_EVENT_STOP are more readable
than plain booleans, but haven't been supported by g-i until
recently. Now that they work, use them ...
src/chatView.js | 18 +++++++++---------
src/entryArea.js | 26 +++++++++++++-------------
src/mainWindow.js | 2 +-
src/pasteManager.js | 10 +++++-----
src/roomList.js | 4 ++--
src/tabCompletion.js | 16 ++++++++--------
src/userList.js | 4 ++--
7 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 604e296..52e9860 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -354,16 +354,16 @@ const ChatView = new Lang.Class({
this.widget.vadjustment.value != 0 ||
dir != Gdk.ScrollDirection.UP ||
this._logWalker.is_end())
- return false;
+ return Gdk.EVENT_PROPAGATE;
this._fetchingBacklog = true;
Mainloop.timeout_add(500, Lang.bind(this,
function() {
this._logWalker.get_events_async(NUM_LOG_EVENTS,
Lang.bind(this, this._onLogEventsReady));
- return false;
+ return GLib.SOURCE_REMOVE;
}));
- return false;
+ return Gdk.EVENT_PROPAGATE;
},
_onValueChanged: function() {
@@ -374,7 +374,7 @@ const ChatView = new Lang.Class({
function() {
this._checkMessages();
this._valueChangedId = 0;
- return false;
+ return GLib.SOURCE_REMOVE;
}));
},
@@ -389,7 +389,7 @@ const ChatView = new Lang.Class({
_handleLinkClicks: function(view, event) {
let [, button] = event.get_button();
if (button != Gdk.BUTTON_PRIMARY)
- return false;
+ return Gdk.EVENT_PROPAGATE;
let isPress = event.get_event_type() == Gdk.EventType.BUTTON_PRESS;
@@ -407,17 +407,17 @@ const ChatView = new Lang.Class({
if (url) {
if (isPress) {
this._clickedUrl = url;
- return true;
+ return Gdk.EVENT_STOP;
} else if (this._clickedUrl == url) {
if (url.indexOf(':') == -1)
url = 'http://' + url;
Gio.AppInfo.launch_default_for_uri(url, null);
- return true;
+ return Gdk.EVENT_STOP;
}
break;
}
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
},
_handleLinkHovers: function(view, event) {
@@ -436,7 +436,7 @@ const ChatView = new Lang.Class({
let cursor = this._hoveringLink ? this._linkCursor : null;
this._view.get_window(Gtk.TextWindowType.TEXT).set_cursor(cursor);
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
},
_checkMessages: function() {
diff --git a/src/entryArea.js b/src/entryArea.js
index 21ef836..db92216 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -62,18 +62,18 @@ const EntryArea = new Lang.Class({
this._entry.grab_focus();
}));
this._nickEntry.connect('focus-out-event', Lang.bind(this,
- function() {
- this._nickEntry.text = '';
- return false;
+ function() {
+ this._nickEntry.text = '';
+ return Gdk.EVENT_PROPAGATE;
}));
this._nickEntry.connect_after('key-press-event', Lang.bind(this,
function(w, event) {
let [, keyval] = event.get_keyval();
if (keyval == Gdk.KEY_Escape) {
this._entry.grab_focus();
- return true;
+ return Gdk.EVENT_STOP;
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
}));
this._entry = new Gtk.Entry({ hexpand: true,
@@ -103,27 +103,27 @@ const EntryArea = new Lang.Class({
_onKeyPressEvent: function(w, event) {
if (!this._entry.get_mapped())
- return false;
+ return Gdk.EVENT_PROPAGATE;
if (this._entry.has_focus)
- return false;
+ return Gdk.EVENT_PROPAGATE;
if (this._entry.get_toplevel().get_focus() instanceof Gtk.Entry)
- return false;
+ return Gdk.EVENT_PROPAGATE;
let [, keyval] = event.get_keyval();
if (Gdk.keyval_to_unicode(keyval) == 0)
- return false;
+ return Gdk.EVENT_PROPAGATE;
let [, state] = event.get_state();
if (state != 0)
- return false;
+ return Gdk.EVENT_PROPAGATE;
this._entry.editable = false;
this._entry.grab_focus();
this._entry.editable = true;
this._entry.event(event);
- return true;
+ return Gdk.EVENT_STOP;
},
_onSensitiveChanged: function() {
@@ -133,7 +133,7 @@ const EntryArea = new Lang.Class({
Mainloop.idle_add(Lang.bind(this,
function() {
this._entry.grab_focus();
- return false;
+ return GLib.SOURCE_REMOVE;
}));
},
@@ -177,7 +177,7 @@ const EntryArea = new Lang.Class({
Mainloop.timeout_add_seconds(MAX_NICK_UPDATE_TIME,
Lang.bind(this, function() {
this._updateNick();
- return false;
+ return GLib.SOURCE_REMOVE;
}));
}));
},
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d19b026..bd94a5f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -147,7 +147,7 @@ const MainWindow = new Lang.Class({
Lang.bind(this, function() {
this._saveGeometry();
this._configureId = 0;
- return false;
+ return GLib.SOURCE_REMOVE;
}));
},
diff --git a/src/pasteManager.js b/src/pasteManager.js
index 8834a71..8c87a92 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -107,10 +107,10 @@ const PasteManager = new Lang.Class({
_onDragDrop: function(widget, context, x, y, time) {
if (!Polari.drag_dest_supports_target(widget, context, null))
- return false;
+ return Gdk.EVENT_PROPAGATE;
Polari.drag_dest_request_data(widget, context, time);
- return true;
+ return Gdk.EVENT_STOP;
},
_onDragLeave: function(widget, context, time) {
@@ -122,7 +122,7 @@ const PasteManager = new Lang.Class({
_onDragMotion: function(widget, context, x, y, time) {
if (!Polari.drag_dest_supports_target(widget, context, null))
- return false;
+ return Gdk.EVENT_PROPAGATE;
let info = Polari.drag_dest_find_target(widget, context);
switch (info) {
@@ -145,7 +145,7 @@ const PasteManager = new Lang.Class({
}
break;
default:
- return false;
+ return Gdk.EVENT_PROPAGATE;
}
if (!this._dragHighlight) {
@@ -153,7 +153,7 @@ const PasteManager = new Lang.Class({
widget.drag_highlight();
}
- return true;
+ return Gdk.EVENT_STOP;
},
diff --git a/src/roomList.js b/src/roomList.js
index 7009528..ffd84e1 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -86,11 +86,11 @@ const RoomRow = new Lang.Class({
_onButtonRelease: function(w, event) {
let [, button] = event.get_button();
if (button != Gdk.BUTTON_SECONDARY)
- return false;
+ return Gdk.EVENT_PROPAGATE;
this.selection_button.active = !this.selection_button.active;
- return true;
+ return Gdk.EVENT_STOP;
},
_createWidget: function(gicon) {
diff --git a/src/tabCompletion.js b/src/tabCompletion.js
index f568f77..5406b4f 100644
--- a/src/tabCompletion.js
+++ b/src/tabCompletion.js
@@ -81,23 +81,23 @@ const TabCompletion = new Lang.Class({
if (this._key.length == 0) {
if (keyval == Gdk.KEY_Tab) {
this._start();
- return true;
+ return Gdk.EVENT_STOP;
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
}
switch (keyval) {
case Gdk.KEY_Tab:
case Gdk.KEY_Down:
this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, 1);
- return true;
+ return Gdk.EVENT_STOP;
case Gdk.KEY_ISO_Left_Tab:
case Gdk.KEY_Up:
this._moveSelection(Gtk.MovementStep.DISPLAY_LINES, -1);
- return true;
+ return Gdk.EVENT_STOP;
case Gdk.KEY_Escape:
this._cancel();
- return true;
+ return Gdk.EVENT_STOP;
}
if (Gdk.keyval_to_unicode(keyval) != 0) {
@@ -110,7 +110,7 @@ const TabCompletion = new Lang.Class({
keyval == Gdk.KEY_KP_Enter ||
keyval == Gdk.KEY_ISO_Enter);
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
},
_getRowCompletion: function(row) {
@@ -178,12 +178,12 @@ const TabCompletion = new Lang.Class({
_onKeynavFailed: function(w, dir) {
if (this._inHandler)
- return false;
+ return Gdk.EVENT_PROPAGATE;
let count = dir == Gtk.DirectionType.DOWN ? -1 : 1;
this._inHandler = true;
this._moveSelection(Gtk.MovementStep.BUFFER_ENDS, count);
this._inHandler = false;
- return true;
+ return Gdk.EVENT_STOP;
},
_moveSelection: function(movement, count) {
diff --git a/src/userList.js b/src/userList.js
index ba4c2aa..1fead78 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -60,9 +60,9 @@ const UserListPopover = new Lang.Class({
let [, keyval] = event.get_keyval();
if (keyval == Gdk.KEY_Escape) {
this._entry.text = '';
- return true;
+ return Gdk.EVENT_STOP;
}
- return false;
+ return Gdk.EVENT_PROPAGATE;
}));
this._revealer.add(this._entry);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]