[niepce: 3/4] * Refactor the ModelRecord for Gtk a bit.



commit de25a0d2127ac26a14c591db434a6c05f72c520c
Author: Hubert Figuiere <hub figuiere net>
Date:   Sat Mar 7 18:02:56 2009 -0500

    	* Refactor the ModelRecord for Gtk a bit.
---
 ChangeLog                                   |    2 +
 src/fwk/toolkit/gtkutils.cpp                |    8 ++---
 src/fwk/toolkit/gtkutils.hpp                |   42 +++++++++++++++++---------
 src/niepce/ui/dialogs/importdialog.hpp      |    7 +---
 src/niepce/ui/dialogs/preferencesdialog.hpp |    2 +-
 5 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0ebded5..8173bc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2009-03-07  Hubert Figuiere  <hub figuiere net>
 
+	* Refactor the ModelRecord for Gtk a bit.
+
 	* Update po files.
 
 	* Tweak UI files. Don't hardcode the list of themes
diff --git a/src/fwk/toolkit/gtkutils.cpp b/src/fwk/toolkit/gtkutils.cpp
index 3e0adb5..ec0952f 100644
--- a/src/fwk/toolkit/gtkutils.cpp
+++ b/src/fwk/toolkit/gtkutils.cpp
@@ -17,14 +17,13 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <gtkmm/liststore.h>
 
 #include "gtkutils.hpp"
 
 namespace fwk {
 
 Glib::RefPtr<Gtk::ListStore> 
-TextTreeviewModel::inject(Gtk::TreeView & treeview)
+ModelRecord::inject(Gtk::TreeView & treeview)
 {
     Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*this);
     treeview.set_model(model);
@@ -32,13 +31,12 @@ TextTreeviewModel::inject(Gtk::TreeView & treeview)
     return model;
 }
 
-
 Glib::RefPtr<Gtk::ListStore> 
-TextPairTreeviewModel::inject(Gtk::ComboBox & combo)
+ModelRecord::inject(Gtk::ComboBox & combo)
 {
     Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*this);
     combo.set_model(model);
-		static_cast<Gtk::CellLayout&>(combo).clear();
+		combo.clear();
 		combo.pack_start(m_col1);
     return model;
 }
diff --git a/src/fwk/toolkit/gtkutils.hpp b/src/fwk/toolkit/gtkutils.hpp
index c1f10be..eb4e70f 100644
--- a/src/fwk/toolkit/gtkutils.hpp
+++ b/src/fwk/toolkit/gtkutils.hpp
@@ -24,41 +24,53 @@
 #include <string>
 #include <gtkmm/treeview.h>
 #include <gtkmm/combobox.h>
+#include <gtkmm/liststore.h>
 
 
 namespace fwk {
 
-class TextTreeviewModel
+
+/** a simple model record with one text column. 
+ * This class is "abstract".
+ */
+class ModelRecord
     : public Gtk::TreeModelColumnRecord
 {
 public:
-    TextTreeviewModel()
-        { add(m_col1); }
-
+    virtual ~ModelRecord()
+        {
+        }
     /** "inject" the model to the TreeView */
-    Glib::RefPtr<Gtk::ListStore> inject(Gtk::TreeView & treeview);
+    virtual Glib::RefPtr<Gtk::ListStore> inject(Gtk::TreeView & treeview);
     /** "inject" the model to the ComboBox */
-    Glib::RefPtr<Gtk::ListStore> inject(Gtk::ComboBox & combox);
+    virtual Glib::RefPtr<Gtk::ListStore> inject(Gtk::ComboBox & combox);
 
     Gtk::TreeModelColumn<std::string> m_col1;
+protected:
+    ModelRecord()
+        {}
 };
 
-class TextPairTreeviewModel
-    : public Gtk::TreeModelColumnRecord
+
+class TextModelRecord
+    : public ModelRecord
+{
+public:
+    TextModelRecord()
+        { add(m_col1); }
+
+};
+
+class TextPairModelRecord
+    : public ModelRecord
 {
 public:
-    TextPairTreeviewModel()
+    TextPairModelRecord()
         {
             add(m_col1);
             add(m_col2);
         }
 
-    /** "inject" the model to the TreeView */
-    Glib::RefPtr<Gtk::ListStore> inject(Gtk::TreeView & treeview);
-    /** "inject" the model to the ComboBox */
-    Glib::RefPtr<Gtk::ListStore> inject(Gtk::ComboBox & combox);
-
-    Gtk::TreeModelColumn<std::string> m_col1;
     Gtk::TreeModelColumn<std::string> m_col2;
 };
 
diff --git a/src/niepce/ui/dialogs/importdialog.hpp b/src/niepce/ui/dialogs/importdialog.hpp
index c7da239..10ff2ff 100644
--- a/src/niepce/ui/dialogs/importdialog.hpp
+++ b/src/niepce/ui/dialogs/importdialog.hpp
@@ -1,5 +1,5 @@
 /*
- * niepce - niepce/ui/importdialog.h
+ * niepce - niepce/ui/dialogs/importdialog.h
  *
  * Copyright (C) 2008-2009 Hubert Figuiere
  *
@@ -50,8 +50,6 @@ public:
 
  	virtual void setup_widget();
 
-//	const Glib::ustring & to_import() const
-//		{ return m_to_import; }
 	const std::list<std::string> & to_import() const
 		{ return m_list_to_import; }
 	void set_to_import(const Glib::SListHandle<Glib::ustring> & l);
@@ -61,14 +59,13 @@ private:
 
 	void do_select_directories();
 	
-//	Glib::ustring m_to_import;
 	std::list<std::string> m_list_to_import;
 	Gtk::ComboBox *m_date_tz_combo;
 	Gtk::CheckButton *m_ufraw_import_check;
 	Gtk::CheckButton *m_rawstudio_import_check;
 	Gtk::Label *m_directory_name;
 	Gtk::TreeView *m_folderList;
-	fwk::TextTreeviewModel m_folderListModelRecord;
+	fwk::TextModelRecord m_folderListModelRecord;
 	Glib::RefPtr<Gtk::ListStore> m_folderListModel;
 };
 
diff --git a/src/niepce/ui/dialogs/preferencesdialog.hpp b/src/niepce/ui/dialogs/preferencesdialog.hpp
index 41f3488..3a169bc 100644
--- a/src/niepce/ui/dialogs/preferencesdialog.hpp
+++ b/src/niepce/ui/dialogs/preferencesdialog.hpp
@@ -35,7 +35,7 @@ public:
     virtual void setup_widget();
 
 private:
-    fwk::TextPairTreeviewModel m_theme_combo_model;
+    fwk::TextPairModelRecord m_theme_combo_model;
 };
 
 



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