Source

lrc / 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 "../include/CompressDecompress.hxx"
#include "../include/EncryptDecrypt.hxx"
#include "MainWindow.hxx"
#include "AddRemoveHandlers.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;


	m_mainWindow = p_mainWin;
	m_refBuilder = p_refBuilder;

	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);
	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->FCompressType);
#ifndef NO_ENCRYPTION
	resFileView->append_column("Verschlüsselung", m_resColModel->FEncryptType);
	resFileView->append_column_editable("Passwort", m_resColModel->FEncPassword);
#endif

	m_listHandler = new ListHandler(m_listResFiles, m_resColModel);
	m_addRemove->setListHandler(m_listHandler);
}

MainWindow::~MainWindow()
{
	delete m_listHandler;
	delete m_resColModel;
	delete m_addRemove;

	m_mainWindow = nullptr;
}