diff options
author | Jorge Saldivar <jsaldivar@paraguayeduca.org> | 2010-05-26 18:58:58 (GMT) |
---|---|---|
committer | Jorge Saldivar <jsaldivar@paraguayeduca.org> | 2010-05-26 18:58:58 (GMT) |
commit | ac89b3395cab06c4222cd61fec0033d29c661746 (patch) | |
tree | 3860985f9cac163c7ba9e89205138599e0ab975e | |
parent | 8fc28f25c3331d98970d36785677fce80d9c9eb3 (diff) |
solve bugs in images support and thumbnails
-rw-r--r-- | poll.py | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -60,7 +60,7 @@ from sugar.presence import presenceservice from sugar.graphics.objectchooser import ObjectChooser from sugar.datastore import datastore from sugar import mime -#from abiword import Canvas as AbiCanvas +from abiword import Canvas as AbiCanvas SERVICE = "org.worldwideworkshop.olpc.PollBuilder" IFACE = SERVICE @@ -826,7 +826,9 @@ class PollBuilder(activity.Activity): if result == gtk.RESPONSE_ACCEPT: logging.debug('ObjectChooser: %r' % chooser.get_selected_object()) jobject = chooser.get_selected_object() - if jobject and jobject.file_path: + images_mime_types = mime.get_generic_type(mime.GENERIC_TYPE_IMAGE).mime_types + if jobject and jobject.file_path and \ + jobject.metadata.get('mime_type') in images_mime_types: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(jobject.file_path, self._image_size['height'], self._image_size['width']) @@ -835,6 +837,13 @@ class PollBuilder(activity.Activity): self._poll.images_ds_objects[int(data)]['file_path'] = jobject.file_path self._show_image_thumbnail(data2, data) button.set_label(_('Change Image')) + else: + alert = NotifyAlert(timeout=3) + alert.props.title = _('Poll Activity') + alert.props.msg = _('Your selection is not an image') + self.add_alert(alert) + alert.connect('response', self._alert_cancel_cb) + alert.show() finally: chooser.destroy() del chooser @@ -842,13 +851,17 @@ class PollBuilder(activity.Activity): def _show_image_thumbnail(self, parent_box, answer_number): hbox = gtk.HBox() image_file_path = self._poll.images_ds_objects[int(answer_number)]['file_path'] - pixbuf_thumbnail = gtk.gdk.pixbuf_new_from_file_at_size(image_file_path, IMAGE_THUMBNAIL_HEIGHT, + pixbuf_thumbnail = gtk.gdk.pixbuf_new_from_file_at_size(image_file_path, + IMAGE_THUMBNAIL_HEIGHT, IMAGE_THUMBNAIL_WIDTH) image = gtk.Image() image.set_from_pixbuf(pixbuf_thumbnail) image.show() hbox.add(image) hbox.show() + chl = parent_box.get_children() + if len(chl) == 4: + parent_box.remove(chl[len(chl)-1]) parent_box.append(hippo.CanvasWidget(widget = hbox)) def _already_loaded_image_in_answer(self, answer_number): |