[niepce: 5/5] * Dialog framework. Move the dialogs in their sub



commit ceab330d21a06761be53f4baf31f7e0568e27716
Author: Hubert Figuiere <hub figuiere net>
Date:   Fri Mar 6 23:48:49 2009 -0500

    	* Dialog framework. Move the dialogs in their subdir
    	and convert the code.
---
 ChangeLog                                   |    3 +
 src/fwk/toolkit/Makefile.am                 |    1 +
 src/fwk/toolkit/dialog.cpp                  |   51 +++++++++
 src/fwk/toolkit/dialog.hpp                  |   70 ++++++++++++
 src/fwk/toolkit/frame.cpp                   |   29 +----
 src/fwk/toolkit/frame.hpp                   |   15 +--
 src/niepce/ui/Makefile.am                   |    3 +-
 src/niepce/ui/dialogs/Makefile.am           |    3 +-
 src/niepce/ui/dialogs/importdialog.cpp      |    9 +-
 src/niepce/ui/dialogs/importdialog.hpp      |   16 ++-
 src/niepce/ui/dialogs/preferences.glade     |  146 ++++++++++++++++++++++++
 src/niepce/ui/dialogs/preferences.ui        |  160 +++++++++++++++++++++++++++
 src/niepce/ui/dialogs/preferencesdialog.cpp |   85 ++++++++++++++
 src/niepce/ui/dialogs/preferencesdialog.hpp |   52 +++++++++
 src/niepce/ui/niepcewindow.cpp              |   61 ++---------
 src/niepce/ui/preferences.glade             |  146 ------------------------
 src/niepce/ui/preferences.ui                |  160 ---------------------------
 17 files changed, 609 insertions(+), 401 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b88cf19..2dd5728 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-03-06  Hubert Figuiere  <hub figuiere net>
 
+	* Dialog framework. Move the dialogs in their subdir
+	and convert the code.
+	
 	* Rename framework namespace to fwk.
 	* Move dialogs in their directory
 	* Rename some .h to .hpp
diff --git a/src/fwk/toolkit/Makefile.am b/src/fwk/toolkit/Makefile.am
index bc3a4ed..7601bac 100644
--- a/src/fwk/toolkit/Makefile.am
+++ b/src/fwk/toolkit/Makefile.am
@@ -14,6 +14,7 @@ noinst_HEADERS =   \
 
 libniepceframework_a_SOURCES = configuration.hpp configuration.cpp \
 	application.hpp application.cpp \
+	dialog.hpp dialog.cpp \
 	frame.hpp frame.cpp \
 	controller.hpp controller.cpp \
 	notification.hpp \
diff --git a/src/fwk/toolkit/dialog.cpp b/src/fwk/toolkit/dialog.cpp
new file mode 100644
index 0000000..7fd12c4
--- /dev/null
+++ b/src/fwk/toolkit/dialog.cpp
@@ -0,0 +1,51 @@
+/*
+ * niepce - fwk/toolkit/dialog.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "dialog.hpp"
+
+
+namespace fwk {
+
+
+
+int Dialog::run_modal(const Frame::Ptr & parent)
+{
+    int result;
+    if(!m_is_setup) {
+        setup_widget();
+    }
+		gtkDialog().set_transient_for(parent->gtkWindow());
+		gtkDialog().set_default_response(Gtk::RESPONSE_CLOSE);
+		result = gtkDialog().run();
+		gtkDialog().hide();
+		return result;
+}
+
+
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
diff --git a/src/fwk/toolkit/dialog.hpp b/src/fwk/toolkit/dialog.hpp
new file mode 100644
index 0000000..e13d5b4
--- /dev/null
+++ b/src/fwk/toolkit/dialog.hpp
@@ -0,0 +1,70 @@
+/*
+ * niepce - fwk/toolkit/dialog.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __FWK_DIALOG_H__
+#define __FWK_DIALOG_H__
+
+#include <gtkmm/dialog.h>
+
+#include "fwk/toolkit/frame.hpp"
+
+namespace fwk {
+
+/** 
+ * Implement a dialog.
+ */ 
+class Dialog
+	: public fwk::Frame
+{
+public:
+    typedef boost::shared_ptr<Dialog> Ptr;
+
+		Dialog(const std::string & gladeFile, const Glib::ustring & widgetName,
+          const std::string & layout_cfg_key = "")
+        : Frame(gladeFile, widgetName, layout_cfg_key)
+        , m_is_setup(false)
+        { 
+        }
+
+    /** this is called prior to show the dialog 
+     * subclass must implement and set %m_is_setup to true
+     */
+    virtual void setup_widget() = 0;
+    Gtk::Dialog & gtkDialog()
+        { return static_cast<Gtk::Dialog&>(gtkWindow()); }
+    int run_modal();
+    int run_modal(const Frame::Ptr & parent);
+protected:
+    bool m_is_setup;
+};
+
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
+
+#endif
diff --git a/src/fwk/toolkit/frame.cpp b/src/fwk/toolkit/frame.cpp
index e2ab2df..fdd52af 100644
--- a/src/fwk/toolkit/frame.cpp
+++ b/src/fwk/toolkit/frame.cpp
@@ -103,31 +103,6 @@ void Frame::set_title(const std::string & title)
 		gtkWindow().set_title(Glib::ustring(title));
 }
 
-int Frame::show_modal_dialog(Gtk::Dialog & dlg)
-{
-		int result;
-		dlg.set_transient_for(*m_window);
-		dlg.set_default_response(Gtk::RESPONSE_CLOSE);
-		result = dlg.run();
-		dlg.hide();
-		return result;
-}
-
-int Frame::show_modal_dialog(const char *gladefile,
-                             const char *widgetname,
-                             boost::function<void (const Glib::RefPtr<Gtk::Builder> &, 
-                                                   Gtk::Dialog *)> setup)
-{
-		Glib::RefPtr<Gtk::Builder> dialogBuilder 
-        = Gtk::Builder::create_from_file(gladefile);
-		Gtk::Dialog *dlg = NULL;
-
-		dialogBuilder->get_widget(widgetname, dlg);
-		if(setup) {
-        setup(dialogBuilder, dlg);
-		}
-		return show_modal_dialog(*dlg);
-}
 
 void Frame::toggle_tools_visible()
 {
@@ -184,6 +159,10 @@ void Frame::frameRectToConfig()
 		}
 }
 
+Gtk::Widget *Frame::buildWidget()
+{
+    return m_window;
+}
 /*
   Local Variables:
   mode:c++
diff --git a/src/fwk/toolkit/frame.hpp b/src/fwk/toolkit/frame.hpp
index c722085..b2e3c16 100644
--- a/src/fwk/toolkit/frame.hpp
+++ b/src/fwk/toolkit/frame.hpp
@@ -65,17 +65,6 @@ public:
 		 */
 		void set_icon_from_theme(const Glib::ustring & name);
 
-		/** show a model dialog
-		 * @param dlg the dialog to show.
-		 * @return the result from Dialog::run()
-		 */
-		int show_modal_dialog(Gtk::Dialog & dlg);
-		int show_modal_dialog(const char *gladefile,
-                          const char *widgetname,
-                          boost::function<void (const Glib::RefPtr<Gtk::Builder> &, 
-                                                Gtk::Dialog *)> setup = NULL);
-
-        
     void toggle_tools_visible();
 
     sigc::signal<void> signal_hide_tools;
@@ -86,6 +75,10 @@ protected:
     Glib::RefPtr<Gtk::ToggleAction> m_hide_tools_action;
 
 private:
+    /** frame have the widget set at construction time
+     * from a ui file or directly.
+     */
+    virtual Gtk::Widget *buildWidget();
 		void connectSignals();
 		void frameRectFromConfig();
 		void frameRectToConfig();
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index a205904..d1473f6 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -2,7 +2,7 @@
 
 DIST_SUBDIRS = thumb-view dialogs
 
-gladefiles = preferences.ui \
+gladefiles = dialogs/preferences.ui \
 	dialogs/importdialog.ui
 
 gladedir = @datarootdir@/niepce/glade/
@@ -32,6 +32,7 @@ libniepceui_a_SOURCES = niepcewindow.hpp niepcewindow.cpp \
 	workspacecontroller.h workspacecontroller.cpp \
 	metadatapanecontroller.hpp metadatapanecontroller.cpp \
 	dialogs/importdialog.hpp dialogs/importdialog.cpp \
+	dialogs/preferencesdialog.hpp dialogs/preferencesdialog.cpp \
 	selectioncontroller.h selectioncontroller.cpp \
 	filmstripcontroller.h filmstripcontroller.cpp \
 	dialogs/importdialog.hpp dialogs/importdialog.cpp \
diff --git a/src/niepce/ui/dialogs/Makefile.am b/src/niepce/ui/dialogs/Makefile.am
index 69acf4b..4c57d73 100644
--- a/src/niepce/ui/dialogs/Makefile.am
+++ b/src/niepce/ui/dialogs/Makefile.am
@@ -1,2 +1,3 @@
 
-EXTRA_DIST = importdialog.glade
+EXTRA_DIST = importdialog.glade preferences.glade
+
diff --git a/src/niepce/ui/dialogs/importdialog.cpp b/src/niepce/ui/dialogs/importdialog.cpp
index 6ba7123..7d213b7 100644
--- a/src/niepce/ui/dialogs/importdialog.cpp
+++ b/src/niepce/ui/dialogs/importdialog.cpp
@@ -39,7 +39,7 @@ using fwk::Application;
 namespace ui {
 
 ImportDialog::ImportDialog()
-    : fwk::Frame(GLADEDIR"importdialog.ui", "importDialog"),
+    : fwk::Dialog(GLADEDIR"importdialog.ui", "importDialog"),
     m_date_tz_combo(NULL),
 	  m_ufraw_import_check(NULL),
 	  m_rawstudio_import_check(NULL),
@@ -49,8 +49,11 @@ ImportDialog::ImportDialog()
 }
 
 
-Gtk::Widget * ImportDialog::buildWidget()
+void ImportDialog::setup_widget()
 {
+    if(m_is_setup) {
+        return;
+    }
     Glib::RefPtr<Gtk::Builder> _builder = builder();
     Gtk::Button *select_directories = NULL;
     _builder->get_widget("select_directories", select_directories);
@@ -62,7 +65,7 @@ Gtk::Widget * ImportDialog::buildWidget()
     _builder->get_widget("directory_name", m_directory_name);
     _builder->get_widget("folderList", m_folderList);
     m_folderListModel.inject(*m_folderList);
-    return &gtkWindow();
+    m_is_setup = true;
 }
 
 
diff --git a/src/niepce/ui/dialogs/importdialog.hpp b/src/niepce/ui/dialogs/importdialog.hpp
index e1e624f..9210d35 100644
--- a/src/niepce/ui/dialogs/importdialog.hpp
+++ b/src/niepce/ui/dialogs/importdialog.hpp
@@ -29,7 +29,7 @@
 #include <glibmm/refptr.h>
 
 #include "fwk/toolkit/gtkutils.hpp"
-#include "fwk/toolkit/frame.hpp"
+#include "fwk/toolkit/dialog.hpp"
 
 namespace Gtk {
 	class Dialog;
@@ -41,14 +41,14 @@ namespace Gtk {
 namespace ui {
 
 class ImportDialog 
-	: public fwk::Frame
+	: public fwk::Dialog
 {
 public:
 	typedef boost::shared_ptr<ImportDialog> Ptr;
 
 	ImportDialog();
 
- 	Gtk::Widget * buildWidget();
+ 	virtual void setup_widget();
 
 //	const Glib::ustring & to_import() const
 //		{ return m_to_import; }
@@ -73,5 +73,15 @@ private:
 
 }
 
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
+
 #endif
 
diff --git a/src/niepce/ui/dialogs/preferences.glade b/src/niepce/ui/dialogs/preferences.glade
new file mode 100644
index 0000000..578bdd5
--- /dev/null
+++ b/src/niepce/ui/dialogs/preferences.glade
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <widget class="GtkDialog" id="preferences">
+    <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="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <child>
+              <widget class="GtkTable" id="table2">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">12</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <widget class="GtkCheckButton" id="reopen_checkbutton">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">_Reopen Library</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_General</property>
+                <property name="use_underline">True</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">1</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">12</property>
+                <child>
+                  <widget class="GtkComboBox" id="theme_combo">
+                    <property name="visible">True</property>
+                    <property name="items" translatable="yes">System
+Dark</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Theme:	</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">theme_combo</property>
+                  </widget>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_User Interface</property>
+                <property name="use_underline">True</property>
+              </widget>
+              <packing>
+                <property name="type">tab</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</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">GTK_BUTTONBOX_END</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-close</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>
diff --git a/src/niepce/ui/dialogs/preferences.ui b/src/niepce/ui/dialogs/preferences.ui
new file mode 100644
index 0000000..da19af1
--- /dev/null
+++ b/src/niepce/ui/dialogs/preferences.ui
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<!--*- mode: xml -*-->
+<interface>
+  <object class="GtkListStore" id="model1">
+    <columns>
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0">System</col>
+      </row>
+      <row>
+        <col id="0">Dark</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkDialog" id="preferences">
+    <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="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkNotebook" id="notebook1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <child>
+              <object class="GtkTable" id="table2">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">12</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="reopen_checkbutton">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">_Reopen Library</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"/>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</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>
+              <object class="GtkTable" id="table1">
+                <property name="visible">True</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">1</property>
+                <property name="n_columns">2</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">12</property>
+                <child>
+                  <object class="GtkComboBox" id="theme_combo">
+                    <property name="visible">True</property>
+                    <property name="model">model1</property>
+                    <child>
+                      <object class="GtkCellRendererText" id="renderer1"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Theme:	</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">theme_combo</property>
+                  </object>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"/>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label2">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_User Interface</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</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">GTK_BUTTONBOX_END</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-close</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">reopen_checkbutton</action-widget>
+      <action-widget response="0">button1</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/niepce/ui/dialogs/preferencesdialog.cpp b/src/niepce/ui/dialogs/preferencesdialog.cpp
new file mode 100644
index 0000000..ae91bfd
--- /dev/null
+++ b/src/niepce/ui/dialogs/preferencesdialog.cpp
@@ -0,0 +1,85 @@
+/*
+ * niepce - ui/dialogs/preferencesdialog.cpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <boost/bind.hpp>
+
+#include <gtkmm/combobox.h>
+#include <gtkmm/checkbutton.h>
+
+#include "fwk/toolkit/configdatabinder.hpp"
+#include "fwk/toolkit/application.hpp"
+
+
+#include "preferencesdialog.hpp"
+
+namespace ui {
+
+void PreferencesDialog::setup_widget()
+{
+    if(m_is_setup) {
+        return;
+    }
+
+    Gtk::ComboBox * theme_combo = NULL;
+    Gtk::CheckButton * reopen_checkbutton = NULL;
+    utils::DataBinderPool * binder_pool = new utils::DataBinderPool();
+
+    gtkDialog().signal_hide().connect(boost::bind(&utils::DataBinderPool::destroy, 
+                                              binder_pool));
+		
+    builder()->get_widget("theme_combo", theme_combo);
+ 
+// Why are ComboBox so complicated to use?
+//    class Columns : 
+//            public Gtk::TreeModel::ColumnRecord
+//    {
+//    public:
+//        Gtk::TreeModelColumn<Glib::ustring>  label;
+//        Columns() { add(label); }
+//    };
+
+//    Columns columns;
+//    Glib::RefPtr<Gtk::ListStore> model(Gtk::ListStore::create(columns));
+
+//    theme_combo->set_model(model);
+//    const std::vector<fwk::Application::ThemeDesc> & themes = fwk::Application::app()->get_available_themes();
+//    std::vector<fwk::Application::ThemeDesc>::const_iterator i;
+//    for(i = themes.begin(); i != themes.end(); ++i) {
+//        DBG_OUT("adding %s", i->first.c_str());
+//        Gtk::TreeIter iter = model->append();
+//        (*iter).set_value(columns.label, i->first); 
+//    }
+    theme_combo->set_active(fwk::Application::app()
+                            ->get_use_custom_theme());
+    theme_combo->signal_changed().connect(
+        boost::bind(&fwk::Application::set_use_custom_theme,
+                    fwk::Application::app(),
+                    theme_combo->property_active()));
+
+    builder()->get_widget("reopen_checkbutton", reopen_checkbutton);
+    binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
+															reopen_checkbutton->property_active(),
+															fwk::Application::app()->config(),
+															"reopen_last_library"));
+		m_is_setup = true;
+}
+
+
+}
+
diff --git a/src/niepce/ui/dialogs/preferencesdialog.hpp b/src/niepce/ui/dialogs/preferencesdialog.hpp
new file mode 100644
index 0000000..ae48900
--- /dev/null
+++ b/src/niepce/ui/dialogs/preferencesdialog.hpp
@@ -0,0 +1,52 @@
+/*
+ * niepce - ui/dialogs/preferencesdialog.hpp
+ *
+ * Copyright (C) 2009 Hubert Figuiere
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _UI_PREFERENCESDIALOG_H_
+#define _UI_PREFERENCESDIALOG_H_
+
+#include "fwk/toolkit/dialog.hpp"
+
+namespace ui {
+
+class PreferencesDialog
+	: public fwk::Dialog
+{
+public:
+    PreferencesDialog()
+        : fwk::Dialog(GLADEDIR"preferences.ui", "preferences", "")
+        {
+        }
+    virtual void setup_widget();
+
+};
+
+
+}
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0))
+  indent-tabs-mode:nil
+  fill-column:80
+  End:
+*/
+
+#endif
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index 0a7c775..1c79423 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -28,7 +28,6 @@
 #include <gtkmm/stock.h>
 #include <gtkmm/separator.h>
 #include <gtkmm/filechooserdialog.h>
-#include <gtkmm/combobox.h>
 
 #include "niepce/notifications.h"
 #include "niepce/stock.h"
@@ -47,6 +46,7 @@
 #include "niepcewindow.hpp"
 #include "librarymainviewcontroller.h"
 #include "dialogs/importdialog.hpp"
+#include "dialogs/preferencesdialog.hpp"
 #include "selectioncontroller.h"
 
 using libraryclient::LibraryClient;
@@ -397,8 +397,8 @@ void NiepceWindow::on_action_file_import()
 	
     ImportDialog::Ptr import_dialog(new ImportDialog());
 
-    result = show_modal_dialog(
-        *static_cast<Gtk::Dialog*>(import_dialog->buildWidget()));
+    result = import_dialog->run_modal(
+        boost::static_pointer_cast<fwk::Frame>(shared_from_this()));
     switch(result) {
     case 0:
     {
@@ -481,59 +481,18 @@ void NiepceWindow::on_open_library()
 }
 
 
-void NiepceWindow::preference_dialog_setup(const Glib::RefPtr<Gtk::Builder> & xml, 
-                                           Gtk::Dialog * dialog)
-{
-    Gtk::ComboBox * theme_combo = NULL;
-    Gtk::CheckButton * reopen_checkbutton = NULL;
-    utils::DataBinderPool * binder_pool = new utils::DataBinderPool();
-
-    dialog->signal_hide().connect(boost::bind(&utils::DataBinderPool::destroy, 
-                                              binder_pool));
-		
-    xml->get_widget("theme_combo", theme_combo);
- 
-// Why are ComboBox so complicated to use?
-//    class Columns : 
-//            public Gtk::TreeModel::ColumnRecord
-//    {
-//    public:
-//        Gtk::TreeModelColumn<Glib::ustring>  label;
-//        Columns() { add(label); }
-//    };
-
-//    Columns columns;
-//    Glib::RefPtr<Gtk::ListStore> model(Gtk::ListStore::create(columns));
-
-//    theme_combo->set_model(model);
-//    const std::vector<fwk::Application::ThemeDesc> & themes = fwk::Application::app()->get_available_themes();
-//    std::vector<fwk::Application::ThemeDesc>::const_iterator i;
-//    for(i = themes.begin(); i != themes.end(); ++i) {
-//        DBG_OUT("adding %s", i->first.c_str());
-//        Gtk::TreeIter iter = model->append();
-//        (*iter).set_value(columns.label, i->first); 
-//    }
-    theme_combo->set_active(fwk::Application::app()
-                            ->get_use_custom_theme());
-    theme_combo->signal_changed().connect(
-        boost::bind(&fwk::Application::set_use_custom_theme,
-                    fwk::Application::app(),
-                    theme_combo->property_active()));
-
-    xml->get_widget("reopen_checkbutton", reopen_checkbutton);
-    binder_pool->add_binder(new fwk::ConfigDataBinder<bool>(
-                                reopen_checkbutton->property_active(),
-                                fwk::Application::app()->config(),
-                                "reopen_last_library"));
-}
 
 
 void NiepceWindow::on_preferences()
 {
     DBG_OUT("on_preferences");
-    show_modal_dialog(GLADEDIR"preferences.ui", "preferences",
-                      boost::bind(&NiepceWindow::preference_dialog_setup,
-                                  this, _1, _2));
+
+    fwk::Dialog::Ptr dlg(new PreferencesDialog());
+    dlg->run_modal(boost::static_pointer_cast<Frame>(shared_from_this()));
+
+//    show_modal_dialog(GLADEDIR"preferences.ui", "preferences",
+//                      boost::bind(&NiepceWindow::preference_dialog_setup,
+//                                  this, _1, _2));
     DBG_OUT("end on_preferences");
 }
 
diff --git a/src/niepce/ui/preferences.glade b/src/niepce/ui/preferences.glade
deleted file mode 100644
index 578bdd5..0000000
--- a/src/niepce/ui/preferences.glade
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--*- mode: xml -*-->
-<glade-interface>
-  <widget class="GtkDialog" id="preferences">
-    <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="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">2</property>
-        <child>
-          <widget class="GtkNotebook" id="notebook1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <child>
-              <widget class="GtkTable" id="table2">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <property name="n_rows">2</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <widget class="GtkCheckButton" id="reopen_checkbutton">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">_Reopen Library</property>
-                    <property name="use_underline">True</property>
-                    <property name="response_id">0</property>
-                    <property name="draw_indicator">True</property>
-                  </widget>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-              </widget>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">_General</property>
-                <property name="use_underline">True</property>
-              </widget>
-              <packing>
-                <property name="type">tab</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkTable" id="table1">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <property name="n_rows">1</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <widget class="GtkComboBox" id="theme_combo">
-                    <property name="visible">True</property>
-                    <property name="items" translatable="yes">System
-Dark</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label3">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">_Theme:	</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">theme_combo</property>
-                  </widget>
-                  <packing>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">_User Interface</property>
-                <property name="use_underline">True</property>
-              </widget>
-              <packing>
-                <property name="type">tab</property>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</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">GTK_BUTTONBOX_END</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <widget class="GtkButton" id="button1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="label">gtk-close</property>
-                <property name="use_stock">True</property>
-                <property name="response_id">0</property>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
-</glade-interface>
diff --git a/src/niepce/ui/preferences.ui b/src/niepce/ui/preferences.ui
deleted file mode 100644
index da19af1..0000000
--- a/src/niepce/ui/preferences.ui
+++ /dev/null
@@ -1,160 +0,0 @@
-<?xml version="1.0"?>
-<!--*- mode: xml -*-->
-<interface>
-  <object class="GtkListStore" id="model1">
-    <columns>
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0">System</col>
-      </row>
-      <row>
-        <col id="0">Dark</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkDialog" id="preferences">
-    <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="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkNotebook" id="notebook1">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <child>
-              <object class="GtkTable" id="table2">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <property name="n_rows">2</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="reopen_checkbutton">
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="label" translatable="yes">_Reopen Library</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</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>
-              <object class="GtkTable" id="table1">
-                <property name="visible">True</property>
-                <property name="border_width">12</property>
-                <property name="n_rows">1</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">12</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <object class="GtkComboBox" id="theme_combo">
-                    <property name="visible">True</property>
-                    <property name="model">model1</property>
-                    <child>
-                      <object class="GtkCellRendererText" id="renderer1"/>
-                      <attributes>
-                        <attribute name="text">0</attribute>
-                      </attributes>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="label3">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">_Theme:	</property>
-                    <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">theme_combo</property>
-                  </object>
-                  <packing>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="label2">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">_User Interface</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</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">GTK_BUTTONBOX_END</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="label">gtk-close</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">reopen_checkbutton</action-widget>
-      <action-widget response="0">button1</action-widget>
-    </action-widgets>
-  </object>
-</interface>



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