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 3 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.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
57 changes: 36 additions & 21 deletions emote/emojis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import json
import csv
from collections import defaultdict
from emote import user_data, config

Expand All @@ -9,25 +8,41 @@

emojis_by_category = defaultdict(list)
all_emojis = []
blocklisted_emoji_categories = ["component", "extras-openmoji", "extras-unicode"]


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"

with open(filename, "r") as f:
emojis = json.load(f)

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

emojis_by_category[emoji["category"]].append(emoji)
filename = (
f"{config.snap_root}/static/emojis.csv"
if config.is_snap
else "static/emojis.csv"
)

with open(filename, newline="") as csvfile:
reader = csv.DictReader(csvfile)

for row in reader:
category = row["group"]

if category in blocklisted_emoji_categories:
continue

if row["skintone"] != "":
continue

emoji = {
"keywords": row["tags"].split(", "),
tom-james-watson marked this conversation as resolved.
Show resolved Hide resolved
"char": row["emoji"],
"name": " ".join(
[part.capitalize() for part in row["annotation"].split(" ")]
),
"shortcode": row["annotation"].replace(" ", "_").replace("-", "_"),
"skintone": row["skintone_combination"] == "simple",
}
emojis_by_category[row["group"]].append(emoji)
all_emojis.append(emoji)

update_recent_category()
Expand Down Expand Up @@ -63,11 +78,11 @@ 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", "✈️"),
("people-body", "Smileys & People", "🙂"),
("animals-nature", "Animals & Nature", "🐯"),
("food-drink", "Food & Drink", "🍔"),
("activities", "Activities", "⚽"),
("travel-places", "Travel & Places", "✈️"),
("objects", "Objects", "💡"),
("symbols", "Symbols", "❤️"),
("flags", "Flags", "🇺🇳"),
Expand All @@ -85,6 +100,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))
6 changes: 2 additions & 4 deletions emote/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ def init_action_bar(self):
def show_emoji_preview(self, char):
emoji = emojis.get_emoji_by_char(char)
self.previewed_emoji_label.set_text(emoji["char"])
self.previewed_emoji_shortcode_label.set_text(f':{emoji["name"]}:')
self.previewed_emoji_name_label.set_text(
" ".join([part.capitalize() for part in emoji["name"].split("_")])
)
self.previewed_emoji_shortcode_label.set_text(f':{emoji["shortcode"]}:')
self.previewed_emoji_name_label.set_text(emoji["name"])

def reset_emoji_preview(self):
if len(self.current_emojis) > 0:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
},
install_requires=[
"pygobject==3.36.0",
"manimpango==0.3.0"
]
)
Binary file added static/NotoColorEmoji.ttf
Binary file not shown.
Loading