Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-04-15 12:35:16 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-04-15 12:35:16 (GMT)
commit0e069dcc5a4a416e679dc5c1a15fd468246bc0f5 (patch)
treee3a0c3f1c055207990bf0f278f66bda421113548 /src
parenta4c97e5c60d93cf7ce42ccf6b191dc376df383d1 (diff)
Back switch to old jobject format
Diffstat (limited to 'src')
-rw-r--r--src/BaseThought.py7
-rw-r--r--src/DrawingThought.py4
-rw-r--r--src/ImageThought.py38
-rw-r--r--src/MMapArea.py22
-rw-r--r--src/TextThought.py4
5 files changed, 31 insertions, 44 deletions
diff --git a/src/BaseThought.py b/src/BaseThought.py
index 4279d49..9f5c265 100644
--- a/src/BaseThought.py
+++ b/src/BaseThought.py
@@ -186,10 +186,13 @@ class BaseThought (gobject.GObject):
def draw (self, context):
pass
- def load (self, node, zip):
+ def load (self, node, tar):
pass
- def update_save (self, zip):
+ def update_save (self):
+ pass
+
+ def save (self, tar):
pass
def copy_text (self, clip):
diff --git a/src/DrawingThought.py b/src/DrawingThought.py
index 5a8448c..8b2e34e 100644
--- a/src/DrawingThought.py
+++ b/src/DrawingThought.py
@@ -334,7 +334,7 @@ class DrawingThought (ResizableThought):
map(lambda p : p.move_by(x,y), self.points)
ResizableThought.move_content_by(self, x, y)
- def update_save (self, zip):
+ def update_save (self):
next = self.element.firstChild
while next:
m = next.nextSibling
@@ -383,7 +383,7 @@ class DrawingThought (ResizableThought):
elem.setAttribute ("color", p.color.to_string())
return
- def load (self, node, zip):
+ def load (self, node, tar):
tmp = node.getAttribute ("ul-coords")
self.ul = utils.parse_coords (tmp)
tmp = node.getAttribute ("lr-coords")
diff --git a/src/ImageThought.py b/src/ImageThought.py
index 78bba20..8884e61 100644
--- a/src/ImageThought.py
+++ b/src/ImageThought.py
@@ -72,7 +72,7 @@ class ImageThought (ResizableThought):
logging.debug("journal_open_image: fname=%s" % jobject.file_path)
try:
self.orig_pic = gtk.gdk.pixbuf_new_from_file (jobject.file_path)
- self.filename = os.path.basename(jobject.file_path)
+ self.filename = os.path.join('images', os.path.basename(jobject.file_path))
except Exception, e:
logging.error("journal_open_image: %s" % e)
return False
@@ -158,7 +158,7 @@ class ImageThought (ResizableThought):
return False
- def update_save (self, zip):
+ def update_save (self):
text = self.extended_buffer.get_text ()
if text:
self.extended_buffer.update_save()
@@ -189,16 +189,17 @@ class ImageThought (ResizableThought):
except xml.dom.NotFoundErr:
pass
- arcname = self.filename.encode('cp437')
- if not [i for i in zip.namelist() if i == arcname]:
- zip.writestr(arcname, pixbuf2str(self.orig_pic))
+ def save (self, tar):
+ if not [i for i in tar.getnames() if i == self.filename]:
+ tar.write(self.filename, self.orig_pic)
- def load (self, node, zip):
+ def load (self, node, tar):
tmp = node.getAttribute ("ul-coords")
self.ul = utils.parse_coords (tmp)
tmp = node.getAttribute ("lr-coords")
self.lr = utils.parse_coords (tmp)
- self.filename = node.getAttribute ("file")
+ self.filename = os.path.join('images',
+ os.path.basename(node.getAttribute ("file")))
self.identity = int (node.getAttribute ("identity"))
try:
tmp = node.getAttribute ("background-color")
@@ -217,30 +218,9 @@ class ImageThought (ResizableThought):
print "Unknown: "+n.nodeName
margin = utils.margin_required (utils.STYLE_NORMAL)
self.pic_location = (self.ul[0]+margin[0], self.ul[1]+margin[1])
- self.orig_pic = str2pixbuf(zip.read(self.filename.encode('cp437')))
+ self.orig_pic = tar.read_pixbuf(self.filename)
self.lr = (self.pic_location[0]+self.width+margin[2], self.pic_location[1]+self.height+margin[3])
self.recalc_edges()
def enter (self):
self.editing = True
-
-def pixbuf2str(pixbuf):
- def push(data, buffer):
- buffer.write(data)
-
- buffer = cStringIO.StringIO()
- pixbuf.save_to_callback(push, 'png', user_data=buffer)
-
- return buffer.getvalue()
-
-def str2pixbuf(data):
- fd, path = tempfile.mkstemp()
-
- f = os.fdopen(fd, 'w')
- f.write(data)
- f.close()
-
- out = gtk.gdk.pixbuf_new_from_file(path)
- os.unlink(path)
-
- return out
diff --git a/src/MMapArea.py b/src/MMapArea.py
index dccc2e7..e89ff68 100644
--- a/src/MMapArea.py
+++ b/src/MMapArea.py
@@ -1006,10 +1006,10 @@ class MMapArea (gtk.DrawingArea):
self.invalidate ()
return True
- def load_thought (self, node, type, zip):
+ def load_thought (self, node, type, tar):
thought = self.create_new_thought (None, type, loading = True)
thought.creating = False
- thought.load (node, zip)
+ thought.load (node, tar)
def load_link (self, node):
link = Link (self.save)
@@ -1019,16 +1019,16 @@ class MMapArea (gtk.DrawingArea):
element = link.get_save_element ()
self.element.appendChild (element)
- def load_thyself (self, top_element, doc, zip):
+ def load_thyself (self, top_element, doc, tar):
for node in top_element.childNodes:
if node.nodeName == "thought":
- self.load_thought (node, MODE_TEXT, zip)
+ self.load_thought (node, MODE_TEXT, tar)
elif node.nodeName == "image_thought":
- self.load_thought (node, MODE_IMAGE, zip)
+ self.load_thought (node, MODE_IMAGE, tar)
elif node.nodeName == "drawing_thought":
- self.load_thought (node, MODE_DRAW, zip)
+ self.load_thought (node, MODE_DRAW, tar)
elif node.nodeName == "res_thought":
- self.load_thought (node, MODE_RESOURCE, zip)
+ self.load_thought (node, MODE_RESOURCE, tar)
elif node.nodeName == "link":
self.load_link (node)
else:
@@ -1079,12 +1079,16 @@ class MMapArea (gtk.DrawingArea):
for l in del_links:
self.delete_link (l)
- def update_save(self, zip):
+ def update_save(self):
for t in self.thoughts:
- t.update_save (zip)
+ t.update_save ()
for l in self.links:
l.update_save ()
+ def save_thyself(self, tar):
+ for t in self.thoughts:
+ t.save(tar)
+
def text_selection_cb (self, thought, start, end, text):
self.emit ("text_selection_changed", start, end, text)
diff --git a/src/TextThought.py b/src/TextThought.py
index 3bb0599..59fb914 100644
--- a/src/TextThought.py
+++ b/src/TextThought.py
@@ -790,7 +790,7 @@ class TextThought (ResizableThought):
context.set_source_rgb (0,0,0)
context.stroke ()
- def update_save (self, zip):
+ def update_save (self):
next = self.element.firstChild
while next:
m = next.nextSibling
@@ -886,7 +886,7 @@ class TextThought (ResizableThought):
self.bindex = self.b_f_i (self.index)
self.text = tmp
- def load (self, node, zip):
+ def load (self, node, tar):
self.index = int (node.getAttribute ("cursor"))
self.end_index = self.index
tmp = node.getAttribute ("ul-coords")