update WrongLayoutPlugin to py3
This commit is contained in:
@@ -1 +1 @@
|
|||||||
from plugin import WrongLayoutPlugin
|
from .plugin import WrongLayoutPlugin
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ version: 0.1.3
|
|||||||
description: Press alt+r to convert chars typed in wrong layout Rus<>Eng
|
description: Press alt+r to convert chars typed in wrong layout Rus<>Eng
|
||||||
authors: Denis Fomin <fominde@gmail.com>
|
authors: Denis Fomin <fominde@gmail.com>
|
||||||
homepage: http://trac-plugins.gajim.org/wiki/WrongLayoutPlugin
|
homepage: http://trac-plugins.gajim.org/wiki/WrongLayoutPlugin
|
||||||
max_gajim_version: 0.15.9
|
min_gajim_version: 0.15.10
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
||||||
from plugins import GajimPlugin
|
from plugins import GajimPlugin
|
||||||
from plugins.helpers import log_calls, log
|
from plugins.helpers import log_calls
|
||||||
|
|
||||||
|
|
||||||
class WrongLayoutPlugin(GajimPlugin):
|
class WrongLayoutPlugin(GajimPlugin):
|
||||||
@@ -34,7 +35,7 @@ class WrongLayoutPlugin(GajimPlugin):
|
|||||||
'X': 'Ч', 'C': 'С', 'V': 'М', 'B': 'И', 'N': 'Т', 'M': 'Ь',
|
'X': 'Ч', 'C': 'С', 'V': 'М', 'B': 'И', 'N': 'Т', 'M': 'Ь',
|
||||||
'<': 'Б', '>': 'Ю', '?': ',', ':': 'Ж'}
|
'<': 'Б', '>': 'Ю', '?': ',', ':': 'Ж'}
|
||||||
self.dict_ru = {}
|
self.dict_ru = {}
|
||||||
for key in self.dict_eng.keys():
|
for key in list(self.dict_eng.keys()):
|
||||||
self.dict_ru[self.dict_eng[key]] = key
|
self.dict_ru[self.dict_eng[key]] = key
|
||||||
|
|
||||||
@log_calls('WrongLayoutPlugin')
|
@log_calls('WrongLayoutPlugin')
|
||||||
@@ -73,11 +74,11 @@ class Base(object):
|
|||||||
self.chat_control.msg_textview.disconnect(self.id_)
|
self.chat_control.msg_textview.disconnect(self.id_)
|
||||||
|
|
||||||
def mykeypress_event(self, widget, event):
|
def mykeypress_event(self, widget, event):
|
||||||
if event.keyval == gtk.keysyms.r or event.keyval == 1739:
|
if event.keyval == Gdk.KEY_r or event.keyval == 1739:
|
||||||
if event.state & gtk.gdk.MOD1_MASK: # alt+r
|
if event.state & Gdk.ModifierType.MOD1_MASK: # alt+r
|
||||||
start, end, iter_ = self.get_start_end()
|
start, end, iter_ = self.get_start_end()
|
||||||
count_eng = count_rus = 0
|
count_eng = count_rus = 0
|
||||||
c = iter_.get_char().decode('utf-8')
|
c = iter_.get_char()
|
||||||
while ((c != 0) & iter_.in_range(start, end)):
|
while ((c != 0) & iter_.in_range(start, end)):
|
||||||
if ((ord(c) > 65) & (ord(c) < 122)) | \
|
if ((ord(c) > 65) & (ord(c) < 122)) | \
|
||||||
(c == '@') | (c == '#') | (c == '$') | (c == '^') | \
|
(c == '@') | (c == '#') | (c == '$') | (c == '^') | \
|
||||||
@@ -89,10 +90,10 @@ class Base(object):
|
|||||||
(c == 'Ё') | (c == '№'):
|
(c == 'Ё') | (c == '№'):
|
||||||
count_rus += 1
|
count_rus += 1
|
||||||
iter_.forward_char()
|
iter_.forward_char()
|
||||||
c = iter_.get_char().decode('utf-8')
|
c = iter_.get_char()
|
||||||
is_russian = (count_rus >= count_eng)
|
is_russian = (count_rus >= count_eng)
|
||||||
start, end, iter_ = self.get_start_end()
|
start, end, iter_ = self.get_start_end()
|
||||||
c = iter_.get_char().decode('utf-8')
|
c = iter_.get_char()
|
||||||
text = ''
|
text = ''
|
||||||
while ((c != 0) & iter_.in_range(start, end)):
|
while ((c != 0) & iter_.in_range(start, end)):
|
||||||
if not is_russian:
|
if not is_russian:
|
||||||
@@ -101,7 +102,7 @@ class Base(object):
|
|||||||
conv = self.plugin.dict_ru.get(c.encode('utf-8'), c)
|
conv = self.plugin.dict_ru.get(c.encode('utf-8'), c)
|
||||||
text = text + conv
|
text = text + conv
|
||||||
iter_.forward_char()
|
iter_.forward_char()
|
||||||
c = iter_.get_char().decode('utf-8')
|
c = iter_.get_char()
|
||||||
start, end, iter_ = self.get_start_end()
|
start, end, iter_ = self.get_start_end()
|
||||||
message_buffer = self.chat_control.msg_textview.get_buffer()
|
message_buffer = self.chat_control.msg_textview.get_buffer()
|
||||||
message_buffer.delete(start, end)
|
message_buffer.delete(start, end)
|
||||||
@@ -118,7 +119,7 @@ class Base(object):
|
|||||||
start = message_buffer.get_start_iter()
|
start = message_buffer.get_start_iter()
|
||||||
end = message_buffer.get_end_iter()
|
end = message_buffer.get_end_iter()
|
||||||
stext = gajim.config.get('gc_refer_to_nick_char')
|
stext = gajim.config.get('gc_refer_to_nick_char')
|
||||||
res = start.forward_search(stext, gtk.TEXT_SEARCH_TEXT_ONLY)
|
res = start.forward_search(stext, Gtk.TextSearchFlags.TEXT_ONLY, None)
|
||||||
if res:
|
if res:
|
||||||
first, start = res
|
first, start = res
|
||||||
start.order(end)
|
start.order(end)
|
||||||
|
|||||||
Reference in New Issue
Block a user