Commits

Andreas Tscharner  committed 0fd4d8e

gui: Prepare for ComboBox for compression and encryption

* Create new columns for combo boxes
* Create and fill the list stores for new combo boxes

  • Participants
  • Parent commits 9b69b17

Comments (0)

Files changed (5)

File src/gui/ComboModels.cxx

+/*
+ * ComboModels.cxx
+ *
+ * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+
+#include "ComboModels.hxx"
+
+
+CompTypeModelColumns::CompTypeModelColumns()
+{
+	this->add(FCompTypeName);
+	this->add(FCompTypeData);
+}
+
+
+EncTypeModelColumns::EncTypeModelColumns()
+{
+	this->add(FEncTypeName);
+	this->add(FEncTypeData);
+}

File src/gui/ComboModels.hxx

+/*
+ * ComboModels.hxx
+ *
+ * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+
+/*! \file ComboModels.hxx
+ *
+ * This file contains the declaration of the models of both combo boxes,
+ * the compression type combo and the encryption type combo
+ *
+ * \author Andreas Tscharner
+ * \date 2012-09-01
+ */
+
+
+#ifndef __COMBOMODELS_HXX__
+#define __COMBOMODELS_HXX__
+
+
+#include <gtkmm/treemodelcolumn.h>
+#include "../include/CompressDecompress.hxx"
+#include "../include/EncryptDecrypt.hxx"
+
+
+/*! \class CompTypeModelColumns
+ *  \brief Column model for compression type combo box
+ *
+ * This class defines the columns for the compression type combo box
+ */
+class CompTypeModelColumns : public Gtk::TreeModelColumnRecord
+{
+	public:
+		Gtk::TreeModelColumn<Glib::ustring> FCompTypeName;           //!< Name of compression type
+		Gtk::TreeModelColumn<lrc::CompressionType> FCompTypeData;    //!< Actual type data of compression type
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor sets the columns for the compression type up
+		 */
+		CompTypeModelColumns();
+};
+
+/*! \class EncTypeModelColumns
+ *  \brief Column model for encryption type combo box
+ *
+ * This class defines the columns for the encryption type combo box
+ */
+class EncTypeModelColumns : public Gtk::TreeModelColumnRecord
+{
+	public:
+		Gtk::TreeModelColumn<Glib::ustring> FEncTypeName;            //!< Name of encryption type
+		Gtk::TreeModelColumn<lrc::EncryptionType> FEncTypeData;      //!< Actual type data of encryption type
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor sets the columns for the encryption type up
+		 */
+		EncTypeModelColumns();
+};
+
+
+#endif /* __COMBOMODELS_HXX__ */

File src/gui/MainWindow.cxx

 
 
 #include <gtkmm/treeview.h>
+#include "../include/CompressDecompress.hxx"
+#include "../include/EncryptDecrypt.hxx"
 #include "MainWindow.hxx"
 #include "AddRemoveHandlers.hxx"
 #include "ResColumnModel.hxx"
 MainWindow::MainWindow(Gtk::Window *p_mainWin, Glib::RefPtr<Gtk::Builder> p_refBuilder)
 {
 	Gtk::TreeView *resFileView;
+	Gtk::TreeModel::Row aRow;
 
 
 	m_mainWindow = p_mainWin;
 
 	m_addRemove = new AddRemoveHandlers(m_refBuilder);
 
+	m_compColModel = new CompTypeModelColumns();
+	m_listCompTypes = Gtk::ListStore::create(*m_compColModel);
+	aRow = *(m_listCompTypes->append());
+	aRow[m_compColModel->FCompTypeName] = "Keine";
+	aRow[m_compColModel->FCompTypeData] = lrc::NoneCompression;
+	aRow = *(m_listCompTypes->append());
+	aRow[m_compColModel->FCompTypeName] = "zLib";
+	aRow[m_compColModel->FCompTypeData] = lrc::zLibCompression;
+	aRow = *(m_listCompTypes->append());
+	aRow[m_compColModel->FCompTypeName] = "bzip2";
+	aRow[m_compColModel->FCompTypeData] = lrc::bz2LibCompression;
+
+	m_encColModel = new EncTypeModelColumns();
+	m_listEncTypes = Gtk::ListStore::create(*m_encColModel);
+	aRow = *(m_listEncTypes->append());
+	aRow[m_encColModel->FEncTypeName] = "Keine";
+	aRow[m_encColModel->FEncTypeData] = lrc::NoneEncryption;
+#ifndef NO_ENCRYPTION
+	aRow = *(m_listEncTypes->append());
+	aRow[m_encColModel->FEncTypeName] = "Serpent";
+	aRow[m_encColModel->FEncTypeData] = lrc::SerpentEncryption;
+#endif
+
 	m_resColModel = new ResColumnModel();
 	m_listResFiles = Gtk::ListStore::create(*m_resColModel);
 	m_refBuilder->get_widget("resTreeView", resFileView);

File src/gui/MainWindow.hxx

 /*
- * MainWindow.h
+ * MainWindow.hxx
  *
  * Copyright 2012 Andreas Tscharner <andy@vis.ethz.ch>
  *
  * classes
  *
  * \author Andreas Tscharner
- * \date 2012-07-29
+ * \date 2012-09-01
  */
 
 
 #include <gtkmm/liststore.h>
 #include "AddRemoveHandlers.hxx"
 #include "ResColumnModel.hxx"
+#include "ComboModels.hxx"
 #include "ListHandler.hxx"
 
 
 		Gtk::Window *m_mainWindow;     //!< Reference to main window class
 		Glib::RefPtr<Gtk::Builder> m_refBuilder;     //!< Reference to builder that created the UI from XML
 		Glib::RefPtr<Gtk::ListStore> m_listResFiles; //!< Reference to list store for the main list view
+		Glib::RefPtr<Gtk::ListStore> m_listCompTypes;//!< Reference to list store for the compression types combo
+		Glib::RefPtr<Gtk::ListStore> m_listEncTypes; //!< Reference to list store for the encryption types combo
 
 		AddRemoveHandlers *m_addRemove;//!< Class instance to handle the "Add" and "Remove" button
 		ResColumnModel *m_resColModel; //!< Class that defines the column model for the list store
+		CompTypeModelColumns *m_compColModel; //!< Class that defines the column model for the compression type list store
+		EncTypeModelColumns *m_encColModel; //!< Class that defines the column model for the encryption type list store
 		ListHandler *m_listHandler;    //!< Class for handling the list in the view
 
 	public:

File src/gui/Makefile.am

 lrcResourceEditor_SOURCES = MainWindow.hxx MainWindow.cxx               \
                             AddRemoveHandlers.hxx AddRemoveHandlers.cxx \
                             ResColumnModel.hxx ResColumnModel.cxx       \
+                            ComboModels.hxx ComboModels.cxx             \
                             ListHandler.hxx ListHandler.cxx             \
                             lrcResourceEditor.cxx