Source

lrc / src / gui / AddRemoveHandlers.cxx

Full commit
/*
 * 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 "AddRemoveHandlers.hxx"


void AddRemoveHandlers::on_add_button_clicked(void)
{
	int dlgRet;


	dlgRet = m_addFilesDlg->run();
	m_addFilesDlg->hide();
}

void AddRemoveHandlers::on_remove_button_clicked(void)
{
}

AddRemoveHandlers::AddRemoveHandlers(Glib::RefPtr<Gtk::Builder> p_refBuilder)
{
	Gtk::Window *mainWin;
	Glib::RefPtr<Gtk::FileFilter> anyFile = Gtk::FileFilter::create();


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

AddRemoveHandlers::~AddRemoveHandlers(void)
{
	delete m_addFilesDlg;
	delete m_removeButton;
	delete m_addButton;
}