[polari/wip/fmuellner/paste-confirmation: 5/16] entryArea: Split out a _setPasteContent() method
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/paste-confirmation: 5/16] entryArea: Split out a _setPasteContent() method
- Date: Fri, 12 Feb 2016 21:26:01 +0000 (UTC)
commit 78deca42d5aab7f603def1941b69d13a78dec9fc
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..8f6cc57 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._pasteButton.grab_focus();
+ this.visible_child_name = 'paste-confirmation';
+ } else {
+ this._chatEntry.text = '';
+ this._chatEntry.grab_focus_without_selecting();
+ this.visible_child_name = 'default';
+ }
+ },
+
_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]