[simple-scan] Move JPEG compression setting to save dialog and drop in preferences
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Move JPEG compression setting to save dialog and drop in preferences
- Date: Sat, 20 May 2017 01:31:56 +0000 (UTC)
commit 9464a5840138792f7d1d9526039456597371df07
Author: Robert Ancell <robert ancell canonical com>
Date: Sat May 20 13:31:40 2017 +1200
Move JPEG compression setting to save dialog and drop in preferences
help/C/quality.page | 2 +-
src/app-window.vala | 35 ++++++++++++++++++++++++-----------
src/preferences-dialog.ui | 40 ++--------------------------------------
src/preferences-dialog.vala | 24 ------------------------
4 files changed, 27 insertions(+), 74 deletions(-)
---
diff --git a/help/C/quality.page b/help/C/quality.page
index 1075783..53e8d45 100644
--- a/help/C/quality.page
+++ b/help/C/quality.page
@@ -9,7 +9,7 @@
<title>Setting the Image Quality</title>
<p>
- You can adjust the image quality that is used when the scan is converted to a file by changing this
setting in the <guiseq><gui>Document</gui><gui>Preferences</gui></guiseq> menu.
+ You can adjust the image quality that is used when the scan is converted to a file by changing this
setting in the save dialog.
Using a low quality will result in a small file size but may show some blurring or blockiness in the
image.
A high quality will keep all the scanned information but require a larger file size.
See the <link href="https://en.wikipedia.org/wiki/Lossy_compression">Lossy compression Wikipedia
page</link> for more information.
diff --git a/src/app-window.vala b/src/app-window.vala
index ccb0e57..ee6f4c5 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -184,12 +184,6 @@ public class AppWindow : Gtk.ApplicationWindow
set { preferences_dialog.set_contrast (value); }
}
- public int quality
- {
- get { return preferences_dialog.get_quality (); }
- set { preferences_dialog.set_quality (value); }
- }
-
public int page_delay
{
get { return preferences_dialog.get_page_delay (); }
@@ -402,6 +396,23 @@ public class AppWindow : Gtk.ApplicationWindow
var renderer = new Gtk.CellRendererText ();
file_type_combo.pack_start (renderer, true);
file_type_combo.add_attribute (renderer, "text", 0);
+ box.pack_start (file_type_combo, false, true, 0);
+
+ /* Label in save dialog beside compression slider */
+ var quality_label = new Gtk.Label (_("Compression:"));
+ box.pack_start (quality_label, false, false, 0);
+
+ var quality_adjustment = new Gtk.Adjustment (75, 0, 100, 1, 10, 0);
+ var quality_scale = new Gtk.Scale (Gtk.Orientation.HORIZONTAL, quality_adjustment);
+ quality_scale.width_request = 200;
+ quality_scale.draw_value = false;
+ quality_scale.add_mark (0, Gtk.PositionType.BOTTOM, null);
+ quality_scale.add_mark (75, Gtk.PositionType.BOTTOM, null);
+ quality_scale.add_mark (90, Gtk.PositionType.BOTTOM, null);
+ quality_scale.add_mark (100, Gtk.PositionType.BOTTOM, null);
+ quality_adjustment.value = settings.get_int ("jpeg-quality");
+ quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", (int)
quality_adjustment.value); });
+ box.pack_start (quality_scale, false, false, 0);
file_type_combo.set_active (0);
file_type_combo.changed.connect (() =>
@@ -420,8 +431,10 @@ public class AppWindow : Gtk.ApplicationWindow
filename = filename.slice (0, extension_index);
filename = filename + extension;
save_dialog.set_current_name (filename);
+
+ /* Quality only applicable for JPEG */
+ quality_scale.visible = quality_label.visible = extension == ".jpg";
});
- box.pack_start (file_type_combo, false, false, 0);
string? uri = null;
while (true)
@@ -516,7 +529,7 @@ public class AppWindow : Gtk.ApplicationWindow
show_progress_dialog ();
try
{
- book.save (format, quality, file);
+ book.save (format, settings.get_int ("jpeg-quality"), file);
}
catch (Error e)
{
@@ -776,7 +789,7 @@ public class AppWindow : Gtk.ApplicationWindow
try
{
- page.save ("png", quality, file);
+ page.save ("png", 0, file);
}
catch (Error e)
{
@@ -1202,7 +1215,7 @@ public class AppWindow : Gtk.ApplicationWindow
show_progress_dialog ();
try
{
- book.save ("pdf", quality, file);
+ book.save ("pdf", 0, file);
}
catch (Error e)
{
@@ -1227,7 +1240,7 @@ public class AppWindow : Gtk.ApplicationWindow
var file = File.new_for_path (path);
try
{
- book.get_page (i).save ("jpeg", quality, file);
+ book.get_page (i).save ("jpeg", settings.get_int ("jpeg-quality"), file);
}
catch (Error e)
{
diff --git a/src/preferences-dialog.ui b/src/preferences-dialog.ui
index 263ddb6..a84a73e 100644
--- a/src/preferences-dialog.ui
+++ b/src/preferences-dialog.ui
@@ -45,11 +45,6 @@
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkAdjustment" id="quality_adjustment">
- <property name="upper">100</property>
- <property name="step_increment">1</property>
- <property name="page_increment">10</property>
- </object>
<object class="GtkListStore" id="text_dpi_model">
<columns>
<!-- column-name dpi -->
@@ -362,23 +357,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="quality_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes" comments="Label beside quality
scale">Quality</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">quality_scale</property>
- <property name="xalign">1</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="page_delay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -392,7 +370,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
@@ -422,19 +400,6 @@
</packing>
</child>
<child>
- <object class="GtkScale" id="quality_scale">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="adjustment">quality_adjustment</property>
- <property name="draw_value">False</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- </packing>
- </child>
- <child>
<object class="GtkScale" id="page_delay_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -443,7 +408,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">2</property>
</packing>
</child>
</object>
@@ -475,7 +440,6 @@
<widget name="photo_dpi_label"/>
<widget name="brightness_label"/>
<widget name="contrast_label"/>
- <widget name="quality_label"/>
<widget name="page_delay_label"/>
</widgets>
</object>
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 5a61bbe..f7e6b91 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -31,8 +31,6 @@ private class PreferencesDialog : Gtk.Dialog
[GtkChild]
private Gtk.Scale contrast_scale;
[GtkChild]
- private Gtk.Scale quality_scale;
- [GtkChild]
private Gtk.Scale page_delay_scale;
[GtkChild]
private Gtk.ListStore device_model;
@@ -53,8 +51,6 @@ private class PreferencesDialog : Gtk.Dialog
[GtkChild]
private Gtk.Adjustment contrast_adjustment;
[GtkChild]
- private Gtk.Adjustment quality_adjustment;
- [GtkChild]
private Gtk.Adjustment page_delay_adjustment;
[GtkChild]
private Gtk.Button preferences_close_button;
@@ -139,16 +135,6 @@ private class PreferencesDialog : Gtk.Dialog
contrast_adjustment.value = settings.get_int ("contrast");
contrast_adjustment.value_changed.connect (() => { settings.set_int ("contrast", get_contrast ());
});
- lower = quality_adjustment.lower;
- var minimum_label = "<small>%s</small>".printf (_("Minimum"));
- upper = quality_adjustment.upper;
- var maximum_label = "<small>%s</small>".printf (_("Maximum"));
- quality_scale.add_mark (lower, Gtk.PositionType.BOTTOM, minimum_label);
- quality_scale.add_mark (75, Gtk.PositionType.BOTTOM, null);
- quality_scale.add_mark (upper, Gtk.PositionType.BOTTOM, maximum_label);
- quality_adjustment.value = settings.get_int ("jpeg-quality");
- quality_adjustment.value_changed.connect (() => { settings.set_int ("jpeg-quality", get_quality ());
});
-
var paper_width = settings.get_int ("paper-width");
var paper_height = settings.get_int ("paper-height");
set_paper_size (paper_width, paper_height);
@@ -407,16 +393,6 @@ private class PreferencesDialog : Gtk.Dialog
contrast_adjustment.value = contrast;
}
- public int get_quality ()
- {
- return (int) quality_adjustment.value;
- }
-
- public void set_quality (int quality)
- {
- quality_adjustment.value = quality;
- }
-
public int get_page_delay ()
{
return (int) page_delay_adjustment.value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]