Source

lrc / src / gui / EditDialog.cxx

Diff from to

src/gui/EditDialog.cxx

 
 
 #include "EditDialog.hxx"
+#include "Utils.hxx"
 #include "../include/CompressDecompress.hxx"
 #include "../include/EncryptDecrypt.hxx"
 
 	return 0;
 }
 
-
-void EditDialog::on_enc_combo_changed(void)
-{
-	Gtk::Entry *edResPassword;
-
-
-	m_refBuilder->get_widget("edPassword", edResPassword);
-//	edResPassword->set_editable(this->encNameToIndex(encTypeName.c_str()) > lrc::NoneEncryption);
-}
-
-
-EditDialog::EditDialog(Glib::RefPtr<Gtk::Builder> p_refBuilder, ResColumnModel *p_resColModel)
-{
-	m_refBuilder = p_refBuilder;
-	m_resColModel = p_resColModel;
-
-	m_refBuilder->get_widget("dlgEdit", m_editDialog);
-
-	p_refBuilder->get_widget("cbxCompression", m_compSelect);
-	for (unsigned int iter = lrc::NoneCompression; iter < lrc::lastCompression; iter++) {
-		m_compSelect->append(lrc::CompressionTypeNames[iter]);
-	};
-
-	p_refBuilder->get_widget("cbxEncryption", m_encSelect);
-	for (unsigned int iter = lrc::NoneEncryption; iter < lrc::lastEncryption; iter++) {
-		m_encSelect->append(lrc::EncryptionTypeNames[iter]);
-	};
-}
-
-EditDialog::~EditDialog(void)
-{
-	delete m_encSelect;
-	delete m_compSelect;
-	delete m_editDialog;
-}
-
-int EditDialog::show_dialog(Gtk::TreeModel::Row p_row)
+void EditDialog::SetUpValues(Gtk::TreeModel::Row p_row)
 {
 	Gtk::Entry *edResID;
 	Gtk::Entry *edResFilename;
 	Gtk::Entry *edResPassword;
 	Glib::ustring compTypeName;
 	Glib::ustring encTypeName;
-	int retVal;
 
 
-	if (!this->m_editDialog)
-		return -1;
-
 	this->m_compSelect->set_active(0);
 	this->m_encSelect->set_active(0);
 
 		edResPassword->set_text(p_row[this->m_resColModel->FEncPassword]);
 	};
 	edResPassword->set_editable(this->encNameToIndex(encTypeName.c_str()) > lrc::NoneEncryption);
+}
+
+
+void EditDialog::on_enc_combo_changed(void)
+{
+	Gtk::TreeModel::iterator activeEncIter;
+	Gtk::TreeModel::Row activeEncRow;
+	Gtk::Entry *edResPassword;
+	Glib::ustring encTypeName;
+
+
+	DEBUG_PRINT(("on_enc_combo_changed starts\n"))
+	activeEncIter = this->m_encSelect->get_active();
+	if (!activeEncIter)
+		return;
+
+	DEBUG_PRINT(("We have an active encryption iterator..."))
+	activeEncRow = *activeEncIter;
+	if (!activeEncRow)
+		return;
+
+	DEBUG_PRINT((" and a corresponding row\n"))
+	DEBUG_PRINT(("this->m_resColModel->FEncryptTypeName: %s\n", this->m_resColModel->FEncryptTypeName))
+	encTypeName = activeEncRow[this->m_resColModel->FEncryptTypeName];
+	m_refBuilder->get_widget("edPassword", edResPassword);
+	edResPassword->set_editable(this->encNameToIndex(encTypeName.c_str()) > lrc::NoneEncryption);
+
+	DEBUG_PRINT(("on_enc_combo_changed ends. New encryption: %s\n", encTypeName.c_str()))
+}
+
+
+EditDialog::EditDialog(Glib::RefPtr<Gtk::Builder> p_refBuilder, ResColumnModel *p_resColModel)
+{
+	m_refBuilder = p_refBuilder;
+	m_resColModel = p_resColModel;
+
+	m_refBuilder->get_widget("dlgEdit", m_editDialog);
+
+	p_refBuilder->get_widget("cbxCompression", m_compSelect);
+	for (unsigned int iter = lrc::NoneCompression; iter < lrc::lastCompression; iter++) {
+		m_compSelect->append(lrc::CompressionTypeNames[iter]);
+	};
+
+	p_refBuilder->get_widget("cbxEncryption", m_encSelect);
+	for (unsigned int iter = lrc::NoneEncryption; iter < lrc::lastEncryption; iter++) {
+		m_encSelect->append(lrc::EncryptionTypeNames[iter]);
+	};
+	this->m_encSelect->signal_changed().connect(sigc::mem_fun(*this, &EditDialog::on_enc_combo_changed));
+}
+
+EditDialog::~EditDialog(void)
+{
+	delete m_encSelect;
+	delete m_compSelect;
+	delete m_editDialog;
+}
+
+int EditDialog::show_dialog(Gtk::TreeModel::Row p_row)
+{
+	int retVal;
+
+
+	if (!this->m_editDialog)
+		return -1;
+
+	this->SetUpValues(p_row);
 
 	retVal = this->m_editDialog->run();
 	this->m_editDialog->hide();
 
 	return retVal;
 }
+
+void EditDialog::GetEditedValues(Gtk::TreeModel::Row p_row)
+{
+}