fix some bug thanks to pychecker

This commit is contained in:
Yann Leboulanger 2005-07-19 20:12:02 +00:00
parent c048984641
commit b14b33fb1b
5 changed files with 56 additions and 54 deletions

View File

@ -53,8 +53,8 @@ class CellRendererImage(gtk.GenericCellRenderer):
model = tree.get_model()
model.foreach(self.func, (image, tree))
if self.redraw:
iter = image.get_data('iter')
gobject.timeout_add(iter.get_delay_time(),
i = image.get_data('iter')
gobject.timeout_add(i.get_delay_time(),
self.animation_timeout, tree, image)
else:
image.set_data('iter', None)
@ -79,8 +79,8 @@ class CellRendererImage(gtk.GenericCellRenderer):
if not self.image.get_data('iter'):
animation = self.image.get_animation()
self.image.set_data('iter', animation.get_iter())
iter = self.image.get_data('iter')
gobject.timeout_add(iter.get_delay_time(),
i = self.image.get_data('iter')
gobject.timeout_add(i.get_delay_time(),
self.animation_timeout,
widget, self.image)

View File

@ -120,11 +120,10 @@ class HistoryWindow:
def new_line(self, date, type, data):
"""write a new line"""
buffer = self.history_buffer
start_iter = buffer.get_start_iter()
end_iter = buffer.get_end_iter()
buff = self.history_buffer
start_iter = buff.get_start_iter()
tim = time.strftime('[%x %X] ', time.localtime(float(date)))
buffer.insert(start_iter, tim)
buff.insert(start_iter, tim)
name = None
tag_name = ''
tag_msg = ''
@ -160,11 +159,11 @@ class HistoryWindow:
before_str = gajim.config.get('before_nickname')
after_str = gajim.config.get('after_nickname')
format = before_str + name + after_str + ' '
buffer.insert_with_tags_by_name(start_iter, format, tag_name)
buff.insert_with_tags_by_name(start_iter, format, tag_name)
if tag_msg:
buffer.insert_with_tags_by_name(start_iter, msg, tag_msg)
buff.insert_with_tags_by_name(start_iter, msg, tag_msg)
else:
buffer.insert(start_iter, msg)
buff.insert(start_iter, msg)
def __init__(self, plugin, jid, account):
self.plugin = plugin

View File

@ -17,12 +17,17 @@
## GNU General Public License for more details.
##
import gtk
import gobject
from common import gajim
from time import time
from common import i18n
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain (APP, i18n.DIR)
gtk.glade.textdomain (APP)
try:
import dbus
except:
@ -109,8 +114,8 @@ class SignalObject(DbusPrototype):
if _version[1] >= 30:
from dbus import dbus_bindings
message = dbus_bindings.Signal(OBJ_PATH, INTERFACE, signal)
iter = message.get_iter(True)
iter.append(arg)
i = message.get_iter(True)
i.append(arg)
self._connection.send(message)
else:
self.emit_signal(INTERFACE, signal, arg)
@ -232,14 +237,13 @@ class SignalObject(DbusPrototype):
return None
accounts = gajim.contacts.keys()
iq = None
for account in accounts:
if gajim.contacts[account].has_key(jid):
self.vcard_account = account
gajim.connections[account].register_handler('VCARD',
self._receive_vcard)
iq = gajim.connections[account].request_vcard(jid)
gajim.connections[account].request_vcard(jid)
break
return None

View File

@ -67,9 +67,9 @@ class Systray:
self.img_tray.set_from_pixbuf(image.get_pixbuf())
def add_jid(self, jid, account):
list = [account, jid]
if not list in self.jids:
self.jids.append(list)
l = [account, jid]
if not l in self.jids:
self.jids.append(l)
self.set_img()
#we append to the number of unread messages
nb = self.plugin.roster.nb_unread
@ -84,9 +84,9 @@ class Systray:
self.set_tooltip(nb) # update the tooltip
def remove_jid(self, jid, account):
list = [account, jid]
if list in self.jids:
self.jids.remove(list)
l = [account, jid]
if l in self.jids:
self.jids.remove(l)
self.set_img()
#we remove from the number of unread messages
nb = self.plugin.roster.nb_unread
@ -269,8 +269,8 @@ class Systray:
self.make_menu(event)
def on_show_menuitem_activate(self, widget, show):
list = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'offline']
index = list.index(show)
l = ['online', 'chat', 'away', 'xa', 'dnd', 'invisible', 'offline']
index = l.index(show)
self.plugin.roster.status_combobox.set_active(index)
def show_icon(self):

View File

@ -119,29 +119,29 @@ class VcardWindow:
widget.get_preview_widget().set_from_file(path_to_file)
def on_set_avatar_button_clicked(self, widget):
file = None
f = None
dialog = gtk.FileChooserDialog(_('Choose avatar'), None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)
filter = gtk.FileFilter()
filter.set_name(_('All files'))
filter.add_pattern('*')
dialog.add_filter(filter)
filtr = gtk.FileFilter()
filtr.set_name(_('All files'))
filtr.add_pattern('*')
dialog.add_filter(filtr)
filter = gtk.FileFilter()
filter.set_name(_('Images'))
filter.add_mime_type('image/png')
filter.add_mime_type('image/jpeg')
filter.add_mime_type('image/gif')
filter.add_pattern('*.png')
filter.add_pattern('*.jpg')
filter.add_pattern('*.gif')
filter.add_pattern('*.tif')
filter.add_pattern('*.xpm')
dialog.add_filter(filter)
dialog.set_filter(filter)
filtr = gtk.FileFilter()
filtr.set_name(_('Images'))
filtr.add_mime_type('image/png')
filtr.add_mime_type('image/jpeg')
filtr.add_mime_type('image/gif')
filtr.add_pattern('*.png')
filtr.add_pattern('*.jpg')
filtr.add_pattern('*.gif')
filtr.add_pattern('*.tif')
filtr.add_pattern('*.xpm')
dialog.add_filter(filtr)
dialog.set_filter(filtr)
dialog.set_use_preview_label(False)
dialog.set_preview_widget(gtk.Image())
dialog.connect('selection-changed', self.update_preview)
@ -150,21 +150,21 @@ class VcardWindow:
while not ok:
response = dialog.run()
if response == gtk.RESPONSE_OK:
file = dialog.get_filename()
if self.image_is_ok(file):
f = dialog.get_filename()
if self.image_is_ok(f):
ok = True
else:
ok = True
dialog.destroy()
if file:
filesize = os.path.getsize(file) # in bytes
if f:
filesize = os.path.getsize(f) # in bytes
if filesize > 8192: # 8 kb
dialogs.ErrorDialog(_('The filesize of image "%s" is too large')\
% file,
% f,
_('The file must not be more than 8 kilobytes.')).get_response()
return
fd = open(file)
fd = open(f)
data = fd.read()
pixbufloader = gtk.gdk.PixbufLoader()
pixbufloader.write(data)
@ -173,12 +173,12 @@ class VcardWindow:
image = self.xml.get_widget('PHOTO_image')
image.set_from_pixbuf(pixbuf)
self.avatar_encoded = base64.encodestring(data)
self.avatar_mime_type = mimetypes.guess_type(file)[0]
self.avatar_mime_type = mimetypes.guess_type(f)[0]
def set_value(self, entry_name, value):
try:
self.xml.get_widget(entry_name).set_text(value)
except AttributeError, e:
except AttributeError:
pass
def set_values(self, vcard):
@ -341,10 +341,10 @@ class VcardWindow:
vcard = self.add_to_vcard(vcard, e, txt)
# DESC textview
buffer = self.xml.get_widget('DESC_textview').get_buffer()
start_iter = buffer.get_start_iter()
end_iter = buffer.get_end_iter()
txt = buffer.get_text(start_iter, end_iter, 0)
buff = self.xml.get_widget('DESC_textview').get_buffer()
start_iter = buff.get_start_iter()
end_iter = buff.get_end_iter()
txt = buff.get_text(start_iter, end_iter, 0)
if txt != '':
vcard['DESC'] = txt
@ -390,7 +390,6 @@ class VcardWindow:
def change_to_vcard(self):
self.xml.get_widget('information_notebook').remove_page(0)
self.xml.get_widget('nickname_label').set_text('Personal details')
information_hbuttonbox = self.xml.get_widget('information_hbuttonbox')
self.publish_button.show()
self.retrieve_button.show()