Source

lrc / src / gui / MainWindow.cxx

Diff from to

src/gui/MainWindow.cxx

 
 
 #include <gtkmm/treeview.h>
+#include <gtkmm/cellrenderercombo.h>
 #include "../include/CompressDecompress.hxx"
 #include "../include/EncryptDecrypt.hxx"
 #include "MainWindow.hxx"
 #include "AddRemoveHandlers.hxx"
+#include "ComboModels.hxx"
 #include "ResColumnModel.hxx"
 
 #ifdef HAVE_CONFIG_H
 {
 	Gtk::TreeView *resFileView;
 	Gtk::TreeModel::Row aRow;
+	Gtk::TreeView::Column *compCol;
+	Gtk::TreeView::Column *encCol;
+	Gtk::CellRendererCombo *compRenderer;
+	Gtk::CellRendererCombo *encRenderer;
 
 
 	m_mainWindow = p_mainWin;
 	m_refBuilder = p_refBuilder;
 
+	m_resColModel = new ResColumnModel();
+	m_listResFiles = Gtk::ListStore::create(*m_resColModel);
 	m_addRemove = new AddRemoveHandlers(m_refBuilder);
+	m_listHandler = new ListHandler(m_listResFiles, m_resColModel);
+	m_addRemove->setListHandler(m_listHandler);
 
-	m_compColModel = new CompTypeModelColumns();
-	m_listCompTypes = Gtk::ListStore::create(*m_compColModel);
+	m_listCompTypes = Gtk::ListStore::create(*m_listHandler->FCompColModel);
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "Keine";
-	aRow[m_compColModel->FCompTypeData] = lrc::NoneCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "Keine";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::NoneCompression;
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "zLib";
-	aRow[m_compColModel->FCompTypeData] = lrc::zLibCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "zLib";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::zLibCompression;
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "bzip2";
-	aRow[m_compColModel->FCompTypeData] = lrc::bz2LibCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "bzip2";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::bz2LibCompression;
 
-	m_encColModel = new EncTypeModelColumns();
-	m_listEncTypes = Gtk::ListStore::create(*m_encColModel);
+	m_listEncTypes = Gtk::ListStore::create(*m_listHandler->FEncColModel);
 	aRow = *(m_listEncTypes->append());
-	aRow[m_encColModel->FEncTypeName] = "Keine";
-	aRow[m_encColModel->FEncTypeData] = lrc::NoneEncryption;
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Keine";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::NoneEncryption;
 #ifndef NO_ENCRYPTION
 	aRow = *(m_listEncTypes->append());
-	aRow[m_encColModel->FEncTypeName] = "Serpent";
-	aRow[m_encColModel->FEncTypeData] = lrc::SerpentEncryption;
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Serpent";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::SerpentEncryption;
 #endif
 
-	m_resColModel = new ResColumnModel();
-	m_listResFiles = Gtk::ListStore::create(*m_resColModel);
 	m_refBuilder->get_widget("resTreeView", resFileView);
 	resFileView->set_model(m_listResFiles);
 
 	resFileView->append_column_editable("Resource ID", m_resColModel->FUniqueResID);
 	resFileView->append_column("Dateiname", m_resColModel->FResFilename);
-	resFileView->append_column("Komprimierung", m_resColModel->FCompressType);
+	//resFileView->append_column("Komprimierung", m_resColModel->FCompressTypeName);
+	compCol = Gtk::manage(new Gtk::TreeView::Column("Komprimierung"));
+	compRenderer = Gtk::manage(new Gtk::CellRendererCombo);
+	compCol->pack_start(*compRenderer);
+	resFileView->append_column(*compCol);
+#ifdef GLIBMM_PROPERTIES_ENABLED
+	compCol->add_attribute(compRenderer->property_text(), m_resColModel->FCompressTypeName);
+#else
+	compCol->add_ttribute(*compRenderer, "Keine", m_resColModel->FCompressTypeName);
+#endif /* GLIBMM_PROPERTIES_ENABLED */
+
 #ifndef NO_ENCRYPTION
-	resFileView->append_column("Verschlüsselung", m_resColModel->FEncryptType);
+	//resFileView->append_column("Verschlüsselung", m_resColModel->FEncryptTypeName);
+	encCol = Gtk::manage(new Gtk::TreeView::Column("Verschlüsselung"));
+	encRenderer = Gtk::manage(new Gtk::CellRendererCombo);
+	encCol->pack_start(*encRenderer);
+	resFileView->append_column(*encCol);
+#ifdef GLIBMM_PROPERTIES_ENABLED
+	encCol->add_attribute(encRenderer->property_text(), m_resColModel->FEncryptTypeName);
+#else
+	encCol->add_ttribute(*encRenderer, "Keine", m_resColModel->FEncryptTypeName);
+#endif /* GLIBMM_PROPERTIES_ENABLED */
 	resFileView->append_column_editable("Passwort", m_resColModel->FEncPassword);
-#endif
-
-	m_listHandler = new ListHandler(m_listResFiles, m_resColModel);
-	m_addRemove->setListHandler(m_listHandler);
+#endif /* NO_ENCRYPTION */
 }
 
 MainWindow::~MainWindow()
 	delete m_resColModel;
 	delete m_addRemove;
 
+	//m_refBuilder = nullptr;
 	m_mainWindow = nullptr;
 }