[polari] Make paste functions generic
- From: Kunal Jain <kunaljain src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] Make paste functions generic
- Date: Thu, 11 Feb 2016 18:36:01 +0000 (UTC)
commit 8a67ef099d20f2f346d8b1df6dd21eff2b02d163
Author: Kunaal Jain <kunaalus gmail com>
Date: Thu Feb 11 09:44:25 2016 +0530
Make paste functions generic
Change the name of the functions, signals, actions
to generic paste-content rather than paste-text, as
soon we will be adding support for pasting image, and
most of the code for pasting text and image is same,
so reuse the code.
https://bugzilla.gnome.org/show_bug.cgi?id=760346
data/resources/entry-area.ui | 2 +-
src/application.js | 19 +++++++++++++------
src/entryArea.js | 3 ++-
3 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/data/resources/entry-area.ui b/data/resources/entry-area.ui
index 40af1e0..f7beca8 100644
--- a/data/resources/entry-area.ui
+++ b/data/resources/entry-area.ui
@@ -123,7 +123,7 @@
<property name="label" translatable="yes">_Paste</property>
<property name="visible">True</property>
<property name="receives-default">True</property>
- <property name="action-name">app.paste-text</property>
+ <property name="action-name">app.paste-content</property>
<property name="use-underline">True</property>
<style>
<class name="suggested-action"/>
diff --git a/src/application.js b/src/application.js
index 62ff472..b0ca0cf 100644
--- a/src/application.js
+++ b/src/application.js
@@ -67,9 +67,9 @@ const Application = new Lang.Class({
{ name: 'message-user',
activate: Lang.bind(this, this._onMessageUser),
parameter_type: GLib.VariantType.new('(sssu)') },
- { name: 'paste-text',
- activate: Lang.bind(this, this._onPasteText),
- parameter_type: GLib.VariantType.new('s') },
+ { name: 'paste-content',
+ activate: Lang.bind(this, this._onPasteContent),
+ parameter_type: GLib.VariantType.new('(ayi)') },
{ name: 'leave-room',
activate: Lang.bind(this, this._onLeaveRoom),
parameter_type: GLib.VariantType.new('(ss)') },
@@ -378,9 +378,16 @@ const Application = new Lang.Class({
}));
},
- _onPasteText: function(action, parameter) {
- let text = parameter.deep_unpack();
- this.pasteManager.pasteText(text);
+ _onPasteContent: function(action, parameter) {
+ let [data, type] = parameter.deep_unpack();
+ switch (type) {
+ case PasteManager.DndTargetType.TEXT:
+ let text = data.toString();
+ this.pasteManager.pasteText(text);
+ break;
+ default:
+ log('Unhandled paste content of type %d'.format(type));
+ }
},
_onLeaveRoom: function(action, parameter) {
diff --git a/src/entryArea.js b/src/entryArea.js
index b54dd6c..dff3187 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -9,6 +9,7 @@ const Lang = imports.lang;
const Mainloop = imports.mainloop;
const TabCompletion = imports.tabCompletion;
const Tp = imports.gi.TelepathyGLib;
+const PasteManager = imports.pasteManager;
const MAX_NICK_UPDATE_TIME = 5; /* s */
const MAX_LINES = 5;
@@ -209,7 +210,7 @@ const EntryArea = new Lang.Class({
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('s', text);
+ this._pasteButton.action_target = new GLib.Variant('(ayi)', [text, PasteManager.DndTargetType.TEXT]);
this.visible_child_name = 'multiline';
this._pasteButton.grab_focus();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]