[ease] Added utility function for finding paths in data dirs.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Added utility function for finding paths in data dirs.
- Date: Fri, 11 Jun 2010 06:44:12 +0000 (UTC)
commit 7f71972d5a6adf2a3bb57f874637802c5d44284e
Author: Nate Stedman <natesm gmail com>
Date: Fri Jun 11 02:34:46 2010 -0400
Added utility function for finding paths in data dirs.
- Used this function to find handle SVGs properly
- Renamed ErrorDialog.vala to a generic Utility.vala
Makefile.am | 2 +-
src/Handle.vala | 10 +++++-----
src/{ErrorDialog.vala => Utility.vala} | 23 +++++++++++++++++++++++
3 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index cabcab6..b6651b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,7 +21,6 @@ ease_SOURCES = \
src/ElementMapValue.vala \
src/Element.vala \
src/Enums.vala \
- src/ErrorDialog.vala \
src/Handle.vala \
src/HTMLExporter.vala \
src/ImageActor.vala \
@@ -51,6 +50,7 @@ ease_SOURCES = \
src/Transitions.vala \
src/UndoActions.vala \
src/UndoController.vala \
+ src/Utility.vala \
src/VideoActor.vala \
src/VideoElement.vala \
src/WelcomeActor.vala \
diff --git a/src/Handle.vala b/src/Handle.vala
index d8eb9e7..534a909 100644
--- a/src/Handle.vala
+++ b/src/Handle.vala
@@ -33,12 +33,12 @@ public class Ease.Handle : Clutter.Texture
/**
* The path to the white circle with a black border.
*/
- public const string W_PATH = "/usr/local/share/ease/svg/handle-white.svg";
+ public const string W_PATH = "ease/svg/handle-white.svg";
/**
* The path to the black circle with a white border.
*/
- public const string B_PATH = "/usr/local/share/ease/svg/handle-black.svg";
+ public const string B_PATH = "ease/svg/handle-black.svg";
/**
* Creates a Handle. Does automatically set the Handle's position - call
@@ -53,7 +53,7 @@ public class Ease.Handle : Clutter.Texture
position = pos;
// load the handle texture
- filename = W_PATH;
+ filename = data_path(W_PATH);
// set the handle's anchor
set_anchor_point(width / 2, height / 2);
@@ -229,11 +229,11 @@ public class Ease.Handle : Clutter.Texture
{
if (flipped)
{
- filename = W_PATH;
+ filename = data_path(W_PATH);
}
else
{
- filename = B_PATH;
+ filename = data_path(B_PATH);
}
flipped = !flipped;
diff --git a/src/ErrorDialog.vala b/src/Utility.vala
similarity index 71%
rename from src/ErrorDialog.vala
rename to src/Utility.vala
index e6b5cbf..89453f6 100644
--- a/src/ErrorDialog.vala
+++ b/src/Utility.vala
@@ -34,4 +34,27 @@ namespace Ease
dialog.run();
dialog.destroy();
}
+
+ /**
+ * Finds the given path in the data directories (ie /usr/share). Return null
+ * if the path cannot be found.
+ *
+ * @param path The path to search for.
+ */
+ public string? data_path(string path)
+ {
+ string[] data_dirs = Environment.get_system_data_dirs();
+ foreach (string dir in data_dirs)
+ {
+ var filename = Path.build_filename(dir, path);
+ var file = File.new_for_path(filename);
+
+ if (file.query_exists(null))
+ {
+ return filename;
+ }
+ }
+
+ return null;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]