[ease] [fileformat] Write backgrounds to their own JSON object
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [fileformat] Write backgrounds to their own JSON object
- Date: Mon, 11 Oct 2010 19:07:42 +0000 (UTC)
commit d58668f4e1a60f330a9aaf3c4be74702cf978457
Author: Nate Stedman <natesm gmail com>
Date: Fri Oct 8 21:03:32 2010 -0400
[fileformat] Write backgrounds to their own JSON object
This is a breaking change with all previous documents.
ease-core/ease-background.vala | 5 +++-
ease-core/ease-pdf-element.vala | 5 ++-
ease-core/ease-shape-element.vala | 5 ++-
ease-core/ease-slide.vala | 42 ++----------------------------------
ease-core/ease-theme.vala | 1 +
5 files changed, 14 insertions(+), 44 deletions(-)
---
diff --git a/ease-core/ease-background.vala b/ease-core/ease-background.vala
index c4fb3ea..56f61ed 100644
--- a/ease-core/ease-background.vala
+++ b/ease-core/ease-background.vala
@@ -112,8 +112,10 @@ public class Ease.Background : GLib.Object
/**
* Writes this background's properties to the given JSON object.
*/
- public void to_json(ref Json.Object obj)
+ public Json.Object to_json()
{
+ var obj = new Json.Object();
+
if (image != null)
{
obj.set_string_member(Theme.BACKGROUND_IMAGE, image.filename);
@@ -133,6 +135,7 @@ public class Ease.Background : GLib.Object
}
obj.set_string_member(Theme.BACKGROUND_TYPE,
background_type.to_string());
+ return obj;
}
/**
diff --git a/ease-core/ease-pdf-element.vala b/ease-core/ease-pdf-element.vala
index bc588af..3c970cc 100644
--- a/ease-core/ease-pdf-element.vala
+++ b/ease-core/ease-pdf-element.vala
@@ -54,7 +54,8 @@ public class Ease.PdfElement : MediaElement
parent = owner;
default_page = obj.get_string_member(Theme.PDF_DEFAULT_PAGE).to_int();
- background = new Background.from_json(obj);
+ background =
+ new Background.from_json(obj.get_object_member(Theme.BACKGROUND));
pdf_doc = new Poppler.Document.from_file(
Filename.to_uri(full_filename),
@@ -69,7 +70,7 @@ public class Ease.PdfElement : MediaElement
public override Json.Object to_json()
{
var obj = base.to_json();
- background.to_json(ref obj);
+ obj.set_object_member(Theme.BACKGROUND, background.to_json());
obj.set_string_member(Theme.PDF_DEFAULT_PAGE, default_page.to_string());
return obj;
}
diff --git a/ease-core/ease-shape-element.vala b/ease-core/ease-shape-element.vala
index 962185f..a24a0fa 100644
--- a/ease-core/ease-shape-element.vala
+++ b/ease-core/ease-shape-element.vala
@@ -52,7 +52,8 @@ public class Ease.ShapeElement : CairoElement
ShapeType.from_string(obj.get_string_member(Theme.SHAPE_TYPE));
// read the shapes's background properties
- background = new Background.from_json(obj);
+ background =
+ new Background.from_json(obj.get_object_member(Theme.BACKGROUND));
}
/**
@@ -64,7 +65,7 @@ public class Ease.ShapeElement : CairoElement
obj.set_string_member(Theme.SHAPE_TYPE, shape_type.to_string());
// write the shape's background properties
- background.to_json(ref obj);
+ obj.set_object_member(Theme.BACKGROUND, background.to_json());
return obj;
}
diff --git a/ease-core/ease-slide.vala b/ease-core/ease-slide.vala
index e6aa678..eb55230 100644
--- a/ease-core/ease-slide.vala
+++ b/ease-core/ease-slide.vala
@@ -263,26 +263,8 @@ public class Ease.Slide : GLib.Object, UndoSource
obj.get_string_member("advance_delay").to_double();
// read the slide's background properties
- if (obj.has_member(Theme.BACKGROUND_IMAGE))
- {
- background.image.filename = obj.get_string_member(Theme.BACKGROUND_IMAGE);
- background.image.source =
- obj.get_string_member("background-image-source");
- }
- if (obj.has_member(Theme.BACKGROUND_COLOR))
- {
- background.color =
- new Color.from_string(
- obj.get_string_member(Theme.BACKGROUND_COLOR));
- }
- if (obj.has_member(Theme.BACKGROUND_GRADIENT))
- {
- background.gradient =
- new Gradient.from_string(
- obj.get_string_member(Theme.BACKGROUND_GRADIENT));
- }
- background.background_type = BackgroundType.from_string(
- obj.get_string_member(Theme.BACKGROUND_TYPE));
+ background =
+ new Background.from_json(obj.get_object_member(Theme.BACKGROUND));
// parse the elements
var elements = obj.get_array_member("elements");
@@ -336,25 +318,7 @@ public class Ease.Slide : GLib.Object, UndoSource
obj.set_string_member("advance_delay", advance_delay.to_string());
// write the slide's background properties
- if (background.image.filename != null)
- {
- obj.set_string_member(Theme.BACKGROUND_IMAGE,
- background.image.filename);
- obj.set_string_member("background-image-source",
- background.image.source);
- }
- if (background.color != null)
- {
- obj.set_string_member(Theme.BACKGROUND_COLOR,
- background.color.to_string());
- }
- if (background.gradient != null)
- {
- obj.set_string_member(Theme.BACKGROUND_GRADIENT,
- background.gradient.to_string());
- }
- obj.set_string_member(Theme.BACKGROUND_TYPE,
- background.background_type.to_string());
+ obj.set_object_member(Theme.BACKGROUND, background.to_json());
// add the slide's elements
var json_elements = new Json.Array();
diff --git a/ease-core/ease-theme.vala b/ease-core/ease-theme.vala
index d2ddca4..4cdf1a0 100644
--- a/ease-core/ease-theme.vala
+++ b/ease-core/ease-theme.vala
@@ -70,6 +70,7 @@ public class Ease.Theme : GLib.Object
private const string BACKGROUND_TYPE_COLOR = "background-type-color";
private const string BACKGROUND_TYPE_GRADIENT = "background-type-gradient";
private const string BACKGROUND_TYPE_IMAGE = "background-type-image";
+ public const string BACKGROUND = "background";
// text content types
public const string TITLE_TEXT = "title-text";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]