summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-09-04 20:33:17 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-09-04 20:33:17 +0200
commit46c7d1c8d370e549c23ad8425c2a0ab516f5d787 (patch)
treed2aafe2273d9c6c67d9138f5fb63bd53d125a21d /src
parent92a79aacbf96307f4d31f0034f5058415cc34c5c (diff)
parente2ede7c4bc7accffd3d1526bf98121654e24bbae (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src')
-rw-r--r--src/app-window.ui11
-rw-r--r--src/app-window.vala53
-rw-r--r--src/book-view.vala4
-rw-r--r--src/page.vala8
-rw-r--r--src/preferences-dialog.vala2
-rw-r--r--src/scanner.vala7
-rw-r--r--src/simple-scan.vala15
7 files changed, 62 insertions, 38 deletions
diff --git a/src/app-window.ui b/src/app-window.ui
index bbdf1c7..6e13088 100644
--- a/src/app-window.ui
+++ b/src/app-window.ui
@@ -391,6 +391,17 @@
</object>
</child>
<child>
+ <object class="GtkRadioMenuItem" id="a3_menuitem">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" comments="Radio button for cropping page to A3">A_3</property>
+ <property name="use_underline">True</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">no_crop_menuitem</property>
+ <signal name="toggled" handler="a3_menuitem_toggled_cb" swapped="no"/>
+ </object>
+ </child>
+ <child>
<object class="GtkRadioMenuItem" id="custom_crop_menuitem">
<property name="visible">True</property>
<property name="can_focus">False</property>
diff --git a/src/app-window.vala b/src/app-window.vala
index 1475e0a..153b975 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -52,6 +52,8 @@ public class AppWindow : Gtk.ApplicationWindow
[GtkChild]
private Gtk.RadioMenuItem custom_crop_menuitem;
[GtkChild]
+ private Gtk.RadioMenuItem a3_menuitem;
+ [GtkChild]
private Gtk.RadioMenuItem a4_menuitem;
[GtkChild]
private Gtk.RadioMenuItem a5_menuitem;
@@ -762,7 +764,9 @@ public class AppWindow : Gtk.ApplicationWindow
var crop_name = page.crop_name;
if (crop_name != null)
{
- if (crop_name == "A4")
+ if (crop_name == "A3")
+ menuitem = a3_menuitem;
+ else if (crop_name == "A4")
menuitem = a4_menuitem;
else if (crop_name == "A5")
menuitem = a5_menuitem;
@@ -814,9 +818,9 @@ public class AppWindow : Gtk.ApplicationWindow
}
}
- private void show_page_menu_cb (BookView view)
+ private void show_page_menu_cb (BookView view, Gdk.Event event)
{
- page_menu.popup (null, null, null, 3, Gtk.get_current_event_time ());
+ page_menu.popup_at_pointer (event);
}
[GtkCallback]
@@ -925,6 +929,13 @@ public class AppWindow : Gtk.ApplicationWindow
}
[GtkCallback]
+ private void a3_menuitem_toggled_cb (Gtk.CheckMenuItem widget)
+ {
+ if (widget.active)
+ set_crop ("A3");
+ }
+
+ [GtkCallback]
private void crop_rotate_menuitem_activate_cb (Gtk.Widget widget)
{
var page = book_view.selected_page;
@@ -1068,7 +1079,7 @@ public class AppWindow : Gtk.ApplicationWindow
{
if (items[i] == '-')
{
- var a = new Gtk.Arrow (Gtk.ArrowType.RIGHT, Gtk.ShadowType.NONE);
+ var a = new Gtk.Label ("➤");
a.visible = true;
box.pack_start (a, false, false, 0);
page_box = null;
@@ -1561,34 +1572,24 @@ public class AppWindow : Gtk.ApplicationWindow
app.add_action_entries (action_entries, this);
- var appmenu = new Menu ();
-
- var section = new Menu ();
- appmenu.append_section (null, section);
- section.append (_("Preferences"), "app.preferences");
-
- section = new Menu ();
- appmenu.append_section (null, section);
- section.append (_("Keyboard Shortcuts"), "win.show-help-overlay");
- section.append (_("Help"), "app.help");
- section.append (_("About"), "app.about");
- section.append (_("Quit"), "app.quit");
-
- app.app_menu = appmenu;
-
- app.add_accelerator ("<Ctrl>N", "app.new_document", null);
- app.add_accelerator ("<Ctrl>S", "app.save", null);
- app.add_accelerator ("<Ctrl>E", "app.email", null);
- app.add_accelerator ("<Ctrl>P", "app.print", null);
- app.add_accelerator ("F1", "app.help", null);
- app.add_accelerator ("<Ctrl>Q", "app.quit", null);
+ app.set_accels_for_action ("app.new_document", { "<Ctrl>N" });
+ app.set_accels_for_action ("app.save", { "<Ctrl>S" });
+ app.set_accels_for_action ("app.email", { "<Ctrl>E" });
+ app.set_accels_for_action ("app.print", { "<Ctrl>P" });
+ app.set_accels_for_action ("app.help", { "F1" });
+ app.set_accels_for_action ("app.quit", { "<Ctrl>Q" });
var gear_menu = new Menu ();
- section = new Menu ();
+ var section = new Menu ();
gear_menu.append_section (null, section);
section.append (_("Email"), "app.email");
section.append (_("Reorder Pages"), "app.reorder");
+ 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"), "app.about");
menu_button.set_menu_model (gear_menu);
}
app.add_window (this);
diff --git a/src/book-view.vala b/src/book-view.vala
index 9a9c9bb..3ffcdf8 100644
--- a/src/book-view.vala
+++ b/src/book-view.vala
@@ -57,7 +57,7 @@ public class BookView : Gtk.Box
public signal void page_selected (Page? page);
public signal void show_page (Page page);
- public signal void show_menu ();
+ public signal void show_menu (Gdk.Event event);
public int x_offset
{
@@ -515,7 +515,7 @@ public class BookView : Gtk.Box
/* Show pop-up menu on right click */
if (event.button == 3)
- show_menu ();
+ show_menu (event);
return false;
}
diff --git a/src/page.vala b/src/page.vala
index 582aef8..13de4d2 100644
--- a/src/page.vala
+++ b/src/page.vala
@@ -86,7 +86,7 @@ public class Page
public bool is_color { get { return n_channels > 1; } }
/* Rotation of scanned data */
- private ScanDirection scan_direction_;
+ private ScanDirection scan_direction_ = ScanDirection.TOP_TO_BOTTOM;
public ScanDirection scan_direction
{
get { return scan_direction_; }
@@ -142,8 +142,6 @@ public class Page
if (has_crop)
crop_changed ();
}
-
- default = ScanDirection.TOP_TO_BOTTOM;
}
/* True if the page has a crop set */
@@ -401,6 +399,10 @@ public class Page
double w, h;
switch (name)
{
+ case "A3":
+ w = 11.7;
+ h = 16.5;
+ break;
case "A4":
w = 8.3;
h = 11.7;
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 962fa79..d58c066 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -82,6 +82,8 @@ private class PreferencesDialog : Gtk.Dialog
paper_size_model.append (out iter);
paper_size_model.set (iter, 0, 2100, 1, 2970, 2, "A4", -1);
paper_size_model.append (out iter);
+ paper_size_model.set (iter, 0, 2970, 1, 4200, 2, "A3", -1);
+ paper_size_model.append (out iter);
paper_size_model.set (iter, 0, 2159, 1, 2794, 2, "Letter", -1);
paper_size_model.append (out iter);
paper_size_model.set (iter, 0, 2159, 1, 3556, 2, "Legal", -1);
diff --git a/src/scanner.vala b/src/scanner.vala
index cd7c300..58141b8 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -1331,6 +1331,13 @@ public class Scanner
return;
}
+ /* Some ADF scanners only return NO_DOCS after a read */
+ if (status == Sane.Status.NO_DOCS)
+ {
+ do_complete_document ();
+ return;
+ }
+
/* Communication error */
if (status != Sane.Status.GOOD)
{
diff --git a/src/simple-scan.vala b/src/simple-scan.vala
index d029cd7..d30aa45 100644
--- a/src/simple-scan.vala
+++ b/src/simple-scan.vala
@@ -35,6 +35,7 @@ public class SimpleScan : Gtk.Application
private AppWindow app;
private Scanner scanner;
private Book book;
+ private Page scanned_page;
public SimpleScan (ScanDevice? device = null)
{
@@ -350,25 +351,24 @@ public class SimpleScan : Gtk.Application
info.width, info.height, info.depth);
/* Add a new page */
- var page = append_page ();
- page.set_page_info (info);
+ scanned_page = append_page ();
+ scanned_page.set_page_info (info);
/* Get ICC color profile */
/* FIXME: The ICC profile could change */
/* FIXME: Don't do a D-bus call for each page, cache color profiles */
- page.color_profile = get_profile_for_device (info.device);
+ scanned_page.color_profile = get_profile_for_device (info.device);
}
private void scanner_line_cb (Scanner scanner, ScanLine line)
{
- var page = book.get_page ((int) book.n_pages - 1);
- page.parse_scan_line (line);
+ scanned_page.parse_scan_line (line);
}
private void scanner_page_done_cb (Scanner scanner)
{
- var page = book.get_page ((int) book.n_pages - 1);
- page.finish ();
+ scanned_page.finish ();
+ scanned_page = null;
}
private void remove_empty_page ()
@@ -386,6 +386,7 @@ public class SimpleScan : Gtk.Application
private void scanner_failed_cb (Scanner scanner, int error_code, string error_string)
{
remove_empty_page ();
+ scanned_page = null;
if (error_code != Sane.Status.CANCELLED)
{
app.show_error_dialog (/* Title of error dialog when scan failed */