adding WIP emoji logic
This commit is contained in:
parent
2366e524a7
commit
2e4d1cd803
|
@ -53,18 +53,22 @@ keys_json = {
|
|||
"row1": {
|
||||
"pKeys": ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
|
||||
"sKeys": ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
|
||||
"eKeys": ['🤩', '\U0001F600', '', '', '', '', '', '', '', '']
|
||||
},
|
||||
"row2": {
|
||||
"pKeys": ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
|
||||
"sKeys": ['\\', '^', '#', '$', '%', '&', '-', '_', '<', '>'],
|
||||
"eKeys": ['', '', '', '', '', '', '', '', '', '']
|
||||
},
|
||||
"row3": {
|
||||
"pKeys": ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', "'"],
|
||||
"sKeys": ['\\', '/', '|', ':', '=', '+', '"', '*', ';', '!'],
|
||||
"eKeys": ['', '', '', '', '', '', '', '', '', '']
|
||||
},
|
||||
"row4": {
|
||||
"pKeys": ['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '?'],
|
||||
"sKeys": ['`', '', '', '', '[', ']', '(', ')', '{', '}']
|
||||
"sKeys": ['`', '', '', '', '[', ']', '(', ')', '{', '}'],
|
||||
"eKeys": ['', '', '', '', '', '', '', '', '', '']
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,17 @@ class Keys_Column(Gtk.Box):
|
|||
for child in children:
|
||||
pKeys = keys[child]["pKeys"]
|
||||
sKeys = keys[child]["sKeys"]
|
||||
eKeys = keys[child]["eKeys"]
|
||||
|
||||
row_box = self.add_row()
|
||||
if len(pKeys) == len(sKeys):
|
||||
if len(pKeys) == len(sKeys) and len(pKeys) == len(eKeys):
|
||||
for i in range(10):
|
||||
pkey = pKeys[i]
|
||||
sKey = sKeys[i]
|
||||
row_box.add(Key(pkey, sKey))
|
||||
eKey = eKeys[i]
|
||||
row_box.add(Key(pkey, sKey, eKey))
|
||||
else:
|
||||
raise KeyboardRowMatchError("A row in keys_json has missmatched pKeys and sKeys lengths.")
|
||||
raise KeyboardRowMatchError("A row in keys_json has missmatched pKeys, sKeys, or eKeys lengths.")
|
||||
|
||||
self.add(Bottom_Key_Row())
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ gi.require_version('Gtk', '3.0')
|
|||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
from ..widgets.defined_keys import Backspace_Key, Enter_Key
|
||||
from ..widgets.defined_keys import Emoji_Keys, Backspace_Key, Enter_Key
|
||||
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ class Right_Column(Gtk.Box):
|
|||
|
||||
self.setup_styling()
|
||||
|
||||
for key in [Backspace_Key(), Enter_Key()]:
|
||||
for key in [Emoji_Keys(), Backspace_Key(), Enter_Key()]:
|
||||
self.add(key)
|
||||
|
||||
self.show_all()
|
||||
|
|
|
@ -16,3 +16,4 @@ class SignalsMixin:
|
|||
def setup_custom_event_signals(self):
|
||||
GObject.signal_new('toggle-caps', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
GObject.signal_new('toggle-symbol-keys', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
GObject.signal_new('toggle-emoji-keys', Key, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, (GObject.TYPE_PYOBJECT,))
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue