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
1=== modified file 'README.md'
2--- README.md 2017-03-29 04:04:48 +0000
3+++ README.md 2017-04-06 07:15:00 +0000
4@@ -12,7 +12,7 @@
5
6 Install the dependencies (on Ubuntu/Debian):
7 ```
8-$ sudo apt install bzr valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool
9+$ sudo apt install bzr meson valac libgtk-3-dev libgusb-dev libcolord-dev libpackagekit-glib2-dev libsane-dev gettext itstool
10 ```
11
12 Get the source:
13@@ -24,7 +24,7 @@
14 ```
15 $ meson --prefix $PWD/install build/
16 $ ninja -C build/ all install
17-$ XDG_DATA_DIRS=install/share/$XDG_DATA_DIRS ./install/bin/simple-scan
18+$ XDG_DATA_DIRS=install/share:$XDG_DATA_DIRS ./install/bin/simple-scan
19 ```
20
21 ## DEBUGGING
22
23=== modified file 'data/org.gnome.SimpleScan.gschema.xml'
24--- data/org.gnome.SimpleScan.gschema.xml 2016-07-29 00:53:03 +0000
25+++ data/org.gnome.SimpleScan.gschema.xml 2017-04-06 07:15:00 +0000
26@@ -66,5 +66,11 @@
27 <summary>Quality value to use for JPEG compression</summary>
28 <description>Quality value to use for JPEG compression.</description>
29 </key>
30+ <key name="batch-speed" type="i">
31+ <range min="0" max="10000000" />
32+ <default>1000000</default>
33+ <summary>Delay in microsecond to use in batch scan</summary>
34+ <description>Delay in microsecond to use in batch scan.</description>
35+ </key>
36 </schema>
37 </schemalist>
38
39=== modified file 'src/scanner.vala'
40--- src/scanner.vala 2017-03-29 03:53:07 +0000
41+++ src/scanner.vala 2017-04-06 07:15:00 +0000
42@@ -83,6 +83,7 @@
43 public int paper_height;
44 public int brightness;
45 public int contrast;
46+ public int speed; // Batch scan only.
47 }
48
49 private class ScanJob
50@@ -97,6 +98,7 @@
51 public int page_height;
52 public int brightness;
53 public int contrast;
54+ public int speed; // Batch scan only.
55 }
56
57 private class Request {}
58@@ -1293,6 +1295,10 @@
59 /* Go back for another page */
60 if (job.type != ScanType.SINGLE)
61 {
62+
63+ if (job.type == ScanType.BATCH)
64+ Thread.usleep (job.speed);
65+
66 page_number++;
67 pass_number = 0;
68 notify (new NotifyPageDone (job.id));
69@@ -1561,10 +1567,10 @@
70
71 public void scan (string? device, ScanOptions options)
72 {
73- debug ("Scanner.scan (\"%s\", dpi=%d, scan_mode=%s, depth=%d, type=%s, paper_width=%d, paper_height=%d, brightness=%d, contrast=%d)",
74+ 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)",
75 device != null ? device : "(null)", options.dpi, get_scan_mode_string (options.scan_mode), options.depth,
76 get_scan_type_string (options.type), options.paper_width, options.paper_height,
77- options.brightness, options.contrast);
78+ options.brightness, options.contrast, options.speed);
79 var request = new RequestStartScan ();
80 request.job = new ScanJob ();
81 request.job.id = job_id++;
82@@ -1577,6 +1583,7 @@
83 request.job.page_height = options.paper_height;
84 request.job.brightness = options.brightness;
85 request.job.contrast = options.contrast;
86+ request.job.speed = options.speed;
87 request_queue.push (request);
88 }
89
90
91=== modified file 'src/simple-scan.ui'
92--- src/simple-scan.ui 2017-03-29 07:40:42 +0000
93+++ src/simple-scan.ui 2017-04-06 07:15:00 +0000
94@@ -220,6 +220,12 @@
95 <property name="step_increment">1</property>
96 <property name="page_increment">10</property>
97 </object>
98+ <object class="GtkAdjustment" id="speed_adjustment">
99+ <property name="lower">0</property>
100+ <property name="upper">10000000</property>
101+ <property name="step_increment">100000</property>
102+ <property name="page_increment">1000000</property>
103+ </object>
104 <template class="UserInterface" parent="GtkApplicationWindow">
105 <property name="can_focus">False</property>
106 <property name="title" translatable="yes" comments="Title of scan window">Simple Scan</property>
107@@ -287,13 +293,13 @@
108 </object>
109 </child>
110 <child>
111- <object class="GtkMenuItem" id="burst_menuitem">
112+ <object class="GtkMenuItem" id="batch_menuitem">
113 <property name="visible">True</property>
114 <property name="can_focus">False</property>
115 <property name="label" translatable="yes" comments="Scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
116 <property name="use_underline">True</property>
117 <accelerator key="m" signal="activate" modifiers="GDK_CONTROL_MASK"/>
118- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
119+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
120 </object>
121 </child>
122 <child>
123@@ -1282,7 +1288,38 @@
124 <property name="width">1</property>
125 <property name="height">1</property>
126 </packing>
127+ </child>
128+ <child>
129+ <object class="GtkLabel" id="speed_label">
130+ <property name="visible">True</property>
131+ <property name="can_focus">False</property>
132+ <property name="xalign">0</property>
133+ <property name="label" translatable="yes" comments="Label beside speed scale">Batch scan speed:</property>
134+ <property name="use_underline">True</property>
135+ <property name="mnemonic_widget">speed_scale</property>
136+ </object>
137+ <packing>
138+ <property name="left_attach">0</property>
139+ <property name="top_attach">8</property>
140+ <property name="width">1</property>
141+ <property name="height">1</property>
142+ </packing>
143 </child>
144+ <child>
145+ <object class="GtkScale" id="speed_scale">
146+ <property name="visible">True</property>
147+ <property name="can_focus">True</property>
148+ <property name="hexpand">True</property>
149+ <property name="adjustment">speed_adjustment</property>
150+ <property name="draw_value">False</property>
151+ </object>
152+ <packing>
153+ <property name="left_attach">1</property>
154+ <property name="top_attach">8</property>
155+ <property name="width">1</property>
156+ <property name="height">1</property>
157+ </packing>
158+ </child>
159 </object>
160 <packing>
161 <property name="expand">False</property>
162@@ -1318,12 +1355,12 @@
163 </object>
164 </child>
165 <child>
166- <object class="GtkMenuItem" id="burst_button_menuitem">
167+ <object class="GtkMenuItem" id="batch_button_menuitem">
168 <property name="visible">True</property>
169 <property name="can_focus">False</property>
170 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
171 <property name="use_underline">True</property>
172- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
173+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
174 </object>
175 </child>
176 <child>
177@@ -1377,12 +1414,12 @@
178 </object>
179 </child>
180 <child>
181- <object class="GtkMenuItem" id="burst_button_hb_menuitem">
182+ <object class="GtkMenuItem" id="batch_button_hb_menuitem">
183 <property name="visible">True</property>
184 <property name="can_focus">False</property>
185 <property name="label" translatable="yes" comments="Toolbar scan menu item to scan continuously from the flatbed">_Multiple Pages From Flatbed</property>
186 <property name="use_underline">True</property>
187- <signal name="activate" handler="burst_button_clicked_cb" swapped="no"/>
188+ <signal name="activate" handler="batch_button_clicked_cb" swapped="no"/>
189 </object>
190 </child>
191 <child>
192
193=== modified file 'src/ui.vala'
194--- src/ui.vala 2017-03-29 09:40:01 +0000
195+++ src/ui.vala 2017-04-06 07:15:00 +0000
196@@ -135,6 +135,8 @@
197 [GtkChild]
198 private Gtk.Scale quality_scale;
199 [GtkChild]
200+ private Gtk.Scale speed_scale;
201+ [GtkChild]
202 private Gtk.ListStore device_model;
203 [GtkChild]
204 private Gtk.ListStore text_dpi_model;
205@@ -150,6 +152,8 @@
206 private Gtk.Adjustment contrast_adjustment;
207 [GtkChild]
208 private Gtk.Adjustment quality_adjustment;
209+ [GtkChild]
210+ private Gtk.Adjustment speed_adjustment;
211 private bool setting_devices;
212 private string? missing_driver = null;
213 private bool user_selected_device;
214@@ -229,6 +233,12 @@
215 set { quality_adjustment.value = value; }
216 }
217
218+ public int speed
219+ {
220+ get { return (int) speed_adjustment.value; }
221+ set { speed_adjustment.value = value; }
222+ }
223+
224 public string? selected_device
225 {
226 owned get
227@@ -911,6 +921,7 @@
228 get_paper_size (out options.paper_width, out options.paper_height);
229 options.brightness = brightness;
230 options.contrast = contrast;
231+ options.speed = speed;
232
233 return options;
234 }
235@@ -943,7 +954,7 @@
236 }
237
238 [GtkCallback]
239- private void burst_button_clicked_cb (Gtk.Widget widget)
240+ private void batch_button_clicked_cb (Gtk.Widget widget)
241 {
242 var options = make_scan_options ();
243 options.type = ScanType.BATCH;
244@@ -2010,6 +2021,16 @@
245 quality = settings.get_int ("jpeg-quality");
246 quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", quality); });
247
248+ lower = speed_adjustment.lower;
249+ var fast_label = "<small>%s</small>".printf (_("Fast"));
250+ upper = speed_adjustment.upper;
251+ var slow_label = "<small>%s</small>".printf (_("Slow"));
252+ speed_scale.add_mark (lower, Gtk.PositionType.BOTTOM, fast_label);
253+ speed_scale.add_mark (1000000, Gtk.PositionType.BOTTOM, null);
254+ speed_scale.add_mark (upper, Gtk.PositionType.BOTTOM, slow_label);
255+ speed = settings.get_int ("batch-speed");
256+ speed_adjustment.value_changed.connect (() => { settings.set_int ("batch-speed", speed); });
257+
258 var document_type = settings.get_string ("document-type");
259 if (document_type != null)
260 set_document_hint (document_type);

Subscribers

People subscribed via source and target branches