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 ...@@ -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 at_the_end
from gajim.gtk.util import get_show_in_roster from gajim.gtk.util import get_show_in_roster
from gajim.gtk.util import get_show_in_systray 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.gtk.emoji_chooser import emoji_chooser
from gajim.command_system.implementation.middleware import ChatCommandProcessor from gajim.command_system.implementation.middleware import ChatCommandProcessor
...@@ -81,24 +82,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): ...@@ -81,24 +82,6 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
A base class containing a banner, ConversationTextview, MessageTextView A base class containing a banner, ConversationTextview, MessageTextView
""" """
keymap = Gdk.Keymap.get_for_display(Gdk.Display.get_default())
try:
keycode_c = keymap.get_entries_for_keyval(Gdk.KEY_c)[1][0].keycode
except TypeError:
keycode_c = 54
except IndexError:
# FIXME
# On some keyboard layouts there is no keyval for KEY_c
keycode_c = None
try:
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): def make_href(self, match):
url_color = app.css_config.get_value('.gajim-url', StyleAttr.COLOR) url_color = app.css_config.get_value('.gajim-url', StyleAttr.COLOR)
color = convert_rgb_to_hex(url_color) color = convert_rgb_to_hex(url_color)
...@@ -567,20 +550,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): ...@@ -567,20 +550,18 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
if event.button == 3: # right click if event.button == 3: # right click
self.parent_win.popup_menu(event) self.parent_win.popup_menu(event)
def _conv_textview_key_press_event(self, widget, event): def _conv_textview_key_press_event(self, _widget, event):
# translate any layout to latin_layout if (event.get_state() & get_primary_accel_mod() and
_valid, entries = self.keymap.get_entries_for_keyval(event.keyval) event.keyval in (Gdk.KEY_c, Gdk.KEY_Insert)):
keycode = entries[0].keycode return Gdk.EVENT_PROPAGATE
if (event.get_state() & Gdk.ModifierType.CONTROL_MASK and keycode in (
self.keycode_c, self.keycode_ins)):
return False
if event.get_state() & Gdk.ModifierType.SHIFT_MASK and \ if (event.get_state() & Gdk.ModifierType.SHIFT_MASK and
event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up): event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up)):
self._on_scroll(None, event.keyval) self._on_scroll(None, event.keyval)
return False return Gdk.EVENT_PROPAGATE
self.parent_win.notebook.event(event) self.parent_win.notebook.event(event)
return True return Gdk.EVENT_STOP
def _on_message_textview_key_press_event(self, widget, event): def _on_message_textview_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_space: if event.keyval == Gdk.KEY_space:
......
...@@ -472,3 +472,11 @@ def get_show_in_systray(type_, jid): ...@@ -472,3 +472,11 @@ def get_show_in_systray(type_, jid):
# it's not an highlighted message, don't show in systray # it's not an highlighted message, don't show in systray
return False return False
return app.config.get('trayicon_notification_on_events') 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
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment