[polari/wip/fmuellner/emoji-picker: 2/3] entryArea: Include emoji picker
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/emoji-picker: 2/3] entryArea: Include emoji picker
- Date: Wed, 9 Aug 2017 23:37:42 +0000 (UTC)
commit 1977d4dff0099f5d6e7d6ee3dded5436f29342bc
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Aug 8 03:46:54 2017 +0200
entryArea: Include emoji picker
Now that the platform supports color emoji, expose the newly added
picker as secondary icon in the entry area to make it easy to insert
emojis.
https://bugzilla.gnome.org/show_bug.cgi?id=755579
data/resources/entry-area.ui | 1 +
src/entryArea.js | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/data/resources/entry-area.ui b/data/resources/entry-area.ui
index 475803b..9de1d43 100644
--- a/data/resources/entry-area.ui
+++ b/data/resources/entry-area.ui
@@ -84,6 +84,7 @@
<object class="Gjs_ChatEntry" id="chatEntry">
<property name="visible">True</property>
<property name="hexpand">True</property>
+ <property name="secondary-icon-name">face-smile-symbolic</property>
</object>
</child>
</object>
diff --git a/src/entryArea.js b/src/entryArea.js
index e078bde..c4feea0 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -7,6 +7,7 @@ const Gspell = imports.gi.Gspell;
const Gtk = imports.gi.Gtk;
const ChatView = imports.chatView;
+const EmojiPicker = imports.emojiPicker;
const IrcParser = imports.ircParser;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -36,6 +37,10 @@ var ChatEntry = new Lang.Class({
PasteManager.DropTargetIface.addTargets(this, this);
+ this._emojiPicker = null;
+
+ this.connect('icon-press', Lang.bind(this, this._showEmojiPicker));
+
if (!_checker)
_checker = new Gspell.Checker();
@@ -48,6 +53,26 @@ var ChatEntry = new Lang.Class({
this._useDefaultHandler = false;
},
+ _showEmojiPicker: function() {
+ if (!this.is_sensitive() || !this.get_mapped())
+ return;
+
+ if (!this._emojiPicker) {
+ this._emojiPicker = new EmojiPicker.EmojiPicker();
+ this._emojiPicker.connect('emoji-picked', (w, emoji) => {
+ this.delete_selection();
+ let pos = this.insert_text(emoji, -1, this.get_position());
+ this.set_position(pos);
+ this.grab_focus_without_selecting();
+ });
+ }
+
+ let rect = this.get_icon_area(Gtk.EntryIconPosition.SECONDARY);
+ this._emojiPicker.set_relative_to(this);
+ this._emojiPicker.set_pointing_to(rect);
+ this._emojiPicker.popup();
+ },
+
get can_drop() {
return true;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]