Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.0 #49

Merged
merged 10 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ verify_ssl = true

[packages]
pygobject = "==3.38.0"
manimpango = "==0.3.0"

[dev-packages]
black = "==19.10b0"
Expand Down
221 changes: 117 additions & 104 deletions Pipfile.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ Previous Emoji Category: `Ctrl+Shift+Tab`

### Requirements

Install gtk development libraries:
Install development libraries:

```bash
sudo apt install libgtk-3-dev libgirepository1.0-dev python3-venv gir1.2-keybinder-3.0 libkeybinder-dev
sudo apt install xdotool libgtk-3-dev libgirepository1.0-dev python3-venv gir1.2-keybinder-3.0 libkeybinder-dev
```

Install pipenv:
Expand Down Expand Up @@ -130,3 +130,7 @@ Push the packaged snap to the `edge` channel on the snap store.
```bash
snapcraft push --release=edge <path to .snap>
```

### Attribution

Emoji data is sourced from https://raw.githubusercontent.com/hfg-gmuend/openmoji/master/data/openmoji.csv which is compiled by the lovely people at https://openmoji.org.
6 changes: 6 additions & 0 deletions emote/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import sys
import subprocess
import gi
import manimpango

gi.require_version("Gtk", "3.0")
gi.require_version("Keybinder", "3.0")
from gi.repository import Gtk, Keybinder
from emote import picker, css, emojis, user_data, config

# Register updated emoji font
if config.is_snap:
manimpango.register_font(f"{config.snap_root}/static/NotoColorEmoji.ttf")
else:
manimpango.register_font("static/NotoColorEmoji.ttf")

settings = Gtk.Settings.get_default()

Expand Down
300 changes: 277 additions & 23 deletions emote/emojis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,231 @@
import os
import json
import csv
import re
from collections import defaultdict
from emote import user_data, config


MAX_VERSION = 10.0
# These are emojis that support skintone sequences but that are not yet
# supported on the core18 snap base and as such would render as two separate
# emojis.
SKINTONE_SEQUENCE_BLOCKLIST = [
"hand_with_fingers_splayed",
"victory_hand",
"backhand_index_pointing_left",
"backhand_index_pointing_right",
"backhand_index_pointing_up",
"backhand_index_pointing_down",
"index_pointing_up",
"thumbs_up",
"thumbs_down",
"writing_hand",
"ear",
"man_beard",
"woman_beard",
"woman_blond_hair",
"man_blond_hair",
"man_frowning",
"woman_frowning",
"man_pouting",
"woman_pouting",
"man_gesturing_no",
"woman_gesturing_no",
"man_gesturing_ok",
"woman_gesturing_ok",
"man_tipping_hand",
"woman_tipping_hand",
"man_raising_hand",
"woman_raising_hand",
"man_bowing",
"woman_bowing",
"man_facepalming",
"woman_facepalming",
"man_shrugging",
"woman_shrugging",
"health_worker",
"man_health_worker",
"woman_health_worker",
"student",
"man_student",
"woman_student",
"teacher",
"man_teacher",
"woman_teacher",
"judge",
"man_judge",
"woman_judge",
"farmer",
"man_farmer",
"woman_farmer",
"cook",
"man_cook",
"woman_cook",
"mechanic",
"man_mechanic",
"woman_mechanic",
"factory_worker",
"man_factory_worker",
"woman_factory_worker",
"office_worker",
"man_office_worker",
"woman_office_worker",
"scientist",
"man_scientist",
"woman_scientist",
"technologist",
"man_technologist",
"woman_technologist",
"singer",
"man_singer",
"woman_singer",
"artist",
"man_artist",
"woman_artist",
"pilot",
"man_pilot",
"woman_pilot",
"astronaut",
"man_astronaut",
"woman_astronaut",
"firefighter",
"man_firefighter",
"woman_firefighter",
"man_police_officer",
"woman_police_officer",
"detective",
"man_detective",
"woman_detective",
"man_guard",
"woman_guard",
"man_construction_worker",
"woman_construction_worker",
"man_wearing_turban",
"woman_wearing_turban",
"man_in_tuxedo",
"woman_in_tuxedo",
"man_with_veil",
"woman_with_veil",
"woman_feeding_baby",
"man_feeding_baby",
"person_feeding_baby",
"mx_claus",
"man_mage",
"woman_mage",
"man_fairy",
"woman_fairy",
"man_vampire",
"woman_vampire",
"merman",
"mermaid",
"man_elf",
"woman_elf",
"man_getting_massage",
"woman_getting_massage",
"man_getting_haircut",
"woman_getting_haircut",
"man_walking",
"woman_walking",
"man_running",
"woman_running",
"person_in_suit_levitating",
"man_in_steamy_room",
"woman_in_steamy_room",
"man_climbing",
"woman_climbing",
"snowboarder",
"person_golfing",
"man_golfing",
"woman_golfing",
"person_surfing",
"man_surfing",
"woman_surfing",
"man_rowing_boat",
"woman_rowing_boat",
"person_swimming",
"man_swimming",
"woman_swimming",
"person_bouncing_ball",
"man_bouncing_ball",
"woman_bouncing_ball",
"person_lifting_weights",
"man_lifting_weights",
"woman_lifting_weights",
"man_biking",
"woman_biking",
"man_mountain_biking",
"woman_mountain_biking",
"man_cartwheeling",
"woman_cartwheeling",
"man_playing_water_polo",
"woman_playing_water_polo",
"man_playing_handball",
"woman_playing_handball",
"man_juggling",
"woman_juggling",
"man_in_lotus_position",
"woman_in_lotus_position",
"people_holding_hands",
"kiss_woman_man",
"kiss_man_man",
"kiss_woman_woman",
"couple_with_heart_woman_man",
"couple_with_heart_man_man",
"couple_with_heart_woman_woman",
"pinched_fingers",
"pinching_hand",
"leg",
"foot",
"ear_with_hearing_aid",
"deaf_person",
"ninja",
"superhero",
"supervillain",
"person_standing",
"person_kneeling",
]
# These are emojis that are not supported on core18 snap base and as such
# render as two separate emojis. The app itself bundles a recent version of the
# NotoColorEmoji font and so can display recent single char emojis, however any
# emojis that are sequences also require a recent version of pango for the OS
# to recognise and combine the sequences. Upgrading to core20 should let us
# include more recent unicode sequences:
# https://github.com/tom-james-watson/Emote/issues/48.
SEQUENCE_BLOCKLIST = [
"man_red_hair",
"man_curly_hair",
"man_white_hair",
"man_bald",
"woman_red_hair",
"person_red_hair",
"woman_curly_hair",
"person_curly_hair",
"woman_white_hair",
"person_white_hair",
"woman_bald",
"person_bald",
"deaf_man",
"deaf_woman",
"man_superhero",
"woman_superhero",
"man_supervillain",
"woman_supervillain",
"man_standing",
"woman_standing",
"man_kneeling",
"woman_kneeling",
"person_with_white_cane",
"man_with_white_cane",
"woman_with_white_cane",
"person_in_motorized_wheelchair",
"man_in_motorized_wheelchair",
"woman_in_motorized_wheelchair",
"person_in_manual_wheelchair",
"man_in_manual_wheelchair",
"woman_in_manual_wheelchair",
"service_dog",
"transgender_flag",
"mending_heart",
]
EMOJI_CATEGORY_BLOCKLIST = ["component", "extras-openmoji", "extras-unicode"]


emojis_by_category = defaultdict(list)
Expand All @@ -15,25 +236,60 @@ def init():
global all_emojis
global emojis_by_category

if config.is_snap:
filename = f"{config.snap_root}/static/emojis.json"
else:
filename = "static/emojis.json"
filename = (
f"{config.snap_root}/static/emojis.csv"
if config.is_snap
else "static/emojis.csv"
)

with open(filename, "r") as f:
emojis = json.load(f)
with open(filename, newline="") as csvfile:
reader = csv.DictReader(csvfile)

for emoji_key in emojis.keys():
emoji = emojis[emoji_key].copy()
emoji.update({"name": emoji_key})
for row in reader:
category = row["group"]

emojis_by_category[emoji["category"]].append(emoji)
# Ignore uninteresting emojis
if category in EMOJI_CATEGORY_BLOCKLIST:
continue

if category in ["smileys-emotion", "people-body"]:
category = "smileys-people"

# Ignore emojis that are skintone combinations of other emojis. We
# will handle this ourselves in the app.
if row["skintone"] != "":
continue

shortcode = row["annotation"].lower().replace("-", " ")
shortcode = re.sub(r"[^\w\s]", "", shortcode).replace(" ", "_")

if shortcode in SEQUENCE_BLOCKLIST:
continue

emoji = {
"keywords": (row["tags"] + row["openmoji_tags"]).split(", "),
"char": row["emoji"],
"name": row["annotation"].capitalize(),
"shortcode": shortcode,
"skintone": row["skintone_combination"] == "single"
and shortcode not in SKINTONE_SEQUENCE_BLOCKLIST,
}
emojis_by_category[category].append(emoji)
all_emojis.append(emoji)

update_recent_category()


def strip_char_skintone(char):
for skintone in user_data.SKINTONES:
char = char.replace(skintone, "")

return char


def get_emoji_by_char(char):
char = strip_char_skintone(char)

for emoji in all_emojis:
if emoji["char"] == char:
return emoji
Expand All @@ -49,9 +305,7 @@ def update_recent_category():
emoji = get_emoji_by_char(char)
except:
continue
emojis_by_category["recent"].append(
{"char": char, "category": "recent", "name": emoji["name"]}
)
emojis_by_category["recent"].append(emoji)


def get_category_order():
Expand All @@ -63,13 +317,13 @@ def get_category_order():
"""
return [
("recent", "Recently Used", "🕙"),
("people", "Smileys & People", "🙂"),
("animals_and_nature", "Animals & Nature", "🐯"),
("food_and_drink", "Food & Drink", "🍔"),
("activity", "Activities", "⚽"),
("travel_and_places", "Travel & Places", "✈️"),
("smileys-people", "Smileys & People", "🙂"),
("animals-nature", "Animals & Nature", "🐯"),
("food-drink", "Food & Drink", "🍔"),
("activities", "Activities", "⚽"),
("travel-places", "Travel & Places", "✈️"),
("objects", "Objects", "💡"),
("symbols", "Symbols", "️"),
("symbols", "Symbols", "️"),
("flags", "Flags", "🇺🇳"),
]

Expand All @@ -85,6 +339,6 @@ def search_filter(emoji):
parts = emoji["name"].split("_")
search_terms = parts + [" ".join(parts)] + emoji["keywords"]
search_terms = [search_term.lower() for search_term in search_terms]
return any(search_term.startswith(query) for search_term in search_terms)
return any(query in search_term for search_term in search_terms)

return list(filter(search_filter, all_emojis))
Loading