Merge lp:~mbarnes.redhat/simple-scan/default-save-format into lp:~simple-scan-team/simple-scan/trunk

Proposed by Matthew Barnes
Status: Needs review
Proposed branch: lp:~mbarnes.redhat/simple-scan/default-save-format
Merge into: lp:~simple-scan-team/simple-scan/trunk
Diff against target: 91 lines (+13/-13)
1 file modified
src/ui.vala (+13/-13)
To merge this branch: bzr merge lp:~mbarnes.redhat/simple-scan/default-save-format
Reviewer Review Type Date Requested Status
Robert Ancell Needs Fixing
Matthew Barnes Pending
Review via email: mp+322293@code.launchpad.net

Description of the change

I frequently use simple-scan to save scanned images as JPEG files. However, each time I have to manually change the save format from PDF to JPEG, even though the "document-hint" setting is "photo".

This branch sets the default save format according to the "document-hint" setting: PDF for text scans, JPEG for photo scans. (This assumes, I think correctly, that JPEG is most likely wanted for photos.)

Also, for convenience, if the user manually selects a different file format in the save dialog, simple-scan will remember that in subsequent save dialogs for the remainder of the session, or until the user changes the "document-hint" setting again.

Note, this branch alters a translated string ("Scanned Document.pdf" -> "Scanned Document").

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

We actually changed from this behaviour because it was confusing when you had multi-page scans (bug 1480605). So I think it makes sense to save to PDF by default to be less confusing. However we should definitely remember the setting if the user changes it. This would ideally also persist between runs (i.e. store in gsettings).

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

Note - I have moved simple-scan to GNOME git, if this change is still relevant we should work on it there.

Revision history for this message
Matthew Barnes (mbarnes.redhat) wrote :

Thanks. Was on vacation for a week. Still intend to revise this as suggested.

Unmerged revisions

962. By Matthew Barnes

Choose a save format appropriate for the document-hint

Scanning text will select .pdf by default when saving, scanning photo(s)
will select .jpg by default.

Also, remember the save format between save dialogs during a session
until the document-hint is changed again.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui.vala'
2--- src/ui.vala 2017-03-29 09:40:01 +0000
3+++ src/ui.vala 2017-04-10 14:26:17 +0000
4@@ -156,6 +156,7 @@
5
6 private Gtk.FileChooserDialog? save_dialog;
7 private ProgressBarDialog progress_dialog;
8+ private string? save_dialog_extension = ".pdf";
9
10 private bool have_error;
11 private string error_title;
12@@ -507,9 +508,12 @@
13 if (book_uri != null)
14 save_dialog.set_uri (book_uri);
15 else {
16+ var filename = _("Scanned Document") + save_dialog_extension;
17+
18 save_dialog.set_current_folder (directory);
19 /* Default filename to use when saving document */
20- save_dialog.set_current_name (_("Scanned Document.pdf"));
21+ debug ("Setting filename to '%s'", filename);
22+ save_dialog.set_current_name (filename);
23 }
24
25 /* Filter to only show images by default */
26@@ -556,18 +560,16 @@
27 box.pack_start (label, false, false, 0);
28
29 var file_type_combo = new Gtk.ComboBox.with_model (file_type_store);
30+ file_type_combo.set_id_column (1);
31 file_type_combo.visible = true;
32 var renderer = new Gtk.CellRendererText ();
33 file_type_combo.pack_start (renderer, true);
34 file_type_combo.add_attribute (renderer, "text", 0);
35
36- file_type_combo.set_active (0);
37+ file_type_combo.set_active_id (save_dialog_extension);
38 file_type_combo.changed.connect (() =>
39 {
40- var extension = "";
41- Gtk.TreeIter i;
42- if (file_type_combo.get_active_iter (out i))
43- file_type_store.get (i, 1, out extension, -1);
44+ save_dialog_extension = file_type_combo.get_active_id ();
45
46 var path = save_dialog.get_filename ();
47 var filename = Path.get_basename (path);
48@@ -576,7 +578,8 @@
49 var extension_index = filename.last_index_of_char ('.');
50 if (extension_index >= 0)
51 filename = filename.slice (0, extension_index);
52- filename = filename + extension;
53+ filename = filename + save_dialog_extension;
54+ debug ("Setting filename to '%s'", filename);
55 save_dialog.set_current_name (filename);
56 });
57 box.pack_start (file_type_combo, false, false, 0);
58@@ -588,17 +591,12 @@
59 if (response != Gtk.ResponseType.ACCEPT)
60 break;
61
62- var extension = "";
63- Gtk.TreeIter i;
64- if (file_type_combo.get_active_iter (out i))
65- file_type_store.get (i, 1, out extension, -1);
66-
67 var path = save_dialog.get_filename ();
68 var filename = Path.get_basename (path);
69
70 var extension_index = filename.last_index_of_char ('.');
71 if (extension_index < 0)
72- path += extension;
73+ path += save_dialog_extension;
74
75 uri = File.new_for_path (path).get_uri ();
76
77@@ -780,12 +778,14 @@
78 text_button_menuitem.active = true;
79 text_button_hb_menuitem.active = true;
80 text_menuitem.active = true;
81+ save_dialog_extension = ".pdf";
82 }
83 else if (document_hint == "photo")
84 {
85 photo_button_menuitem.active = true;
86 photo_button_hb_menuitem.active = true;
87 photo_menuitem.active = true;
88+ save_dialog_extension = ".jpg";
89 }
90
91 if (save)

Subscribers

People subscribed via source and target branches