[simple-scan] Layout preferences dialog closer to new design



commit 434eb91547dbc8ffecea13f4ca669cc051f16f02
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed May 17 21:32:37 2017 +1200

    Layout preferences dialog closer to new design

 src/app-window.vala         |    6 +-
 src/preferences-dialog.ui   |  544 +++++++++++++++++++++++-------------------
 src/preferences-dialog.vala |    9 +-
 3 files changed, 310 insertions(+), 249 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 2256dc3..031c2fd 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -1621,7 +1621,9 @@ public class AppWindow : Gtk.ApplicationWindow
 
     private void load ()
     {
-        preferences_dialog = new PreferencesDialog (settings);
+        var use_header_bar = !is_traditional_desktop ();
+
+        preferences_dialog = new PreferencesDialog (settings, use_header_bar);
         preferences_dialog.delete_event.connect (() => { return true; });
         preferences_dialog.response.connect (() => { preferences_dialog.visible = false; });
 
@@ -1631,7 +1633,7 @@ public class AppWindow : Gtk.ApplicationWindow
 
         var app = Application.get_default () as Gtk.Application;
 
-        if (is_traditional_desktop ())
+        if (!use_header_bar)
         {
             set_titlebar (null);
             menubar.visible = true;
diff --git a/src/preferences-dialog.ui b/src/preferences-dialog.ui
index 7d77775..9e8842f 100644
--- a/src/preferences-dialog.ui
+++ b/src/preferences-dialog.ui
@@ -60,7 +60,7 @@
   </object>
   <template class="PreferencesDialog" parent="GtkDialog">
     <property name="can_focus">False</property>
-    <property name="border_width">7</property>
+    <property name="border_width">30</property>
     <property name="title" translatable="yes" comments="Title of preferences dialog">Preferences</property>
     <property name="resizable">False</property>
     <property name="icon_name">scanner</property>
@@ -75,6 +75,7 @@
           <object class="GtkButtonBox" id="dialog-action_area2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="margin_top">30</property>
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="preferences_close_button">
@@ -99,293 +100,331 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid3">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="border_width">5</property>
-            <property name="row_spacing">6</property>
-            <property name="column_spacing">6</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">30</property>
             <child>
-              <object class="GtkLabel" id="source_label">
+              <object class="GtkGrid" id="grid3">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside scan source combo box">Scan 
S_ource:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">device_combo</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="device_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="model">device_model</property>
-                <signal name="changed" handler="device_combo_changed_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="text_dpi_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside scan source combo 
box">_Text Resolution:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">text_dpi_combo</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="photo_dpi_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside scan source combo 
box">_Photo Resolution:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">photo_dpi_combo</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="text_dpi_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="model">text_dpi_model</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="photo_dpi_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="model">photo_dpi_model</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="page_side_label">
-                <property name="visible">True</property>
-                <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">scan_side_box</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</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>
-                <property name="label" translatable="yes" comments="Label beside page size combo box">Page 
Size:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">photo_dpi_combo</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkComboBox" id="paper_size_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="model">paper_size_model</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="brightness_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside brightness 
scale">Brightness:</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScale" id="brightness_scale">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="adjustment">brightness_adjustment</property>
-                <property name="draw_value">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="contrast_label">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside contrast 
scale">Contrast:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">contrast_scale</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">6</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScale" id="contrast_scale">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="adjustment">contrast_adjustment</property>
-                <property name="draw_value">False</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">6</property>
-              </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">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">7</property>
-              </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>
+                <property name="border_width">5</property>
+                <property name="row_spacing">10</property>
+                <property name="column_spacing">10</property>
+                <child>
+                  <object class="GtkLabel" id="source_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside scan source combo 
box">Scan S_ource:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">device_combo</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="device_combo">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="model">device_model</property>
+                    <signal name="changed" handler="device_combo_changed_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="page_side_label">
+                    <property name="visible">True</property>
+                    <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">scan_side_box</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="paper_size_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside page size combo 
box">Page Size:</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="paper_size_combo">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="model">paper_size_model</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">2</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">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">7</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="page_delay_label">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes" comments="Label beside page delay scale">Delay 
between pages:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">page_delay_scale</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">8</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkScale" id="page_delay_scale">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="adjustment">page_delay_adjustment</property>
+                <property name="row_spacing">10</property>
+                <property name="column_spacing">10</property>
+                <child>
+                  <object class="GtkLabel" id="text_dpi_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside scan source combo 
box">_Text Resolution:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">text_dpi_combo</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="photo_dpi_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside scan source combo 
box">_Photo Resolution:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">photo_dpi_combo</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="text_dpi_combo">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="model">text_dpi_model</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="photo_dpi_combo">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="model">photo_dpi_model</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">8</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="scan_side_box">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="homogeneous">True</property>
+                <property name="row_spacing">10</property>
+                <property name="column_spacing">10</property>
+                <child>
+                  <object class="GtkLabel" id="brightness_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside brightness 
scale">Brightness:</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="contrast_label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes" comments="Label beside contrast 
scale">Contrast:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">contrast_scale</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
                 <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>
+                  <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">0</property>
+                  </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>
+                    <property name="label" translatable="yes" comments="Label beside page delay scale">Delay 
between pages:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">page_delay_scale</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScale" id="brightness_scale">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="adjustment">brightness_adjustment</property>
+                    <property name="draw_value">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScale" id="contrast_scale">
                     <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="hexpand">True</property>
+                    <property name="adjustment">contrast_adjustment</property>
+                    <property name="draw_value">False</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</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>
+                  <object class="GtkScale" id="quality_scale">
                     <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>
+                    <property name="hexpand">True</property>
+                    <property name="adjustment">quality_adjustment</property>
+                    <property name="draw_value">False</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">2</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>
+                  <object class="GtkScale" id="page_delay_scale">
                     <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>
+                    <property name="hexpand">True</property>
+                    <property name="adjustment">page_delay_adjustment</property>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">3</property>
                   </packing>
                 </child>
-                <style>
-                  <class name="linked"/>
-                </style>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">3</property>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -401,4 +440,17 @@
       <action-widget response="1">preferences_close_button</action-widget>
     </action-widgets>
   </template>
+  <object class="GtkSizeGroup">
+    <widgets>
+      <widget name="source_label"/>
+      <widget name="page_side_label"/>
+      <widget name="paper_size_label"/>
+      <widget name="text_dpi_label"/>
+      <widget name="photo_dpi_label"/>
+      <widget name="brightness_label"/>
+      <widget name="contrast_label"/>
+      <widget name="quality_label"/>
+      <widget name="page_delay_label"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 3878b4b..5a61bbe 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -56,9 +56,16 @@ private class PreferencesDialog : Gtk.Dialog
     private Gtk.Adjustment quality_adjustment;
     [GtkChild]
     private Gtk.Adjustment page_delay_adjustment;
+    [GtkChild]
+    private Gtk.Button preferences_close_button;
 
-    public PreferencesDialog (Settings settings)
+    public PreferencesDialog (Settings settings, bool use_header_bar)
     {
+        Object (use_header_bar: use_header_bar ? 1 : -1);
+
+        if (use_header_bar)
+            preferences_close_button.visible = false;
+
         this.settings = settings;
 
         Gtk.TreeIter iter;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]