adding WIP emoji logic

This commit is contained in:
2022-09-16 20:53:04 -05:00
parent 2366e524a7
commit 2e4d1cd803
6 changed files with 48 additions and 8 deletions

View File

@@ -28,8 +28,10 @@ class Symbols_Key(Key):
self.connect("released", self._clicked)
def _clicked(self, widget = None):
key_columns = self.get_parent().get_parent().get_children()[1]
ctx = widget.get_style_context()
ctx.remove_class("toggled_bttn") if ctx.has_class("toggled_bttn") else ctx.add_class("toggled_bttn")
key_columns = self.get_parent().get_parent().get_children()[1]
for row in key_columns.get_children():
for key in row:
key.emit("toggle-symbol-keys", ())
@@ -69,6 +71,22 @@ class Backspace_Key(Key):
def _clicked(self, widget = None):
typwriter.press_special_keys(self.get_label())
class Emoji_Keys(Key):
def __init__(self):
super(Emoji_Keys, self).__init__("Emoji", "Emoji")
def setup_signals(self):
self.connect("released", self._clicked)
def _clicked(self, widget = None):
ctx = widget.get_style_context()
ctx.remove_class("toggled_bttn") if ctx.has_class("toggled_bttn") else ctx.add_class("toggled_bttn")
key_columns = self.get_parent().get_parent().get_children()[1]
for row in key_columns.get_children():
for key in row:
key.emit("toggle-emoji-keys", ())
class Enter_Key(Key):
def __init__(self):
super(Enter_Key, self).__init__("Enter", "Enter")

View File

@@ -9,13 +9,15 @@ from gi.repository import Gtk
class Key(Gtk.Button or Gtk.ToggleButton):
def __init__(self, primary = "NULL", secondary = "NULL"):
def __init__(self, primary = "NULL", secondary = "NULL", emoji = "NULL"):
super(Key, self).__init__()
self._primary_symbol = primary
self._secondary_symbol = secondary
self._emoji_symbol = emoji
self._is_upper = False
self._is_symbol = False
self._is_emoji = False
self.set_label(self._primary_symbol)
self.setup_signals()
@@ -25,6 +27,7 @@ class Key(Gtk.Button or Gtk.ToggleButton):
self.connect("released", self._do_type)
self.connect("toggle-caps", self.toggle_caps)
self.connect("toggle-symbol-keys", self.toggle_symbol_keys)
self.connect("toggle-emoji-keys", self.toggle_emoji_keys)
def _do_type(self, widget = None):
key = self.get_label().strip()
@@ -42,6 +45,18 @@ class Key(Gtk.Button or Gtk.ToggleButton):
self._is_symbol = not self._is_symbol
if self._is_symbol:
self.set_label(self._secondary_symbol)
elif self._is_emoji:
self.set_label(self._emoji_symbol)
else:
self.set_label(self._primary_symbol.upper()) if self._is_upper else self.set_label(self._primary_symbol.lower())
# NOTE: Might use name attrib on widgets and de-duplicate this and the above logic.
def toggle_emoji_keys(self, widget = None, eve = None):
self._is_emoji = not self._is_emoji
if self._is_emoji:
self.set_label(self._emoji_symbol)
elif self._is_symbol:
self.set_label(self._secondary_symbol)
else:
self.set_label(self._primary_symbol.upper()) if self._is_upper else self.set_label(self._primary_symbol.lower())