From 976b5a4b0e8a4f4769f449d5357e22f04a4b4afd Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Sat, 12 Jun 2010 04:14:40 +0000 Subject: fix #1771 - paint overwrites file type instead of creating new file Paint only writes type image/png. It can load other types, but overwrites as image/png. This patch detects reading a type that is not image/png, and forgets the association between the image being edited and the journal entry that was read, so that the original journal entry is not overwritten. http://bugs.sugarlabs.org/ticket/1771 --- diff --git a/OficinaActivity.py b/OficinaActivity.py index c72576a..21ccc04 100644 --- a/OficinaActivity.py +++ b/OficinaActivity.py @@ -140,8 +140,7 @@ class OficinaActivity(activity.Activity): def read_file(self, file_path): '''Read file from Sugar Journal.''' - - logging.debug('reading file %s', file_path) + logging.debug('reading file %s, mimetype: %s, title: %s', file_path, self.metadata['mime_type'],self.metadata['title']) pixbuf = gtk.gdk.pixbuf_new_from_file(file_path) @@ -155,6 +154,14 @@ class OficinaActivity(activity.Activity): self._setup_handle = self.fixed.connect('size_allocate', size_allocate_cb) + # disassociate with journal entry to avoid overwrite (SL #1771) + if self.metadata['mime_type'] != "image/png": + self._jobject.object_id = None + last_point_posi = self.metadata['title'].rfind('.') + if last_point_posi > -1: + self.metadata['title'] = self.metadata['title'][0:last_point_posi] + '.png' + logging.error('title: %s', self.metadata['title']) + def write_file(self, file_path): '''Save file on Sugar Journal. ''' -- cgit v0.9.1