Source

lrc / src / gui / ButtonHandlers.cxx

Diff from to

File src/gui/ButtonHandlers.cxx

 #include <gtkmm/stock.h>
 #include <gtkmm/treeview.h>
 #include "ButtonHandlers.hxx"
-#include "../include/CompressDecompress.hxx"
-#include "../include/EncryptDecrypt.hxx"
+#include "EditDialog.hxx"
 
 
-void ButtonHandlers::setupEditDialog(Gtk::TreeModel::Row p_row)
-{
-	Gtk::Entry *edResID;
-	Gtk::Entry *edResFilename;
-	Gtk::Entry *edResPassword;
-	Glib::ustring compTypeName;
-	Glib::ustring encTypeName;
-
-
-	if (!m_editDialog) {
-		return;
-	};
-
-	m_refBuilder->get_widget("edID", edResID);
-	edResID->set_text(p_row[m_resColModel->FUniqueResID]);
-
-	m_refBuilder->get_widget("edFilename", edResFilename);
-	edResFilename->set_text(p_row[m_resColModel->FResFilename]);
-
-	compTypeName = p_row[m_resColModel->FCompressTypeName];
-	m_compSelect->set_active(this->compNameToIndex(compTypeName.c_str()));
-
-	encTypeName = p_row[m_resColModel->FEncryptTypeName];
-	m_encSelect->set_active(this->encNameToIndex(encTypeName.c_str()));
-
-	m_refBuilder->get_widget("edPassword", edResPassword);
-	edResPassword->set_text(p_row[m_resColModel->FEncPassword]);
-}
-
-inline int ButtonHandlers::compNameToIndex(const char *p_compName)
-{
-	if (strcmp("None", p_compName) == 0) {
-		return 0;
-	};
-
-	for (int iter = lrc::NoneCompression; iter < lrc::lastCompression; iter++) {
-		if (strcmp(lrc::CompressionTypeNames[iter], p_compName) == 0) {
-			return iter;
-		};
-	};
-
-	return 0;
-}
-
-inline int ButtonHandlers::encNameToIndex(const char *p_encName)
-{
-	if (strcmp("None", p_encName) == 0) {
-		return 0;
-	};
-
-	for (int iter = lrc::NoneEncryption; iter < lrc::lastEncryption; iter++) {
-		if (strcmp(lrc::EncryptionTypeNames[iter], p_encName) == 0) {
-			return iter;
-		};
-	};
-
-	return 0;
-}
-
 void ButtonHandlers::on_add_button_clicked(void)
 {
 	int dlgRet;
 
 	for (auto eachPath : selectedRows) {
 		currentRow = m_listHandler->getResourceEntry(eachPath);
-		this->setupEditDialog(currentRow);
-		dlgRet = m_editDialog->run();
-		m_editDialog->hide();
+		dlgRet = m_editDlg->show_dialog(currentRow);
 	};
 }
 
 
 
 	m_refBuilder = p_refBuilder;
-	m_resColModel = p_resColModel;
 
 	p_refBuilder->get_widget("bnAdd", m_addButton);
 	m_addButton->signal_clicked().connect(sigc::mem_fun(*this,
 	anyFile->add_pattern("*");
 	m_addFilesDlg->add_filter(anyFile);
 
-	p_refBuilder->get_widget("dlgEdit", m_editDialog);
+	m_listHandler = nullptr;
 
-	p_refBuilder->get_widget("cbxCompression", m_compSelect);
-	for (unsigned int iter = lrc::NoneCompression; iter < lrc::lastCompression; iter++) {
-		m_compSelect->append(lrc::CompressionTypeNames[iter]);
-	};
-	m_compSelect->set_active(0);
-
-	p_refBuilder->get_widget("cbxEncryption", m_encSelect);
-	for (unsigned int iter = lrc::NoneEncryption; iter < lrc::lastEncryption; iter++) {
-		m_encSelect->append(lrc::EncryptionTypeNames[iter]);
-	};
-	m_encSelect->set_active(0);
-
-	m_listHandler = nullptr;
+	m_editDlg = new EditDialog(p_refBuilder, p_resColModel);
 }
 
 ButtonHandlers::~ButtonHandlers(void)
 {
-	delete m_encSelect;
-	delete m_compSelect;
-	delete m_editDialog;
+	delete m_editDlg;
 	delete m_addFilesDlg;
 	delete m_editButton;
 	delete m_removeButton;