From 383626437ca8f9d26518408719b5d778e696eecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 21 Aug 2021 10:58:17 +0200 Subject: New upstream version 40.1 --- src/app-window.ui | 843 --------------------------------------- src/app-window.vala | 143 ++++--- src/authorize-dialog.ui | 111 ------ src/authorize-dialog.vala | 8 +- src/book-view.vala | 9 +- src/help-overlay.ui | 162 -------- src/meson.build | 6 +- src/page-view.vala | 10 +- src/page.vala | 4 +- src/preferences-dialog.ui | 456 --------------------- src/preferences-dialog.vala | 90 ++--- src/scan-type-adf-symbolic.svg | 9 - src/scan-type-batch-symbolic.svg | 9 - src/scanner.vala | 199 +++++---- src/simple-scan.gresource.xml | 15 - src/simple-scan.vala | 2 + 16 files changed, 276 insertions(+), 1800 deletions(-) delete mode 100644 src/app-window.ui delete mode 100644 src/authorize-dialog.ui delete mode 100644 src/help-overlay.ui delete mode 100644 src/preferences-dialog.ui delete mode 100644 src/scan-type-adf-symbolic.svg delete mode 100644 src/scan-type-batch-symbolic.svg delete mode 100644 src/simple-scan.gresource.xml (limited to 'src') diff --git a/src/app-window.ui b/src/app-window.ui deleted file mode 100644 index 6f42a51..0000000 --- a/src/app-window.ui +++ /dev/null @@ -1,843 +0,0 @@ - - - - - - True - False - - - True - False - Rotate _Left - True - - - - - - - True - False - Rotate _Right - True - - - - - - - True - False - _Crop - True - - - True - False - - - True - False - _None - True - True - True - - - - - - True - False - A_4 - True - True - no_crop_menuitem - - - - - - True - False - A_5 - True - True - no_crop_menuitem - - - - - - True - False - A_6 - True - True - no_crop_menuitem - - - - - - True - False - _Letter - True - True - no_crop_menuitem - - - - - - True - False - Le_gal - True - True - no_crop_menuitem - - - - - - True - False - 4×6 - True - True - no_crop_menuitem - - - - - - True - False - A_3 - True - True - no_crop_menuitem - - - - - - True - False - _Custom - True - True - no_crop_menuitem - - - - - - True - False - - - - - True - False - False - _Rotate Crop - True - - - - - - - - - - True - False - Move Left - - - - - - - True - False - Move Right - True - - - - - - - gtk-copy - True - False - False - True - True - - - - - - - gtk-delete - True - False - True - True - - - - - - - - - - - - - - - False - - - True - False - 12 - 12 - 12 - 12 - vertical - 6 - - - True - False - False - False - - - - True - False - 12 - 12 - 6 - 6 - 12 - - - True - False - scanner-symbolic - - - False - True - 0 - - - - - True - False - _Single Page - True - - - False - True - 1 - - - - - - - False - True - 0 - - - - - True - False - False - False - scan_single_radio - - - - True - False - 12 - 12 - 6 - 6 - 12 - - - True - False - scan-type-adf-symbolic - - - False - True - 0 - - - - - True - False - All Pages From _Feeder - True - - - False - True - 1 - - - - - - - False - True - 1 - - - - - True - False - False - False - scan_single_radio - - - - True - False - 12 - 12 - 6 - 6 - 12 - - - True - False - scan-type-batch-symbolic - - - False - True - 0 - - - - - True - False - _Multiple Pages From Flatbed - True - - - False - True - 1 - - - - - - - False - True - 2 - - - - - True - False - False - 12 - False - - - - True - False - 12 - 12 - 6 - 6 - 12 - - - True - False - x-office-document-symbolic - - - False - True - 0 - - - - - True - False - _Text - True - - - False - True - 1 - - - - - - - False - True - 3 - - - - - True - False - False - False - text_radio - - - - True - False - 12 - 12 - 6 - 6 - 12 - - - True - False - image-x-generic-symbolic - - - False - True - 0 - - - - - True - False - _Image - True - - - False - True - 1 - - - - - - - False - True - 4 - - - - - _Preferences - 40 - True - True - True - 12 - True - - - - False - True - 5 - - - - - - - diff --git a/src/app-window.vala b/src/app-window.vala index 67f10a8..c1d4ea3 100644 --- a/src/app-window.vala +++ b/src/app-window.vala @@ -13,8 +13,8 @@ private const int DEFAULT_TEXT_DPI = 150; private const int DEFAULT_PHOTO_DPI = 300; -[GtkTemplate (ui = "/org/gnome/SimpleScan/app-window.ui")] -public class AppWindow : Gtk.ApplicationWindow +[GtkTemplate (ui = "/org/gnome/SimpleScan/ui/app-window.ui")] +public class AppWindow : Hdy.ApplicationWindow { private const GLib.ActionEntry[] action_entries = { @@ -48,77 +48,79 @@ public class AppWindow : Gtk.ApplicationWindow private bool user_selected_device; [GtkChild] - private Gtk.HeaderBar header_bar; + private unowned Hdy.HeaderBar header_bar; [GtkChild] - private Gtk.Menu page_menu; + private unowned Gtk.Menu page_menu; [GtkChild] - private Gtk.Stack stack; + private unowned Gtk.Stack stack; [GtkChild] - private Gtk.Label status_primary_label; + private unowned Hdy.StatusPage status_page; [GtkChild] - private Gtk.ListStore device_model; + private unowned Gtk.Label status_secondary_label; [GtkChild] - private Gtk.ComboBox device_combo; + private unowned Gtk.ListStore device_model; [GtkChild] - private Gtk.Label status_secondary_label; + private unowned Gtk.Box device_buttons_box; [GtkChild] - private Gtk.Box main_vbox; + private unowned Gtk.ComboBox device_combo; [GtkChild] - private Gtk.RadioMenuItem custom_crop_menuitem; + private unowned Gtk.Box main_vbox; [GtkChild] - private Gtk.RadioMenuItem a3_menuitem; + private unowned Gtk.RadioMenuItem custom_crop_menuitem; [GtkChild] - private Gtk.RadioMenuItem a4_menuitem; + private unowned Gtk.RadioMenuItem a3_menuitem; [GtkChild] - private Gtk.RadioMenuItem a5_menuitem; + private unowned Gtk.RadioMenuItem a4_menuitem; [GtkChild] - private Gtk.RadioMenuItem a6_menuitem; + private unowned Gtk.RadioMenuItem a5_menuitem; [GtkChild] - private Gtk.RadioMenuItem letter_menuitem; + private unowned Gtk.RadioMenuItem a6_menuitem; [GtkChild] - private Gtk.RadioMenuItem legal_menuitem; + private unowned Gtk.RadioMenuItem letter_menuitem; [GtkChild] - private Gtk.RadioMenuItem four_by_six_menuitem; + private unowned Gtk.RadioMenuItem legal_menuitem; [GtkChild] - private Gtk.RadioMenuItem no_crop_menuitem; + private unowned Gtk.RadioMenuItem four_by_six_menuitem; [GtkChild] - private Gtk.MenuItem page_move_left_menuitem; + private unowned Gtk.RadioMenuItem no_crop_menuitem; [GtkChild] - private Gtk.MenuItem page_move_right_menuitem; + private unowned Gtk.MenuItem page_move_left_menuitem; [GtkChild] - private Gtk.MenuItem page_delete_menuitem; + private unowned Gtk.MenuItem page_move_right_menuitem; [GtkChild] - private Gtk.MenuItem crop_rotate_menuitem; + private unowned Gtk.MenuItem page_delete_menuitem; [GtkChild] - private Gtk.MenuItem copy_to_clipboard_menuitem; + private unowned Gtk.MenuItem crop_rotate_menuitem; [GtkChild] - private Gtk.Button save_button; + private unowned Gtk.MenuItem copy_to_clipboard_menuitem; [GtkChild] - private Gtk.Button stop_button; + private unowned Gtk.Button save_button; [GtkChild] - private Gtk.Button scan_button; + private unowned Gtk.Button stop_button; [GtkChild] - private Gtk.ActionBar action_bar; + private unowned Gtk.Button scan_button; + [GtkChild] + private unowned Gtk.ActionBar action_bar; private Gtk.ToggleButton crop_button; private Gtk.Button delete_button; [GtkChild] - private Gtk.Image scan_options_image; + private unowned Gtk.Image scan_options_image; [GtkChild] - private Gtk.Image scan_hint_image; + private unowned Gtk.Image scan_hint_image; [GtkChild] - private Gtk.RadioButton scan_single_radio; + private unowned Gtk.RadioButton scan_single_radio; [GtkChild] - private Gtk.RadioButton scan_adf_radio; + private unowned Gtk.RadioButton scan_adf_radio; [GtkChild] - private Gtk.RadioButton scan_batch_radio; + private unowned Gtk.RadioButton scan_batch_radio; [GtkChild] - private Gtk.RadioButton text_radio; + private unowned Gtk.RadioButton text_radio; [GtkChild] - private Gtk.RadioButton photo_radio; + private unowned Gtk.RadioButton photo_radio; [GtkChild] - private Gtk.MenuButton menu_button; + private unowned Gtk.MenuButton menu_button; private bool have_devices = false; private string? missing_driver = null; @@ -249,38 +251,41 @@ public class AppWindow : Gtk.ApplicationWindow scan_button.sensitive = false; if (!have_devices) { - status_primary_label.set_text (/* Label shown when searching for scanners */ - _("Searching for Scanners…")); + status_page.set_title (/* Label shown when searching for scanners */ + _("Searching for Scanners…")); status_secondary_label.visible = false; - device_combo.visible = false; + device_buttons_box.visible = false; } else if (get_selected_device () != null) { scan_button.sensitive = true; - status_primary_label.set_text (/* Label shown when detected a scanner */ - _("Ready to Scan")); + status_page.set_title (/* Label shown when detected a scanner */ + _("Ready to Scan")); status_secondary_label.set_text (get_selected_device_label ()); status_secondary_label.visible = false; - device_combo.visible = true; + device_buttons_box.visible = true; + device_buttons_box.sensitive = true; device_combo.sensitive = true; } else if (this.missing_driver != null) { - status_primary_label.set_text (/* Warning displayed when no drivers are installed but a compatible scanner is detected */ - _("Additional software needed")); + status_page.set_title (/* Warning displayed when no drivers are installed but a compatible scanner is detected */ + _("Additional Software Needed")); /* Instructions to install driver software */ status_secondary_label.set_markup (_("You need to install driver software for your scanner.")); status_secondary_label.visible = true; - device_combo.visible = false; + device_buttons_box.visible = false; } else { /* Warning displayed when no scanners are detected */ - status_primary_label.set_text (_("No scanners detected")); + status_page.set_title (_("No Scanners Detected")); /* Hint to user on why there are no scanners detected */ - status_secondary_label.set_text (_("Please check your scanner is connected and powered on")); + status_secondary_label.set_text (_("Please check your scanner is connected and powered on.")); status_secondary_label.visible = true; - device_combo.visible = false; + device_buttons_box.visible = true; + device_buttons_box.sensitive = true; + device_combo.sensitive = false; // We would like to be refresh button to be active } } @@ -796,9 +801,6 @@ public class AppWindow : Gtk.ApplicationWindow if (scanning) stop_scan (); - have_devices = false; - /* Refresh list of devices to detect network scanners, and fix issues with disconnected scanners */ - redetect (); clear_document (); }); } @@ -820,11 +822,20 @@ public class AppWindow : Gtk.ApplicationWindow new_document (); } + [GtkCallback] + private void redetect_button_clicked_cb (Gtk.Button button) + { + have_devices = false; + update_scan_status (); + redetect (); + } + private void scan (ScanOptions options) { - status_primary_label.set_text (/* Label shown when scan started */ - _("Contacting scanner…")); - device_combo.sensitive = false; + status_page.set_title (/* Label shown when scan started */ + _("Contacting Scanner…")); + device_buttons_box.visible = true; + device_buttons_box.sensitive = false; start_scan (get_selected_device (), options); } @@ -838,8 +849,7 @@ public class AppWindow : Gtk.ApplicationWindow private void scan_adf_cb () { var options = make_scan_options (); - options.type = ScanType.ADF_BOTH; - options.type = preferences_dialog.get_page_side (); + options.type = ScanType.ADF; scan (options); } @@ -895,7 +905,7 @@ public class AppWindow : Gtk.ApplicationWindow scan_single_radio.active = true; scan_options_image.icon_name = "scanner-symbolic"; break; - case ScanType.ADF_BOTH: + case ScanType.ADF: scan_adf_radio.active = true; scan_options_image.icon_name = "scan-type-adf-symbolic"; break; @@ -917,7 +927,7 @@ public class AppWindow : Gtk.ApplicationWindow private void scan_adf_radio_toggled_cb (Gtk.ToggleButton button) { if (button.active) - set_scan_type (ScanType.ADF_BOTH); + set_scan_type (ScanType.ADF); } [GtkCallback] @@ -985,6 +995,7 @@ public class AppWindow : Gtk.ApplicationWindow options.brightness = brightness; options.contrast = contrast; options.page_delay = page_delay; + options.side = preferences_dialog.get_page_side (); return options; } @@ -1006,8 +1017,6 @@ public class AppWindow : Gtk.ApplicationWindow stop_button.visible = true; var options = make_scan_options (); options.type = scan_type; - if (options.type == ScanType.ADF_BOTH) - options.type = preferences_dialog.get_page_side (); scan (options); } @@ -1834,8 +1843,12 @@ public class AppWindow : Gtk.ApplicationWindow private void load () { preferences_dialog = new PreferencesDialog (settings); - preferences_dialog.delete_event.connect (() => { return true; }); - preferences_dialog.response.connect (() => { preferences_dialog.visible = false; }); + preferences_dialog.delete_event.connect (() => { + preferences_dialog.visible = false; + return true; + }); + preferences_dialog.transient_for = this; + preferences_dialog.modal = true; Gtk.Window.set_default_icon_name ("org.gnome.SimpleScan"); @@ -1872,9 +1885,9 @@ public class AppWindow : Gtk.ApplicationWindow section.append (_("Email"), "app.email"); section.append (_("Print"), "app.print"); section.append (C_("menu", "Reorder Pages"), "app.reorder"); - section.append (_("Preferences"), "app.preferences"); section = new Menu (); gear_menu.append_section (null, section); + section.append (_("Preferences"), "app.preferences"); section.append (_("Keyboard Shortcuts"), "win.show-help-overlay"); section.append (_("Help"), "app.help"); section.append (_("About Document Scanner"), "app.about"); @@ -1885,7 +1898,7 @@ public class AppWindow : Gtk.ApplicationWindow /* Populate ActionBar (not supported in Glade) */ /* https://bugzilla.gnome.org/show_bug.cgi?id=769966 */ var button = new Gtk.Button.with_label (/* Label on new document button */ - _("Start Again…")); + _("New Document")); button.visible = true; button.clicked.connect (new_document_cb); action_bar.pack_start (button); @@ -1919,7 +1932,7 @@ public class AppWindow : Gtk.ApplicationWindow crop_button = new Gtk.ToggleButton (); crop_button.visible = true; - var image = new Gtk.Image.from_icon_name ("edit-cut-symbolic", Gtk.IconSize.BUTTON); + var image = new Gtk.Image.from_icon_name ("crop-symbolic", Gtk.IconSize.BUTTON); image.visible = true; image.margin_start = 18; image.margin_end = 18; diff --git a/src/authorize-dialog.ui b/src/authorize-dialog.ui deleted file mode 100644 index 79e43fd..0000000 --- a/src/authorize-dialog.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - diff --git a/src/authorize-dialog.vala b/src/authorize-dialog.vala index a6e5ab0..7cb2a66 100644 --- a/src/authorize-dialog.vala +++ b/src/authorize-dialog.vala @@ -10,15 +10,15 @@ * license. */ -[GtkTemplate (ui = "/org/gnome/SimpleScan/authorize-dialog.ui")] +[GtkTemplate (ui = "/org/gnome/SimpleScan/ui/authorize-dialog.ui")] private class AuthorizeDialog : Gtk.Dialog { [GtkChild] - private Gtk.Label authorize_label; + private unowned Gtk.Label authorize_label; [GtkChild] - private Gtk.Entry username_entry; + private unowned Gtk.Entry username_entry; [GtkChild] - private Gtk.Entry password_entry; + private unowned Gtk.Entry password_entry; public AuthorizeDialog (string title) { diff --git a/src/book-view.vala b/src/book-view.vala index 12da06f..59e2469 100644 --- a/src/book-view.vala +++ b/src/book-view.vala @@ -189,7 +189,14 @@ public class BookView : Gtk.Box private void add_cb (Book book, Page page) { - var page_view = new PageView (page); + Gdk.RGBA page_ruler_color; + if (!get_style_context ().lookup_color ("theme_fg_color", out page_ruler_color)) + { + warning ("Couldn't get theme_fg_color from GTK theme, needed to draw the page view ruler"); + /* Use a bright color so that theme makers notice it. */ + page_ruler_color.parse ("#00ff00"); + } + var page_view = new PageView (page, page_ruler_color); page_view.changed.connect (page_view_changed_cb); page_view.size_changed.connect (page_view_size_changed_cb); page_data.insert (page, page_view); diff --git a/src/help-overlay.ui b/src/help-overlay.ui deleted file mode 100644 index 105d876..0000000 --- a/src/help-overlay.ui +++ /dev/null @@ -1,162 +0,0 @@ - - - - - 1 - - - 1 - - - 1 - Scanning - - - 1 - <ctrl>1 - Scan a single page - - - - - 1 - <ctrl>f - Scan all pages from document feeder - - - - - 1 - <ctrl>m - Scan continuously from a flatbed scanner - - - - - 1 - Escape - Stop scan in progress - - - - - - - 1 - Document Modification - - - 1 - less - Move page left - - - - - 1 - greater - Move page right - - - - - 1 - bracketleft - Rotate page to the left (anti-clockwise) - - - - - 1 - bracketright - Rotate page to the right (clockwise) - - - - - 1 - Delete - Delete page - - - - - - - 1 - Document Management - - - 1 - <ctrl>n - Start new document - - - - - 1 - <ctrl>s - Save scanned document - - - - - 1 - <ctrl>e - Email scanned document - - - - - 1 - <ctrl>p - Print scanned document - - - - - 1 - <ctrl>c - Copy current page to clipboard - - - - - - - 1 - General - - - 1 - F1 - Show help - - - - - 1 - F10 - Open menu - - - - - 1 - <ctrl>question - Keyboard shortcuts - - - - - 1 - <ctrl>q - Quit - - - - - - - - diff --git a/src/meson.build b/src/meson.build index 419ed06..3f699eb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,9 +1,5 @@ -resources = gnome.compile_resources ('resources', 'simple-scan.gresource.xml', - source_dir: '.', - c_name: 'resources') - vala_args = [ '--pkg=posix', '--vapidir=' + meson.current_source_dir () ] -dependencies = [ glib_dep, gtk_dep, zlib_dep, cairo_dep, gdk_pixbuf_dep, gusb_dep, sane_dep ] +dependencies = [ glib_dep, gtk_dep, libhandy_dep, zlib_dep, cairo_dep, gdk_pixbuf_dep, gusb_dep, sane_dep ] if colord_dep.found () vala_args += [ '-D', 'HAVE_COLORD' ] dependencies += colord_dep diff --git a/src/page-view.vala b/src/page-view.vala index 90a8071..342df27 100644 --- a/src/page-view.vala +++ b/src/page-view.vala @@ -45,6 +45,8 @@ public class PageView : Object } } + private Gdk.RGBA ruler_color; + private int ruler_width = 8; private int border_width = 2; @@ -84,9 +86,13 @@ public class PageView : Object public signal void size_changed (); public signal void changed (); - public PageView (Page page) + /* It is necessary to ask the ruler color since it is themed with the GTK */ + /* theme foreground color, and this class doesn't have any GTK widget */ + /* available to lookup the color. */ + public PageView (Page page, Gdk.RGBA ruler_color) { this.page = page; + this.ruler_color = ruler_color; page.pixels_changed.connect (page_pixels_changed_cb); page.size_changed.connect (page_size_changed_cb); page.crop_changed.connect (page_overlay_changed_cb); @@ -839,7 +845,7 @@ public class PageView : Object context.paint (); /* Draw page border */ - context.set_source_rgb (0, 0, 0); + context.set_source_rgb (ruler_color.red, ruler_color.green, ruler_color.blue); context.set_line_width (border_width); context.rectangle (0, diff --git a/src/page.vala b/src/page.vala index c6b532e..62af773 100644 --- a/src/page.vala +++ b/src/page.vala @@ -216,8 +216,8 @@ public class Page : Object this.crop_name = crop_name; this.crop_x = crop_x; this.crop_y = crop_y; - this.crop_width = crop_width; - this.crop_height = crop_height; + this.crop_width = (crop_x + crop_width > scan_width) ? scan_width : crop_width; + this.crop_height = (crop_y + crop_height > scan_height) ? scan_height : crop_height; } public void set_page_info (ScanPageInfo info) diff --git a/src/preferences-dialog.ui b/src/preferences-dialog.ui deleted file mode 100644 index 63d06e0..0000000 --- a/src/preferences-dialog.ui +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - -100 - 100 - 1 - 10 - - - -100 - 100 - 1 - 10 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala index a0fb9e9..8d992ab 100644 --- a/src/preferences-dialog.vala +++ b/src/preferences-dialog.vala @@ -10,52 +10,50 @@ * license. */ -[GtkTemplate (ui = "/org/gnome/SimpleScan/preferences-dialog.ui")] -private class PreferencesDialog : Gtk.Dialog +[GtkTemplate (ui = "/org/gnome/SimpleScan/ui/preferences-dialog.ui")] +private class PreferencesDialog : Hdy.PreferencesWindow { private Settings settings; [GtkChild] - private Gtk.ComboBox text_dpi_combo; + private unowned Gtk.ComboBox text_dpi_combo; [GtkChild] - private Gtk.ComboBox photo_dpi_combo; + private unowned Gtk.ComboBox photo_dpi_combo; [GtkChild] - private Gtk.ComboBox paper_size_combo; + private unowned Gtk.ComboBox paper_size_combo; [GtkChild] - private Gtk.Scale brightness_scale; + private unowned Gtk.Scale brightness_scale; [GtkChild] - private Gtk.Scale contrast_scale; + private unowned Gtk.Scale contrast_scale; [GtkChild] - private Gtk.RadioButton page_delay_3s_button; + private unowned Gtk.RadioButton page_delay_0s_button; [GtkChild] - private Gtk.RadioButton page_delay_5s_button; + private unowned Gtk.RadioButton page_delay_3s_button; [GtkChild] - private Gtk.RadioButton page_delay_7s_button; + private unowned Gtk.RadioButton page_delay_6s_button; [GtkChild] - private Gtk.RadioButton page_delay_10s_button; + private unowned Gtk.RadioButton page_delay_10s_button; [GtkChild] - private Gtk.RadioButton page_delay_15s_button; + private unowned Gtk.RadioButton page_delay_15s_button; [GtkChild] - private Gtk.ListStore text_dpi_model; + private unowned Gtk.ListStore text_dpi_model; [GtkChild] - private Gtk.ListStore photo_dpi_model; + private unowned Gtk.ListStore photo_dpi_model; [GtkChild] - private Gtk.RadioButton front_side_button; + private unowned Gtk.RadioButton front_side_button; [GtkChild] - private Gtk.RadioButton back_side_button; + private unowned Gtk.RadioButton back_side_button; [GtkChild] - private Gtk.RadioButton both_side_button; + private unowned Gtk.RadioButton both_side_button; [GtkChild] - private Gtk.ListStore paper_size_model; + private unowned Gtk.ListStore paper_size_model; [GtkChild] - private Gtk.Adjustment brightness_adjustment; + private unowned Gtk.Adjustment brightness_adjustment; [GtkChild] - private Gtk.Adjustment contrast_adjustment; + private unowned Gtk.Adjustment contrast_adjustment; public PreferencesDialog (Settings settings) { - Object (use_header_bar: 1); - this.settings = settings; Gtk.TreeIter iter; @@ -89,10 +87,10 @@ private class PreferencesDialog : Gtk.Dialog set_dpi_combo (photo_dpi_combo, DEFAULT_PHOTO_DPI, dpi); photo_dpi_combo.changed.connect (() => { settings.set_int ("photo-dpi", get_photo_dpi ()); }); - set_page_side ((ScanType) settings.get_enum ("page-side")); - front_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanType.ADF_FRONT); }); - back_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanType.ADF_BACK); }); - both_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanType.ADF_BOTH); }); + set_page_side ((ScanSide) settings.get_enum ("page-side")); + front_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanSide.FRONT); }); + back_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanSide.BACK); }); + both_side_button.toggled.connect ((button) => { if (button.active) settings.set_enum ("page-side", ScanSide.BOTH); }); var renderer = new Gtk.CellRendererText (); paper_size_combo.pack_start (renderer, true); @@ -130,38 +128,38 @@ private class PreferencesDialog : Gtk.Dialog }); set_page_delay (settings.get_int ("page-delay")); + page_delay_0s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 0); }); page_delay_3s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 3000); }); - page_delay_5s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 5000); }); - page_delay_7s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 7000); }); + page_delay_6s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 6000); }); page_delay_10s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 10000); }); page_delay_15s_button.toggled.connect ((button) => { if (button.active) settings.set_int ("page-delay", 15000); }); } - private void set_page_side (ScanType page_side) + private void set_page_side (ScanSide page_side) { switch (page_side) { - case ScanType.ADF_FRONT: + case ScanSide.FRONT: front_side_button.active = true; break; - case ScanType.ADF_BACK: + case ScanSide.BACK: back_side_button.active = true; break; default: - case ScanType.ADF_BOTH: + case ScanSide.BOTH: both_side_button.active = true; break; } } - public ScanType get_page_side () + public ScanSide get_page_side () { if (front_side_button.active) - return ScanType.ADF_FRONT; + return ScanSide.FRONT; else if (back_side_button.active) - return ScanType.ADF_BACK; + return ScanSide.BACK; else - return ScanType.ADF_BOTH; + return ScanSide.BOTH; } public void set_paper_size (int width, int height) @@ -247,12 +245,12 @@ private class PreferencesDialog : Gtk.Dialog return 15000; else if (page_delay_10s_button.active) return 10000; - else if (page_delay_7s_button.active) - return 7000; - else if (page_delay_5s_button.active) - return 5000; - else + else if (page_delay_6s_button.active) + return 6000; + else if (page_delay_3s_button.active) return 3000; + else + return 0; } public void set_page_delay (int page_delay) @@ -261,12 +259,12 @@ private class PreferencesDialog : Gtk.Dialog page_delay_15s_button.active = true; else if (page_delay >= 10000) page_delay_10s_button.active = true; - else if (page_delay >= 7000) - page_delay_7s_button.active = true; - else if (page_delay >= 5000) - page_delay_5s_button.active = true; - else + else if (page_delay >= 6000) + page_delay_6s_button.active = true; + else if (page_delay >= 3000) page_delay_3s_button.active = true; + else + page_delay_0s_button.active = true; } private void set_dpi_combo (Gtk.ComboBox combo, int default_dpi, int current_dpi) diff --git a/src/scan-type-adf-symbolic.svg b/src/scan-type-adf-symbolic.svg deleted file mode 100644 index 4ddb4de..0000000 --- a/src/scan-type-adf-symbolic.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/scan-type-batch-symbolic.svg b/src/scan-type-batch-symbolic.svg deleted file mode 100644 index a11715d..0000000 --- a/src/scan-type-batch-symbolic.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/scanner.vala b/src/scanner.vala index 237e1eb..745b779 100644 --- a/src/scanner.vala +++ b/src/scanner.vala @@ -67,18 +67,24 @@ public enum ScanMode public enum ScanType { SINGLE, - ADF_FRONT, - ADF_BACK, - ADF_BOTH, + ADF, BATCH } +public enum ScanSide +{ + FRONT, + BACK, + BOTH +} + public class ScanOptions : Object { public int dpi; public ScanMode scan_mode; public int depth; public ScanType type; + public ScanSide side; public int paper_width; public int paper_height; public int brightness; @@ -94,6 +100,7 @@ private class ScanJob : Object public ScanMode scan_mode; public int depth; public ScanType type; + public ScanSide side; public int page_width; public int page_height; public int brightness; @@ -361,7 +368,12 @@ public class Scanner : Object if (vendor == "Hewlett-Packard") vendor = "HP"; - scan_device.label = "%s %s".printf (vendor, device_list[i].model); + /* Don't repeat vendor name */ + if (device_list[i].model.down().has_prefix (vendor.down())) + scan_device.label = device_list[i].model; + else + scan_device.label = "%s %s".printf (vendor, device_list[i].model); + /* Replace underscores in name */ scan_device.label.replace ("_", " "); @@ -906,6 +918,62 @@ public class Scanner : Object state = ScanState.GET_OPTION; } + private void set_adf (ScanJob job, Sane.OptionDescriptor option, Sane.Int index) + { + string[] adf_sources = + { + "Automatic Document Feeder", + Sane.I18N ("Automatic Document Feeder"), + "ADF", + "Automatic Document Feeder(left aligned)", /* Seen in the proprietary brother3 driver */ + "Automatic Document Feeder(centrally aligned)", /* Seen in the proprietary brother3 driver */ + "ADF Simplex" /* Samsung unified driver. LP: # 892915 */ + }; + + string[] adf_front_sources = + { + "ADF Front", + Sane.I18N ("ADF Front") + }; + + string[] adf_back_sources = + { + "ADF Back", + Sane.I18N ("ADF Back") + }; + + string[] adf_duplex_sources = + { + "ADF Duplex", + "Duplex ADF", /* Brother DS-720, #157 */ + Sane.I18N ("ADF Duplex"), + "ADF Duplex - Long-Edge Binding", /* Samsung unified driver. LP: # 892915 */ + "ADF Duplex - Short-Edge Binding", + "Duplex", /* HP duplex scan support. LP: #1353599 */ + "Automatic Document Feeder(centrally aligned,Duplex)", /* Brother duplex scan support. LP: #1343773 */ + "Automatic Document Feeder(left aligned,Duplex)" + }; + + if (job.side == ScanSide.FRONT) + { + if (!set_constrained_string_option (handle, option, index, adf_front_sources, null)) + if (!set_constrained_string_option (handle, option, index, adf_sources, null)) + warning ("Unable to set front ADF source, please file a bug"); + } + else if (job.side == ScanSide.BACK) + { + if (!set_constrained_string_option (handle, option, index, adf_back_sources, null)) + if (!set_constrained_string_option (handle, option, index, adf_sources, null)) + warning ("Unable to set back ADF source, please file a bug"); + } + else if (job.side == ScanSide.BOTH) + { + if (!set_constrained_string_option (handle, option, index, adf_duplex_sources, null)) + if (!set_constrained_string_option (handle, option, index, adf_sources, null)) + warning ("Unable to set duplex ADF source, please file a bug"); + } + } + private void do_get_option () { var job = (ScanJob) job_queue.data; @@ -938,62 +1006,20 @@ public class Scanner : Object "Document Table" /* Epson scanners, eg. ET-3760 */ }; - string[] adf_sources = - { - "Automatic Document Feeder", - Sane.I18N ("Automatic Document Feeder"), - "ADF", - "Automatic Document Feeder(left aligned)", /* Seen in the proprietary brother3 driver */ - "Automatic Document Feeder(centrally aligned)", /* Seen in the proprietary brother3 driver */ - "ADF Simplex" /* Samsung unified driver. LP: # 892915 */ - }; - - string[] adf_front_sources = - { - "ADF Front", - Sane.I18N ("ADF Front") - }; - - string[] adf_back_sources = - { - "ADF Back", - Sane.I18N ("ADF Back") - }; - - string[] adf_duplex_sources = - { - "ADF Duplex", - "Duplex ADF", /* Brother DS-720, #157 */ - Sane.I18N ("ADF Duplex"), - "ADF Duplex - Long-Edge Binding", /* Samsung unified driver. LP: # 892915 */ - "ADF Duplex - Short-Edge Binding", - "Duplex", /* HP duplex scan support. LP: #1353599 */ - "Automatic Document Feeder(centrally aligned,Duplex)", /* Brother duplex scan support. LP: #1343773 */ - "Automatic Document Feeder(left aligned,Duplex)" - }; - switch (job.type) { case ScanType.SINGLE: case ScanType.BATCH: if (!set_default_option (handle, option, index)) if (!set_constrained_string_option (handle, option, index, flatbed_sources, null)) - warning ("Unable to set single page source, please file a bug"); - break; - case ScanType.ADF_FRONT: - if (!set_constrained_string_option (handle, option, index, adf_front_sources, null)) - if (!set_constrained_string_option (handle, option, index, adf_sources, null)) - warning ("Unable to set front ADF source, please file a bug"); - break; - case ScanType.ADF_BACK: - if (!set_constrained_string_option (handle, option, index, adf_back_sources, null)) - if (!set_constrained_string_option (handle, option, index, adf_sources, null)) - warning ("Unable to set back ADF source, please file a bug"); + { + warning ("Unable to set single page source, trying to set ADF instead"); + warning ("If Flatbed is existing and it is not set, please file a bug"); + set_adf (job, option, index); + } break; - case ScanType.ADF_BOTH: - if (!set_constrained_string_option (handle, option, index, adf_duplex_sources, null)) - if (!set_constrained_string_option (handle, option, index, adf_sources, null)) - warning ("Unable to set duplex ADF source, please file a bug"); + case ScanType.ADF: + set_adf (job, option, index); break; } } @@ -1071,7 +1097,7 @@ public class Scanner : Object if (option != null) { if (option.type == Sane.ValueType.BOOL) - set_bool_option (handle, option, index, job.type == ScanType.ADF_BOTH, null); + set_bool_option (handle, option, index, job.side == ScanSide.BOTH, null); } /* Non-standard Epson GT-S50 ADF options */ @@ -1086,7 +1112,7 @@ public class Scanner : Object { "Duplex" }; - if (job.type == ScanType.ADF_BOTH) + if (job.side == ScanSide.BOTH) set_constrained_string_option (handle, option, index, adf_duplex_modes, null); else set_constrained_string_option (handle, option, index, adf_simplex_modes, null); @@ -1107,7 +1133,15 @@ public class Scanner : Object } /* Set resolution and bit depth */ - option = get_option_by_name (handle, Sane.NAME_SCAN_RESOLUTION, out index); + /* Epson may have separate resolution settings for x and y axes, which is preferable options to set */ + option = get_option_by_name (handle, Sane.NAME_SCAN_X_RESOLUTION, out index); + if (option != null && (0 != (option.cap & Sane.Capability.SOFT_SELECT))) // L4160 has non-selectable separate options + { + set_fixed_or_int_option (handle, option, index, job.dpi, out job.dpi); + option = get_option_by_name (handle, Sane.NAME_SCAN_Y_RESOLUTION, out index); + } + else + option = get_option_by_name (handle, Sane.NAME_SCAN_RESOLUTION, out index); if (option == null) /* #161 Lexmark CX310dn Duplex */ option = get_option_by_name (handle, "scan-resolution", out index); if (option != null) @@ -1655,12 +1689,8 @@ public class Scanner : Object return "single"; case ScanType.BATCH: return "batch"; - case ScanType.ADF_FRONT: - return "adf-front"; - case ScanType.ADF_BACK: - return "adf-back"; - case ScanType.ADF_BOTH: - return "adf-both"; + case ScanType.ADF: + return "adf"; default: return "%d".printf (type); } @@ -1674,23 +1704,51 @@ public class Scanner : Object return ScanType.SINGLE; case "batch": return ScanType.BATCH; - case "adf-front": - return ScanType.ADF_FRONT; - case "adf-back": - return ScanType.ADF_BACK; - case "adf-both": - return ScanType.ADF_BOTH; + case "adf": + return ScanType.ADF; default: warning ("Unknown ScanType: %s. Please report this error.", type); return ScanType.SINGLE; } } + public static string side_to_string (ScanSide side) + { + switch (side) + { + case ScanSide.FRONT: + return "front"; + case ScanSide.BACK: + return "back"; + case ScanSide.BOTH: + return "both"; + default: + return "%d".printf (side); + } + } + + public static ScanSide side_from_string (string side) + { + switch (side) + { + case "front": + return ScanSide.FRONT; + case "back": + return ScanSide.BACK; + case "both": + return ScanSide.BOTH; + default: + warning ("Unknown ScanSide: %s. Please report this error.", side); + return ScanSide.FRONT; + } + } + 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, delay=%dms)", + debug ("Scanner.scan (\"%s\", dpi=%d, scan_mode=%s, depth=%d, type=%s, side=%s, paper_width=%d, paper_height=%d, brightness=%d, contrast=%d, delay=%dms)", device != null ? device : "(null)", options.dpi, get_scan_mode_string (options.scan_mode), options.depth, - type_to_string (options.type), options.paper_width, options.paper_height, + type_to_string (options.type), side_to_string (options.side), + options.paper_width, options.paper_height, options.brightness, options.contrast, options.page_delay); var request = new RequestStartScan (); request.job = new ScanJob (); @@ -1700,6 +1758,7 @@ public class Scanner : Object request.job.scan_mode = options.scan_mode; request.job.depth = options.depth; request.job.type = options.type; + request.job.side = options.side; request.job.page_width = options.paper_width; request.job.page_height = options.paper_height; request.job.brightness = options.brightness; diff --git a/src/simple-scan.gresource.xml b/src/simple-scan.gresource.xml deleted file mode 100644 index 2348f75..0000000 --- a/src/simple-scan.gresource.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - app-window.ui - preferences-dialog.ui - authorize-dialog.ui - - - scan-type-adf-symbolic.svg - scan-type-batch-symbolic.svg - - - help-overlay.ui - - diff --git a/src/simple-scan.vala b/src/simple-scan.vala index 84d8a8c..c15a541 100644 --- a/src/simple-scan.vala +++ b/src/simple-scan.vala @@ -50,6 +50,8 @@ public class SimpleScan : Gtk.Application { base.startup (); + Hdy.init (); + app = new AppWindow (); book = app.book; app.start_scan.connect (scan_cb); -- cgit v1.2.3