Commit 19b0e73f authored by Philipp Hörist's avatar Philipp Hörist

Fix error on key press

Fixes #9471
parent 674ec48f
Pipeline #2846 passed with stages
in 3 minutes and 48 seconds
......@@ -57,6 +57,7 @@ from gajim.gtk.util import convert_rgb_to_hex
from gajim.gtk.util import at_the_end
from gajim.gtk.util import get_show_in_roster
from gajim.gtk.util import get_show_in_systray
from gajim.gtk.util import get_primary_accel_mod
from gajim.gtk.emoji_chooser import emoji_chooser
from gajim.command_system.implementation.middleware import ChatCommandProcessor
......@@ -81,24 +82,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
A base class containing a banner, ConversationTextview, MessageTextView
keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())
keycode_c = keymap.get_entries_for_keyval(Gdk.KEY_c)[1][0].keycode
except TypeError:
keycode_c = 54
except IndexError:
# On some keyboard layouts there is no keyval for KEY_c
keycode_c = None
keycode_ins = keymap.get_entries_for_keyval(Gdk.KEY_Insert)[1][0].keycode
except TypeError:
keycode_ins = 118
except IndexError:
# There is no KEY_Insert (MacOS)
keycode_ins = None
def make_href(self, match):
url_color = app.css_config.get_value('.gajim-url', StyleAttr.COLOR)
color = convert_rgb_to_hex(url_color)
......@@ -567,20 +550,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if event.button == 3: # right click
def _conv_textview_key_press_event(self, widget, event):
# translate any layout to latin_layout
_valid, entries = self.keymap.get_entries_for_keyval(event.keyval)
keycode = entries[0].keycode
if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and keycode in (
self.keycode_c, self.keycode_ins)):
return False
def _conv_textview_key_press_event(self, _widget, event):
if (event.get_state() & get_primary_accel_mod() and
event.keyval in (Gdk.KEY_c, Gdk.KEY_Insert)):
if event.get_state() & Gdk.ModifierType.SHIFT_MASK and \
event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up):
if (event.get_state() & Gdk.ModifierType.SHIFT_MASK and
event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up)):
self._on_scroll(None, event.keyval)
return False
return True
return Gdk.EVENT_STOP
def _on_message_textview_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_space:
......@@ -472,3 +472,11 @@ def get_show_in_systray(type_, jid):
# it's not an highlighted message, don't show in systray
return False
return app.config.get('trayicon_notification_on_events')
def get_primary_accel_mod():
Returns the primary Gdk.ModifierType modifier.
cmd on osx, ctrl everywhere else.
return Gtk.accelerator_parse("<Primary>")[1]
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment