[shotwell/wip/gtk4: 82/94] Fix printing dialog




commit 580a4f43cecaff9558184965e13e5535ef096a0d
Author: Jens Georg <mail jensge org>
Date:   Wed Apr 20 15:42:47 2022 +0200

    Fix printing dialog

 data/ui/printing_widget.ui      | 261 ++++++++++------------------------------
 src/Printing.vala               |  54 ++++-----
 src/dialogs/ProgressDialog.vala |  14 +--
 3 files changed, 94 insertions(+), 235 deletions(-)
---
diff --git a/data/ui/printing_widget.ui b/data/ui/printing_widget.ui
index 401156da..d05754dd 100644
--- a/data/ui/printing_widget.ui
+++ b/data/ui/printing_widget.ui
@@ -1,339 +1,208 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
 <interface domain="shotwell">
-  <requires lib="gtk+" version="3.18"/>
+  <requires lib="gtk" version="4.0"/>
   <template class="CustomPrintTab" parent="GtkBox">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="margin_left">12</property>
-    <property name="margin_right">12</property>
+    <property name="margin-start">12</property>
+    <property name="margin-end">12</property>
     <property name="margin_top">12</property>
     <property name="margin_bottom">12</property>
     <property name="orientation">vertical</property>
     <child>
       <object class="GtkLabel" id="lbl_PrintedImageSize">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="halign">start</property>
         <property name="label" translatable="yes">&lt;b&gt;Printed Image Size&lt;/b&gt;</property>
-        <property name="use_markup">True</property>
+        <property name="use_markup">1</property>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">0</property>
-      </packing>
     </child>
     <child>
       <object class="GtkGrid" id="box2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_left">12</property>
+        <property name="margin-start">12</property>
         <property name="margin_top">2</property>
         <property name="row_spacing">6</property>
         <property name="column_spacing">6</property>
-        <property name="row_homogeneous">True</property>
+        <property name="row_homogeneous">1</property>
         <child>
-          <object class="GtkToggleButton" id="standard_size_radio">
+          <object class="GtkCheckButton" id="standard_size_radio">
             <property name="label" translatable="yes">Use a _standard size:</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
+            <property name="focusable">1</property>
             <property name="halign">start</property>
-            <property name="use_underline">True</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="use_underline">1</property>
+            <property name="active">1</property>
             <property name="group">custom_size_radio</property>
+            <layout>
+              <property name="column">0</property>
+              <property name="row">0</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkComboBoxText" id="standard_sizes_combo">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <layout>
+              <property name="column">1</property>
+              <property name="row">0</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">0</property>
-          </packing>
         </child>
         <child>
-          <object class="GtkToggleButton" id="custom_size_radio">
+          <object class="GtkCheckButton" id="custom_size_radio">
             <property name="label" translatable="yes">Use a c_ustom size:</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
+            <property name="focusable">1</property>
             <property name="halign">start</property>
-            <property name="use_underline">True</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="use_underline">1</property>
+            <property name="active">0</property>
+            <layout>
+              <property name="column">0</property>
+              <property name="row">1</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">1</property>
-          </packing>
         </child>
         <child>
           <object class="GtkBox" id="box4">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="spacing">4</property>
             <child>
               <object class="GtkEntry" id="custom_width_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="focusable">1</property>
                 <property name="invisible_char">●</property>
                 <property name="width_chars">10</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
             </child>
             <child>
               <object class="GtkLabel" id="lbl_MultSymbol">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="label">×</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
             </child>
             <child>
               <object class="GtkEntry" id="custom_height_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
+                <property name="focusable">1</property>
                 <property name="invisible_char">●</property>
                 <property name="width_chars">10</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
             </child>
             <child>
               <object class="GtkComboBoxText" id="units_combo">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="active">0</property>
                 <items>
                   <item translatable="yes" comments="Abbrevation for &quot;inch&quot;">in.</item>
                   <item translatable="yes" comments="Abbrevation for &quot;centimeters&quot;">cm</item>
                 </items>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">3</property>
-              </packing>
             </child>
+            <layout>
+              <property name="column">1</property>
+              <property name="row">1</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">1</property>
-          </packing>
         </child>
         <child>
           <object class="GtkCheckButton" id="aspect_ratio_check">
             <property name="label" translatable="yes">_Match photo aspect ratio</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
+            <property name="focusable">1</property>
             <property name="halign">start</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="use_underline">1</property>
+            <layout>
+              <property name="column">1</property>
+              <property name="row">2</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">2</property>
-          </packing>
         </child>
         <child>
-          <object class="GtkToggleButton" id="image_per_page_radio">
+          <object class="GtkCheckButton" id="image_per_page_radio">
             <property name="label" translatable="yes">_Autosize:</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
+            <property name="focusable">1</property>
             <property name="halign">start</property>
-            <property name="use_underline">True</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="use_underline">1</property>
+            <property name="active">0</property>
             <property name="group">custom_size_radio</property>
+            <layout>
+              <property name="column">0</property>
+              <property name="row">3</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">0</property>
-            <property name="top_attach">3</property>
-          </packing>
         </child>
         <child>
           <object class="GtkComboBoxText" id="image_per_page_combo">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <layout>
+              <property name="column">1</property>
+              <property name="row">3</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">1</property>
-            <property name="top_attach">3</property>
-          </packing>
         </child>
         <child>
           <placeholder/>
         </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="padding">6</property>
-        <property name="position">1</property>
-      </packing>
     </child>
     <child>
       <object class="GtkLabel" id="lbl_Titles">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="halign">start</property>
         <property name="label" translatable="yes">&lt;b&gt;Titles&lt;/b&gt;</property>
-        <property name="use_markup">True</property>
+        <property name="use_markup">1</property>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">2</property>
-      </packing>
     </child>
     <child>
       <object class="GtkBox" id="box6">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_left">12</property>
+        <property name="margin-start">12</property>
         <property name="margin_top">2</property>
         <child>
           <object class="GtkCheckButton" id="title_print_check">
             <property name="label" translatable="yes">Print image _title</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
+            <property name="focusable">1</property>
             <property name="halign">start</property>
-            <property name="use_underline">True</property>
-            <property name="draw_indicator">True</property>
+            <property name="use_underline">1</property>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkFontButton" id="title_print_font">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="margin_left">49</property>
+            <property name="focusable">1</property>
+            <property name="receives_default">1</property>
+            <property name="margin-start">49</property>
             <property name="font">Sans 12</property>
-            <property name="preview_text"/>
-            <property name="show_preview_entry">False</property>
+            <property name="preview_text"></property>
+            <property name="show_preview_entry">0</property>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">3</property>
-      </packing>
     </child>
     <child>
       <object class="GtkLabel" id="lbl_PixelResolution">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="halign">start</property>
         <property name="margin_top">12</property>
         <property name="label" translatable="yes">&lt;b&gt;Pixel Resolution&lt;/b&gt;</property>
-        <property name="use_markup">True</property>
+        <property name="use_markup">1</property>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">4</property>
-      </packing>
     </child>
     <child>
       <object class="GtkBox" id="box7">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin_left">12</property>
+        <property name="margin-start">12</property>
         <property name="margin_top">2</property>
         <child>
           <object class="GtkLabel" id="lbl_OutputPhotoAt">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="label" translatable="yes">_Output photo at:</property>
-            <property name="use_underline">True</property>
+            <property name="use_underline">1</property>
             <property name="mnemonic_widget">ppi_entry</property>
             <property name="ellipsize">start</property>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkBox" id="box8">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="margin_left">65</property>
+            <property name="margin-start">65</property>
             <child>
               <object class="GtkEntry" id="ppi_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="margin_right">8</property>
+                <property name="focusable">1</property>
+                <property name="margin-end">8</property>
                 <property name="invisible_char">●</property>
                 <property name="width_chars">13</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
             </child>
             <child>
               <object class="GtkLabel" id="lbl_PixelsPerInch">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="label" translatable="yes">pixels per inch</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">5</property>
-      </packing>
     </child>
   </template>
 </interface>
diff --git a/src/Printing.vala b/src/Printing.vala
index ed4b5a6b..0c7d0b9a 100644
--- a/src/Printing.vala
+++ b/src/Printing.vala
@@ -271,11 +271,11 @@ public class CustomPrintTab : Gtk.Box {
     private const int CENTIMETERS_COMBO_CHOICE = 1;
 
     [GtkChild]
-    private unowned Gtk.ToggleButton standard_size_radio;
+    private unowned Gtk.CheckButton standard_size_radio;
     [GtkChild]
-    private unowned Gtk.ToggleButton custom_size_radio;
+    private unowned Gtk.CheckButton custom_size_radio;
     [GtkChild]
-    private unowned Gtk.ToggleButton image_per_page_radio;
+    private unowned Gtk.CheckButton image_per_page_radio;
     [GtkChild]
     private unowned Gtk.ComboBoxText image_per_page_combo;
     [GtkChild]
@@ -304,9 +304,9 @@ public class CustomPrintTab : Gtk.Box {
     public CustomPrintTab(PrintJob source_job) {
         this.source_job = source_job;
 
-        standard_size_radio.clicked.connect(on_radio_group_click);
-        custom_size_radio.clicked.connect(on_radio_group_click);
-        image_per_page_radio.clicked.connect(on_radio_group_click);
+        standard_size_radio.toggled.connect(on_radio_group_click);
+        custom_size_radio.toggled.connect(on_radio_group_click);
+        image_per_page_radio.toggled.connect(on_radio_group_click);
 
         foreach (PrintLayout layout in PrintLayout.get_all()) {
             image_per_page_combo.append_text(layout.to_string());
@@ -320,17 +320,23 @@ public class CustomPrintTab : Gtk.Box {
 
         standard_sizes_combo.set_active(9 * Resources.get_default_measurement_unit());
 
+        var focus = new Gtk.EventControllerFocus();
+        focus.leave.connect(on_width_entry_focus_out);
+        custom_width_entry.add_controller(focus);
         custom_width_entry.insert_text.connect(on_entry_insert_text);
-        //custom_width_entry.focus_out_event.connect(on_width_entry_focus_out);
 
+        focus = new Gtk.EventControllerFocus();
+        focus.leave.connect(on_height_entry_focus_out);
+        custom_height_entry.add_controller(focus);
         custom_height_entry.insert_text.connect(on_entry_insert_text);
-        //custom_height_entry.focus_out_event.connect(on_height_entry_focus_out);
 
         units_combo.changed.connect(on_units_combo_changed);
         units_combo.set_active(Resources.get_default_measurement_unit());
 
         ppi_entry.insert_text.connect(on_ppi_entry_insert_text);
-        //ppi_entry.focus_out_event.connect(on_ppi_entry_focus_out);
+        focus = new Gtk.EventControllerFocus();
+        focus.leave.connect(on_ppi_entry_focus_out);
+        ppi_entry.add_controller(focus);
 
         sync_state_from_job(source_job);
 
@@ -349,11 +355,10 @@ public class CustomPrintTab : Gtk.Box {
         }
     }
 
-#if 0
-    private bool on_width_entry_focus_out(Gdk.EventFocus event) {
+    private void on_width_entry_focus_out(Gtk.EventControllerFocus event) {
         if (custom_width_entry.get_text() == (format_measurement_as(local_content_width,
             get_user_unit_choice())))
-            return false;
+            return;
 
         Measurement new_width = get_width_entry_value();
         Measurement min_width = source_job.get_local_settings().get_minimum_content_dimension();
@@ -361,7 +366,7 @@ public class CustomPrintTab : Gtk.Box {
 
         if (new_width.is_less_than(min_width) || new_width.is_greater_than(max_width)) {
             custom_width_entry.set_text(format_measurement(local_content_width));
-            return false;
+            return;
         }
 
         if (is_match_aspect_ratio_enabled()) {
@@ -374,9 +379,8 @@ public class CustomPrintTab : Gtk.Box {
 
         local_content_width = new_width;
         custom_width_entry.set_text(format_measurement(new_width));
-        return false;
+        return;
     }
-    #endif
 
     private string format_measurement(Measurement measurement) {
         return "%.2f".printf(measurement.value);
@@ -388,12 +392,9 @@ public class CustomPrintTab : Gtk.Box {
         return format_measurement(converted_measurement);
     }
 
-#if 0
-    private bool on_ppi_entry_focus_out(Gdk.EventFocus event) {
+    private void on_ppi_entry_focus_out(Gtk.EventControllerFocus event) {
         set_content_ppi(int.parse(ppi_entry.get_text()));
-        return false;
     }
-    #endif
 
     private void on_ppi_entry_insert_text(Gtk.Editable editable, string text, int length,
         ref int position) {
@@ -421,11 +422,10 @@ public class CustomPrintTab : Gtk.Box {
         is_text_insertion_in_progress = false;
     }
 
-#if 0
-    private bool on_height_entry_focus_out(Gdk.EventFocus event) {
+    private void on_height_entry_focus_out(Gtk.EventControllerFocus event) {
         if (custom_height_entry.get_text() == (format_measurement_as(local_content_height,
             get_user_unit_choice())))
-            return false;
+            return;
 
         Measurement new_height = get_height_entry_value();
         Measurement min_height = source_job.get_local_settings().get_minimum_content_dimension();
@@ -433,7 +433,7 @@ public class CustomPrintTab : Gtk.Box {
 
         if (new_height.is_less_than(min_height) || new_height.is_greater_than(max_height)) {
             custom_height_entry.set_text(format_measurement(local_content_height));
-            return false;
+            return;
         }
 
         if (is_match_aspect_ratio_enabled()) {
@@ -446,9 +446,7 @@ public class CustomPrintTab : Gtk.Box {
 
         local_content_height = new_height;
         custom_height_entry.set_text(format_measurement(new_height));
-        return false;
     }
-    #endif
 
     private MeasurementUnit get_user_unit_choice() {
         if (units_combo.get_active() == INCHES_COMBO_CHOICE) {
@@ -531,10 +529,7 @@ public class CustomPrintTab : Gtk.Box {
         set_print_titles_font(job.get_local_settings().get_print_titles_font());
     }
 
-    private void on_radio_group_click(Gtk.Button b) {
-    #if 0
-        Gtk.RadioButton sender = (Gtk.RadioButton) b;
-        
+    private void on_radio_group_click(Gtk.CheckButton sender) {
         if (sender == standard_size_radio) {
             set_content_layout_control_state(ContentLayout.STANDARD_SIZE);
             standard_sizes_combo.grab_focus();
@@ -544,7 +539,6 @@ public class CustomPrintTab : Gtk.Box {
         } else if (sender == image_per_page_radio) {
             set_content_layout_control_state(ContentLayout.IMAGE_PER_PAGE);
         }
-        #endif
     }
 
     private void on_units_combo_changed() {
diff --git a/src/dialogs/ProgressDialog.vala b/src/dialogs/ProgressDialog.vala
index f4e2693c..2f65f2cd 100644
--- a/src/dialogs/ProgressDialog.vala
+++ b/src/dialogs/ProgressDialog.vala
@@ -47,7 +47,7 @@ public class ProgressDialog : Gtk.Window {
 
         Gtk.Box vbox = new Gtk.Box(Gtk.Orientation.VERTICAL, 12);
         vbox.prepend(primary_text_label);
-        vbox.prepend(hbox);
+        vbox.append(hbox);
         vbox.halign = Gtk.Align.CENTER;
         vbox.valign = Gtk.Align.CENTER;
         vbox.hexpand = true;
@@ -60,14 +60,10 @@ public class ProgressDialog : Gtk.Window {
         set_child(vbox);
 
         time_started = now_ms();
-    }
-
-    public override void realize() {
-        base.realize();
-
-        // if unable to cancel the progress bar, remove the close button
-        //if (cancellable == null)
-            //get_window().set_functions(Gdk.WMFunction.MOVE);
+        set_titlebar(new Gtk.HeaderBar());
+        if (cancellable == null) {
+            ((Gtk.HeaderBar)get_titlebar()).set_show_title_buttons(false);
+        }
     }
 
     public void update_display_every(int update_every) {


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