[niepce/gtk4: 7/10] gtk4: Fix dialogs




commit 10942eabe168d4b60de8168b64257508b7f98189
Author: Hubert Figuière <hub figuiere net>
Date:   Sun Mar 20 21:42:47 2022 -0400

    gtk4: Fix dialogs
    
    - the editlabel dialog still closes itself
    - the import dialog was still using the old image_grid_view API

 src/fwk/toolkit/dialog.cpp                         |  21 +-
 src/fwk/toolkit/dialog.hpp                         |  11 +-
 src/fwk/toolkit/frame.hpp                          |   7 +
 src/niepce/ui/dialogs/editlabels.cpp               |   5 +-
 src/niepce/ui/dialogs/editlabels.hpp               |  17 +-
 src/niepce/ui/dialogs/editlabels.ui                | 263 +++++++-----------
 src/niepce/ui/dialogs/importdialog.cpp             |  11 +-
 src/niepce/ui/dialogs/importdialog.hpp             |   2 +
 src/niepce/ui/dialogs/importdialog.ui              | 309 ++++-----------------
 .../ui/dialogs/importers/cameraimporterui.ui       |  43 ++-
 .../ui/dialogs/importers/directoryimporterui.ui    |  36 +--
 src/niepce/ui/dialogs/preferences.ui               | 217 +++++----------
 src/niepce/ui/workspacecontroller.cpp              |  73 +++--
 src/niepce/ui/workspacecontroller.hpp              |   5 +-
 14 files changed, 344 insertions(+), 676 deletions(-)
---
diff --git a/src/fwk/toolkit/dialog.cpp b/src/fwk/toolkit/dialog.cpp
index 7d72791..972eac8 100644
--- a/src/fwk/toolkit/dialog.cpp
+++ b/src/fwk/toolkit/dialog.cpp
@@ -22,33 +22,34 @@
 
 #include <gtkmm/box.h>
 #include <gtkmm/label.h>
-#include "dialog.hpp"
 
+#include "dialog.hpp"
+#include "fwk/base/debug.hpp"
 
 namespace fwk {
 
-
-
 void Dialog::add_header(const std::string & label)
 {
     Gtk::Box * vbox = builder()->get_widget<Gtk::Box>("dialog-vbox1");
+    auto header = Gtk::manage(new Gtk::Label());
     auto markup = str(boost::format("<span size=\"x-large\">%1%</span>") % label);
-    auto header = Gtk::manage(new Gtk::Label(markup));
-    vbox->append(*header);
+    header->set_markup(markup);
+    vbox->insert_child_at_start(*header);
 }
 
-int Dialog::run_modal(const Frame::Ptr & parent)
+/** Run the dialog modal. on_ok is called if the dialog response is ok */
+void Dialog::run_modal(const Frame::Ptr& parent, std::function<void(int)> on_ok)
 {
-    int result = 0;
-    if(!m_is_setup) {
+    DBG_OUT("run_modal");
+    if (!m_is_setup) {
         setup_widget();
     }
     gtkDialog().set_transient_for(parent->gtkWindow());
     gtkDialog().set_default_response(Gtk::ResponseType::CLOSE);
     gtkDialog().set_modal();
+    gtkDialog().signal_response().connect(on_ok);
     gtkDialog().show();
-    gtkDialog().hide();
-    return result;
+    DBG_OUT("dialog shown");
 }
 
 Gtk::Widget *Dialog::buildWidget()
diff --git a/src/fwk/toolkit/dialog.hpp b/src/fwk/toolkit/dialog.hpp
index 7c8e1ea..90e340a 100644
--- a/src/fwk/toolkit/dialog.hpp
+++ b/src/fwk/toolkit/dialog.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - fwk/toolkit/dialog.hpp
  *
- * Copyright (C) 2009-2014 Hubert Figuiere
+ * Copyright (C) 2009-2022 Hubert Figuière
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-#ifndef __FWK_DIALOG_H__
-#define __FWK_DIALOG_H__
+#pragma once
 
 #include <gtkmm/dialog.h>
 
@@ -54,8 +52,7 @@ public:
      */
     void add_header(const std::string & label);
 
-    int run_modal();
-    int run_modal(const Frame::Ptr & parent);
+    void run_modal(const Frame::Ptr& parent, std::function<void(int)> on_ok = [](int){});
 protected:
     virtual Gtk::Widget *buildWidget() override;
 
@@ -73,5 +70,3 @@ protected:
   fill-column:80
   End:
 */
-
-#endif
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index 18ff5be..465af55 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -70,6 +70,13 @@ public:
     Glib::RefPtr<Gtk::Builder> & builder()
         { return m_builder; }
 
+    void close()
+        {
+            if (m_window) {
+                m_window->close();
+            }
+        }
+
     /** @param header MUST be managed */
     void setHeaderBar(Gtk::HeaderBar* header)
         {
diff --git a/src/niepce/ui/dialogs/editlabels.cpp b/src/niepce/ui/dialogs/editlabels.cpp
index f7738c9..661a366 100644
--- a/src/niepce/ui/dialogs/editlabels.cpp
+++ b/src/niepce/ui/dialogs/editlabels.cpp
@@ -50,12 +50,12 @@ EditLabels::EditLabels(const LibraryClientPtr & libclient)
 void EditLabels::setup_widget()
 {
     Glib::RefPtr<Gtk::Builder> _builder = builder();
-
+    DBG_OUT("setup Edit Labels dialog");
     add_header(_("Edit Labels"));
 
     const char * colour_fmt = "colorbutton%1%";
     const char * value_fmt = "value%1%";
-    for (size_t i = 0; i < 5; i++) {
+    for (size_t i = 0; i < NUM_LABELS; i++) {
         bool has_label = m_labels.size() > i;
 
         Gtk::ColorButton *colourbutton;
@@ -76,6 +76,7 @@ void EditLabels::setup_widget()
         labelentry->signal_changed().connect(
             sigc::bind(sigc::mem_fun(*this, &EditLabels::label_name_changed), i));
     }
+    DBG_OUT("all colours setup");
     gtkDialog().signal_response().connect(sigc::mem_fun(*this, &EditLabels::update_labels));
 }
 
diff --git a/src/niepce/ui/dialogs/editlabels.hpp b/src/niepce/ui/dialogs/editlabels.hpp
index df1d473..1e3f6c2 100644
--- a/src/niepce/ui/dialogs/editlabels.hpp
+++ b/src/niepce/ui/dialogs/editlabels.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - niepce/ui/dialogs/editlabels.hpp
  *
- * Copyright (C) 2009-2013 Hubert Figuiere
+ * Copyright (C) 2009-2022 Hubert Figuière
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,9 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-#ifndef __UI_EDITLABELS_HPP__
-#define __UI_EDITLABELS_HPP__
+#pragma once
 
 #include <array>
 
@@ -41,20 +39,20 @@ public:
     EditLabels(const libraryclient::LibraryClientPtr &);
 
     virtual void setup_widget() override;
+
+    constexpr static int NUM_LABELS = 5;
 private:
     void label_name_changed(size_t idx);
     void label_colour_changed(size_t idx);
     void update_labels(int /*response*/);
     const eng::LabelList& m_labels;
-    std::array<Gtk::ColorButton*, 5> m_colours;
-    std::array<Gtk::Entry*, 5> m_entries;
-    std::array<bool, 5> m_status;
+    std::array<Gtk::ColorButton*, NUM_LABELS> m_colours;
+    std::array<Gtk::Entry*, NUM_LABELS> m_entries;
+    std::array<bool, NUM_LABELS> m_status;
     libraryclient::LibraryClientPtr m_lib_client;
 };
 
-
 }
-
 /*
   Local Variables:
   mode:c++
@@ -64,4 +62,3 @@ private:
   fill-column:80
   End:
 */
-#endif
diff --git a/src/niepce/ui/dialogs/editlabels.ui b/src/niepce/ui/dialogs/editlabels.ui
index 104758d..ad02e95 100644
--- a/src/niepce/ui/dialogs/editlabels.ui
+++ b/src/niepce/ui/dialogs/editlabels.ui
@@ -1,253 +1,190 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
+  <requires lib="gtk" version="4.0"/>
   <object class="GtkDialog" id="editLabels">
-    <property name="can-focus">False</property>
-    <property name="border-width">5</property>
     <property name="title" translatable="yes">Edit Labels</property>
-    <property name="type-hint">normal</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-            <property name="layout-style">end</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="receives-default">True</property>
-                <property name="use-stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
           <placeholder/>
         </child>
         <child>
           <object class="GtkFrame" id="frame1">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-            <property name="label-xalign">0</property>
-            <property name="shadow-type">none</property>
-            <child>
-              <!-- n-columns=4 n-rows=5 -->
+            <property name="child">
               <object class="GtkGrid" id="table2">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
                 <property name="margin-start">18</property>
                 <property name="margin-end">12</property>
                 <property name="margin-bottom">18</property>
                 <property name="row-spacing">8</property>
                 <property name="column-spacing">8</property>
-                <property name="row-homogeneous">True</property>
+                <property name="row-homogeneous">1</property>
                 <child>
                   <object class="GtkLabel" id="label1">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">Label _6</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-underline">1</property>
                     <property name="mnemonic-widget">value1</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="GtkLabel" id="label2">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">Label _7</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-underline">1</property>
                     <property name="mnemonic-widget">value2</property>
+                    <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="GtkLabel" id="label3">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">Label _8</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-underline">1</property>
                     <property name="mnemonic-widget">value3</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="GtkLabel" id="label4">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">Label _9</property>
-                    <property name="use-markup">True</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-markup">1</property>
+                    <property name="use-underline">1</property>
                     <property name="mnemonic-widget">value4</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>
                   <object class="GtkEntry" id="value1">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="focusable">1</property>
                     <property name="invisible-char">●</property>
+                    <layout>
+                      <property name="column">2</property>
+                      <property name="row">0</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">2</property>
-                    <property name="top-attach">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="value2">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="focusable">1</property>
                     <property name="invisible-char">●</property>
+                    <layout>
+                      <property name="column">2</property>
+                      <property name="row">1</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">2</property>
-                    <property name="top-attach">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="value3">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="focusable">1</property>
                     <property name="invisible-char">●</property>
+                    <layout>
+                      <property name="column">2</property>
+                      <property name="row">2</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">2</property>
-                    <property name="top-attach">2</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="value4">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="focusable">1</property>
                     <property name="invisible-char">●</property>
+                    <layout>
+                      <property name="column">2</property>
+                      <property name="row">3</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">2</property>
-                    <property name="top-attach">3</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label5">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">Label _10</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-underline">1</property>
                     <property name="mnemonic-widget">value5</property>
+                    <layout>
+                      <property name="column">1</property>
+                      <property name="row">4</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">1</property>
-                    <property name="top-attach">4</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkEntry" id="value5">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="focusable">1</property>
                     <property name="invisible-char">•</property>
+                    <layout>
+                      <property name="column">2</property>
+                      <property name="row">4</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">2</property>
-                    <property name="top-attach">4</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkColorButton" id="colorbutton1">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">True</property>
+                    <property name="focusable">1</property>
+                    <property name="receives-default">1</property>
                     <property name="rgba">rgb(204,0,0)</property>
+                    <layout>
+                      <property name="column">3</property>
+                      <property name="row">0</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">3</property>
-                    <property name="top-attach">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkColorButton" id="colorbutton2">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">True</property>
+                    <property name="focusable">1</property>
+                    <property name="receives-default">1</property>
                     <property name="rgba">rgb(245,121,0)</property>
+                    <layout>
+                      <property name="column">3</property>
+                      <property name="row">1</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">3</property>
-                    <property name="top-attach">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkColorButton" id="colorbutton3">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">True</property>
+                    <property name="focusable">1</property>
+                    <property name="receives-default">1</property>
                     <property name="rgba">rgb(237,212,0)</property>
+                    <layout>
+                      <property name="column">3</property>
+                      <property name="row">2</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">3</property>
-                    <property name="top-attach">2</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkColorButton" id="colorbutton4">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">True</property>
+                    <property name="focusable">1</property>
+                    <property name="receives-default">1</property>
                     <property name="rgba">rgb(115,210,22)</property>
+                    <layout>
+                      <property name="column">3</property>
+                      <property name="row">3</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">3</property>
-                    <property name="top-attach">3</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkColorButton" id="colorbutton5">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">True</property>
+                    <property name="focusable">1</property>
+                    <property name="receives-default">1</property>
                     <property name="rgba">rgb(52,101,164)</property>
+                    <layout>
+                      <property name="column">3</property>
+                      <property name="row">4</property>
+                    </layout>
                   </object>
-                  <packing>
-                    <property name="left-attach">3</property>
-                    <property name="top-attach">4</property>
-                  </packing>
                 </child>
                 <child>
                   <placeholder/>
@@ -265,33 +202,41 @@
                   <placeholder/>
                 </child>
               </object>
-            </child>
+            </property>
             <child type="label">
               <object class="GtkLabel" id="dialog_title">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
                 <property name="halign">start</property>
                 <property name="margin-start">12</property>
                 <property name="margin-end">12</property>
                 <property name="margin-top">6</property>
                 <property name="margin-bottom">12</property>
-                <property name="hexpand">True</property>
+                <property name="hexpand">1</property>
                 <property name="label" translatable="yes">&lt;b&gt;Labels&lt;/b&gt;</property>
-                <property name="use-markup">True</property>
+                <property name="use-markup">1</property>
               </object>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">2</property>
-          </packing>
         </child>
       </object>
     </child>
     <action-widgets>
       <action-widget response="0">button1</action-widget>
     </action-widgets>
+    <child internal-child="action_area">
+      <object class="GtkBox" id="dialog-action_area1">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <object class="GtkButton" id="button1">
+            <property name="label">gtk-close</property>
+            <property name="focusable">1</property>
+            <property name="receives-default">1</property>
+          </object>
+        </child>
+      </object>
+    </child>
   </object>
 </interface>
diff --git a/src/niepce/ui/dialogs/importdialog.cpp b/src/niepce/ui/dialogs/importdialog.cpp
index d1c0e42..2c2c1a2 100644
--- a/src/niepce/ui/dialogs/importdialog.cpp
+++ b/src/niepce/ui/dialogs/importdialog.cpp
@@ -17,7 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
 #include <glibmm/miscutils.h>
 #include <gtkmm/button.h>
 #include <gtkmm/checkbutton.h>
@@ -118,9 +117,13 @@ void ImportDialog::setup_widget()
     // Gridview of previews.
     m_images_list_scrolled = a_builder->get_widget<Gtk::ScrolledWindow>("images_list_scrolled");
     m_images_list_model = Gtk::ListStore::create(m_grid_columns);
-    m_gridview = Gtk::manage(
-        Glib::wrap(GTK_ICON_VIEW(ffi::npc_image_grid_view_new(
-                                     GTK_TREE_MODEL(g_object_ref(m_images_list_model->gobj()))))));
+    m_image_gridview = std::shared_ptr<ffi::ImageGridView>(
+        ffi::npc_image_grid_view_new(
+            GTK_TREE_MODEL(g_object_ref(m_images_list_model->gobj()))),
+        ffi::npc_image_grid_view_release);
+    m_gridview = Gtk::manage(Glib::wrap(GTK_ICON_VIEW(
+                                            ffi::npc_image_grid_view_get_icon_view(
+                                                m_image_gridview.get()))));
     m_gridview->set_pixbuf_column(m_grid_columns.pixbuf);
     m_gridview->set_text_column(m_grid_columns.filename);
     m_gridview->set_item_width(100);
diff --git a/src/niepce/ui/dialogs/importdialog.hpp b/src/niepce/ui/dialogs/importdialog.hpp
index b9ee2ec..2be884e 100644
--- a/src/niepce/ui/dialogs/importdialog.hpp
+++ b/src/niepce/ui/dialogs/importdialog.hpp
@@ -30,6 +30,7 @@
 #include "fwk/toolkit/gtkutils.hpp"
 #include "fwk/toolkit/dialog.hpp"
 #include "fwk/toolkit/uiresult.hpp"
+#include "fwk/toolkit/thumbnail.hpp"
 #include "metadatapanecontroller.hpp"
 #include "importers/iimporterui.hpp"
 
@@ -112,6 +113,7 @@ private:
     Glib::RefPtr<Gtk::ListStore> m_images_list_model;
     std::map<std::string, Gtk::TreeModel::iterator> m_images_list_map;
 
+    std::shared_ptr<ffi::ImageGridView> m_image_gridview;
     Gtk::IconView *m_gridview;
 
     MetaDataPaneController::Ptr m_metadata_pane;
diff --git a/src/niepce/ui/dialogs/importdialog.ui b/src/niepce/ui/dialogs/importdialog.ui
index 5d27478..e88ef0d 100644
--- a/src/niepce/ui/dialogs/importdialog.ui
+++ b/src/niepce/ui/dialogs/importdialog.ui
@@ -1,12 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
+  <requires lib="gtk" version="4.0"/>
   <object class="GtkListStore" id="preset_combo_model">
     <columns>
-      <!-- column-name label -->
       <column type="gchararray"/>
-      <!-- column-name id -->
       <column type="gchararray"/>
     </columns>
     <data>
@@ -18,9 +15,7 @@
   </object>
   <object class="GtkListStore" id="tz_combo_model">
     <columns>
-      <!-- column-name label -->
       <column type="gchararray"/>
-      <!-- column-name id -->
       <column type="gchararray"/>
     </columns>
     <data>
@@ -35,71 +30,19 @@
     </data>
   </object>
   <object class="GtkDialog" id="importDialog">
-    <property name="can-focus">False</property>
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-    <property name="border-width">5</property>
     <property name="title" translatable="yes">Import</property>
-    <property name="window-position">center-on-parent</property>
     <property name="default-width">900</property>
     <property name="default-height">700</property>
-    <property name="type-hint">dialog</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
         <property name="orientation">vertical</property>
         <property name="spacing">6</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout-style">end</property>
-            <child>
-              <object class="GtkButton" id="button3">
-                <property name="label">Cancel</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="can-default">True</property>
-                <property name="receives-default">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="button4">
-                <property name="label" translatable="yes">_Import</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="can-default">True</property>
-                <property name="receives-default">True</property>
-                <property name="use-underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
           <placeholder/>
         </child>
         <child>
           <object class="GtkBox" id="box1">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
+            <property name="vexpand">1</property>
             <property name="margin-start">12</property>
             <property name="margin-end">12</property>
             <property name="margin-top">12</property>
@@ -107,130 +50,75 @@
             <property name="spacing">6</property>
             <child>
               <object class="GtkBox" id="source_box">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+                <property name="hexpand">1</property>
                 <property name="margin-end">12</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkComboBoxText" id="import_source_combo">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="active">0</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkStack" id="importer_ui_stack">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <child>
                       <placeholder/>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkLabel" id="label1">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
+                    <property name="valign">center</property>
                     <property name="halign">start</property>
                     <property name="label" translatable="yes">_Images to import</property>
-                    <property name="use-underline">True</property>
+                    <property name="use-underline">1</property>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">2</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkScrolledWindow" id="images_list_scrolled">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
+                    <property name="vexpand">1</property>
+                    <property name="focusable">1</property>
                     <property name="hscrollbar-policy">never</property>
-                    <property name="shadow-type">in</property>
                     <child>
                       <placeholder/>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">3</property>
-                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
             </child>
             <child>
               <object class="GtkBox" id="box3">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
                 <property name="margin-start">12</property>
                 <property name="orientation">vertical</property>
                 <property name="spacing">6</property>
                 <child>
                   <object class="GtkBox" id="hbox2">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkLabel" id="label6">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
+                        <property name="hexpand">1</property>
                         <property name="label" translatable="yes">Destination _Folder</property>
-                        <property name="use-underline">True</property>
+                        <property name="use-underline">1</property>
                       </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                     <child>
                       <placeholder/>
                     </child>
                     <child>
                       <object class="GtkEntry" id="destinationFolder">
-                        <property name="visible">True</property>
-                        <property name="can-focus">True</property>
+                        <property name="hexpand">1</property>
+                        <property name="focusable">1</property>
                         <property name="invisible-char">•</property>
                       </object>
-                      <packing>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                        <property name="position">2</property>
-                      </packing>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkExpander" id="expander1">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="expanded">True</property>
+                    <property name="focusable">1</property>
+                    <property name="expanded">1</property>
                     <child>
                       <object class="GtkBox" id="vbox3">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
                         <property name="margin-start">18</property>
                         <property name="margin-end">6</property>
                         <property name="margin-top">6</property>
@@ -239,64 +127,40 @@
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkCheckButton" id="ufraw_import_check">
+                            <property name="valign">center</property>
                             <property name="label" translatable="yes">Import _UFRaw</property>
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="can-focus">True</property>
-                            <property name="receives-default">False</property>
+                            <property name="sensitive">0</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">False</property>
-                            <property name="position">0</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkCheckButton" id="rawstudio_import_check">
+                            <property name="valign">center</property>
                             <property name="label" translatable="yes">Import Raw_Studio</property>
-                            <property name="visible">True</property>
-                            <property name="sensitive">False</property>
-                            <property name="can-focus">True</property>
-                            <property name="receives-default">False</property>
+                            <property name="sensitive">0</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">False</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                       </object>
                     </child>
                     <child type="label">
                       <object class="GtkLabel" id="label3">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
                         <property name="label" translatable="yes">_Options</property>
-                        <property name="use-underline">True</property>
+                        <property name="use-underline">1</property>
                       </object>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
                 </child>
                 <child>
                   <object class="GtkExpander" id="expander2">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="expanded">True</property>
+                    <property name="focusable">1</property>
+                    <property name="expanded">1</property>
                     <child>
                       <object class="GtkBox" id="box4">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
                         <property name="margin-start">18</property>
                         <property name="margin-end">6</property>
                         <property name="margin-top">6</property>
@@ -305,16 +169,10 @@
                         <property name="spacing">6</property>
                         <child>
                           <object class="GtkFrame" id="preset_frame">
-                            <property name="visible">True</property>
-                            <property name="can-focus">False</property>
                             <property name="margin-top">6</property>
                             <property name="margin-bottom">6</property>
-                            <property name="label-xalign">0</property>
-                            <property name="shadow-type">none</property>
-                            <child>
+                            <property name="child">
                               <object class="GtkComboBox" id="preset_combo">
-                                <property name="visible">True</property>
-                                <property name="can-focus">False</property>
                                 <property name="margin-start">6</property>
                                 <property name="margin-top">6</property>
                                 <property name="model">preset_combo_model</property>
@@ -326,44 +184,28 @@
                                   </attributes>
                                 </child>
                               </object>
-                            </child>
+                            </property>
                             <child type="label">
                               <object class="GtkLabel" id="label8">
-                                <property name="visible">True</property>
-                                <property name="can-focus">False</property>
                                 <property name="label" translatable="yes">Presets:</property>
                                 <attributes>
-                                  <attribute name="weight" value="bold"/>
+                                  <attribute name="weight" value="bold"></attribute>
                                 </attributes>
                               </object>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">0</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkFrame" id="date_frame">
-                            <property name="visible">True</property>
-                            <property name="can-focus">False</property>
-                            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                             <property name="margin-top">6</property>
                             <property name="margin-bottom">6</property>
-                            <property name="label-xalign">0</property>
-                            <property name="shadow-type">none</property>
-                            <child>
+                            <property name="child">
                               <object class="GtkBox" id="vbox1">
-                                <property name="visible">True</property>
-                                <property name="can-focus">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                 <property name="orientation">vertical</property>
                                 <property name="spacing">4</property>
                                 <child>
                                   <object class="GtkComboBox" id="date_tz_combo">
-                                    <property name="visible">True</property>
-                                    <property name="can-focus">False</property>
+                                    <property name="vexpand">1</property>
                                     <property name="margin-start">6</property>
                                     <property name="margin-top">6</property>
                                     <property name="model">tz_combo_model</property>
@@ -375,119 +217,70 @@
                                       </attributes>
                                     </child>
                                   </object>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">0</property>
-                                  </packing>
                                 </child>
                                 <child>
                                   <object class="GtkLabel" id="label5">
-                                    <property name="visible">True</property>
-                                    <property name="can-focus">False</property>
-                                    <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                    <property name="vexpand">1</property>
                                     <property name="margin-start">6</property>
                                     <property name="label" translatable="yes">You can still change this 
after importing the pictures.</property>
-                                    <property name="wrap">True</property>
+                                    <property name="wrap">1</property>
                                     <attributes>
-                                      <attribute name="style" value="italic"/>
+                                      <attribute name="style" value="italic"></attribute>
                                     </attributes>
                                   </object>
-                                  <packing>
-                                    <property name="expand">True</property>
-                                    <property name="fill">True</property>
-                                    <property name="position">1</property>
-                                  </packing>
                                 </child>
                               </object>
-                            </child>
+                            </property>
                             <child type="label">
                               <object class="GtkLabel" id="label4">
-                                <property name="visible">True</property>
-                                <property name="can-focus">False</property>
-                                <property name="events">GDK_POINTER_MOTION_MASK | 
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                 <property name="label" translatable="yes">Date:</property>
                                 <attributes>
-                                  <attribute name="weight" value="bold"/>
+                                  <attribute name="weight" value="bold"></attribute>
                                 </attributes>
                               </object>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">True</property>
-                            <property name="position">1</property>
-                          </packing>
                         </child>
                         <child>
                           <object class="GtkFrame" id="attributes_frame">
-                            <property name="visible">True</property>
-                            <property name="can-focus">False</property>
+                            <property name="vexpand">1</property>
                             <property name="margin-top">6</property>
                             <property name="margin-bottom">6</property>
-                            <property name="label-xalign">0</property>
-                            <property name="shadow-type">none</property>
-                            <child>
+                            <property name="child">
                               <object class="GtkScrolledWindow" id="attributes_scrolled">
-                                <property name="visible">True</property>
-                                <property name="can-focus">True</property>
+                                <property name="focusable">1</property>
                                 <property name="margin-start">6</property>
                                 <property name="margin-top">6</property>
                                 <property name="margin-bottom">6</property>
-                                <property name="vexpand">True</property>
+                                <property name="vexpand">1</property>
                                 <property name="hscrollbar-policy">never</property>
                                 <child>
                                   <placeholder/>
                                 </child>
                               </object>
-                            </child>
+                            </property>
                             <child type="label">
                               <object class="GtkLabel" id="label9">
-                                <property name="visible">True</property>
-                                <property name="can-focus">False</property>
                                 <property name="label" translatable="yes">Attributes:</property>
                                 <attributes>
-                                  <attribute name="weight" value="bold"/>
+                                  <attribute name="weight" value="bold"></attribute>
                                 </attributes>
                               </object>
                             </child>
                           </object>
-                          <packing>
-                            <property name="expand">True</property>
-                            <property name="fill">True</property>
-                            <property name="position">2</property>
-                          </packing>
                         </child>
                       </object>
                     </child>
                     <child type="label">
                       <object class="GtkLabel" id="label7">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
                         <property name="label" translatable="yes">Metadata</property>
                       </object>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">2</property>
-                  </packing>
                 </child>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">2</property>
-          </packing>
         </child>
       </object>
     </child>
@@ -495,5 +288,25 @@
       <action-widget response="1">button3</action-widget>
       <action-widget response="0">button4</action-widget>
     </action-widgets>
+    <child internal-child="action_area">
+      <object class="GtkBox" id="dialog-action_area2">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <child>
+          <object class="GtkButton" id="button3">
+            <property name="label">Cancel</property>
+            <property name="focusable">1</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkButton" id="button4">
+            <property name="label" translatable="yes">_Import</property>
+            <property name="focusable">1</property>
+            <property name="receives-default">1</property>
+            <property name="use-underline">1</property>
+          </object>
+        </child>
+      </object>
+    </child>
   </object>
 </interface>
diff --git a/src/niepce/ui/dialogs/importers/cameraimporterui.ui 
b/src/niepce/ui/dialogs/importers/cameraimporterui.ui
index 8144192..d600e5c 100644
--- a/src/niepce/ui/dialogs/importers/cameraimporterui.ui
+++ b/src/niepce/ui/dialogs/importers/cameraimporterui.ui
@@ -1,48 +1,39 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
-  <object class="GtkOffscreenWindow">
-    <property name="can_focus">False</property>
+  <requires lib="gtk" version="4.0"/>
+  <object class="GtkWindow">
     <child>
       <object class="GtkGrid" id="main_widget">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <child>
           <object class="GtkComboBoxText" id="camera_list_combo">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="halign">start</property>
-            <property name="hexpand">True</property>
+            <property name="hexpand">1</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="GtkLabel">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="label" translatable="yes">Available cameras:</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="GtkButton" id="select_camera_btn">
             <property name="label" translatable="yes">Select</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
+            <property name="focusable">1</property>
+            <property name="receives_default">1</property>
+            <layout>
+              <property name="column">2</property>
+              <property name="row">0</property>
+            </layout>
           </object>
-          <packing>
-            <property name="left_attach">2</property>
-            <property name="top_attach">0</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/niepce/ui/dialogs/importers/directoryimporterui.ui 
b/src/niepce/ui/dialogs/importers/directoryimporterui.ui
index 1e5e177..03b1469 100644
--- a/src/niepce/ui/dialogs/importers/directoryimporterui.ui
+++ b/src/niepce/ui/dialogs/importers/directoryimporterui.ui
@@ -1,52 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
-  <object class="GtkOffscreenWindow">
+  <requires lib="gtk" version="4.0"/>
+  <object class="GtkWindow">
     <property name="can_focus">False</property>
     <child>
       <object class="GtkBox" id="main_widget">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="spacing">8</property>
         <child>
           <object class="GtkLabel" id="label2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="halign">center</property>
             <property name="label" translatable="yes">_Directory:</property>
-            <property name="use_underline">True</property>
+            <property name="use_underline">1</property>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkLabel" id="directory_name">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="hexpand">1</property>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
         <child>
           <object class="GtkButton" id="select_directories">
             <property name="label" translatable="yes">...</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="focusable">1</property>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/niepce/ui/dialogs/preferences.ui b/src/niepce/ui/dialogs/preferences.ui
index 99fe242..f86bb28 100644
--- a/src/niepce/ui/dialogs/preferences.ui
+++ b/src/niepce/ui/dialogs/preferences.ui
@@ -1,176 +1,111 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
+  <requires lib="gtk" version="4.0"/>
   <object class="GtkDialog" id="preferences">
-    <property name="can-focus">False</property>
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | 
GDK_BUTTON_RELEASE_MASK</property>
-    <property name="border-width">5</property>
     <property name="title" translatable="yes">Preferences</property>
-    <property name="window-position">center-on-parent</property>
     <property name="default-width">400</property>
     <property name="default-height">300</property>
-    <property name="type-hint">dialog</property>
-    <child internal-child="vbox">
+    <child internal-child="content_area">
       <object class="GtkBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
         <property name="orientation">vertical</property>
         <property name="spacing">6</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | 
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout-style">end</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-close</property>
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="can-default">True</property>
-                <property name="receives-default">False</property>
-                <property name="use-stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
           <placeholder/>
         </child>
         <child>
           <object class="GtkNotebook" id="notebook1">
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
+            <property name="vexpand">1</property>
+            <property name="focusable">1</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>
             <child>
-              <!-- n-columns=2 n-rows=2 -->
-              <object class="GtkGrid" id="table2">
-                <property name="visible">True</property>
-                <property name="can-focus">False</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="row-spacing">6</property>
-                <property name="column-spacing">6</property>
-                <child>
-                  <object class="GtkCheckButton" id="reopen_checkbutton">
-                    <property name="label" translatable="yes">_Reopen Catalog</property>
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">False</property>
-                    <property name="halign">start</property>
-                    <property name="use-underline">True</property>
-                    <property name="draw-indicator">True</property>
+              <object class="GtkNotebookPage">
+                <property name="child">
+                  <object class="GtkGrid" id="table2">
+                    <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="row-spacing">6</property>
+                    <property name="column-spacing">6</property>
+                    <child>
+                      <object class="GtkCheckButton" id="reopen_checkbutton">
+                        <property name="label" translatable="yes">_Reopen Catalog</property>
+                        <property name="focusable">1</property>
+                        <property name="halign">start</property>
+                        <property name="use-underline">1</property>
+                        <layout>
+                          <property name="column">0</property>
+                          <property name="row">0</property>
+                          <property name="column-span">2</property>
+                        </layout>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="write_xmp_checkbutton">
+                        <property name="label" translatable="yes">Write XMP automatically (not 
recommended)</property>
+                        <property name="focusable">1</property>
+                        <property name="halign">start</property>
+                        <layout>
+                          <property name="column">0</property>
+                          <property name="row">1</property>
+                          <property name="column-span">2</property>
+                        </layout>
+                      </object>
+                    </child>
                   </object>
-                  <packing>
-                    <property name="left-attach">0</property>
-                    <property name="top-attach">0</property>
-                    <property name="width">2</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="write_xmp_checkbutton">
-                    <property name="label" translatable="yes">Write XMP automatically (not 
recommended)</property>
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">False</property>
-                    <property name="halign">start</property>
-                    <property name="draw-indicator">True</property>
+                </property>
+                <property name="tab">
+                  <object class="GtkLabel" id="label1">
+                    <property name="label" translatable="yes">_General</property>
+                    <property name="use-underline">1</property>
                   </object>
-                  <packing>
-                    <property name="left-attach">0</property>
-                    <property name="top-attach">1</property>
-                    <property name="width">2</property>
-                  </packing>
-                </child>
+                </property>
               </object>
             </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="label" translatable="yes">_General</property>
-                <property name="use-underline">True</property>
-              </object>
-              <packing>
-                <property name="tab-fill">False</property>
-              </packing>
-            </child>
             <child>
-              <!-- n-columns=2 n-rows=1 -->
-              <object class="GtkGrid" id="table1">
-                <property name="visible">True</property>
-                <property name="can-focus">False</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="row-spacing">6</property>
-                <property name="column-spacing">6</property>
-                <child>
-                  <object class="GtkCheckButton" id="dark_theme_checkbox">
-                    <property name="label" translatable="yes">Use dark interface</property>
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="receives-default">False</property>
-                    <property name="halign">start</property>
-                    <property name="draw-indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left-attach">0</property>
-                    <property name="top-attach">0</property>
-                    <property name="width">2</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
+              <object class="GtkNotebookPage">
                 <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="label" translatable="yes">_User Interface</property>
-                <property name="use-underline">True</property>
+                <property name="child">
+                  <object class="GtkGrid" id="table1">
+                    <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="row-spacing">6</property>
+                    <property name="column-spacing">6</property>
+                    <child>
+                      <object class="GtkCheckButton" id="dark_theme_checkbox">
+                        <property name="label" translatable="yes">Use dark interface</property>
+                        <property name="focusable">1</property>
+                        <property name="halign">start</property>
+                        <layout>
+                          <property name="column">0</property>
+                          <property name="row">0</property>
+                          <property name="column-span">2</property>
+                        </layout>
+                      </object>
+                    </child>
+                  </object>
+                </property>
+                <property name="tab">
+                  <object class="GtkLabel" id="label2">
+                    <property name="label" translatable="yes">_User Interface</property>
+                    <property name="use-underline">1</property>
+                  </object>
+                </property>
               </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab-fill">False</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="pack-type">end</property>
-            <property name="position">2</property>
-          </packing>
         </child>
       </object>
+          <object class="GtkButton" id="button1">
+          </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button1</action-widget>
+      <action-widget response="ok" default="true">button1</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index 39d373f..0b05030 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -103,51 +103,50 @@ void WorkspaceController::action_delete_folder()
     }
 }
 
-void WorkspaceController::action_file_import()
+void WorkspaceController::perform_file_import(ImportDialog::Ptr dialog)
 {
-    int result;
     auto& cfg = Application::app()->config(); // XXX change to getLibraryConfig()
     // as the last import should be part of the library not the application.
 
-    ImportDialog::Ptr import_dialog(new ImportDialog());
-
-    result = import_dialog->run_modal(std::dynamic_pointer_cast<NiepceWindow>(m_parent.lock()));
-    switch(result) {
-    case 0:
-    {
-        // import
-        // XXX change the API to provide more details.
-        std::string source = import_dialog->get_source();
-        if(source.empty()) {
-            return;
-        }
-        // XXX this should be a different config key
-        // specific to the importer.
-        cfg.setValue("last_import_location", source);
-
-        auto importer = import_dialog->get_importer();
-        DBG_ASSERT(!!importer, "Import can't be null if we clicked import");
-        if (importer) {
-            auto dest_dir = import_dialog->get_dest_dir();
-            importer->do_import(
-                source, dest_dir,
-                [this] (const std::string& path, const fwk::FileListPtr& files, Managed manage) -> bool {
-                        ffi::libraryclient_import_files(
-                            getLibraryClient()->client(), path.c_str(), files.get(), manage);
-                        // XXX the libraryclient function returns void
-                        return true;
-                });
-        }
-        break;
+    // import
+    // XXX change the API to provide more details.
+    std::string source = dialog->get_source();
+    if (source.empty()) {
+        return;
     }
-    case 1:
-        // cancel
-        break;
-    default:
-        break;
+    // XXX this should be a different config key
+    // specific to the importer.
+    cfg.setValue("last_import_location", source);
+
+    auto importer = dialog->get_importer();
+    DBG_ASSERT(!!importer, "Import can't be null if we clicked import");
+    if (importer) {
+        auto dest_dir = dialog->get_dest_dir();
+        importer->do_import(
+            source, dest_dir,
+            [this] (const std::string& path, const fwk::FileListPtr& files, Managed manage) -> bool {
+                ffi::libraryclient_import_files(
+                    getLibraryClient()->client(), path.c_str(), files.get(), manage);
+                // XXX the libraryclient function returns void
+                return true;
+            });
     }
 }
 
+void WorkspaceController::action_file_import()
+{
+    ImportDialog::Ptr import_dialog(new ImportDialog());
+
+    import_dialog->run_modal(std::dynamic_pointer_cast<NiepceWindow>(m_parent.lock()),
+                             [this, import_dialog] (int response) {
+                                 DBG_OUT("import dialog response: %d", response);
+                                 import_dialog->close();
+                                 if (response == 0) {
+                                     this->perform_file_import(import_dialog);
+                                 }
+                             });
+}
+
 
 void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
 {
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index 0b414f9..d3349cf 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -30,6 +30,7 @@
 #include "fwk/toolkit/uicontroller.hpp"
 #include "fwk/toolkit/notification.hpp"
 #include "niepce/ui/niepcewindow.hpp"
+#include "dialogs/importdialog.hpp"
 
 namespace ui {
 
@@ -87,8 +88,10 @@ private:
     /** action to create a new folder */
     void action_new_folder();
     void action_delete_folder();
-    /** action to import images */
+    /** action to import images: run the dialog */
     void action_file_import();
+    /** */
+    void perform_file_import(ImportDialog::Ptr dialog);
 
     void on_row_expanded_collapsed(const Gtk::TreeModel::iterator& iter,
                                    const Gtk::TreeModel::Path& path, bool expanded);


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