[niepce] ui: fix saving preferences



commit 6c2c9a752161e931be03c99e1a48240901961177
Author: Hubert Figuière <hub figuiere net>
Date:   Sat Oct 15 10:00:55 2022 -0400

    ui: fix saving preferences

 src/fwk/toolkit/dialog.cpp                  |  1 -
 src/niepce/ui/dialogs/preferencesdialog.cpp | 13 +++----------
 src/niepce/ui/dialogs/preferencesdialog.hpp | 10 +++++-----
 3 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/src/fwk/toolkit/dialog.cpp b/src/fwk/toolkit/dialog.cpp
index b680d293..972eac89 100644
--- a/src/fwk/toolkit/dialog.cpp
+++ b/src/fwk/toolkit/dialog.cpp
@@ -47,7 +47,6 @@ void Dialog::run_modal(const Frame::Ptr& parent, std::function<void(int)> on_ok)
     gtkDialog().set_transient_for(parent->gtkWindow());
     gtkDialog().set_default_response(Gtk::ResponseType::CLOSE);
     gtkDialog().set_modal();
-    gtkDialog().set_hide_on_close(true);
     gtkDialog().signal_response().connect(on_ok);
     gtkDialog().show();
     DBG_OUT("dialog shown");
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
index 05b5593a..dcdb8ac8 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.cpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -18,8 +18,6 @@
  */
 
 #include <glibmm/i18n.h>
-#include <gtkmm/combobox.h>
-#include <gtkmm/liststore.h>
 #include <gtkmm/checkbutton.h>
 
 #include "fwk/toolkit/configdatabinder.hpp"
@@ -42,12 +40,7 @@ void PreferencesDialog::setup_widget()
     Gtk::CheckButton* theme_checkbutton = nullptr;
     Gtk::CheckButton* reopen_checkbutton = nullptr;
     Gtk::CheckButton* write_xmp_checkbutton = nullptr;
-    fwk::DataBinderPool* binder_pool = new fwk::DataBinderPool();
-
-    gtkDialog().signal_hide().connect(
-        [binder_pool] () {
-            fwk::DataBinderPool::destroy(binder_pool);
-        });
+    m_binder_pool = std::make_unique<fwk::DataBinderPool>();
 
     theme_checkbutton = builder()->get_widget<Gtk::CheckButton>("dark_theme_checkbox");
     theme_checkbutton->set_active(fwk::Application::app()
@@ -59,12 +52,12 @@ void PreferencesDialog::setup_widget()
         });
 
     reopen_checkbutton = builder()->get_widget<Gtk::CheckButton>("reopen_checkbutton");
-    binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
+    m_binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
                                    reopen_checkbutton->property_active(),
                                    fwk::Application::app()->config(),
                                    "reopen_last_catalog"));
     write_xmp_checkbutton = builder()->get_widget<Gtk::CheckButton>("write_xmp_checkbutton");
-    binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
+    m_binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
                                  write_xmp_checkbutton->property_active(),
                                  fwk::Application::app()->config(),
                                  "write_xmp_automatically"));
diff --git a/src/niepce/ui/dialogs/preferencesdialog.hpp b/src/niepce/ui/dialogs/preferencesdialog.hpp
index 96cdba6e..71c3f229 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.hpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - ui/dialogs/preferencesdialog.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,8 +17,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _UI_PREFERENCESDIALOG_H_
-#define _UI_PREFERENCESDIALOG_H_
+#pragma once
+
+#include <memory>
 
 #include "fwk/toolkit/gtkutils.hpp"
 #include "fwk/toolkit/dialog.hpp"
@@ -36,10 +37,10 @@ public:
     virtual void setup_widget() override;
 
 private:
+    std::unique_ptr<fwk::DataBinderPool> m_binder_pool;
     fwk::TextPairModelRecord m_theme_combo_model;
 };
 
-
 }
 
 /*
@@ -52,4 +53,3 @@ private:
   End:
 */
 
-#endif


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