[ease/inspector] Better handling of paths.



commit 1139d26e217be925d924a5a46018f648778d1bda
Author: Nate Stedman <natesm gmail com>
Date:   Fri Jun 4 08:07:32 2010 -0400

    Better handling of paths.

 src/Document.vala     |    5 -----
 src/Element.vala      |    4 +++-
 src/HTMLExporter.vala |    3 ++-
 src/ImageActor.vala   |    2 +-
 src/JSONParser.vala   |    3 ++-
 src/Slide.vala        |    5 ++++-
 src/SlideActor.vala   |    4 ++--
 src/SlideSet.vala     |    5 +++++
 src/VideoActor.vala   |    3 ++-
 9 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/src/Document.vala b/src/Document.vala
index e21f8cb..3f21276 100644
--- a/src/Document.vala
+++ b/src/Document.vala
@@ -42,11 +42,6 @@ public class Ease.Document : SlideSet
 	 * The aspect ratio of the Document.
 	 */
 	public float aspect { get { return (float)width / (float)height; } }
-	
-	/**
-	 * The file path of the Document.
-	 */
-	public string path { get; set; }
 
 	/**
 	 * Default constructor, used for new documents.
diff --git a/src/Element.vala b/src/Element.vala
index 0aa86b3..86cc783 100644
--- a/src/Element.vala
+++ b/src/Element.vala
@@ -217,7 +217,9 @@ public class Ease.Element : GLib.Object
 	
 	private void pdf_render_image(Cairo.Context context) throws Error
 	{
-		var filename = parent.parent.path + "/" + data.get("filename");
+		var filename = Path.build_path("/",
+		                               parent.parent.path,
+		                               data.get("filename"));
 		
 		// load the image
 		var pixbuf = new Gdk.Pixbuf.from_file_at_scale(filename,
diff --git a/src/HTMLExporter.vala b/src/HTMLExporter.vala
index bcdf6c5..6b2ce73 100644
--- a/src/HTMLExporter.vala
+++ b/src/HTMLExporter.vala
@@ -110,7 +110,8 @@ public class Ease.HTMLExporter : GLib.Object
 	 */
 	public void copy_file(string end_path, string base_path)
 	{
-		var source = File.new_for_path(base_path + "/" + end_path);
+		var source = File.new_for_path(Path.build_path("/",
+		                                               base_path, end_path));
 		var destination = File.new_for_path(path + " " + end_path);
 
 		try
diff --git a/src/ImageActor.vala b/src/ImageActor.vala
index 226ce73..8b1d1f9 100644
--- a/src/ImageActor.vala
+++ b/src/ImageActor.vala
@@ -40,7 +40,7 @@ public class Ease.ImageActor : Actor
 		
 		try
 		{
-			contents = new Clutter.Texture.from_file(e.parent.parent.path + e.get("filename"));
+			contents = new Clutter.Texture.from_file(Path.build_path("/", e.parent.parent.path, e.get("filename")));
 		}
 		catch (GLib.Error e)
 		{
diff --git a/src/JSONParser.vala b/src/JSONParser.vala
index 14af130..300134d 100644
--- a/src/JSONParser.vala
+++ b/src/JSONParser.vala
@@ -62,6 +62,7 @@ public static class Ease.JSONParser
 	public static Theme theme(string filename) throws GLib.Error
 	{
 		var theme = new Theme();
+		theme.path = filename;
 	
 		var parser = new Json.Parser();
 		
@@ -183,7 +184,7 @@ public static class Ease.JSONParser
 		var generator = new Json.Generator();
 		generator.set_root(root);
 		generator.pretty = true;
-		generator.to_file(document.path + "/Document.json");
+		generator.to_file(Path.build_path("/", document.path, "Document.json"));
 	}
 	
 	private static Json.Node document_write_slide(Slide slide)
diff --git a/src/Slide.vala b/src/Slide.vala
index ced3f0b..8182e5c 100644
--- a/src/Slide.vala
+++ b/src/Slide.vala
@@ -78,7 +78,10 @@ public class Ease.Slide
 	 */
 	public string background_abs
 	{
-		owned get { return parent.path + "/" + background_image; }
+		owned get
+		{
+			return Path.build_path("/",parent.path, background_image);
+		}
 	}
 	
 	/**
diff --git a/src/SlideActor.vala b/src/SlideActor.vala
index 9a5ed15..9819bdf 100644
--- a/src/SlideActor.vala
+++ b/src/SlideActor.vala
@@ -186,8 +186,8 @@ public class Ease.SlideActor : Clutter.Group
 		{
 			try
 			{
-				background = new Clutter.Texture.from_file(slide.parent.path +
-				                                    slide.background_image);
+				background =
+					new Clutter.Texture.from_file(slide.background_abs);
 			}
 			catch (GLib.Error e)
 			{
diff --git a/src/SlideSet.vala b/src/SlideSet.vala
index 7840979..0e7b317 100644
--- a/src/SlideSet.vala
+++ b/src/SlideSet.vala
@@ -21,6 +21,11 @@
 public abstract class Ease.SlideSet : Object
 {
 	/**
+	 * The file path of the SlideSet.
+	 */
+	public string path { get; set; }
+
+	/**
 	 * All { link Slide}s in this SlideSet.
 	 */
 	public Gee.ArrayList<Slide> slides = new Gee.ArrayList<Slide>();
diff --git a/src/VideoActor.vala b/src/VideoActor.vala
index a1d97c6..b5a51ed 100644
--- a/src/VideoActor.vala
+++ b/src/VideoActor.vala
@@ -40,7 +40,8 @@ public class Ease.VideoActor : Actor, Clutter.Media
 		base(e, c);
 
 		video = new ClutterGst.VideoTexture();
-		video.set_filename(e.parent.parent.path + e.get("filename"));
+		video.set_filename(Path.build_path("/", e.parent.parent.path,
+		                                   e.get("filename")));
 
 		// play the video if it's in the presentation
 		if (c == ActorContext.PRESENTATION)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]