gnome-scan r685 - in trunk: . lib
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r685 - in trunk: . lib
- Date: Sun, 14 Dec 2008 17:20:25 +0000 (UTC)
Author: bersace
Date: Sun Dec 14 17:20:25 2008
New Revision: 685
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=685&view=rev
Log:
Added double option.
Modified:
trunk/ChangeLog
trunk/lib/gnome-scan-init.vala
trunk/lib/gnome-scan-option.vala
trunk/lib/gnome-scan-scale-widget.vala
Modified: trunk/lib/gnome-scan-init.vala
==============================================================================
--- trunk/lib/gnome-scan-init.vala (original)
+++ trunk/lib/gnome-scan-init.vala Sun Dec 14 17:20:25 2008
@@ -40,6 +40,7 @@
option_manager = new OptionManager();
option_manager.register_rule_by_type(typeof(OptionBool), typeof(CheckboxWidget));
option_manager.register_rule_by_type(typeof(OptionInt), typeof(ScaleWidget));
+ option_manager.register_rule_by_type(typeof(OptionDouble), typeof(ScaleWidget));
module_path = string.join(GLib.Path.SEARCHPATH_SEPARATOR_S, MODULE_DIR,
"modules/gsfile", "modules/gsane",
Modified: trunk/lib/gnome-scan-option.vala
==============================================================================
--- trunk/lib/gnome-scan-option.vala (original)
+++ trunk/lib/gnome-scan-option.vala Sun Dec 14 17:20:25 2008
@@ -87,4 +87,26 @@
this.hint = hint;
}
}
+
+ public class OptionDouble : Option {
+ public double value {set; get;}
+ public double min {set construct; get;}
+ public double step {set construct; get;}
+ public double max {set construct; get;}
+
+ public OptionDouble(string name, string title, string desc, string group, string domain, double value, double min, double step, double max, Gnome.Scan.Unit unit, OptionHint hint)
+ {
+ this.name = name;
+ this.title = title;
+ this.desc = desc;
+ this.group = group;
+ this.domain = domain;
+ this.value = value;
+ this.min = min;
+ this.step = step;
+ this.max = max;
+ this.unit = unit;
+ this.hint = hint;
+ }
+ }
}
Modified: trunk/lib/gnome-scan-scale-widget.vala
==============================================================================
--- trunk/lib/gnome-scan-scale-widget.vala (original)
+++ trunk/lib/gnome-scan-scale-widget.vala Sun Dec 14 17:20:25 2008
@@ -30,41 +30,72 @@
this.expand = false;
this.no_label = false;
- var option = this.option as OptionInt;
- option.notify["value"] += this.on_option_value_changed;
-
- adj = new Adjustment(option.value, option.min, option.max, option.step, option.step, 0);
- adj.value_changed += this.on_adj_value_changed;
-
+ SpinButton spin;
+ if (option is OptionInt) {
+ var option = this.option as OptionInt;
+ adj = new Adjustment(option.value, option.min, option.max, option.step, option.step, 0);
+ adj.value_changed += this.on_int_adj_value_changed;
+ spin = new SpinButton(adj, option.step, 0);
+ option.notify["value"] += this.on_int_option_value_changed;
+ }
+ else if (option is OptionDouble) {
+ var option = this.option as OptionDouble;
+ adj = new Adjustment(option.value, option.min, option.max, option.step, option.step, 0);
+ adj.value_changed += this.on_double_adj_value_changed;
+ spin = new SpinButton(adj, option.step, 2);
+ option.notify["value"] += this.on_double_option_value_changed;
+ }
var scale = new HScale(adj);
scale.draw_value = false;
this.pack_start(scale, true, true, 0);
- var spin = new SpinButton(adj, option.step, 0);
this.pack_start(spin, false, true, 0);
}
- private void on_option_value_changed()
+ private void on_int_option_value_changed()
{
if (inhibit)
return;
- var option = this.option as OptionInt;
+ var option = option as OptionInt;
inhibit = true;
adj.value = (double) option.value;
inhibit = false;
}
- private void on_adj_value_changed()
+ private void on_int_adj_value_changed()
{
if (inhibit)
return;
- var option = this.option as OptionInt;
+ var option = option as OptionInt;
inhibit = true;
option.value = (int) adj.value;
inhibit = false;
}
+
+ private void on_double_option_value_changed()
+ {
+ if (inhibit)
+ return;
+
+ var option = option as OptionDouble;
+
+ inhibit = true;
+ adj.value = option.value;
+ inhibit = false;
+ }
+
+ private void on_double_adj_value_changed()
+ {
+ if (inhibit)
+ return;
+
+ var option = option as OptionDouble;
+ inhibit = true;
+ option.value = adj.value;
+ inhibit = false;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]