[ease/serialize: 2/52] serialize
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/serialize: 2/52] serialize
- Date: Tue, 22 Feb 2011 22:56:56 +0000 (UTC)
commit 88ea8a116e0f32c9ac45adbda2112be80eb3e147
Author: Nate Stedman <natesm gmail com>
Date: Sun Nov 7 12:56:14 2010 -0500
serialize
configure.ac | 2 +
ease-core/Makefile.am | 4 +++
ease-core/ease-document.vala | 7 +++++
ease-core/ease-init.vala | 24 +++++++++++++++++
ease-core/ease-plugins.vala | 31 +++++++++++++++++++++
ease-core/ease-serializable.vala | 21 ++++++++++++++
ease-core/ease-serializer.vala | 54 ++++++++++++++++++++++++++++++++++++++
ease/ease-main.vala | 3 ++
vapi/seed.vapi | 4 ++-
9 files changed, 149 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eb91cec..96835c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ pkg_modules="\
poppler-glib\
rest-0.6 \
rest-extras-0.6\
+ seed \
unique-1.0"
PKG_CHECK_MODULES(EASE, [$pkg_modules])
@@ -75,6 +76,7 @@ EASE_PACKAGES="\
--pkg libarchive\
--pkg poppler-glib\
--pkg rest-extras-0.6\
+ --pkg seed \
--pkg unique-1.0"
AC_SUBST(EASE_CFLAGS)
diff --git a/ease-core/Makefile.am b/ease-core/Makefile.am
index 648cea2..c6ef188 100644
--- a/ease-core/Makefile.am
+++ b/ease-core/Makefile.am
@@ -21,14 +21,18 @@ libease_core_ EASE_CORE_VERSION@_la_SOURCES = \
ease-image-actor.vala \
ease-image-element.vala \
ease-image.vala \
+ ease-init.vala \
ease-iterable-models.vala \
ease-media-element.vala \
ease-plugin-import-media.vala \
ease-plugin-import-service.vala \
+ ease-plugins.vala \
ease-pdf-actor.vala \
ease-pdf-element.vala \
ease-scrolled-embed.vala \
ease-scrolled-embed-window.vala \
+ ease-serializable.vala \
+ ease-serializer.vala \
ease-shape-element.vala \
ease-slide.vala \
ease-temp.vala \
diff --git a/ease-core/ease-document.vala b/ease-core/ease-document.vala
index 4549465..78ec4a3 100644
--- a/ease-core/ease-document.vala
+++ b/ease-core/ease-document.vala
@@ -109,6 +109,11 @@ public class Ease.Document : GLib.Object, UndoSource
* The file path of the Document (extracted).
*/
public string path { get; set; }
+
+ public string[] serialize_exclude()
+ {
+ return { "path", "filename", "aspect", "length" };
+ }
/**
* All { link Slide}s in this Document.
@@ -210,6 +215,8 @@ public class Ease.Document : GLib.Object, UndoSource
var slide = theme.create_slide(DEFAULT_FIRST, width, height);
slide.parent = this;
append_slide(slide);
+
+ Serializer.write(this);
}
public void to_json(Gtk.Window? window) throws GLib.Error
diff --git a/ease-core/ease-init.vala b/ease-core/ease-init.vala
new file mode 100644
index 0000000..4c5a4c6
--- /dev/null
+++ b/ease-core/ease-init.vala
@@ -0,0 +1,24 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+namespace Ease
+{
+ public void init(string[] args)
+ {
+ Plugins.engine = Seed.init(ref args);
+ }
+}
diff --git a/ease-core/ease-plugins.vala b/ease-core/ease-plugins.vala
new file mode 100644
index 0000000..5533f88
--- /dev/null
+++ b/ease-core/ease-plugins.vala
@@ -0,0 +1,31 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+public static class Ease.Plugins
+{
+ public static unowned Seed.Engine engine { get; internal set; }
+
+ internal static void exception(ref Seed.Context context,
+ ref Seed.Script script)
+ {
+ Seed.Exception? e = null;
+ if ((e = script.exception()) != null)
+ {
+ critical("%s", Seed.Exception.to_string(context, e));
+ }
+ }
+}
diff --git a/ease-core/ease-serializable.vala b/ease-core/ease-serializable.vala
new file mode 100644
index 0000000..3354438
--- /dev/null
+++ b/ease-core/ease-serializable.vala
@@ -0,0 +1,21 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+public interface Ease.Serializable
+{
+ public abstract string[] serialize_exclude();
+}
diff --git a/ease-core/ease-serializer.vala b/ease-core/ease-serializer.vala
new file mode 100644
index 0000000..9c2aaf3
--- /dev/null
+++ b/ease-core/ease-serializer.vala
@@ -0,0 +1,54 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+public static class Ease.Serializer
+{
+ private const string SCRIPT = """
+ for (i in object.get_class().get_properties())
+ {
+ print(i);
+ }
+ """;
+
+ public static void write(GLib.Object object)
+ {
+ debug("Seed should happen now:");
+ var context = Seed.Context.create(null, null);
+ Seed.prepare_global_context(context);
+
+ Seed.Object.set_property(context,
+ context.get_global_object(),
+ "object",
+ Seed.Value.from_object(context, object, null));
+
+ unowned Seed.Script script = Seed.make_script(context, SCRIPT, null, 0);
+
+ Seed.Exception? e = null;
+ if ((e = script.exception()) != null)
+ {
+ critical("%s", Seed.Exception.to_string(context, e));
+ }
+
+ unowned Seed.Value val = Seed.evaluate(context, script, null);
+
+ e = null;
+ if ((e = script.exception()) != null)
+ {
+ critical("%s", Seed.Exception.to_string(context, e));
+ }
+ }
+}
diff --git a/ease/ease-main.vala b/ease/ease-main.vala
index 35f0a66..39ef32e 100644
--- a/ease/ease-main.vala
+++ b/ease/ease-main.vala
@@ -118,6 +118,9 @@ internal class Ease.Main : GLib.Object
// init gstreamer
Gst.init(ref args);
+
+ // init ease-core
+ Ease.init(args);
// react to command line flags
UndoController.enable_debug = debug_undo;
diff --git a/vapi/seed.vapi b/vapi/seed.vapi
index aa2007a..8f8785d 100644
--- a/vapi/seed.vapi
+++ b/vapi/seed.vapi
@@ -47,11 +47,12 @@ namespace Seed {
public static bool set_property (Seed.Context ctx, Seed.Object object, string name, Seed.Value value);
public static void set_property_at_index (Seed.Context ctx, Seed.Object object, int index, Seed.Value value, Seed.Exception exception);
}
+
[Compact]
[CCode (free_function = "seed_script_destroy", cheader_filename = "seed.h")]
public class Script {
- public Seed.Exception exception ();
[CCode (has_construct_function = false)]
+ public Seed.Exception exception();
public Script.from_file (Seed.Context ctx, string file);
}
[Compact]
@@ -141,6 +142,7 @@ namespace Seed {
public weak Seed.ObjectSetPropertyCallback set_property;
}
[CCode (type_id = "SEED_TYPE_EXCEPTION", cheader_filename = "seed.h")]
+ [SimpleType]
public struct Exception {
public static unowned string get_file (Seed.Context ctx, Seed.Exception exception);
public static uint get_line (Seed.Context ctx, Seed.Exception exception);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]