[polari] entryArea: Split out a _setPasteContent() method
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] entryArea: Split out a _setPasteContent() method
- Date: Thu, 18 Feb 2016 00:16:32 +0000 (UTC)
commit b9133009a1c3bc7c0775c6c718ea555ca8381c71
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 11 22:42:30 2016 +0100
entryArea: Split out a _setPasteContent() method
More than avoiding a bit of code duplication, this gives us a central
place to manage switches between entry and paste confirmation UI.
https://bugzilla.gnome.org/show_bug.cgi?id=760315
src/entryArea.js | 24 ++++++++++++++++--------
1 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index 2da7d26..3e6718e 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -215,14 +215,25 @@ const EntryArea = new Lang.Class({
this._chatEntry.get_style_context().remove_class('error');
},
+ _setPasteContent: function(content) {
+ this._pasteButton.action_target = content;
+
+ if (content) {
+ this.visible_child_name = 'paste-confirmation';
+ this._pasteButton.grab_focus();
+ } else {
+ this.visible_child_name = 'default';
+ this._chatEntry.text = '';
+ this._chatEntry.grab_focus_without_selecting();
+ }
+ },
+
_onTextPasted: function(entry, text, nLines) {
this._confirmLabel.label =
ngettext("Paste %s line of text to public paste service?",
"Paste %s lines of text to public paste service?",
nLines).format(nLines);
- this._pasteButton.action_target = new GLib.Variant('(ayi)', [text, PasteManager.DndTargetType.TEXT]);
- this.visible_child_name = 'paste-confirmation';
- this._pasteButton.grab_focus();
+ this._setPasteContent(new GLib.Variant('(ayi)', [text, PasteManager.DndTargetType.TEXT]));
},
_onImagePasted: function(entry, data) {
@@ -232,14 +243,11 @@ const EntryArea = new Lang.Class({
if (!success)
return;
- this._pasteButton.action_target = new GLib.Variant('(ayi)', [buffer,
PasteManager.DndTargetType.IMAGE]);
- this.visible_child_name = 'paste-confirmation';
- this._pasteButton.grab_focus();
+ this._setPasteContent(new GLib.Variant('(ayi)', [buffer, PasteManager.DndTargetType.IMAGE]));
},
_onButtonClicked: function() {
- this._chatEntry.text = '';
- this.visible_child_name = 'default';
+ this._setPasteContent(null);
},
_onSensitiveChanged: function() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]