gnome-scan r802 - in trunk: . lib
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r802 - in trunk: . lib
- Date: Sat, 31 Jan 2009 13:49:37 +0000 (UTC)
Author: bersace
Date: Sat Jan 31 13:49:37 2009
New Revision: 802
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=802&view=rev
Log:
Added preselection feature
Added:
trunk/lib/gnome-scan-preselection.vala
Modified:
trunk/ChangeLog
trunk/lib/Makefile.am
trunk/lib/gnome-scan-job.vala
trunk/lib/gnome-scan-option-manager.vala
Modified: trunk/lib/Makefile.am
==============================================================================
--- trunk/lib/Makefile.am (original)
+++ trunk/lib/Makefile.am Sat Jan 31 13:49:37 2009
@@ -20,6 +20,7 @@
gnome-scan-node.vala \
gnome-scan-scanner.vala \
gnome-scan-sink.vala \
+ gnome-scan-preselection.vala \
gnome-scan-job.vala \
gnome-scan-backend.vala \
gnome-scan-option-manager.vala \
Modified: trunk/lib/gnome-scan-job.vala
==============================================================================
--- trunk/lib/gnome-scan-job.vala (original)
+++ trunk/lib/gnome-scan-job.vala Sat Jan 31 13:49:37 2009
@@ -57,6 +57,7 @@
}
}
+ private SList<Preselection> preselections;
private bool cancelled = false;
private Gegl.Node load_buffer;
private SList<Gegl.Node> graph;
@@ -64,15 +65,16 @@
private Gegl.Processor processor = null;
private SList<Gnome.Scan.Node> nodes = null;
- construct {
- this.graph = null;
- }
-
public Job(Sink sink)
{
this.sink = sink;
}
+ public void register_preselection(Preselection preselection)
+ {
+ preselections.append(preselection);
+ }
+
public bool is_running()
{
return this._status == Status.PROCESSING;
@@ -156,6 +158,8 @@
}
if (node != null) {
+ this.apply_preselections(node);
+
node.notify["status"] += this.check_nodes_status;
node.notify["graph"] += this.build_graph;
@@ -176,6 +180,19 @@
this.build_graph();
}
+ private void apply_preselections(Node node)
+ {
+ debug("Applying preselections to node %s",
+ node.get_type().name());
+ foreach(Preselection presel in preselections) {
+ var option = node.lookup_option(presel.option_name);
+ if (option != null) {
+ debug("Apply preselection on %s", presel.option_name);
+ presel.apply(option);
+ }
+ }
+ }
+
private void build_graph()
{
if ((int)this._status < (int)Status.READY)
Modified: trunk/lib/gnome-scan-option-manager.vala
==============================================================================
--- trunk/lib/gnome-scan-option-manager.vala (original)
+++ trunk/lib/gnome-scan-option-manager.vala Sat Jan 31 13:49:37 2009
@@ -33,21 +33,10 @@
// option name -> option instance
private HashTable<weak string,Option> options;
- // PREREQUISITE
- // option name -> value
- private HashTable<weak string,Value?> defaults;
- // option name -> range
- private HashTable<weak string,Gnome.Scan.Range?> ranges;
- // option name -> enums
- private HashTable<weak string,SList<weak Gnome.Scan.EnumValue?>> enums;
-
construct {
this.rules_by_name = new HashTable<weak string,Type>(GLib.str_hash, GLib.str_equal);
this.rules_by_type = new HashTable<Type,Type>(GLib.direct_hash, GLib.direct_equal);
this.options = new HashTable<weak string,Option>(GLib.str_hash, GLib.str_equal);
- this.defaults = new HashTable<weak string,Value?>(GLib.str_hash, GLib.str_equal);
- this.ranges = new HashTable<weak string,Gnome.Scan.Range?>(GLib.str_hash, GLib.str_equal);
- this.enums = new HashTable<weak string,SList<weak Gnome.Scan.EnumValue?>>(GLib.str_hash, GLib.str_equal);
}
public void register_option(Option option)
@@ -78,20 +67,5 @@
return Type.INVALID;
}
-
- public void register_default_value(string option_name, Value value)
- {
- this.defaults.insert(option_name, value);
- }
-
- public void register_constraint_range(string option_name, Gnome.Scan.Range range)
- {
- this.ranges.insert(option_name, range);
- }
-
- public void register_constraint_enum(string option_name, SList<weak Gnome.Scan.EnumValue?> values)
- {
- this.enums.insert(option_name, values.copy());
- }
}
}
Added: trunk/lib/gnome-scan-preselection.vala
==============================================================================
--- (empty file)
+++ trunk/lib/gnome-scan-preselection.vala Sat Jan 31 13:49:37 2009
@@ -0,0 +1,49 @@
+/* GNOME Scan - Scan as easy as you print
+ * Copyright  2006-2009 Ãtienne Bersac <bersace gnome org>
+ *
+ * GNOME Scan is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GNOME Scan 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GNOME Scan. If not, write to:
+ *
+ * the Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA
+ */
+
+using GLib;
+
+namespace Gnome.Scan {
+ public abstract class Preselection : Object {
+ public string option_name { set construct; get; }
+
+ public virtual void apply(Option option)
+ {
+ message("%s does not implement apply, asked for option %s %s",
+ this.get_type().name(), option.get_type().name(), option.name);
+ }
+ }
+
+ public class PreselValue : Preselection {
+ public Value value { set construct; get; }
+
+ public PreselValue(string option_name, Value value)
+ {
+ this.option_name = option_name;
+ this.value = value;
+ }
+
+ public override void apply(Option option)
+ {
+ option.set_g_value(this.value);
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]