[cheese/three-point-oh] Read .effect files from system data directory and user level data directory (~/.cheese/effects)
- From: Yuvaraj Pandian <yuvipanda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/three-point-oh] Read .effect files from system data directory and user level data directory (~/.cheese/effects)
- Date: Fri, 25 Jun 2010 12:25:27 +0000 (UTC)
commit 1d9d95d2c5d0fdf844d5526cb8cb6efeb4408d08
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date: Fri Jun 25 17:55:19 2010 +0530
Read .effect files from system data directory and user level data directory (~/.cheese/effects)
configure.ac | 5 ++-
data/effects/Makefile.am | 2 +-
data/effects/warptv.effect | 3 ++
valasrc/Makefile.am | 1 +
valasrc/cheese-effects-manager.vala | 45 +++++++++++++++++++++++++++++++++++
valasrc/cheese-window.vala | 6 ++--
6 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a64458a..8acbbfe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -92,7 +92,7 @@ CLUTTER_REQUIRED=1.0
CLUTTERGTK_REQUIRED=0.10
CLUTTERGST_REQUIRED=0.10
UNIQUE_REQUIRED=1.1
-
+GEE_REQUIRED=0.5
#*******************************************************************************
# Check for udev
#*******************************************************************************
@@ -150,7 +150,8 @@ PKG_CHECK_MODULES(CHEESE, \
clutter-1.0 >= $CLUTTER_REQUIRED \
clutter-gtk-0.10 >= $CLUTTERGTK_REQUIRED \
clutter-gst-0.10 >= $CLUTTERGST_REQUIRED \
- unique-1.0 >= $UNIQUE_REQUIRED \
+ unique-1.0 >= $UNIQUE_REQUIRED \
+ gee-1.0 >= $GEE_REQUIRED \
libcanberra-gtk $UDEV_PKG
)
AC_SUBST(CHEESE_CFLAGS)
diff --git a/data/effects/Makefile.am b/data/effects/Makefile.am
index 28a2c3a..800d86d 100644
--- a/data/effects/Makefile.am
+++ b/data/effects/Makefile.am
@@ -1,6 +1,6 @@
Datadir = $(datadir)/cheese/effects
-Data_DATA = noir.effect
+Data_DATA = *.effect
EXTRA_DIST = \
$(Data_DATA)
diff --git a/data/effects/warptv.effect b/data/effects/warptv.effect
new file mode 100644
index 0000000..ac32ae7
--- /dev/null
+++ b/data/effects/warptv.effect
@@ -0,0 +1,3 @@
+[effect]
+name=WarpTv
+pipeline_desc=warptv
\ No newline at end of file
diff --git a/valasrc/Makefile.am b/valasrc/Makefile.am
index bae91a1..ee60473 100644
--- a/valasrc/Makefile.am
+++ b/valasrc/Makefile.am
@@ -4,6 +4,7 @@ VALAFLAGS = \
--pkg config \
--pkg gtk+-2.0 \
--pkg gmodule-2.0 \
+ --pkg gee-1.0 \
--pkg clutter-1.0 \
--pkg clutter-gtk-0.10 \
--pkg gconf-2.0 \
diff --git a/valasrc/cheese-effects-manager.vala b/valasrc/cheese-effects-manager.vala
index 3f63a6d..7f3c6be 100644
--- a/valasrc/cheese-effects-manager.vala
+++ b/valasrc/cheese-effects-manager.vala
@@ -1,4 +1,5 @@
using GLib;
+using Gee;
const string GROUP_NAME = "effect";
@@ -14,4 +15,48 @@ internal class Cheese.EffectsManager : GLib.Object
critical("%s", eff.pipeline_desc);
return eff;
}
+
+ public ArrayList<Effect> effects;
+
+ private ArrayList<Effect> load_effects_from_directory (string directory)
+ {
+ ArrayList<Effect> effects = new ArrayList<Effect>();
+ if (FileUtils.test (directory, FileTest.EXISTS | FileTest.IS_DIR))
+ {
+ Dir dir = Dir.open(directory);
+ string cur_file;
+ cur_file = dir.read_name();
+ while (cur_file != null)
+ {
+ Effect effect = EffectsManager.parse_effect_file (GLib.Path.build_filename(directory, cur_file));
+ effects.add(effect);
+ cur_file = dir.read_name();
+ }
+ }
+ return effects;
+ }
+
+ public EffectsManager()
+ {
+ effects = new ArrayList<Effect>();
+ }
+
+ public void load_effects()
+ {
+ string system_effects = GLib.Path.build_filename (Config.PACKAGE_DATADIR, "effects");
+ effects.add_all(load_effects_from_directory (system_effects));
+
+ string user_effects = GLib.Path.build_filename (Environment.get_user_data_dir(), ".cheese", "effects");
+ effects.add_all(load_effects_from_directory (user_effects));
+ }
+
+ public Effect get_effect(string name)
+ {
+ foreach (Effect eff in effects)
+ {
+ if (eff.name == name)
+ return eff;
+ }
+ return null;
+ }
}
\ No newline at end of file
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index c6ffd63..8d63621 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -471,9 +471,9 @@ public class Cheese.MainWindow : Gtk.Window
camera.setup (conf.gconf_prop_camera);
camera.play ();
- string mock_path = GLib.Path.build_filename (Config.PACKAGE_DATADIR, "effects", "noir.effect");
- Effect e = EffectsManager.parse_effect_file (mock_path);
- camera.set_effect(e);
+ effects_manager = new EffectsManager();
+ effects_manager.load_effects();
+ camera.set_effect(effects_manager.get_effect(conf.gconf_prop_selected_effects));
set_wide_mode (conf.gconf_prop_wide_mode, true);
set_mode (MediaMode.PHOTO);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]