From 9514da7dff0c01c48fe24cc09dac857bc9de4255 Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Thu, 17 Dec 2009 09:43:41 -0200 Subject: [PATCH] Now it should be using the avatar cache properly; convert types from the settings window --- mitterlib/ui/ui_pygtk.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/mitterlib/ui/ui_pygtk.py b/mitterlib/ui/ui_pygtk.py index 588395a..5f462d1 100644 --- a/mitterlib/ui/ui_pygtk.py +++ b/mitterlib/ui/ui_pygtk.py @@ -526,15 +526,14 @@ class Interface(object): data = store.get_value(position, 0) pic = data.avatar 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 # again. Once downloaded, the _post_download_pic will update the # image and force a redraw. 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]) @@ -872,7 +871,7 @@ class Interface(object): # NAMESPACE. To set the values, we just run the dictionaries setting # self._options. self._fields = {self.NAMESPACE: {'refresh_interval': - self._refresh_interval_field}} + (self._refresh_interval_field, 'int')}} # next pages are each network settings net_options = self._connection.settings() @@ -904,7 +903,8 @@ class Interface(object): row += 1 - self._fields[network_name][option_name] = new_field + self._fields[network_name][option_name] = (new_field, + option['type']) net_box.show_all() tabs.insert_page(net_box, gtk.Label(network_name)) @@ -919,8 +919,10 @@ class Interface(object): """Update the interface settings.""" for namespace in self._fields: for option in self._fields[namespace]: - field = self._fields[namespace][option] + (field, field_type) = self._fields[namespace][option] value = field.get_text() + if field_type == 'int': + value = int(value) self._options[namespace][option] = value return True @@ -1035,11 +1037,6 @@ class Interface(object): ### image download function def _download_pic(self, url): """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) _log.debug('Starting request of %s' % (url)) response = urllib2.urlopen(request) @@ -1051,10 +1048,6 @@ class Interface(object): ### Results from the picture request def _post_download_pic(self, widget, data): """Called after the data from the picture is available.""" - if not data: - # image appeared in the queue - return - (url, data) = data loader = gtk.gdk.PixbufLoader()