[gcompris/gcomprixogoo] Improved a little bit the save/load feature, works a little bit
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcompris/gcomprixogoo] Improved a little bit the save/load feature, works a little bit
- Date: Wed, 28 Oct 2009 22:36:54 +0000 (UTC)
commit 643b42b8035098b3e2971e4b323bc540a6278ca0
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Wed Oct 28 23:35:49 2009 +0100
Improved a little bit the save/load feature, works a little bit
for rectangles only. Uncomplete yet.
src/anim-activity/AnimItem.py | 33 ++++++++++++++++++++++++++++++++-
src/anim-activity/anim.py | 7 ++++++-
src/boards/goocanvasmodule.c | 10 +++++-----
3 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/src/anim-activity/AnimItem.py b/src/anim-activity/AnimItem.py
index eed54bd..d359371 100644
--- a/src/anim-activity/AnimItem.py
+++ b/src/anim-activity/AnimItem.py
@@ -40,7 +40,6 @@ class AnimItem:
self.step = 1
self.item = None
- self.events = None
self.anchor = None
self.old_x = 0
@@ -55,6 +54,23 @@ class AnimItem:
# (properties, transformation).
self.timeline = {}
+ def dump(self):
+ print "Dump AnimItem:"
+ print self.timeline
+ print self.item
+ print self.rootitem
+
+ def restore(self, anim_):
+ print "restore AnimItem:"
+ print self.timeline
+ AnimItem.anim = anim_
+ print AnimItem.anim
+ print AnimItem.anim.rootitem
+ self.rootitem = goocanvas.Group(parent = AnimItem.anim.rootitem)
+ # Should not have saved anchor in the first place
+ self.anchor = None
+ pass
+
def test(self):
self.set_visible(0, 10)
self.set_visible(11, 20)
@@ -565,6 +581,21 @@ class AnimItemRect(AnimItem):
filled = False
+ def dump(self):
+ print "Dump Rect:"
+ AnimItem.dump(self)
+
+ def restore(self, anim_):
+ AnimItem.restore(self, anim_)
+ self.item = \
+ goocanvas.Rect(
+ parent = self.rootitem
+ )
+ self.item.set_data("AnimItem", self)
+ self.item.connect("button_press_event", anim_.item_event)
+ self.item.connect("button_release_event", anim_.item_event)
+ self.item.connect("motion_notify_event", anim_.item_event)
+
def __init__(self, anim, x, y, color_fill, color_stroke, line_width):
AnimItem.__init__(self, anim)
x,y = self.snap_to_grid(x, y)
diff --git a/src/anim-activity/anim.py b/src/anim-activity/anim.py
index e5228a6..f8b68e0 100644
--- a/src/anim-activity/anim.py
+++ b/src/anim-activity/anim.py
@@ -746,6 +746,9 @@ class Gcompris_anim:
pickle.dump(self.animlist, file, self.pickle_protocol)
file.close()
+ for item in self.animlist:
+ item.dump()
+
def file_to_anim(self, filename):
file = open(filename, 'rb')
@@ -764,7 +767,9 @@ class Gcompris_anim:
print "load"
self.animlist = pickle.load(file)
for item in self.animlist:
- item.anim = self
+ item.restore(self)
+ item.dump()
+ self.refresh(self.timeline.get_time())
else:
print "ERROR: Unrecognized file format, file", filename, ' has description : ', desc
file.close()
diff --git a/src/boards/goocanvasmodule.c b/src/boards/goocanvasmodule.c
index ff2f491..2e52fba 100644
--- a/src/boards/goocanvasmodule.c
+++ b/src/boards/goocanvasmodule.c
@@ -11,11 +11,11 @@
Pycairo_CAPI_t *Pycairo_CAPI;
-void pygoocanvas_register_classes (PyObject *d);
+void pygoocanvas_register_classes (PyObject *d);
void pygoocanvas_add_constants(PyObject *module, const gchar *strip_prefix);
extern PyMethodDef pygoocanvas_functions[];
-
+
static PyObject *
_cairo_matrix_from_gvalue(const GValue *value)
{
@@ -65,9 +65,9 @@ initgoocanvas (void)
m = Py_InitModule ("goocanvas", pygoocanvas_functions);
d = PyModule_GetDict (m);
-
+
init_pygobject ();
-
+
pygoocanvas_register_classes (d);
pygoocanvas_add_constants(m, "GOO_CANVAS_");
PyModule_AddObject(m, "TYPE_CAIRO_MATRIX", pyg_type_wrapper_new(GOO_TYPE_CAIRO_MATRIX));
@@ -84,7 +84,7 @@ initgoocanvas (void)
PYGOOCANVAS_MAJOR_VERSION,
PYGOOCANVAS_MINOR_VERSION,
PYGOOCANVAS_MICRO_VERSION));
-
+
if (PyErr_Occurred ())
Py_FatalError ("can't initialise module goocanvas");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]