Browse Source

Now it should be using the avatar cache properly; convert types from the settings window

master
Julio Biason 15 years ago
parent
commit
9514da7dff
  1. 27
      mitterlib/ui/ui_pygtk.py

27
mitterlib/ui/ui_pygtk.py

@ -526,15 +526,14 @@ class Interface(object):
data = store.get_value(position, 0) data = store.get_value(position, 0)
pic = data.avatar pic = data.avatar
if not pic in self._avatars: if not pic in self._avatars:
self._threads.add_work(self._post_download_pic,
self._exception_download_pic,
self._download_pic,
pic)
# set the user avatar to the default image, so it won't get queued # set the user avatar to the default image, so it won't get queued
# again. Once downloaded, the _post_download_pic will update the # again. Once downloaded, the _post_download_pic will update the
# image and force a redraw. # image and force a redraw.
self._avatars[pic] = self._images['avatar'] self._avatars[pic] = self._images['avatar']
self._threads.add_work(self._post_download_pic,
self._exception_download_pic,
self._download_pic,
pic)
cell.set_property('pixbuf', self._avatars[pic]) cell.set_property('pixbuf', self._avatars[pic])
@ -872,7 +871,7 @@ class Interface(object):
# NAMESPACE. To set the values, we just run the dictionaries setting # NAMESPACE. To set the values, we just run the dictionaries setting
# self._options. # self._options.
self._fields = {self.NAMESPACE: {'refresh_interval': self._fields = {self.NAMESPACE: {'refresh_interval':
self._refresh_interval_field}} (self._refresh_interval_field, 'int')}}
# next pages are each network settings # next pages are each network settings
net_options = self._connection.settings() net_options = self._connection.settings()
@ -904,7 +903,8 @@ class Interface(object):
row += 1 row += 1
self._fields[network_name][option_name] = new_field self._fields[network_name][option_name] = (new_field,
option['type'])
net_box.show_all() net_box.show_all()
tabs.insert_page(net_box, gtk.Label(network_name)) tabs.insert_page(net_box, gtk.Label(network_name))
@ -919,8 +919,10 @@ class Interface(object):
"""Update the interface settings.""" """Update the interface settings."""
for namespace in self._fields: for namespace in self._fields:
for option in self._fields[namespace]: for option in self._fields[namespace]:
field = self._fields[namespace][option] (field, field_type) = self._fields[namespace][option]
value = field.get_text() value = field.get_text()
if field_type == 'int':
value = int(value)
self._options[namespace][option] = value self._options[namespace][option] = value
return True return True
@ -1035,11 +1037,6 @@ class Interface(object):
### image download function ### image download function
def _download_pic(self, url): def _download_pic(self, url):
"""Download a picture from the web. Can be used in a thread.""" """Download a picture from the web. Can be used in a thread."""
# recheck if the image wasn't downloaded by other thread
if url in self._avatars:
_log.debug('Image %s available already' % (url))
return None
request = urllib2.Request(url=url) request = urllib2.Request(url=url)
_log.debug('Starting request of %s' % (url)) _log.debug('Starting request of %s' % (url))
response = urllib2.urlopen(request) response = urllib2.urlopen(request)
@ -1051,10 +1048,6 @@ class Interface(object):
### Results from the picture request ### Results from the picture request
def _post_download_pic(self, widget, data): def _post_download_pic(self, widget, data):
"""Called after the data from the picture is available.""" """Called after the data from the picture is available."""
if not data:
# image appeared in the queue
return
(url, data) = data (url, data) = data
loader = gtk.gdk.PixbufLoader() loader = gtk.gdk.PixbufLoader()

Loading…
Cancel
Save