Merge lp:~soliloque/simple-scan/batch-scan into lp:~simple-scan-team/simple-scan/trunk

Proposed by soliloque
Status: Merged
Merged at revision: 963
Proposed branch: lp:~soliloque/simple-scan/batch-scan
Merge into: lp:~simple-scan-team/simple-scan/trunk
Diff against target: 260 lines (+82/-11)
5 files modified
README.md (+2/-2)
data/org.gnome.SimpleScan.gschema.xml (+6/-0)
src/scanner.vala (+9/-2)
src/simple-scan.ui (+43/-6)
src/ui.vala (+22/-1)
To merge this branch: bzr merge lp:~soliloque/simple-scan/batch-scan
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+322088@code.launchpad.net

Commit message

Add a configurable delay to batch scan type

Description of the change

* 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.

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Thanks! I committed with a few changes:
- I merged the build instructions in a separate merge - they don't relate to this change
- I renamed "speed" to "page delay"
- I changed the setting from us to ms (us seems overkill)
- I changed how the slider looks in the UI

The sleep looks fine since this is all running in its own thread.

review: Approve
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I can't remember when any of the versions are bumped, but yes you often can't compile the latest version of simple-scan in older releases of Ubuntu.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
1212
13Install the dependencies (on Ubuntu/Debian):13Install the dependencies (on Ubuntu/Debian):
14```14```
15$ sudo apt install bzr valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool15$ sudo apt install bzr meson valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool
16```16```
1717
18Get the source:18Get the source:
@@ -24,7 +24,7 @@
24```24```
25$ meson --prefix $PWD/install build/25$ meson --prefix $PWD/install build/
26$ ninja -C build/ all install26$ ninja -C build/ all install
27$ XDG_DATA_DIRS=install/share/$XDG_DATA_DIRS ./install/bin/simple-scan27$ XDG_DATA_DIRS=install/share:$XDG_DATA_DIRS ./install/bin/simple-scan
28```28```
2929
30## DEBUGGING30## DEBUGGING
3131
=== 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 @@
66 <summary>Quality value to use for JPEG compression</summary>66 <summary>Quality value to use for JPEG compression</summary>
67 <description>Quality value to use for JPEG compression.</description>67 <description>Quality value to use for JPEG compression.</description>
68 </key>68 </key>
69 <key name="batch-speed" type="i">
70 <range min="0" max="10000000" />
71 <default>1000000</default>
72 <summary>Delay in microsecond to use in batch scan</summary>
73 <description>Delay in microsecond to use in batch scan.</description>
74 </key>
69 </schema>75 </schema>
70</schemalist>76</schemalist>
7177
=== 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 @@
83 public int paper_height;83 public int paper_height;
84 public int brightness;84 public int brightness;
85 public int contrast;85 public int contrast;
86 public int speed; // Batch scan only.
86}87}
8788
88private class ScanJob89private class ScanJob
@@ -97,6 +98,7 @@
97 public int page_height;98 public int page_height;
98 public int brightness;99 public int brightness;
99 public int contrast;100 public int contrast;
101 public int speed; // Batch scan only.
100}102}
101103
102private class Request {}104private class Request {}
@@ -1293,6 +1295,10 @@
1293 /* Go back for another page */1295 /* Go back for another page */
1294 if (job.type != ScanType.SINGLE)1296 if (job.type != ScanType.SINGLE)
1295 {1297 {
1298
1299 if (job.type == ScanType.BATCH)
1300 Thread.usleep (job.speed);
1301
1296 page_number++;1302 page_number++;
1297 pass_number = 0;1303 pass_number = 0;
1298 notify (new NotifyPageDone (job.id));1304 notify (new NotifyPageDone (job.id));
@@ -1561,10 +1567,10 @@
15611567
1562 public void scan (string? device, ScanOptions options)1568 public void scan (string? device, ScanOptions options)
1563 {1569 {
1564 debug ("Scanner.scan (\"%s\", dpi=%d, scan_mode=%s, depth=%d, type=%s, paper_width=%d, paper_height=%d, brightness=%d, contrast=%d)",1570 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)",
1565 device != null ? device : "(null)", options.dpi, get_scan_mode_string (options.scan_mode), options.depth,1571 device != null ? device : "(null)", options.dpi, get_scan_mode_string (options.scan_mode), options.depth,
1566 get_scan_type_string (options.type), options.paper_width, options.paper_height,1572 get_scan_type_string (options.type), options.paper_width, options.paper_height,
1567 options.brightness, options.contrast);1573 options.brightness, options.contrast, options.speed);
1568 var request = new RequestStartScan ();1574 var request = new RequestStartScan ();
1569 request.job = new ScanJob ();1575 request.job = new ScanJob ();
1570 request.job.id = job_id++;1576 request.job.id = job_id++;
@@ -1577,6 +1583,7 @@
1577 request.job.page_height = options.paper_height;1583 request.job.page_height = options.paper_height;
1578 request.job.brightness = options.brightness;1584 request.job.brightness = options.brightness;
1579 request.job.contrast = options.contrast;1585 request.job.contrast = options.contrast;
1586 request.job.speed = options.speed;
1580 request_queue.push (request);1587 request_queue.push (request);
1581 }1588 }
15821589
15831590
=== 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 @@
220 <property name="step_increment">1</property>220 <property name="step_increment">1</property>
221 <property name="page_increment">10</property>221 <property name="page_increment">10</property>
222 </object>222 </object>
223 <object class="GtkAdjustment" id="speed_adjustment">
224 <property name="lower">0</property>
225 <property name="upper">10000000</property>
226 <property name="step_increment">100000</property>
227 <property name="page_increment">1000000</property>
228 </object>
223 <template class="UserInterface" parent="GtkApplicationWindow">229 <template class="UserInterface" parent="GtkApplicationWindow">
224 <property name="can_focus">False</property>230 <property name="can_focus">False</property>
225 <property name="title" translatable="yes" comments="Title of scan window">Simple Scan</property>231 <property name="title" translatable="yes" comments="Title of scan window">Simple Scan</property>
@@ -287,13 +293,13 @@
287 </object>293 </object>
288 </child>294 </child>
289 <child>295 <child>
290 <object class="GtkMenuItem" id="burst_menuitem">296 <object class="GtkMenuItem" id="batch_menuitem">
291 <property name="visible">True</property>297 <property name="visible">True</property>
292 <property name="can_focus">False</property>298 <property name="can_focus">False</property>
293 <property name="label" translatable="yes" comments="Scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>299 <property name="label" translatable="yes" comments="Scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
294 <property name="use_underline">True</property>300 <property name="use_underline">True</property>
295 <accelerator key="m" signal="activate" modifiers="GDK_CONTROL_MASK"/>301 <accelerator key="m" signal="activate" modifiers="GDK_CONTROL_MASK"/>
296 <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>302 <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
297 </object>303 </object>
298 </child> 304 </child>
299 <child>305 <child>
@@ -1282,7 +1288,38 @@
1282 <property name="width">1</property>1288 <property name="width">1</property>
1283 <property name="height">1</property>1289 <property name="height">1</property>
1284 </packing>1290 </packing>
1291 </child>
1292 <child>
1293 <object class="GtkLabel" id="speed_label">
1294 <property name="visible">True</property>
1295 <property name="can_focus">False</property>
1296 <property name="xalign">0</property>
1297 <property name="label" translatable="yes" comments="Label beside speed scale">Batch scan speed:</property>
1298 <property name="use_underline">True</property>
1299 <property name="mnemonic_widget">speed_scale</property>
1300 </object>
1301 <packing>
1302 <property name="left_attach">0</property>
1303 <property name="top_attach">8</property>
1304 <property name="width">1</property>
1305 <property name="height">1</property>
1306 </packing>
1285 </child>1307 </child>
1308 <child>
1309 <object class="GtkScale" id="speed_scale">
1310 <property name="visible">True</property>
1311 <property name="can_focus">True</property>
1312 <property name="hexpand">True</property>
1313 <property name="adjustment">speed_adjustment</property>
1314 <property name="draw_value">False</property>
1315 </object>
1316 <packing>
1317 <property name="left_attach">1</property>
1318 <property name="top_attach">8</property>
1319 <property name="width">1</property>
1320 <property name="height">1</property>
1321 </packing>
1322 </child>
1286 </object>1323 </object>
1287 <packing>1324 <packing>
1288 <property name="expand">False</property>1325 <property name="expand">False</property>
@@ -1318,12 +1355,12 @@
1318 </object>1355 </object>
1319 </child>1356 </child>
1320 <child>1357 <child>
1321 <object class="GtkMenuItem" id="burst_button_menuitem">1358 <object class="GtkMenuItem" id="batch_button_menuitem">
1322 <property name="visible">True</property>1359 <property name="visible">True</property>
1323 <property name="can_focus">False</property>1360 <property name="can_focus">False</property>
1324 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>1361 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
1325 <property name="use_underline">True</property>1362 <property name="use_underline">True</property>
1326 <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>1363 <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
1327 </object>1364 </object>
1328 </child> 1365 </child>
1329 <child>1366 <child>
@@ -1377,12 +1414,12 @@
1377 </object>1414 </object>
1378 </child>1415 </child>
1379 <child>1416 <child>
1380 <object class="GtkMenuItem" id="burst_button_hb_menuitem">1417 <object class="GtkMenuItem" id="batch_button_hb_menuitem">
1381 <property name="visible">True</property>1418 <property name="visible">True</property>
1382 <property name="can_focus">False</property>1419 <property name="can_focus">False</property>
1383 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>1420 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
1384 <property name="use_underline">True</property>1421 <property name="use_underline">True</property>
1385 <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>1422 <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
1386 </object>1423 </object>
1387 </child> 1424 </child>
1388 <child>1425 <child>
13891426
=== 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 @@
135 [GtkChild]135 [GtkChild]
136 private Gtk.Scale quality_scale;136 private Gtk.Scale quality_scale;
137 [GtkChild]137 [GtkChild]
138 private Gtk.Scale speed_scale;
139 [GtkChild]
138 private Gtk.ListStore device_model;140 private Gtk.ListStore device_model;
139 [GtkChild]141 [GtkChild]
140 private Gtk.ListStore text_dpi_model;142 private Gtk.ListStore text_dpi_model;
@@ -150,6 +152,8 @@
150 private Gtk.Adjustment contrast_adjustment;152 private Gtk.Adjustment contrast_adjustment;
151 [GtkChild]153 [GtkChild]
152 private Gtk.Adjustment quality_adjustment;154 private Gtk.Adjustment quality_adjustment;
155 [GtkChild]
156 private Gtk.Adjustment speed_adjustment;
153 private bool setting_devices;157 private bool setting_devices;
154 private string? missing_driver = null;158 private string? missing_driver = null;
155 private bool user_selected_device;159 private bool user_selected_device;
@@ -229,6 +233,12 @@
229 set { quality_adjustment.value = value; }233 set { quality_adjustment.value = value; }
230 }234 }
231235
236 public int speed
237 {
238 get { return (int) speed_adjustment.value; }
239 set { speed_adjustment.value = value; }
240 }
241
232 public string? selected_device242 public string? selected_device
233 {243 {
234 owned get244 owned get
@@ -911,6 +921,7 @@
911 get_paper_size (out options.paper_width, out options.paper_height);921 get_paper_size (out options.paper_width, out options.paper_height);
912 options.brightness = brightness;922 options.brightness = brightness;
913 options.contrast = contrast;923 options.contrast = contrast;
924 options.speed = speed;
914925
915 return options;926 return options;
916 }927 }
@@ -943,7 +954,7 @@
943 }954 }
944955
945 [GtkCallback]956 [GtkCallback]
946 private void burst_button_clicked_cb (Gtk.Widget widget)957 private void batch_button_clicked_cb (Gtk.Widget widget)
947 {958 {
948 var options = make_scan_options ();959 var options = make_scan_options ();
949 options.type = ScanType.BATCH;960 options.type = ScanType.BATCH;
@@ -2010,6 +2021,16 @@
2010 quality = settings.get_int ("jpeg-quality");2021 quality = settings.get_int ("jpeg-quality");
2011 quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", quality); });2022 quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", quality); });
20122023
2024 lower = speed_adjustment.lower;
2025 var fast_label = "<small>%s</small>".printf (_("Fast"));
2026 upper = speed_adjustment.upper;
2027 var slow_label = "<small>%s</small>".printf (_("Slow"));
2028 speed_scale.add_mark (lower, Gtk.PositionType.BOTTOM, fast_label);
2029 speed_scale.add_mark (1000000, Gtk.PositionType.BOTTOM, null);
2030 speed_scale.add_mark (upper, Gtk.PositionType.BOTTOM, slow_label);
2031 speed = settings.get_int ("batch-speed");
2032 speed_adjustment.value_changed.connect (() => { settings.set_int ("batch-speed", speed); });
2033
2013 var document_type = settings.get_string ("document-type");2034 var document_type = settings.get_string ("document-type");
2014 if (document_type != null)2035 if (document_type != null)
2015 set_document_hint (document_type);2036 set_document_hint (document_type);

Subscribers

People subscribed via source and target branches