coding style

This commit is contained in:
Denis Fomin
2010-12-06 17:37:14 +03:00
parent 1e9d3b284b
commit 4fcf603aae
8 changed files with 96 additions and 83 deletions

View File

@@ -17,13 +17,12 @@ class ChatstatePlugin(GajimPlugin):
@log_calls('ChatstatePlugin') @log_calls('ChatstatePlugin')
def init(self): def init(self):
self.config_dialog = None#ChatstatePluginConfigDialog(self) self.config_dialog = None # ChatstatePluginConfigDialog(self)
self.events_handlers = {'raw-message-received' : self.events_handlers = {'raw-message-received':
(ged.POSTCORE, self.raw_pres_received),} (ged.POSTCORE, self.raw_pres_received), }
self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused') self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused')
self.active = None self.active = None
def raw_pres_received(self, event_object): def raw_pres_received(self, event_object):
if not self.active: if not self.active:
return return
@@ -64,11 +63,12 @@ class ChatstatePlugin(GajimPlugin):
name = '<span foreground="%s">%s</span>' % ( name = '<span foreground="%s">%s</span>' % (
color, name) color, name)
if contact.status and gajim.config.get('show_status_msgs_in_roster'): if contact.status and gajim.config.get(
'show_status_msgs_in_roster'):
status = contact.status.strip() status = contact.status.strip()
if status != '': if status != '':
status = helpers.reduce_chars_newlines(status, status = helpers.reduce_chars_newlines(status,
max_lines = 1) max_lines=1)
color = gtkgui_helpers.get_fade_color( color = gtkgui_helpers.get_fade_color(
gajim.interface.roster.tree, False, False) gajim.interface.roster.tree, False, False)
colorstring = '#%04x%04x%04x' % (color.red, color.green, colorstring = '#%04x%04x%04x' % (color.red, color.green,

View File

@@ -13,9 +13,9 @@ class ClickableNicknames(GajimPlugin):
@log_calls('ClickableNicknamesPlugin') @log_calls('ClickableNicknamesPlugin')
def init(self): def init(self):
self.config_dialog = None#ClickableNicknamesPluginConfigDialog(self) self.config_dialog = None # ClickableNicknamesPluginConfigDialog(self)
self.gui_extension_points = { self.gui_extension_points = {
'chat_control_base' : (self.connect_with_chat_control, 'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control)} self.disconnect_from_chat_control)}
self.is_active = None self.is_active = None
@@ -58,7 +58,9 @@ class ClickableNicknames(GajimPlugin):
def disconnect_from_chat_control(self, chat_control): def disconnect_from_chat_control(self, chat_control):
pass pass
class Base(object): class Base(object):
def __init__(self, plugin, chat_control): def __init__(self, plugin, chat_control):
self.plugin = plugin self.plugin = plugin
self.chat_control = chat_control self.chat_control = chat_control

View File

@@ -71,7 +71,7 @@ clients = {
'http://2010.qip.ru/caps': 'qipinfium.png', 'http://2010.qip.ru/caps': 'qipinfium.png',
'http://qip.ru/caps': 'qipinfium.png', 'http://qip.ru/caps': 'qipinfium.png',
'http://glu.net/': 'glu.png', 'http://glu.net/': 'glu.png',
'Siemens': 'siejc.png',# Siemens Native Jabber Client 'Siemens': 'siejc.png', # Siemens Native Jabber Client
'telepathy.': 'telepathy.freedesktop.org.png', 'telepathy.': 'telepathy.freedesktop.org.png',
'http://live.genome.org/empathy/caps': 'telepathy.freedesktop.org.png', 'http://live.genome.org/empathy/caps': 'telepathy.freedesktop.org.png',
'http://live.gnome.org/empathy/caps': 'telepathy.freedesktop.org.png', 'http://live.gnome.org/empathy/caps': 'telepathy.freedesktop.org.png',
@@ -81,6 +81,7 @@ clients = {
'http://juick.com/caps': 'juick.png', 'http://juick.com/caps': 'juick.png',
} }
class ClientsIconsPlugin(GajimPlugin): class ClientsIconsPlugin(GajimPlugin):
@log_calls('ClientsIconsPlugin') @log_calls('ClientsIconsPlugin')
@@ -89,22 +90,21 @@ class ClientsIconsPlugin(GajimPlugin):
self.events_handlers = {'presence-received': self.events_handlers = {'presence-received':
(ged.POSTGUI, self.presence_received), (ged.POSTGUI, self.presence_received),
'gc-presence-received': 'gc-presence-received':
(ged.POSTGUI, self.gc_presence_received),} (ged.POSTGUI, self.gc_presence_received), }
self.gui_extension_points = { self.gui_extension_points = {
'groupchat_control' : (self.connect_with_groupchat_control, 'groupchat_control': (self.connect_with_groupchat_control,
self.disconnect_from_groupchat_control), self.disconnect_from_groupchat_control),
'roster_draw_contact' : (self.connect_with_roster_draw_contact, 'roster_draw_contact': (self.connect_with_roster_draw_contact,
self.disconnect_from_roster_draw_contact) self.disconnect_from_roster_draw_contact)}
}
self.config_default_values = { self.config_default_values = {
'show_in_roster': (True,''), 'show_in_roster': (True, ''),
'show_in_groupchats': (True,''), 'show_in_groupchats': (True, ''),
'show_unknown_icon': (True,''), 'show_unknown_icon': (True, ''),
'pos_in_list': (0,''),} 'pos_in_list': (0, ''), }
self.config_dialog = ClientsIconsPluginConfigDialog(self) self.config_dialog = ClientsIconsPluginConfigDialog(self)
icon_path = os.path.join(self.local_file_path('icons'), 'unknown.png') icon_path = os.path.join(self.local_file_path('icons'), 'unknown.png')
self.default_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( icon_path, self.default_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path,
16, 16) 16, 16)
@log_calls('ClientsIconsPlugin') @log_calls('ClientsIconsPlugin')
@@ -182,7 +182,7 @@ class ClientsIconsPlugin(GajimPlugin):
gc_control.fill_column(col) gc_control.fill_column(col)
gc_control.list_treeview.insert_column(col, 0) gc_control.list_treeview.insert_column(col, 0)
gc_control.columns = gc_control.columns[:self.muc_renderer_num] + \ gc_control.columns = gc_control.columns[:self.muc_renderer_num] + \
gc_control.columns[self.muc_renderer_num+1:] gc_control.columns[self.muc_renderer_num + 1:]
store = gtk.TreeStore(*gc_control.columns) store = gtk.TreeStore(*gc_control.columns)
store.set_sort_func(1, gc_control.tree_compare_iters) store.set_sort_func(1, gc_control.tree_compare_iters)
store.set_sort_column_id(1, gtk.SORT_ASCENDING) store.set_sort_column_id(1, gtk.SORT_ASCENDING)
@@ -238,7 +238,7 @@ class ClientsIconsPlugin(GajimPlugin):
roster.fill_column(col) roster.fill_column(col)
roster.tree.insert_column(col, 0) roster.tree.insert_column(col, 0)
roster.columns = roster.columns[:self.renderer_num] + roster.columns[ roster.columns = roster.columns[:self.renderer_num] + roster.columns[
self.renderer_num+1:] self.renderer_num + 1:]
roster.setup_and_draw_roster() roster.setup_and_draw_roster()
def presence_received(self, iq_obj): def presence_received(self, iq_obj):
@@ -318,6 +318,7 @@ class ClientsIconsPlugin(GajimPlugin):
renderer.set_property('cell-background', None) renderer.set_property('cell-background', None)
renderer.set_property('width', 16) renderer.set_property('width', 16)
class ClientsIconsPluginConfigDialog(GajimPluginConfigDialog): class ClientsIconsPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(

View File

@@ -15,7 +15,7 @@ class FlashingKeyboard(GajimPlugin):
def init(self): def init(self):
self.config_dialog = FlashingKeyboardPluginConfigDialog(self) self.config_dialog = FlashingKeyboardPluginConfigDialog(self)
self.config_default_values = { self.config_default_values = {
'command1': ("xset led named 'Scroll Lock'",''), 'command1': ("xset led named 'Scroll Lock'", ''),
'command2': ("xset -led named 'Scroll Lock'", '')} 'command2': ("xset -led named 'Scroll Lock'", '')}
self.is_active = None self.is_active = None
@@ -62,6 +62,7 @@ class FlashingKeyboard(GajimPlugin):
if self.id_0: if self.id_0:
gobject.source_remove(self.id_0) gobject.source_remove(self.id_0)
class FlashingKeyboardPluginConfigDialog(GajimPluginConfigDialog): class FlashingKeyboardPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
@@ -69,7 +70,7 @@ class FlashingKeyboardPluginConfigDialog(GajimPluginConfigDialog):
self.xml = gtk.Builder() self.xml = gtk.Builder()
self.xml.set_translation_domain('flashingkeyboard') self.xml.set_translation_domain('flashingkeyboard')
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
['config_table']) ['config_table'])
config_table = self.xml.get_object('config_table') config_table = self.xml.get_object('config_table')
self.child.pack_start(config_table) self.child.pack_start(config_table)
self.xml.connect_signals(self) self.xml.connect_signals(self)

View File

@@ -30,34 +30,35 @@ try:
except: except:
pass pass
class JuickPlugin(GajimPlugin): class JuickPlugin(GajimPlugin):
@log_calls('JuickPlugin') @log_calls('JuickPlugin')
def init(self): def init(self):
self.config_dialog = JuickPluginConfigDialog(self) self.config_dialog = JuickPluginConfigDialog(self)
self.gui_extension_points = { self.gui_extension_points = {
'chat_control_base' : (self.connect_with_chat_control, 'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control) self.disconnect_from_chat_control)}
} self.config_default_values = {'SHOW_AVATARS': (False, ''),
self.config_default_values = {'SHOW_AVATARS': (False,''),
'AVATAR_SIZE': (20, _('Avatar size(10-32)')), 'AVATAR_SIZE': (20, _('Avatar size(10-32)')),
'SHOW_PREVIEW': (False,''), 'SHOW_PREVIEW': (False, ''),
'PREVIEW_SIZE': (150, _('Preview size(10-512)')), 'PREVIEW_SIZE': (150, _('Preview size(10-512)')),
'LINK_COLOR' : ('#B8833E', _('Juick link color')), 'LINK_COLOR': ('#B8833E', _('Juick link color')),
'SHOW_TAG_BUTTON': (True,''), 'SHOW_TAG_BUTTON': (True, ''),
'ONLY_AUTHOR_AVATAR':(True,''), 'ONLY_AUTHOR_AVATAR': (True, ''),
'MENUITEM1': ('tune',''), 'MENUITEM_TEXT1': ('*tune',''), 'MENUITEM1': ('tune', ''), 'MENUITEM_TEXT1': ('*tune', ''),
'MENUITEM2': ('geo',''), 'MENUITEM_TEXT2': ('*geo',''), 'MENUITEM2': ('geo', ''), 'MENUITEM_TEXT2': ('*geo', ''),
'MENUITEM3': ('gajim',''), 'MENUITEM_TEXT3': ('*gajim',''), 'MENUITEM3': ('gajim', ''),
'MENUITEM4': ('me',''), 'MENUITEM_TEXT4': ('/me',''), 'MENUITEM_TEXT3': ('*gajim', ''),
'MENUITEM5': ('',''), 'MENUITEM_TEXT5': ('',''), 'MENUITEM4': ('me', ''), 'MENUITEM_TEXT4': ('/me', ''),
'MENUITEM6': ('',''), 'MENUITEM_TEXT6': ('',''), 'MENUITEM5': ('', ''), 'MENUITEM_TEXT5': ('', ''),
'MENUITEM7': ('',''), 'MENUITEM_TEXT7': ('',''), 'MENUITEM6': ('', ''), 'MENUITEM_TEXT6': ('', ''),
'MENUITEM8': ('',''), 'MENUITEM_TEXT8': ('',''), 'MENUITEM7': ('', ''), 'MENUITEM_TEXT7': ('', ''),
'MENUITEM9': ('',''), 'MENUITEM_TEXT9': ('',''), 'MENUITEM8': ('', ''), 'MENUITEM_TEXT8': ('', ''),
'MENUITEM10': ('',''), 'MENUITEM_TEXT10': ('',''),} 'MENUITEM9': ('', ''), 'MENUITEM_TEXT9': ('', ''),
'MENUITEM10': ('', ''), 'MENUITEM_TEXT10': ('', ''), }
self.chat_control = None self.chat_control = None
self.controls = [] self.controls = []
self.cache_path = os.path.join(gajim.AVATAR_PATH, 'juick') self.cache_path = os.path.join(gajim.AVATAR_PATH, 'juick')
if not os.path.isdir(self.cache_path): if not os.path.isdir(self.cache_path):
os.makedirs(self.cache_path) os.makedirs(self.cache_path)
@@ -171,7 +172,8 @@ class Base(object):
img.set_from_stock('juick', gtk.ICON_SIZE_BUTTON) img.set_from_stock('juick', gtk.ICON_SIZE_BUTTON)
self.button.set_image(img) self.button.set_image(img)
send_button = self.chat_control.xml.get_object('send_button') send_button = self.chat_control.xml.get_object('send_button')
send_button_pos = actions_hbox.child_get_property(send_button, 'position') send_button_pos = actions_hbox.child_get_property(send_button,
'position')
actions_hbox.add_with_properties(self.button, 'position', actions_hbox.add_with_properties(self.button, 'position',
send_button_pos - 1, 'expand', False) send_button_pos - 1, 'expand', False)
id_ = self.button.connect('clicked', self.on_juick_button_clicked) id_ = self.button.connect('clicked', self.on_juick_button_clicked)
@@ -240,7 +242,7 @@ class Base(object):
Create juick tag button menu Create juick tag button menu
""" """
self.menu = gtk.Menu() self.menu = gtk.Menu()
for num in xrange(1,11): for num in xrange(1, 11):
menuitem = self.plugin.config['MENUITEM' + str(num)] menuitem = self.plugin.config['MENUITEM' + str(num)]
text = self.plugin.config['MENUITEM_TEXT' + str(num)] text = self.plugin.config['MENUITEM_TEXT' + str(num)]
if menuitem == '' or text == '': if menuitem == '' or text == '':
@@ -327,14 +329,14 @@ class Base(object):
id_ = conn.connection.getAnID() id_ = conn.connection.getAnID()
to = 'juick@juick.com' to = 'juick@juick.com'
iq = common.xmpp.Iq('get', to=to) iq = common.xmpp.Iq('get', to=to)
a = iq.addChild(name = 'query', a = iq.addChild(name='query',
namespace = 'http://juick.com/query#users') namespace='http://juick.com/query#users')
special_text1 = special_text[1:].rstrip(':') special_text1 = special_text[1:].rstrip(':')
a.addChild(name='user', namespace = 'http://juick.com/user', a.addChild(name='user', namespace='http://juick.com/user',
attrs={'uname': special_text1}) attrs={'uname': special_text1})
iq.setID(id_) iq.setID(id_)
conn.connection.SendAndCallForResponse(iq, self._on_response, conn.connection.SendAndCallForResponse(iq, self._on_response,
{'mark':mark, 'special_text':special_text}) {'mark': mark, 'special_text': special_text})
return return
if gajim.interface.juick_pic_re.match(special_text) and \ if gajim.interface.juick_pic_re.match(special_text) and \
self.plugin.config['SHOW_PREVIEW']: self.plugin.config['SHOW_PREVIEW']:
@@ -364,7 +366,6 @@ class Base(object):
tag = ttable.lookup(tag_name) tag = ttable.lookup(tag_name)
return buffer_, buffer_.get_end_iter(), tag return buffer_, buffer_.get_end_iter(), tag
def _on_response(self, a, resp, **kwargs): def _on_response(self, a, resp, **kwargs):
# insert avatar to text mark # insert avatar to text mark
mark = kwargs['mark'] mark = kwargs['mark']
@@ -425,11 +426,11 @@ class Base(object):
if image_width > image_height: if image_width > image_height:
if image_width > size: if image_width > size:
image_height = int(size/float(image_width)*image_height) image_height = int(size / float(image_width) * image_height)
image_width =int(size) image_width = int(size)
else: else:
if image_height > size: if image_height > size:
image_width = int(size/float(image_height)*image_width) image_width = int(size / float(image_height) * image_width)
image_height = int(size) image_height = int(size)
crop_pixbuf = pixbuf.scale_simple(image_width, image_height, crop_pixbuf = pixbuf.scale_simple(image_width, image_height,
@@ -506,7 +507,7 @@ class Base(object):
def send(self, widget, text): def send(self, widget, text):
msg = text.replace('WORD', self.juick_post_uid).replace( msg = text.replace('WORD', self.juick_post_uid).replace(
'NICK',self.juick_nick.rstrip(':')) 'NICK', self.juick_nick.rstrip(':'))
self.chat_control.send_message(msg) self.chat_control.send_message(msg)
self.chat_control.msg_textview.grab_focus() self.chat_control.msg_textview.grab_focus()
@@ -551,10 +552,11 @@ class Base(object):
def mykeypress_event(self, widget, event): def mykeypress_event(self, widget, event):
if event.keyval == gtk.keysyms.Up: if event.keyval == gtk.keysyms.Up:
if event.state & gtk.gdk.MOD1_MASK: # Alt+UP if event.state & gtk.gdk.MOD1_MASK: # Alt+UP
self.on_insert(widget, self.last_juick_num) self.on_insert(widget, self.last_juick_num)
return True return True
class JuickPluginConfigDialog(GajimPluginConfigDialog): class JuickPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
@@ -589,7 +591,7 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog):
self.plugin.config['LINK_COLOR'])) self.plugin.config['LINK_COLOR']))
self.xml.get_object('show_tag_button').set_active( self.xml.get_object('show_tag_button').set_active(
self.plugin.config['SHOW_TAG_BUTTON']) self.plugin.config['SHOW_TAG_BUTTON'])
for num in xrange(1,11): for num in xrange(1, 11):
self.xml.get_object('menuitem' + str(num)).set_text( self.xml.get_object('menuitem' + str(num)).set_text(
self.plugin.config['MENUITEM' + str(num)]) self.plugin.config['MENUITEM' + str(num)])
self.xml.get_object('menuitem_text' + str(num)).set_text( self.xml.get_object('menuitem_text' + str(num)).set_text(
@@ -623,6 +625,7 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog):
for control in self.plugin.controls: for control in self.plugin.controls:
control.textview.tagSharpSlash.set_property('foreground', color) control.textview.tagSharpSlash.set_property('foreground', color)
control.textview.tagJuickNick.set_property('foreground', color) control.textview.tagJuickNick.set_property('foreground', color)
def menuitem_changed(self, widget): def menuitem_changed(self, widget):
name = upper(gtk.Buildable.get_name(widget)) name = upper(gtk.Buildable.get_name(widget))
self.plugin.config[name] = widget.get_text() self.plugin.config[name] = widget.get_text()

View File

@@ -14,15 +14,16 @@ from dialogs import ChangeActivityDialog, ChangeMoodDialog
from common import pep from common import pep
import gtkgui_helpers import gtkgui_helpers
class RosterTweaksPlugin(GajimPlugin): class RosterTweaksPlugin(GajimPlugin):
@log_calls('RosterTweaksPlugin') @log_calls('RosterTweaksPlugin')
def init(self): def init(self):
self.config_dialog = RosterTweaksPluginConfigDialog(self) self.config_dialog = RosterTweaksPluginConfigDialog(self)
self.config_default_values = {'hide_status_combo': (False,''), self.config_default_values = {'hide_status_combo': (False, ''),
'use_ctr_m': (False,''), 'use_ctr_m': (False, ''),
'menu_visible': (True,''), 'menu_visible': (True, ''),
'quick_status': (False, '')} 'quick_status': (False, '')}
@log_calls('RosterTweaksPlugin') @log_calls('RosterTweaksPlugin')
@@ -45,7 +46,8 @@ class RosterTweaksPlugin(GajimPlugin):
).get_font_description() ).get_font_description()
self.activity_button = self.xml.get_object('activity_button') self.activity_button = self.xml.get_object('activity_button')
self.activity_button.set_property('no-show-all', True) self.activity_button.set_property('no-show-all', True)
self.activity_button.set_property('visible', self.config['quick_status']) self.activity_button.set_property('visible', self.config[
'quick_status'])
self.mood_button = self.xml.get_object('mood_button') self.mood_button = self.xml.get_object('mood_button')
self.mood_button.set_property('no-show-all', True) self.mood_button.set_property('no-show-all', True)
self.mood_button.set_property('visible', self.config['quick_status']) self.mood_button.set_property('visible', self.config['quick_status'])
@@ -105,7 +107,7 @@ class RosterTweaksPlugin(GajimPlugin):
for account in accounts: for account in accounts:
gajim.interface.roster.send_pep(account, self.pep_dict) gajim.interface.roster.send_pep(account, self.pep_dict)
ChangeActivityDialog(on_response, self.pep_dict.get('activity', None), ChangeActivityDialog(on_response, self.pep_dict.get('activity', None),
self.pep_dict.get('subactivity',None), self.pep_dict.get('subactivity', None),
self.pep_dict.get('activity_text', None)) self.pep_dict.get('activity_text', None))
def on_mood_button_clicked(self, widget): def on_mood_button_clicked(self, widget):
@@ -148,6 +150,7 @@ class RosterTweaksPlugin(GajimPlugin):
else: else:
img.set_from_stock('gtk-stop', gtk.ICON_SIZE_MENU) img.set_from_stock('gtk-stop', gtk.ICON_SIZE_MENU)
class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog): class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog):
def init(self): def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path( self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(

View File

@@ -22,28 +22,29 @@ try:
except: except:
pass pass
class SetLocationPlugin(GajimPlugin): class SetLocationPlugin(GajimPlugin):
@log_calls('SetLocationPlugin') @log_calls('SetLocationPlugin')
def init(self): def init(self):
self.config_dialog = SetLocationPluginConfigDialog(self) self.config_dialog = SetLocationPluginConfigDialog(self)
self.config_default_values = { self.config_default_values = {
'alt': (1609,''), 'alt': (1609, ''),
'area': ('Central Park', ''), 'area': ('Central Park', ''),
'building': ('The Empire State Building',''), 'building': ('The Empire State Building', ''),
'country': ('United States', ''), 'country': ('United States', ''),
'countrycode' : ('US', ''), 'countrycode': ('US', ''),
'description' : ('Bill\'s house', ''), 'description': ('Bill\'s house', ''),
'floor' : ('102', ''), 'floor': ('102', ''),
'lat' : (39.75, ''), 'lat': (39.75, ''),
'locality' : ('New York City', ''), 'locality': ('New York City', ''),
'lon' : (-104.99, ''), 'lon': (-104.99, ''),
'postalcode' : ('10027', ''), 'postalcode': ('10027', ''),
'region' : ('New York', ''), 'region': ('New York', ''),
'room' : ('Observatory', ''), 'room': ('Observatory', ''),
'street' : ('34th and Broadway', ''), 'street': ('34th and Broadway', ''),
'text' : ('Northwest corner of the lobby', ''), 'text': ('Northwest corner of the lobby', ''),
'uri' : ('http://beta.plazes.com/plazes/1940:jabber_inc', ''), 'uri': ('http://beta.plazes.com/plazes/1940:jabber_inc', ''),
'presets': ({'default': {}}, ''),} 'presets': ({'default': {}}, ''), }
@log_calls('SetLocationPlugin') @log_calls('SetLocationPlugin')
def activate(self): def activate(self):
@@ -165,7 +166,7 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
try: try:
lat = float(self.xml.get_object('lat').get_text()) lat = float(self.xml.get_object('lat').get_text())
lon = float(self.xml.get_object('lon').get_text()) lon = float(self.xml.get_object('lon').get_text())
except ValueError,e: except ValueError, e:
return return
if not -85 < lat < 85 or not -180 < lon < 180: if not -85 < lat < 85 or not -180 < lon < 180:
return return

View File

@@ -14,7 +14,8 @@ locale_path = os.path.dirname(__file__) + '/locale'
try: try:
gett = gettext.Catalog('WrongLayout', locale_path) gett = gettext.Catalog('WrongLayout', locale_path)
_ = gett.gettext _ = gett.gettext
except: pass except:
pass
class WrongLayoutPlugin(GajimPlugin): class WrongLayoutPlugin(GajimPlugin):
@@ -22,12 +23,12 @@ class WrongLayoutPlugin(GajimPlugin):
def init(self): def init(self):
self.config_dialog = None self.config_dialog = None
self.gui_extension_points = { self.gui_extension_points = {
'chat_control_base' : (self.connect_with_chat_control, 'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control) self.disconnect_from_chat_control)}
}
self.chat_control = None self.chat_control = None
self.controls = [] self.controls = []
self.dict_eng = {'`': 'ё', 'q': 'й', 'w': 'ц', 'e': 'у', 'r': 'к', 't': 'е', self.dict_eng = {'`': 'ё', 'q': 'й', 'w': 'ц', 'e': 'у', 'r': 'к',
't': 'е',
'y': 'н', 'u': 'г', 'i': 'ш', 'o': 'щ', 'p': 'з', '[': 'х', 'y': 'н', 'u': 'г', 'i': 'ш', 'o': 'щ', 'p': 'з', '[': 'х',
']': 'ъ', 'a': 'ф', 's': 'ы', 'd': 'в', 'f': 'а', 'g': 'п', ']': 'ъ', 'a': 'ф', 's': 'ы', 'd': 'в', 'f': 'а', 'g': 'п',
'h': 'р', 'j': 'о', 'k': 'л', 'l': 'д', ';': 'ж', '\'': 'э', 'h': 'р', 'j': 'о', 'k': 'л', 'l': 'д', ';': 'ж', '\'': 'э',
@@ -64,6 +65,7 @@ class WrongLayoutPlugin(GajimPlugin):
control.disconnect_from_chat_control() control.disconnect_from_chat_control()
self.controls = [] self.controls = []
class Base(object): class Base(object):
def __init__(self, plugin, chat_control): def __init__(self, plugin, chat_control):
self.plugin = plugin self.plugin = plugin
@@ -80,7 +82,7 @@ class Base(object):
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 == gtk.keysyms.r or event.keyval == 1739:
if event.state & gtk.gdk.MOD1_MASK: # alt+r if event.state & gtk.gdk.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().decode('utf-8')