[simple-scan] Replace scan side combo box with radio button as per new design
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Replace scan side combo box with radio button as per new design
- Date: Wed, 17 May 2017 08:52:07 +0000 (UTC)
commit b9885def2760d404d02885c7948ad7ab83699ca9
Author: Robert Ancell <robert ancell canonical com>
Date: Wed May 17 20:51:48 2017 +1200
Replace scan side combo box with radio button as per new design
src/preferences-dialog.ui | 94 +++++++++++++++++++++++++++----------------
src/preferences-dialog.vala | 62 ++++++++++++++---------------
2 files changed, 89 insertions(+), 67 deletions(-)
---
diff --git a/src/preferences-dialog.ui b/src/preferences-dialog.ui
index 5a38f24..7d77775 100644
--- a/src/preferences-dialog.ui
+++ b/src/preferences-dialog.ui
@@ -27,28 +27,6 @@
<property name="step_increment">100</property>
<property name="page_increment">1000</property>
</object>
- <object class="GtkListStore" id="page_side_model">
- <columns>
- <!-- column-name side -->
- <column type="gint"/>
- <!-- column-name label -->
- <column type="gchararray"/>
- </columns>
- <data>
- <row>
- <col id="0">3</col>
- <col id="1" translatable="yes" comments="Combo box label for scanning both sides of a page">Front
and Back</col>
- </row>
- <row>
- <col id="0">1</col>
- <col id="1" translatable="yes" comments="Combo box label for scanning the front side of a
page">Front</col>
- </row>
- <row>
- <col id="0">2</col>
- <col id="1" translatable="yes" comments="Combo box label for scanning the back side of a
page">Back</col>
- </row>
- </data>
- </object>
<object class="GtkListStore" id="paper_size_model">
<columns>
<!-- column-name width -->
@@ -212,7 +190,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Label beside scan side combo box">Scan
Side:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">photo_dpi_combo</property>
+ <property name="mnemonic_widget">scan_side_box</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -221,18 +199,6 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="page_side_combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- <property name="model">page_side_model</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- </packing>
- </child>
- <child>
<object class="GtkLabel" id="paper_size_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -364,6 +330,64 @@
<property name="top_attach">8</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="scan_side_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkRadioButton" id="front_side_button">
+ <property name="label" translatable="yes" comments="Preferences Dialog: Toggle button to
select scanning on front side of a page">Front</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="draw_indicator">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="back_side_button">
+ <property name="label" translatable="yes" comments="Preferences Dialog: Toggle button to
select scanning on the back side of a page">Back</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">front_side_button</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="both_side_button">
+ <property name="label" translatable="yes" comments="Preferences Dialog: Toggle button to
select scanning on both sides of a page">Both</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">front_side_button</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <style>
+ <class name="linked"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 0849583..3878b4b 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -25,8 +25,6 @@ private class PreferencesDialog : Gtk.Dialog
[GtkChild]
private Gtk.ComboBox photo_dpi_combo;
[GtkChild]
- private Gtk.ComboBox page_side_combo;
- [GtkChild]
private Gtk.ComboBox paper_size_combo;
[GtkChild]
private Gtk.Scale brightness_scale;
@@ -43,7 +41,11 @@ private class PreferencesDialog : Gtk.Dialog
[GtkChild]
private Gtk.ListStore photo_dpi_model;
[GtkChild]
- private Gtk.ListStore page_side_model;
+ private Gtk.ToggleButton front_side_button;
+ [GtkChild]
+ private Gtk.ToggleButton back_side_button;
+ [GtkChild]
+ private Gtk.ToggleButton both_side_button;
[GtkChild]
private Gtk.ListStore paper_size_model;
[GtkChild]
@@ -90,9 +92,6 @@ private class PreferencesDialog : Gtk.Dialog
device_combo.pack_start (renderer, true);
device_combo.add_attribute (renderer, "text", 1);
- renderer = new Gtk.CellRendererText ();
- page_side_combo.pack_start (renderer, true);
- page_side_combo.add_attribute (renderer, "text", 1);
var dpi = settings.get_int ("text-dpi");
if (dpi <= 0)
dpi = DEFAULT_TEXT_DPI;
@@ -105,7 +104,9 @@ private class PreferencesDialog : Gtk.Dialog
photo_dpi_combo.changed.connect (() => { settings.set_int ("photo-dpi", get_photo_dpi ()); });
set_page_side ((ScanType) settings.get_enum ("page-side"));
- page_side_combo.changed.connect (() => { settings.set_enum ("page-side", get_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); });
renderer = new Gtk.CellRendererText ();
paper_size_combo.pack_start (renderer, true);
@@ -297,21 +298,29 @@ private class PreferencesDialog : Gtk.Dialog
private void set_page_side (ScanType page_side)
{
- Gtk.TreeIter iter;
-
- if (page_side_model.get_iter_first (out iter))
+ switch (page_side)
{
- do
- {
- int s;
- page_side_model.get (iter, 0, out s, -1);
- if (s == page_side)
- {
- page_side_combo.set_active_iter (iter);
- return;
- }
- } while (page_side_model.iter_next (ref iter));
- }
+ case ScanType.ADF_FRONT:
+ front_side_button.active = true;
+ break;
+ case ScanType.ADF_BACK:
+ back_side_button.active = true;
+ break;
+ default:
+ case ScanType.ADF_BOTH:
+ both_side_button.active = true;
+ break;
+ }
+ }
+
+ public ScanType get_page_side ()
+ {
+ if (front_side_button.active)
+ return ScanType.ADF_FRONT;
+ else if (back_side_button.active)
+ return ScanType.ADF_BACK;
+ else
+ return ScanType.ADF_BOTH;
}
public void set_paper_size (int width, int height)
@@ -357,17 +366,6 @@ private class PreferencesDialog : Gtk.Dialog
return dpi;
}
- public ScanType get_page_side ()
- {
- Gtk.TreeIter iter;
- int page_side = ScanType.ADF_BOTH;
-
- if (page_side_combo.get_active_iter (out iter))
- page_side_model.get (iter, 0, out page_side, -1);
-
- return (ScanType) page_side;
- }
-
public bool get_paper_size (out int width, out int height)
{
Gtk.TreeIter iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]