Skip to content
Snippets Groups Projects
Commit 4fcf603a authored by Dicson's avatar Dicson
Browse files

coding style

parent 1e9d3b28
No related branches found
No related tags found
No related merge requests found
......@@ -17,13 +17,12 @@ class ChatstatePlugin(GajimPlugin):
@log_calls('ChatstatePlugin')
def init(self):
self.config_dialog = None#ChatstatePluginConfigDialog(self)
self.events_handlers = {'raw-message-received' :
(ged.POSTCORE, self.raw_pres_received),}
self.config_dialog = None # ChatstatePluginConfigDialog(self)
self.events_handlers = {'raw-message-received':
(ged.POSTCORE, self.raw_pres_received), }
self.chatstates = ('active', 'composing', 'gone', 'inactive', 'paused')
self.active = None
def raw_pres_received(self, event_object):
if not self.active:
return
......@@ -64,11 +63,12 @@ class ChatstatePlugin(GajimPlugin):
name = '<span foreground="%s">%s</span>' % (
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()
if status != '':
status = helpers.reduce_chars_newlines(status,
max_lines = 1)
max_lines=1)
color = gtkgui_helpers.get_fade_color(
gajim.interface.roster.tree, False, False)
colorstring = '#%04x%04x%04x' % (color.red, color.green,
......
......@@ -13,9 +13,9 @@ class ClickableNicknames(GajimPlugin):
@log_calls('ClickableNicknamesPlugin')
def init(self):
self.config_dialog = None#ClickableNicknamesPluginConfigDialog(self)
self.config_dialog = None # ClickableNicknamesPluginConfigDialog(self)
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.is_active = None
......@@ -58,7 +58,9 @@ class ClickableNicknames(GajimPlugin):
def disconnect_from_chat_control(self, chat_control):
pass
class Base(object):
def __init__(self, plugin, chat_control):
self.plugin = plugin
self.chat_control = chat_control
......
......@@ -71,7 +71,7 @@ clients = {
'http://2010.qip.ru/caps': 'qipinfium.png',
'http://qip.ru/caps': 'qipinfium.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',
'http://live.genome.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',
}
class ClientsIconsPlugin(GajimPlugin):
@log_calls('ClientsIconsPlugin')
......@@ -89,22 +90,21 @@ class ClientsIconsPlugin(GajimPlugin):
self.events_handlers = {'presence-received':
(ged.POSTGUI, self.presence_received),
'gc-presence-received':
(ged.POSTGUI, self.gc_presence_received),}
(ged.POSTGUI, self.gc_presence_received), }
self.gui_extension_points = {
'groupchat_control' : (self.connect_with_groupchat_control,
'groupchat_control': (self.connect_with_groupchat_control,
self.disconnect_from_groupchat_control),
'roster_draw_contact' : (self.connect_with_roster_draw_contact,
self.disconnect_from_roster_draw_contact)
}
'roster_draw_contact': (self.connect_with_roster_draw_contact,
self.disconnect_from_roster_draw_contact)}
self.config_default_values = {
'show_in_roster': (True,''),
'show_in_groupchats': (True,''),
'show_unknown_icon': (True,''),
'pos_in_list': (0,''),}
'show_in_roster': (True, ''),
'show_in_groupchats': (True, ''),
'show_unknown_icon': (True, ''),
'pos_in_list': (0, ''), }
self.config_dialog = ClientsIconsPluginConfigDialog(self)
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)
@log_calls('ClientsIconsPlugin')
......@@ -182,7 +182,7 @@ class ClientsIconsPlugin(GajimPlugin):
gc_control.fill_column(col)
gc_control.list_treeview.insert_column(col, 0)
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.set_sort_func(1, gc_control.tree_compare_iters)
store.set_sort_column_id(1, gtk.SORT_ASCENDING)
......@@ -238,7 +238,7 @@ class ClientsIconsPlugin(GajimPlugin):
roster.fill_column(col)
roster.tree.insert_column(col, 0)
roster.columns = roster.columns[:self.renderer_num] + roster.columns[
self.renderer_num+1:]
self.renderer_num + 1:]
roster.setup_and_draw_roster()
def presence_received(self, iq_obj):
......@@ -318,6 +318,7 @@ class ClientsIconsPlugin(GajimPlugin):
renderer.set_property('cell-background', None)
renderer.set_property('width', 16)
class ClientsIconsPluginConfigDialog(GajimPluginConfigDialog):
def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
......
......@@ -15,7 +15,7 @@ class FlashingKeyboard(GajimPlugin):
def init(self):
self.config_dialog = FlashingKeyboardPluginConfigDialog(self)
self.config_default_values = {
'command1': ("xset led named 'Scroll Lock'",''),
'command1': ("xset led named 'Scroll Lock'", ''),
'command2': ("xset -led named 'Scroll Lock'", '')}
self.is_active = None
......@@ -62,6 +62,7 @@ class FlashingKeyboard(GajimPlugin):
if self.id_0:
gobject.source_remove(self.id_0)
class FlashingKeyboardPluginConfigDialog(GajimPluginConfigDialog):
def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
......@@ -69,7 +70,7 @@ class FlashingKeyboardPluginConfigDialog(GajimPluginConfigDialog):
self.xml = gtk.Builder()
self.xml.set_translation_domain('flashingkeyboard')
self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH,
['config_table'])
['config_table'])
config_table = self.xml.get_object('config_table')
self.child.pack_start(config_table)
self.xml.connect_signals(self)
......
......@@ -30,34 +30,35 @@ try:
except:
pass
class JuickPlugin(GajimPlugin):
@log_calls('JuickPlugin')
def init(self):
self.config_dialog = JuickPluginConfigDialog(self)
self.gui_extension_points = {
'chat_control_base' : (self.connect_with_chat_control,
self.disconnect_from_chat_control)
}
self.config_default_values = {'SHOW_AVATARS': (False,''),
'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control)}
self.config_default_values = {'SHOW_AVATARS': (False, ''),
'AVATAR_SIZE': (20, _('Avatar size(10-32)')),
'SHOW_PREVIEW': (False,''),
'SHOW_PREVIEW': (False, ''),
'PREVIEW_SIZE': (150, _('Preview size(10-512)')),
'LINK_COLOR' : ('#B8833E', _('Juick link color')),
'SHOW_TAG_BUTTON': (True,''),
'ONLY_AUTHOR_AVATAR':(True,''),
'MENUITEM1': ('tune',''), 'MENUITEM_TEXT1': ('*tune',''),
'MENUITEM2': ('geo',''), 'MENUITEM_TEXT2': ('*geo',''),
'MENUITEM3': ('gajim',''), 'MENUITEM_TEXT3': ('*gajim',''),
'MENUITEM4': ('me',''), 'MENUITEM_TEXT4': ('/me',''),
'MENUITEM5': ('',''), 'MENUITEM_TEXT5': ('',''),
'MENUITEM6': ('',''), 'MENUITEM_TEXT6': ('',''),
'MENUITEM7': ('',''), 'MENUITEM_TEXT7': ('',''),
'MENUITEM8': ('',''), 'MENUITEM_TEXT8': ('',''),
'MENUITEM9': ('',''), 'MENUITEM_TEXT9': ('',''),
'MENUITEM10': ('',''), 'MENUITEM_TEXT10': ('',''),}
'LINK_COLOR': ('#B8833E', _('Juick link color')),
'SHOW_TAG_BUTTON': (True, ''),
'ONLY_AUTHOR_AVATAR': (True, ''),
'MENUITEM1': ('tune', ''), 'MENUITEM_TEXT1': ('*tune', ''),
'MENUITEM2': ('geo', ''), 'MENUITEM_TEXT2': ('*geo', ''),
'MENUITEM3': ('gajim', ''),
'MENUITEM_TEXT3': ('*gajim', ''),
'MENUITEM4': ('me', ''), 'MENUITEM_TEXT4': ('/me', ''),
'MENUITEM5': ('', ''), 'MENUITEM_TEXT5': ('', ''),
'MENUITEM6': ('', ''), 'MENUITEM_TEXT6': ('', ''),
'MENUITEM7': ('', ''), 'MENUITEM_TEXT7': ('', ''),
'MENUITEM8': ('', ''), 'MENUITEM_TEXT8': ('', ''),
'MENUITEM9': ('', ''), 'MENUITEM_TEXT9': ('', ''),
'MENUITEM10': ('', ''), 'MENUITEM_TEXT10': ('', ''), }
self.chat_control = None
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):
os.makedirs(self.cache_path)
......@@ -171,7 +172,8 @@ class Base(object):
img.set_from_stock('juick', gtk.ICON_SIZE_BUTTON)
self.button.set_image(img)
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',
send_button_pos - 1, 'expand', False)
id_ = self.button.connect('clicked', self.on_juick_button_clicked)
......@@ -240,7 +242,7 @@ class Base(object):
Create juick tag button menu
"""
self.menu = gtk.Menu()
for num in xrange(1,11):
for num in xrange(1, 11):
menuitem = self.plugin.config['MENUITEM' + str(num)]
text = self.plugin.config['MENUITEM_TEXT' + str(num)]
if menuitem == '' or text == '':
......@@ -327,14 +329,14 @@ class Base(object):
id_ = conn.connection.getAnID()
to = 'juick@juick.com'
iq = common.xmpp.Iq('get', to=to)
a = iq.addChild(name = 'query',
namespace = 'http://juick.com/query#users')
a = iq.addChild(name='query',
namespace='http://juick.com/query#users')
special_text1 = special_text[1:].rstrip(':')
a.addChild(name='user', namespace = 'http://juick.com/user',
attrs={'uname': special_text1})
a.addChild(name='user', namespace='http://juick.com/user',
attrs={'uname': special_text1})
iq.setID(id_)
conn.connection.SendAndCallForResponse(iq, self._on_response,
{'mark':mark, 'special_text':special_text})
{'mark': mark, 'special_text': special_text})
return
if gajim.interface.juick_pic_re.match(special_text) and \
self.plugin.config['SHOW_PREVIEW']:
......@@ -364,7 +366,6 @@ class Base(object):
tag = ttable.lookup(tag_name)
return buffer_, buffer_.get_end_iter(), tag
def _on_response(self, a, resp, **kwargs):
# insert avatar to text mark
mark = kwargs['mark']
......@@ -425,11 +426,11 @@ class Base(object):
if image_width > image_height:
if image_width > size:
image_height = int(size/float(image_width)*image_height)
image_width =int(size)
image_height = int(size / float(image_width) * image_height)
image_width = int(size)
else:
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)
crop_pixbuf = pixbuf.scale_simple(image_width, image_height,
......@@ -506,7 +507,7 @@ class Base(object):
def send(self, widget, text):
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.msg_textview.grab_focus()
......@@ -551,10 +552,11 @@ class Base(object):
def mykeypress_event(self, widget, event):
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)
return True
class JuickPluginConfigDialog(GajimPluginConfigDialog):
def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
......@@ -589,7 +591,7 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog):
self.plugin.config['LINK_COLOR']))
self.xml.get_object('show_tag_button').set_active(
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.plugin.config['MENUITEM' + str(num)])
self.xml.get_object('menuitem_text' + str(num)).set_text(
......@@ -623,6 +625,7 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog):
for control in self.plugin.controls:
control.textview.tagSharpSlash.set_property('foreground', color)
control.textview.tagJuickNick.set_property('foreground', color)
def menuitem_changed(self, widget):
name = upper(gtk.Buildable.get_name(widget))
self.plugin.config[name] = widget.get_text()
......
......@@ -14,15 +14,16 @@ from dialogs import ChangeActivityDialog, ChangeMoodDialog
from common import pep
import gtkgui_helpers
class RosterTweaksPlugin(GajimPlugin):
@log_calls('RosterTweaksPlugin')
def init(self):
self.config_dialog = RosterTweaksPluginConfigDialog(self)
self.config_default_values = {'hide_status_combo': (False,''),
'use_ctr_m': (False,''),
'menu_visible': (True,''),
self.config_default_values = {'hide_status_combo': (False, ''),
'use_ctr_m': (False, ''),
'menu_visible': (True, ''),
'quick_status': (False, '')}
@log_calls('RosterTweaksPlugin')
......@@ -45,7 +46,8 @@ class RosterTweaksPlugin(GajimPlugin):
).get_font_description()
self.activity_button = self.xml.get_object('activity_button')
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.set_property('no-show-all', True)
self.mood_button.set_property('visible', self.config['quick_status'])
......@@ -105,7 +107,7 @@ class RosterTweaksPlugin(GajimPlugin):
for account in accounts:
gajim.interface.roster.send_pep(account, self.pep_dict)
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))
def on_mood_button_clicked(self, widget):
......@@ -148,6 +150,7 @@ class RosterTweaksPlugin(GajimPlugin):
else:
img.set_from_stock('gtk-stop', gtk.ICON_SIZE_MENU)
class RosterTweaksPluginConfigDialog(GajimPluginConfigDialog):
def init(self):
self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
......
......@@ -22,28 +22,29 @@ try:
except:
pass
class SetLocationPlugin(GajimPlugin):
@log_calls('SetLocationPlugin')
def init(self):
self.config_dialog = SetLocationPluginConfigDialog(self)
self.config_default_values = {
'alt': (1609,''),
'alt': (1609, ''),
'area': ('Central Park', ''),
'building': ('The Empire State Building',''),
'building': ('The Empire State Building', ''),
'country': ('United States', ''),
'countrycode' : ('US', ''),
'description' : ('Bill\'s house', ''),
'floor' : ('102', ''),
'lat' : (39.75, ''),
'locality' : ('New York City', ''),
'lon' : (-104.99, ''),
'postalcode' : ('10027', ''),
'region' : ('New York', ''),
'room' : ('Observatory', ''),
'street' : ('34th and Broadway', ''),
'text' : ('Northwest corner of the lobby', ''),
'uri' : ('http://beta.plazes.com/plazes/1940:jabber_inc', ''),
'presets': ({'default': {}}, ''),}
'countrycode': ('US', ''),
'description': ('Bill\'s house', ''),
'floor': ('102', ''),
'lat': (39.75, ''),
'locality': ('New York City', ''),
'lon': (-104.99, ''),
'postalcode': ('10027', ''),
'region': ('New York', ''),
'room': ('Observatory', ''),
'street': ('34th and Broadway', ''),
'text': ('Northwest corner of the lobby', ''),
'uri': ('http://beta.plazes.com/plazes/1940:jabber_inc', ''),
'presets': ({'default': {}}, ''), }
@log_calls('SetLocationPlugin')
def activate(self):
......@@ -165,7 +166,7 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
try:
lat = float(self.xml.get_object('lat').get_text())
lon = float(self.xml.get_object('lon').get_text())
except ValueError,e:
except ValueError, e:
return
if not -85 < lat < 85 or not -180 < lon < 180:
return
......
......@@ -14,7 +14,8 @@ locale_path = os.path.dirname(__file__) + '/locale'
try:
gett = gettext.Catalog('WrongLayout', locale_path)
_ = gett.gettext
except: pass
except:
pass
class WrongLayoutPlugin(GajimPlugin):
......@@ -22,12 +23,12 @@ class WrongLayoutPlugin(GajimPlugin):
def init(self):
self.config_dialog = None
self.gui_extension_points = {
'chat_control_base' : (self.connect_with_chat_control,
self.disconnect_from_chat_control)
}
'chat_control_base': (self.connect_with_chat_control,
self.disconnect_from_chat_control)}
self.chat_control = None
self.controls = []
self.dict_eng = {'`': 'ё', 'q': 'й', 'w': 'ц', 'e': 'у', 'r': 'к', 't': 'е',
self.dict_eng = {'`': 'ё', 'q': 'й', 'w': 'ц', 'e': 'у', 'r': 'к',
't': 'е',
'y': 'н', 'u': 'г', 'i': 'ш', 'o': 'щ', 'p': 'з', '[': 'х',
']': 'ъ', 'a': 'ф', 's': 'ы', 'd': 'в', 'f': 'а', 'g': 'п',
'h': 'р', 'j': 'о', 'k': 'л', 'l': 'д', ';': 'ж', '\'': 'э',
......@@ -64,6 +65,7 @@ class WrongLayoutPlugin(GajimPlugin):
control.disconnect_from_chat_control()
self.controls = []
class Base(object):
def __init__(self, plugin, chat_control):
self.plugin = plugin
......@@ -80,7 +82,7 @@ class Base(object):
def mykeypress_event(self, widget, event):
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()
count_eng = count_rus = 0
c = iter_.get_char().decode('utf-8')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment