Commits

Andreas Tscharner committed 52cd896 Merge

Merge with gui branch

Comments (0)

Files changed (18)

admin/Resources.txt

+Resources (might be useful for lrc
+==================================
+
+Embedding data directly into executable
+---------------------------------------
+http://www.linuxjournal.com/content/embedding-file-executable-aka-hello-world-version-5967
 src/example/ShowImage
 src/example/PlaySound
 
+# src/gui/ directory
+src/gui/lrcResourceEditor
+
 # src/strategies/cryptopp/ directory
 src/strategies/cryptopp/libcryptopp.a
 PKG_CHECK_EXISTS([tinyxml], [TINYXML_ok="yes"], [TINYXML_ok="no (using internal)"])
 PKG_CHECK_EXISTS([libcryptopp], [CRYPTOPP_ok="yes"], [CRYPTOPP_ok="no (using internal)"])
 PKG_CHECK_EXISTS([libcrypto++], [PPCRYPTO_ok="yes"], [PPCRYPTO_ok="no (using internal)"])
+PKG_CHECK_MODULES([GUI_DEPS],
+                  [glibmm-2.4 >= 2.32.0 gtkmm-3.0 >= 3.4.0],
+                  [GUI_DEPS_ok="yes"],
+                  [GUI_DEPS_ok="no (do not build the gui"])
 
 #
 # Check for header files
 if test "$LRC_ENCRYPTION" != yes; then
   AC_DEFINE([NO_ENCRYPTION], [], [Disable encryption])
 fi
+AC_ARG_ENABLE(gui,
+              AC_HELP_STRING([--disable-gui], [Do not build the lrc Resource Editor]),
+              [LRC_GUI="no"],)
+AM_CONDITIONAL([NO_GUI], [test "$LRC_GUI" = no || test "$GUI_DEPS_ok" != yes])
+
 AM_CONDITIONAL(HAVE_DOXYGEN, test "$doxy_ok" = yes)
-AM_CONDITIONAL(HAVE_ZLIB, test "$zLib_ok" = yes)
 AM_CONDITIONAL(HAVE_ALL_SDL, test "$SDL_ok" = yes && test "$SDLIMAGE_ok" = yes)
 AM_CONDITIONAL(HAVE_TINYXML, test "$TINYXML_ok" = yes)
 AM_CONDITIONAL(HAVE_CRYPTOPP, test "$CRYPTOPP_ok" = yes || test "$PPCRYPTO_ok" = yes)
                 src/compiler/Makefile         \
                 src/compiler/tinyxml/Makefile \
                 src/example/Makefile          \
+                src/gui/Makefile              \
                 src/lib/Makefile              \
                 src/pkgconfig/liblrc.pc       \
                 src/strategies/Makefile       \
 # Define all subdirectories
 SUBDIRS = strategies compiler lib example
 
+if !NO_GUI
+SUBDIRS += gui
+endif
+
 #
 # Add header files for compression and encryption classes
 noinst_HEADERS = include/CompressDecompress.hxx include/EncryptDecrypt.hxx

src/gui/AddRemoveHandlers.cxx

+/*
+ * AddRemoveHandlers.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 <gtkmm/builder.h>
+#include <gtkmm/button.h>
+#include <gtkmm/stock.h>
+#include <gtkmm/treeview.h>
+#include "AddRemoveHandlers.hxx"
+
+
+void AddRemoveHandlers::on_add_button_clicked(void)
+{
+	int dlgRet;
+
+
+	dlgRet = m_addFilesDlg->run();
+	if (dlgRet == Gtk::RESPONSE_OK) {
+		if (m_listHandler) {
+			m_listHandler->newFilesAdded(m_addFilesDlg->get_filenames());
+		};
+	};
+	m_addFilesDlg->hide();
+}
+
+void AddRemoveHandlers::on_remove_button_clicked(void)
+{
+	Gtk::TreeView *resFileView;
+	Glib::RefPtr<Gtk::TreeSelection> selectedRes;
+
+
+	m_refBuilder->get_widget("resTreeView", resFileView);
+	selectedRes = resFileView->get_selection();
+	m_listHandler->removeSelected(selectedRes);
+}
+
+AddRemoveHandlers::AddRemoveHandlers(Glib::RefPtr<Gtk::Builder> p_refBuilder)
+{
+	Gtk::Window *mainWin;
+	Glib::RefPtr<Gtk::FileFilter> anyFile = Gtk::FileFilter::create();
+
+
+	m_refBuilder = p_refBuilder;
+
+	p_refBuilder->get_widget("bnAdd", m_addButton);
+	m_addButton->signal_clicked().connect(sigc::mem_fun(*this,
+	                                         &AddRemoveHandlers::on_add_button_clicked));
+
+	p_refBuilder->get_widget("bnRemove", m_removeButton);
+	m_removeButton->signal_clicked().connect(sigc::mem_fun(*this,
+	                                            &AddRemoveHandlers::on_remove_button_clicked));
+
+	p_refBuilder->get_widget("MainWindow", mainWin);
+	m_addFilesDlg = new Gtk::FileChooserDialog(*mainWin, "Dateien für Resourcen auswählen",
+	                                           Gtk::FILE_CHOOSER_ACTION_OPEN);
+
+	m_addFilesDlg->set_select_multiple(true);
+	m_addFilesDlg->set_has_resize_grip(false);
+	m_addFilesDlg->set_create_folders(false);
+
+	m_addFilesDlg->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+	m_addFilesDlg->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
+
+	anyFile->set_name("Any file");
+	anyFile->add_pattern("*");
+	m_addFilesDlg->add_filter(anyFile);
+
+	m_listHandler = nullptr;
+}
+
+AddRemoveHandlers::~AddRemoveHandlers(void)
+{
+	delete m_addFilesDlg;
+	delete m_removeButton;
+	delete m_addButton;
+}
+
+int AddRemoveHandlers::setListHandler(ListHandler *p_listHandler)
+{
+	m_listHandler = p_listHandler;
+}

src/gui/AddRemoveHandlers.hxx

+/*
+ * AddRemoveHandlers.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 AddRemoveHandlers.hxx
+ *
+ * This file contains the AddRemoveHandlers class. This class is responsible
+ * for the actions if the user clicks the "Add" or "Remove" button on the
+ * main window
+ *
+ * \author Andreas Tscharner
+ * \date 2012-08-31
+ */
+
+
+#ifndef __ADDREMOVEHANDLERS_HXX__
+#define __ADDREMOVEHANDLERS_HXX__
+
+
+#include <gtkmm/button.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/filechooserdialog.h>
+#include "ListHandler.hxx"
+
+
+/*! \class AddRemoveHandlers
+ *  \brief Class to handle the two main buttons
+ *
+ * Class that handles the clicks on the "Add" and the "Remove" button on the
+ * main window
+ */
+class AddRemoveHandlers
+{
+	private:
+		Glib::RefPtr<Gtk::Builder> m_refBuilder; //!< Reference to main builder
+		Gtk::Button *m_addButton;      //!< Reference to "Add" button
+		Gtk::Button *m_removeButton;   //!< Reference to "Remove" button
+		Gtk::FileChooserDialog *m_addFilesDlg;   //!< Reference to "Add Files" dialog
+		ListHandler *m_listHandler;    //!< Reference to (global) list handler class
+
+	protected:
+		/*! \brief Signal handler for "Add" button
+		 *
+		 * This method is the actual signal handler for the "Add" button. It
+		 * shows the file selection window and adds all selected files to
+		 * the list of resource files
+		 */
+		void on_add_button_clicked(void);
+		/*! \brief Signal handler for "Remove" button
+		 *
+		 * This method is the actual sognal handler for the "Remove" button.
+		 * It removes all selected files from the list of resource files.
+		 */
+		void on_remove_button_clicked(void);
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor connects the "clicked" signals of the "Add" and
+		 * "Remove" buttons with the corresponding singnal handler methods
+		 *
+		 * \param[in] p_refBuilder Reference to the builder that loaded the
+		 *                         glade GUI file
+		 */
+		AddRemoveHandlers(Glib::RefPtr<Gtk::Builder>);
+		/*! \brief Destructor
+		 *
+		 * Frees all the used memory
+		 */
+		~AddRemoveHandlers(void);
+
+		/*! \brief Set instance of list handler
+		 *
+		 * This method is used to provide a ListHandler instance for this
+		 * class. It should be used by the MainWindow constructor
+		 *
+		 * \retval NO_ERROR Instance successfully set
+		 */
+		int setListHandler(ListHandler *);
+};
+
+
+#endif /* __ADDREMOVEHANDLERS_HXX__ */

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

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__ */

src/gui/ListHandler.cxx

+/*
+ * ListHandler.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 "../StatusCodes.hxx"
+#include "ListHandler.hxx"
+
+
+ListHandler::ListHandler(Glib::RefPtr<Gtk::ListStore> p_listResEntries, ResColumnModel *p_resColModel)
+{
+	m_listResEntries = p_listResEntries;
+	m_resColModel = p_resColModel;
+
+	FCompColModel = new CompTypeModelColumns();
+	FEncColModel = new EncTypeModelColumns();
+}
+
+ListHandler::~ListHandler()
+{
+	delete FEncColModel;
+	delete FCompColModel;
+}
+
+int ListHandler::newFilesAdded(std::vector<std::string> p_newFiles)
+{
+	std::string fileEntry;
+	Glib::ustring rowEntry;
+	Gtk::TreeModel::Children modelEntries = m_listResEntries->children();
+	Gtk::TreeModel::Children::iterator modelIter;
+	Gtk::TreeModel::Row singleRow;
+
+
+	for (int i=0; i<p_newFiles.size(); i++) {
+		fileEntry = p_newFiles.at(i);
+		for (modelIter = modelEntries.begin(); modelIter != modelEntries.end(); ++modelIter) {
+			singleRow = *modelIter;
+			rowEntry = singleRow[m_resColModel->FResFilename];
+
+			if (fileEntry.compare(rowEntry) == 0) {
+				p_newFiles.erase(p_newFiles.begin()+i);
+			};
+		};
+	};
+
+	for (auto singleEntry : p_newFiles) {
+		modelIter = m_listResEntries->append();
+		singleRow = *modelIter;
+
+		singleRow[m_resColModel->FUniqueResID] = "";
+		singleRow[m_resColModel->FResFilename] = singleEntry;
+		singleRow[m_resColModel->FCompressTypeName] = "Keine";
+//		singleRow[m_resColModel->FCompChoices] = FCompColModel;
+#ifndef NO_ENCRYPTION
+		singleRow[m_resColModel->FEncryptTypeName] = "Keine";
+//		singleRow[m_resColModel->FEncChoices] = FEncColModel;
+		singleRow[m_resColModel->FEncPassword] = "";
+#endif
+	};
+
+	return NO_ERROR;
+}
+
+int ListHandler::removeSelected(Glib::RefPtr<Gtk::TreeSelection> p_selection)
+{
+	std::vector<Gtk::TreeModel::Path> selectedRes;
+	Gtk::TreeModel::iterator selectedIter;
+
+
+	selectedRes = p_selection->get_selected_rows();
+	for (auto oneResPath : selectedRes) {
+		selectedIter = m_listResEntries->get_iter(oneResPath);
+		m_listResEntries->erase(selectedIter);
+	};
+
+	return NO_ERROR;
+}

src/gui/ListHandler.hxx

+/*
+ * ListHandler.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 ListHandler.hxx
+ *
+ * This file contains the definition of the ListHandler class. This class is
+ * responsible to manage the list in the TreeView, especially for adding and
+ * removing new entries
+ *
+ * \author Andreas Tscharner
+ * \date 2012-08-31
+ */
+
+
+#ifndef __LISTHANDLER_HXX__
+#define __LISTHANDLER_HXX__
+
+
+#include <gtkmm/liststore.h>
+#include <gtkmm/treeselection.h>
+#include "ComboModels.hxx"
+#include "ResColumnModel.hxx"
+
+
+/*! \class ListHandler
+ *  \brief Class to handle the list in the Gtk::TreeView
+ *
+ * This class handles the list in the Gtk::TreeView. It is especially
+ * responsible to add new entries to the list and remove the ones that are
+ * no longer used. Finally it provides the data as resource entries if the
+ * user selects "Save (as)"
+ */
+class ListHandler
+{
+	private:
+		Glib::RefPtr<Gtk::ListStore> m_listResEntries; //!< Reference to list store for the main list view
+		ResColumnModel *m_resColModel;                 //!< Class that defines the column model for the list store
+
+	public:
+		CompTypeModelColumns *FCompColModel;//!< Class that defines the column model for the compression type list store
+		EncTypeModelColumns *FEncColModel;  //!< Class that defines the column model for the encryption type list store
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor expects a reference to the list store and a
+		 * pointer to the instance of the column model
+		 *
+		 * \param[in] p_listResEntries Reference to TreeView ListStore
+		 * \param[in] p_resColModel Pointer to single instance of
+		 *            ResColumnModel
+		 */
+		ListHandler(Glib::RefPtr<Gtk::ListStore>, ResColumnModel *);
+		~ListHandler();
+
+		/*! \brief Add new files to TreeView
+		 *
+		 * This method adds the new (given) files into the TreeView. It
+		 * checks for duplicates and removes them if any
+		 *
+		 * \param[in] p_newFiles List of (new) files
+		 *
+		 * \retval NO_ERROR Files successfully added
+		 */
+		int newFilesAdded(std::vector<std::string>);
+
+		/*! \brief Remove the selected resource
+		 *
+		 * This method removes the currently selected resources from the list
+		 * without confirmation
+		 *
+		 * \param[in] p_selection Selection in view
+		 *
+		 * \retval NO_ERROR Resource successfully removed
+		 */
+		int removeSelected(Glib::RefPtr<Gtk::TreeSelection>);
+};
+
+
+#endif /* __LISTHANDLER_HXX__ */

src/gui/MainWindow.cxx

+/*
+ * MainWindow.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 <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
+#include "../lrc_config.h"
+#endif
+
+
+MainWindow::MainWindow(Gtk::Window *p_mainWin, Glib::RefPtr<Gtk::Builder> p_refBuilder)
+{
+	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_listCompTypes = Gtk::ListStore::create(*m_listHandler->FCompColModel);
+	aRow = *(m_listCompTypes->append());
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "Keine";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::NoneCompression;
+	aRow = *(m_listCompTypes->append());
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "zLib";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::zLibCompression;
+	aRow = *(m_listCompTypes->append());
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "bzip2";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::bz2LibCompression;
+
+	m_listEncTypes = Gtk::ListStore::create(*m_listHandler->FEncColModel);
+	aRow = *(m_listEncTypes->append());
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Keine";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::NoneEncryption;
+#ifndef NO_ENCRYPTION
+	aRow = *(m_listEncTypes->append());
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Serpent";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::SerpentEncryption;
+#endif
+
+	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->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->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 /* NO_ENCRYPTION */
+}
+
+MainWindow::~MainWindow()
+{
+	delete m_listHandler;
+	delete m_resColModel;
+	delete m_addRemove;
+
+	//m_refBuilder = nullptr;
+	m_mainWindow = nullptr;
+}

src/gui/MainWindow.hxx

+/*
+ * MainWindow.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 MainWindow.hxx
+ *
+ * This file contains the declaration of the MainWindow class. This class
+ * is responsible for all stuff of the main window.
+ * It may delegate some tasks (like the menu or the list view) to separate
+ * classes
+ *
+ * \author Andreas Tscharner
+ * \date 2012-09-01
+ */
+
+
+#ifndef __MAINWINDOW_HXX__
+#define __MAINWINDOW_HXX__
+
+
+// Include files
+#include <gtkmm/builder.h>
+#include <gtkmm/window.h>
+#include <gtkmm/liststore.h>
+#include "AddRemoveHandlers.hxx"
+#include "ResColumnModel.hxx"
+#include "ListHandler.hxx"
+
+
+/*! \class MainWindow
+ *  \brief Class to handle the main window
+ *
+ * This class handles all the stuff of the main window. It uses other
+ * classes to handle some special tasks (like the menu or the list view)
+ */
+class MainWindow
+{
+	private:
+		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
+		ListHandler *m_listHandler;    //!< Class for handling the list in the view
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor for the MainWindow class. It needs a pointer to
+		 * the window and a reference pointer to the glade file as parameters
+		 *
+		 * \param[in] p_mainWin Pointer to GTK window
+		 * \param[in] p_refBuilder Reference pointer to builder that loaded
+		 *                         the glade file
+		 */
+		MainWindow(Gtk::Window *, Glib::RefPtr<Gtk::Builder>);
+		/*! \brief Destructor
+		 *
+		 * The destructor cleans up any used memory from this class
+		 */
+		~MainWindow();
+};
+
+
+#endif /* __MAINWINDOW_HXX__ */

src/gui/Makefile.am

+#      Makefile.am
+#
+#      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 Lesser General Public License as
+#      published by the Free Software Foundation; either version 3 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 Lesser 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.
+
+
+#
+# Check for DEBUG mode
+if DEBUG
+DEBUG_CFLAGS = -D__DEBUG__
+DEBUG_CXXFLAGS = -D__DEBUG__
+else
+DEBUG_CFLAGS = -O2
+DEBUG_CXXFLAGS = -O2
+endif
+
+#
+# Define C/C++ compiler flags for libraries
+
+
+#
+# Define compiler flags
+AM_CFLAGS = $(DEBUG_CFLAGS) $(GUI_DEPS_CFLAGS)
+AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(GUI_DEPS_CFLAGS) -std=c++0x
+
+#
+# Define main program
+bin_PROGRAMS = lrcResourceEditor
+
+#
+# Define source files for main program
+lrcResourceEditor_SOURCES = MainWindow.hxx MainWindow.cxx               \
+                            AddRemoveHandlers.hxx AddRemoveHandlers.cxx \
+                            ResColumnModel.hxx ResColumnModel.cxx       \
+                            ComboModels.hxx ComboModels.cxx             \
+                            ListHandler.hxx ListHandler.cxx             \
+                            lrcResourceEditor.cxx
+
+#
+# Library flags for main program
+lrcResourceEditor_LDADD = $(GUI_DEPS_LIBS)
+lrcResourceEditor_LDFLAGS = -export-dynamic

src/gui/ResColumnModel.cxx

+/*
+ * ResColumnModel.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.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "../lrc_config.h"
+#endif
+#include "ResColumnModel.hxx"
+
+
+ResColumnModel::ResColumnModel()
+{
+	this->add(FUniqueResID);
+	this->add(FResFilename);
+	this->add(FCompressTypeName);
+	this->add(FCompChoices);
+#ifndef NO_ENCRYPTION
+	this->add(FEncryptTypeName);
+	this->add(FEncChoices);
+	this->add(FEncPassword);
+#endif
+}

src/gui/ResColumnModel.hxx

+/*
+ * ResColumnModel.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 ResColumnModel.hxx
+ *
+ * This file contains the declaration of the model for the list view (the
+ * main part of the main window).
+ *
+ * \author Andreas Tscharner
+ * \date 2012-09-02
+ */
+
+
+#ifndef __RESCOLUMNMODEL_HXX__
+#define __RESCOLUMNMODEL_HXX__
+
+
+#include <gtkmm/treemodelcolumn.h>
+#include <gtkmm/combobox.h>
+
+
+/*! \class ResColumnModel
+ *  \brief Column model for resources
+ *
+ * This class defines the column model for the list view of the main window.
+ * It takes also care whether or not --disable-encryption was set during the
+ * program configuration
+ */
+class ResColumnModel : public Gtk::TreeModelColumnRecord
+{
+	public:
+		Gtk::TreeModelColumn<Glib::ustring> FUniqueResID;            //!< ID for resource
+		Gtk::TreeModelColumn<Glib::ustring> FResFilename;            //!< Filename for resource
+		Gtk::TreeModelColumn<Glib::ustring> FCompressTypeName;       //!< Compression type for resource
+		Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel>> FCompChoices;  //!< Combobox to select compression
+		Gtk::TreeModelColumn<Glib::ustring> FEncryptTypeName;        //!< Encryption type for resource
+		Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel>> FEncChoices;   //!< Combobox to select encryption
+		Gtk::TreeModelColumn<Glib::ustring> FEncPassword;            //!< Password if resource is encrypted
+
+	public:
+		/*! \brief Constructor
+		 *
+		 * The constructor adds the columns to the column record
+		 */
+		ResColumnModel();
+};
+
+
+#endif /* __RESCOLUMNMODEL_HXX__ */

src/gui/ResourceEditor.glade

+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkWindow" id="MainWindow">
+    <property name="can_focus">False</property>
+    <property name="title" translatable="yes">lrc Resource Editor</property>
+    <property name="window_position">mouse</property>
+    <property name="default_width">440</property>
+    <property name="default_height">250</property>
+    <property name="icon">icon/lrc.png</property>
+    <property name="has_resize_grip">False</property>
+    <child>
+      <object class="GtkBox" id="box1">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkMenuBar" id="MainMenu">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkMenuItem" id="mainFile">
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Datei</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miNew">
+                        <property name="label">gtk-new</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miSave">
+                        <property name="label">gtk-save</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miSaveAs">
+                        <property name="label">gtk-save-as</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="sep1">
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miExit">
+                        <property name="label">gtk-quit</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mainEdit">
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Bearbeiten</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miCut">
+                        <property name="label">gtk-cut</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miCopy">
+                        <property name="label">gtk-copy</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miPaste">
+                        <property name="label">gtk-paste</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miDelete">
+                        <property name="label">gtk-delete</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mainView">
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Ansicht</property>
+                <property name="use_underline">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="mainHelp">
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Hilfe</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="miAbout">
+                        <property name="label">gtk-about</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkScrolledWindow" id="scrolledwindow1">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="shadow_type">in</property>
+            <child>
+              <object class="GtkTreeView" id="resTreeView">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="resTreeViewSelection"/>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="homogeneous">True</property>
+            <child>
+              <object class="GtkButton" id="bnAdd">
+                <property name="label">gtk-add</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="bnRemove">
+                <property name="label">gtk-remove</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>

src/gui/icon/lrc.png

Added
New image

src/gui/lrcResourceEditor.cxx

+/*
+ * lrcResourceEditor.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 3 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 <gtkmm/application.h>
+#include <gtkmm/builder.h>
+#include <gtkmm/window.h>
+#include <glibmm/fileutils.h>
+#include <glibmm/markup.h>
+#include <iostream>
+#include "MainWindow.hxx"
+
+int main(int argc, char **argv)
+{
+	Glib::RefPtr<Gtk::Application> mainApp;
+	Glib::RefPtr<Gtk::Builder> builder;
+	Gtk::Window *mainWin = nullptr;
+	MainWindow *mainWinTasks;
+
+
+	mainApp = Gtk::Application::create(argc, argv, "ch.blackmoon.lrcResEdit");
+	try {
+		builder = Gtk::Builder::create_from_file("ResourceEditor.glade");
+	} catch (const Glib::FileError &fErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a FileError: " << fErr.what() << std::endl;
+		return -1;
+	} catch (const Glib::MarkupError &mErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a MarkupError: " << mErr.what() << std::endl;
+		return -1;
+	} catch (const Gtk::BuilderError &bErr) {
+		std::cout << "Loading the ResourceEditor.glade failed with a BuilderError: " << bErr.what() << std::endl;
+		return -1;
+	};
+
+	builder->get_widget("MainWindow", mainWin);
+	mainWinTasks = new MainWindow(mainWin, builder);
+
+	mainApp->run(*mainWin);
+
+	delete mainWinTasks;
+	delete mainWin;
+
+	return 0;
+}
+