simple-scan-team team mailing list archive
-
simple-scan-team team
-
Mailing list archive
-
Message #01365
[Merge] lp:~soliloque/simple-scan/batch-scan into lp:simple-scan
soliloque has proposed merging lp:~soliloque/simple-scan/batch-scan into lp:simple-scan.
Commit message:
Add a configurable delay to batch scan type
Requested reviews:
Robert Ancell (robert-ancell)
For more details, see:
https://code.launchpad.net/~soliloque/simple-scan/batch-scan/+merge/322088
* Fixed a small typo in build instructions (README.md)
* Add meson to the list of software to install (README.md)
Note: Because simple-scan have dependencies on specific versions of other software packages, the build instructions provided in README.md will not work on Ubuntu 16.04LTS. I think these instructions require at least the yet-to-be-released 17.04 version. Is this correct?
* Add a configurable delay to batch scan type
I used a minimum delay of 0 seconds, a maximum delay of 10 seconds, and a default delay of 1 seconds. Maximum delay is set in simple-scan.ui and org.gnome.SimpleScan.gschema.xml. Default delay is set in org.gnome.SimpleScan.gschema.xml and ui.vala. I hope these values are reasonable.
Scanner.vala implement the delay by putting the scanner thread to sleep. Another way would be to add a WAIT ScanState but imho that seemed uselessly complex.
Please comment.
--
Your team Simple Scan Development Team is subscribed to branch lp:simple-scan.
=== modified file 'README.md'
--- README.md 2017-03-29 04:04:48 +0000
+++ README.md 2017-04-06 07:15:00 +0000
@@ -12,7 +12,7 @@
Install the dependencies (on Ubuntu/Debian):
```
-$ sudo apt install bzr valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool
+$ sudo apt install bzr meson valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool
```
Get the source:
@@ -24,7 +24,7 @@
```
$ meson --prefix $PWD/install build/
$ ninja -C build/ all install
-$ XDG_DATA_DIRS=install/share/$XDG_DATA_DIRS ./install/bin/simple-scan
+$ XDG_DATA_DIRS=install/share:$XDG_DATA_DIRS ./install/bin/simple-scan
```
## DEBUGGING
=== modified file 'data/org.gnome.SimpleScan.gschema.xml'
--- data/org.gnome.SimpleScan.gschema.xml 2016-07-29 00:53:03 +0000
+++ data/org.gnome.SimpleScan.gschema.xml 2017-04-06 07:15:00 +0000
@@ -66,5 +66,11 @@
<summary>Quality value to use for JPEG compression</summary>
<description>Quality value to use for JPEG compression.</description>
</key>
+ <key name="batch-speed" type="i">
+ <range min="0" max="10000000" />
+ <default>1000000</default>
+ <summary>Delay in microsecond to use in batch scan</summary>
+ <description>Delay in microsecond to use in batch scan.</description>
+ </key>
</schema>
</schemalist>
=== modified file 'src/scanner.vala'
--- src/scanner.vala 2017-03-29 03:53:07 +0000
+++ src/scanner.vala 2017-04-06 07:15:00 +0000
@@ -83,6 +83,7 @@
public int paper_height;
public int brightness;
public int contrast;
+ public int speed; // Batch scan only.
}
private class ScanJob
@@ -97,6 +98,7 @@
public int page_height;
public int brightness;
public int contrast;
+ public int speed; // Batch scan only.
}
private class Request {}
@@ -1293,6 +1295,10 @@
/* Go back for another page */
if (job.type != ScanType.SINGLE)
{
+
+ if (job.type == ScanType.BATCH)
+ Thread.usleep (job.speed);
+
page_number++;
pass_number = 0;
notify (new NotifyPageDone (job.id));
@@ -1561,10 +1567,10 @@
public void scan (string? device, ScanOptions options)
{
- debug ("Scanner.scan (\"%s\", dpi=%d, scan_mode=%s, depth=%d, type=%s, paper_width=%d, paper_height=%d, brightness=%d, contrast=%d)",
+ debug ("Scanner.scan (\"%s\", dpi=%d, scan_mode=%s, depth=%d, type=%s, paper_width=%d, paper_height=%d, brightness=%d, contrast=%d, speed=%d)",
device != null ? device : "(null)", options.dpi, get_scan_mode_string (options.scan_mode), options.depth,
get_scan_type_string (options.type), options.paper_width, options.paper_height,
- options.brightness, options.contrast);
+ options.brightness, options.contrast, options.speed);
var request = new RequestStartScan ();
request.job = new ScanJob ();
request.job.id = job_id++;
@@ -1577,6 +1583,7 @@
request.job.page_height = options.paper_height;
request.job.brightness = options.brightness;
request.job.contrast = options.contrast;
+ request.job.speed = options.speed;
request_queue.push (request);
}
=== modified file 'src/simple-scan.ui'
--- src/simple-scan.ui 2017-03-29 07:40:42 +0000
+++ src/simple-scan.ui 2017-04-06 07:15:00 +0000
@@ -220,6 +220,12 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="speed_adjustment">
+ <property name="lower">0</property>
+ <property name="upper">10000000</property>
+ <property name="step_increment">100000</property>
+ <property name="page_increment">1000000</property>
+ </object>
<template class="UserInterface" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes" comments="Title of scan window">Simple Scan</property>
@@ -287,13 +293,13 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="burst_menuitem">
+ <object class="GtkMenuItem" id="batch_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
<property name="use_underline">True</property>
<accelerator key="m" signal="activate" modifiers="GDK_CONTROL_MASK"/>
- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
</object>
</child>
<child>
@@ -1282,7 +1288,38 @@
<property name="width">1</property>
<property name="height">1</property>
</packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="speed_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes" comments="Label beside speed scale">Batch scan speed:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">speed_scale</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">8</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
+ <child>
+ <object class="GtkScale" id="speed_scale">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="adjustment">speed_adjustment</property>
+ <property name="draw_value">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">8</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -1318,12 +1355,12 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="burst_button_menuitem">
+ <object class="GtkMenuItem" id="batch_button_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
</object>
</child>
<child>
@@ -1377,12 +1414,12 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="burst_button_hb_menuitem">
+ <object class="GtkMenuItem" id="batch_button_hb_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
</object>
</child>
<child>
=== modified file 'src/ui.vala'
--- src/ui.vala 2017-03-29 09:40:01 +0000
+++ src/ui.vala 2017-04-06 07:15:00 +0000
@@ -135,6 +135,8 @@
[GtkChild]
private Gtk.Scale quality_scale;
[GtkChild]
+ private Gtk.Scale speed_scale;
+ [GtkChild]
private Gtk.ListStore device_model;
[GtkChild]
private Gtk.ListStore text_dpi_model;
@@ -150,6 +152,8 @@
private Gtk.Adjustment contrast_adjustment;
[GtkChild]
private Gtk.Adjustment quality_adjustment;
+ [GtkChild]
+ private Gtk.Adjustment speed_adjustment;
private bool setting_devices;
private string? missing_driver = null;
private bool user_selected_device;
@@ -229,6 +233,12 @@
set { quality_adjustment.value = value; }
}
+ public int speed
+ {
+ get { return (int) speed_adjustment.value; }
+ set { speed_adjustment.value = value; }
+ }
+
public string? selected_device
{
owned get
@@ -911,6 +921,7 @@
get_paper_size (out options.paper_width, out options.paper_height);
options.brightness = brightness;
options.contrast = contrast;
+ options.speed = speed;
return options;
}
@@ -943,7 +954,7 @@
}
[GtkCallback]
- private void burst_button_clicked_cb (Gtk.Widget widget)
+ private void batch_button_clicked_cb (Gtk.Widget widget)
{
var options = make_scan_options ();
options.type = ScanType.BATCH;
@@ -2010,6 +2021,16 @@
quality = settings.get_int ("jpeg-quality");
quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", quality); });
+ lower = speed_adjustment.lower;
+ var fast_label = "<small>%s</small>".printf (_("Fast"));
+ upper = speed_adjustment.upper;
+ var slow_label = "<small>%s</small>".printf (_("Slow"));
+ speed_scale.add_mark (lower, Gtk.PositionType.BOTTOM, fast_label);
+ speed_scale.add_mark (1000000, Gtk.PositionType.BOTTOM, null);
+ speed_scale.add_mark (upper, Gtk.PositionType.BOTTOM, slow_label);
+ speed = settings.get_int ("batch-speed");
+ speed_adjustment.value_changed.connect (() => { settings.set_int ("batch-speed", speed); });
+
var document_type = settings.get_string ("document-type");
if (document_type != null)
set_document_hint (document_type);
Follow ups