Andreas Tscharner avatar Andreas Tscharner committed c46ec09

Small refactoring of show_dialog

Also connected the on_change signal of the drop down menu

Comments (0)

Files changed (2)

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)
+{
+}

src/gui/EditDialog.hxx

  * logic for the edit dialog of one entry
  *
  * \author Andreas Tscharner
- * \date 2013-07-10
+ * \date 2013-08-24
  */
 
 
 		 */
 		inline int encNameToIndex(const char *);
 
+		/*! \brief Set the values for the dialog up
+		 *
+		 * This method sets up the dialog with the given values to edit
+		 *
+		 * \param[in] p_row Row containing the values to edit
+		 */
+		void SetUpValues(Gtk::TreeModel::Row);
+
 	protected:
 		/*! \brief Signal handler for changed encryption combo box
 		 *
 		 * \return Value of clicked button
 		 */
 		int show_dialog(Gtk::TreeModel::Row);
+
+		/*! \brief Gets the edited values from  the dialog
+		 *
+		 * This method gets the edited values from the dialog and uses
+		 * them to update the list model
+		 *
+		 * \param[in] p_row Row to put the edited values
+		 */
+		void GetEditedValues(Gtk::TreeModel::Row);
 };
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.