diff --git a/build/sqlite.py b/build/sqlite.py index 3ea812c..dcaaf39 100755 --- a/build/sqlite.py +++ b/build/sqlite.py @@ -11,13 +11,14 @@ unicode VARCHAR(255) PRIMARY KEY, description VARCHAR(255), skin_tone VARCHAR(255), - emoji_group VARCHAR(255) + emoji_group VARCHAR(255), + clicked_times NUMBER default 0 ) """ # SQL query to insert/replace/update emoji in table INSERT_TBL = """ -REPLACE INTO emojis VALUES (?, ?, ?, ?) +REPLACE INTO emojis VALUES (?, ?, ?, ?, 0) """ # SQL query to get all entries from table diff --git a/emoji-copy@felipeftn/emojiButton.js b/emoji-copy@felipeftn/emojiButton.js index 1c595ec..7f450d3 100644 --- a/emoji-copy@felipeftn/emojiButton.js +++ b/emoji-copy@felipeftn/emojiButton.js @@ -49,7 +49,7 @@ export class EmojiButton { can_focus: true, label: this.baseCharacter, }); - + // Copy the emoji to the clipboard with adequate tags and behavior this.super_btn.connect("button-press-event", this.onButtonPress.bind(this)); this.super_btn.connect("key-press-event", this.onKeyPress.bind(this)); @@ -102,6 +102,7 @@ export class EmojiButton { symbol == Clutter.KP_Enter ) { let emojiToCopy = this.getTaggedEmoji(); + this.emojiCopy.sqlite.increment_selection(emojiToCopy); let [_x, _y, mods] = global.get_pointer(); let majPressed = (mods & Clutter.ModifierType.SHIFT_MASK) != 0; let ctrlPressed = (mods & Clutter.ModifierType.CONTROL_MASK) != 0; @@ -129,6 +130,7 @@ export class EmojiButton { if (emojiToCopy == null) { return Clutter.EVENT_PROPAGATE; } + this.emojiCopy.sqlite.increment_selection(emojiToCopy); if (mouseButton == 1) { return this.replaceClipboardAndClose(emojiToCopy); @@ -160,25 +162,17 @@ export class EmojiButton { emojiToCopy, ); - if (this._settings.get_boolean("paste-on-select")) { - this.triggerPasteHack(); - } - return Clutter.EVENT_STOP; } addToClipboardAndStay(emojiToCopy) { - this.clipboard.get_text(CLIPBOARD_TYPE, function (_, text) { + this.clipboard.get_text(CLIPBOARD_TYPE, (_, text) => { this.clipboard.set_text( CLIPBOARD_TYPE, text + emojiToCopy, ); }); - if (this._settings.get_boolean("paste-on-select")) { - this.triggerPasteHack(); - } - return Clutter.EVENT_STOP; } diff --git a/emoji-copy@felipeftn/handlers/sql.js b/emoji-copy@felipeftn/handlers/sql.js index 19c82b9..4256ce5 100644 --- a/emoji-copy@felipeftn/handlers/sql.js +++ b/emoji-copy@felipeftn/handlers/sql.js @@ -43,6 +43,12 @@ export class SQLite { `); } + increment_selection(unicode) { + return this.query(` + UPDATE emojis SET clicked_times = clicked_times + 1 WHERE unicode = '${unicode}' + `); + } + search_description(search_text, skin_tone = 0) { const sql_string = search_text .split(" ") @@ -53,12 +59,12 @@ export class SQLite { if (skin_tone != 0) { const skin_tone_str = this.get_skin_tone(skin_tone); return this.query(` - SELECT * FROM emojis WHERE (${sql_string}) AND skin_tone LIKE '%${skin_tone_str}%' ORDER BY LENGTH(description); + SELECT * FROM emojis WHERE (${sql_string}) AND skin_tone LIKE '%${skin_tone_str}%' ORDER BY clicked_times DESC; `); } return this.query(` - SELECT * FROM emojis WHERE ${sql_string} ORDER BY LENGTH(description); + SELECT * FROM emojis WHERE ${sql_string} ORDER BY clicked_times DESC; `); } @@ -87,6 +93,7 @@ export class SQLite { item.description = data[1]; item.skin_tone = data[2]; item.group = data[3]; + item.clicked_times = data[4]; return item; }); return result; diff --git a/emoji-copy@felipeftn/metadata.json b/emoji-copy@felipeftn/metadata.json index c91a725..c2c36e9 100644 --- a/emoji-copy@felipeftn/metadata.json +++ b/emoji-copy@felipeftn/metadata.json @@ -6,5 +6,5 @@ "url": "https://github.com/felipeftn/emoji-copy", "settings-schema": "org.gnome.shell.extensions.emoji-copy", "gettext-domain": "emoji-copy", - "version": 21 + "version": 23 }