<commit_before>#include "gui.h"

GUI::GUI(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade)
	: Gtk::Window(cobject),
	mrp_Glade(refGlade),
	m_uiFilterFrame(refGlade),
	mp_AnimalsTree(0)
{
	uiReady = false;
	db = NULL;

	set_title("Spike Database - No database open");

	// Initialize the toolbar
	this->init_toolbar();

	// Initalize the statusbar
	mrp_Glade->get_widget("statusbar", mp_Statusbar);

	// Setup the filter frame
	m_uiFilterFrame.signal_changed().connect(sigc::mem_fun(*this, &GUI::on_filter_changed));
	if (settings.get_int("filterMinFiles") != 0) {
		m_uiFilterFrame.minFiles(settings.get_double("filterMinFiles"));
	} else { 
		settings.set("filterMinFiles", m_uiFilterFrame.minFiles());
	}


	// Create the plots
	mp_PlotSpikes = Gtk::manage(new EasyPlotmm());
	mp_PlotMeans = Gtk::manage(new EasyPlotmm());
	mp_PlotAnalyze = Gtk::manage(new EasyPlotmm());

	// Setup the animal details table
	Gtk::VBox* mp_AnimalDetailsVBox = Gtk::manage(new Gtk::VBox());
	Gtk::Alignment* mp_AlignAnimalDetails; /**< Container for the animal details property table. */
	mrp_Glade->get_widget("alignAnimalDetails", mp_AlignAnimalDetails);
	mp_AlignAnimalDetails->add(*mp_AnimalDetailsVBox);
	mp_AnimalDetailsVBox->pack_start(m_uiAnimalDetails);
	mp_AnimalDetailsVBox->pack_start(m_AnimalTags);
	m_AnimalTags.set_parent(this);
	m_uiAnimalDetails.signal_rowedited().connect(sigc::mem_fun(*this, &GUI::on_animaldetails_edited));
	m_AnimalTags.signal_deleted().connect(sigc::mem_fun(*this, &GUI::on_animal_tag_deleted));
	m_AnimalTags.signal_added().connect(sigc::mem_fun(*this, &GUI::on_animal_tag_added));
	
	// Setup the cell details table
	Gtk::VBox* mp_CellDetailsVBox = Gtk::manage(new Gtk::VBox());
	Gtk::ScrolledWindow* mp_ScrolledCellDetails = Gtk::manage(new Gtk::ScrolledWindow); /**< Container for the cell details property table. */
	mp_ScrolledCellDetails->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	Gtk::Alignment* mp_AlignCellDetails; /**< Container for the animal details property table. */
	mrp_Glade->get_widget("alignCellDetails", mp_AlignCellDetails);
	mp_AlignCellDetails->add(*mp_ScrolledCellDetails);
	mp_ScrolledCellDetails->add(*mp_CellDetailsVBox);
	mp_CellDetailsVBox->pack_start(m_uiCellDetails);
	mp_CellDetailsVBox->pack_start(m_CellTags);
	m_CellTags.set_parent(this);
	m_uiCellDetails.signal_rowedited().connect(sigc::mem_fun(*this, &GUI::on_celldetails_edited));
	m_CellTags.signal_deleted().connect(sigc::mem_fun(*this, &GUI::on_cell_tag_deleted));
	m_CellTags.signal_added().connect(sigc::mem_fun(*this, &GUI::on_cell_tag_added));

	// Animals treeview 
	// Shown on left side under filter frame
	mrp_Glade->get_widget("tvAnimals", mp_AnimalsTree);
	mrp_AnimalTree = Gtk::TreeStore::create(m_AnimalColumns);
	mp_AnimalsTree->set_model(mrp_AnimalTree);
	mp_AnimalsTree->append_column("Animal/Cell ID", m_AnimalColumns.m_col_name);
	mrp_AnimalTree->set_sort_column(m_AnimalColumns.m_col_name, Gtk::SORT_ASCENDING);
	mrp_AnimalTree->set_sort_func(0, sigc::mem_fun(*this, &GUI::on_animal_sort));
	mrp_AnimalSelection = mp_AnimalsTree->get_selection();
	mrp_AnimalSelection->signal_changed().connect(sigc::mem_fun(*this, &GUI::changeAnimalSelection));

	// Create Files Details TreeView
	mp_FileDetailsTree = Gtk::manage( new uiFileDetailsTreeView(&db,this) );
	Gtk::ScrolledWindow* p_swFileDetails; 
	mrp_Glade->get_widget("swFileDetails", p_swFileDetails);
	p_swFileDetails->add(*mp_FileDetailsTree);
	mp_FileDetailsTree->treeSelection()->signal_changed().connect(sigc::mem_fun(*this, &GUI::on_filedetails_selection_changed));
	mp_FileDetailsTree->signal_file_set_hidden().connect(sigc::mem_fun(*this, &GUI::on_filedetails_set_hidden));

	// Setup the analyze widgets
	mrp_Glade->get_widget("vboxAnalyze", mp_VBoxAnalyze);
	mrp_Glade->get_widget("cbDataSource", mp_DataSource);
	mrp_Glade->get_widget("cbXVar", mp_XVar);
	mrp_Glade->get_widget("cbYVar", mp_YVar);
	mrp_DataSource = Gtk::ListStore::create(m_DataSourceColumns);
	mrp_XVar = Gtk::ListStore::create(m_XVarColumns);
	mrp_YVar = Gtk::ListStore::create(m_YVarColumns);
	mp_DataSource->set_model(mrp_DataSource);
	mp_XVar->set_model(mrp_XVar);
	mp_YVar->set_model(mrp_YVar);
	mp_DataSource->pack_start(m_DataSourceColumns.m_col_name);
	mp_XVar->pack_start(m_XVarColumns.m_col_name);
	mp_YVar->pack_start(m_YVarColumns.m_col_name);
	mp_DataSource->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	mp_XVar->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	mp_YVar->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	Gtk::TreeModel::Row row = *(mrp_DataSource->append());
	row[m_DataSourceColumns.m_col_name] = "Animals";
	row = *(mrp_DataSource->append());
	row[m_DataSourceColumns.m_col_name] = "Cells";<commit_msg>Starting to phase out glade<commit_after>#include "gui.h"

GUI::GUI(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& refGlade)
	: Gtk::Window(cobject),
	mrp_Glade(refGlade),
	m_uiFilterFrame(refGlade),
	mp_AnimalsTree(0)
{
	uiReady = false;
	db = NULL;

	set_title("Spike Database - No database open");

	// Initialize the toolbar
	this->init_toolbar();

	// Initalize the statusbar
	mrp_Glade->get_widget("statusbar", mp_Statusbar);

	// Setup the filter frame
	m_uiFilterFrame.signal_changed().connect(sigc::mem_fun(*this, &GUI::on_filter_changed));
	if (settings.get_int("filterMinFiles") != 0) {
		m_uiFilterFrame.minFiles(settings.get_double("filterMinFiles"));
	} else { 
		settings.set("filterMinFiles", m_uiFilterFrame.minFiles());
	}


	// Create the plots
	mp_PlotSpikes = Gtk::manage(new EasyPlotmm());
	mp_PlotMeans = Gtk::manage(new EasyPlotmm());
	mp_PlotAnalyze = Gtk::manage(new EasyPlotmm());

	// Setup the animal details table
	Gtk::VBox* mp_AnimalDetailsVBox = Gtk::manage(new Gtk::VBox());
	Gtk::Alignment* mp_AlignAnimalDetails; /**< Container for the animal details property table. */
	mrp_Glade->get_widget("alignAnimalDetails", mp_AlignAnimalDetails);
	mp_AlignAnimalDetails->add(*mp_AnimalDetailsVBox);
	mp_AnimalDetailsVBox->pack_start(m_uiAnimalDetails);
	mp_AnimalDetailsVBox->pack_start(m_AnimalTags);
	m_AnimalTags.set_parent(this);
	m_uiAnimalDetails.signal_rowedited().connect(sigc::mem_fun(*this, &GUI::on_animaldetails_edited));
	m_AnimalTags.signal_deleted().connect(sigc::mem_fun(*this, &GUI::on_animal_tag_deleted));
	m_AnimalTags.signal_added().connect(sigc::mem_fun(*this, &GUI::on_animal_tag_added));
	
	// Setup the cell details table
	Gtk::VBox* mp_CellDetailsVBox = Gtk::manage(new Gtk::VBox());
	Gtk::ScrolledWindow* mp_ScrolledCellDetails = Gtk::manage(new Gtk::ScrolledWindow); /**< Container for the cell details property table. */
	mp_ScrolledCellDetails->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	Gtk::Alignment* mp_AlignCellDetails; /**< Container for the animal details property table. */
	mrp_Glade->get_widget("alignCellDetails", mp_AlignCellDetails);
	mp_AlignCellDetails->add(*mp_ScrolledCellDetails);
	mp_ScrolledCellDetails->add(*mp_CellDetailsVBox);
	mp_CellDetailsVBox->pack_start(m_uiCellDetails);
	mp_CellDetailsVBox->pack_start(m_CellTags);
	m_CellTags.set_parent(this);
	m_uiCellDetails.signal_rowedited().connect(sigc::mem_fun(*this, &GUI::on_celldetails_edited));
	m_CellTags.signal_deleted().connect(sigc::mem_fun(*this, &GUI::on_cell_tag_deleted));
	m_CellTags.signal_added().connect(sigc::mem_fun(*this, &GUI::on_cell_tag_added));

	// Animals treeview 
	// Shown on left side under filter frame
	mrp_Glade->get_widget("tvAnimals", mp_AnimalsTree);
	mrp_AnimalTree = Gtk::TreeStore::create(m_AnimalColumns);
	mp_AnimalsTree->set_model(mrp_AnimalTree);
	mp_AnimalsTree->append_column("Animal/Cell ID", m_AnimalColumns.m_col_name);
	mrp_AnimalTree->set_sort_column(m_AnimalColumns.m_col_name, Gtk::SORT_ASCENDING);
	mrp_AnimalTree->set_sort_func(0, sigc::mem_fun(*this, &GUI::on_animal_sort));
	mrp_AnimalSelection = mp_AnimalsTree->get_selection();
	mrp_AnimalSelection->signal_changed().connect(sigc::mem_fun(*this, &GUI::changeAnimalSelection));

	// Create Files Details TreeView
	mp_FileDetailsTree = Gtk::manage( new uiFileDetailsTreeView(&db,this) );
	Gtk::ScrolledWindow* p_swFileDetails; 
	mrp_Glade->get_widget("swFileDetails", p_swFileDetails);
	p_swFileDetails->add(*mp_FileDetailsTree);
	mp_FileDetailsTree->treeSelection()->signal_changed().connect(sigc::mem_fun(*this, &GUI::on_filedetails_selection_changed));
	mp_FileDetailsTree->signal_file_set_hidden().connect(sigc::mem_fun(*this, &GUI::on_filedetails_set_hidden));

	// Setup the analyze widgets
	// TODO: Get rid of the analyze tab completely
	mrp_Glade->get_widget("vboxAnalyze", mp_VBoxAnalyze);
	mrp_Glade->get_widget("cbDataSource", mp_DataSource);
	mrp_Glade->get_widget("cbXVar", mp_XVar);
	mrp_Glade->get_widget("cbYVar", mp_YVar);
	mrp_DataSource = Gtk::ListStore::create(m_DataSourceColumns);
	mrp_XVar = Gtk::ListStore::create(m_XVarColumns);
	mrp_YVar = Gtk::ListStore::create(m_YVarColumns);
	mp_DataSource->set_model(mrp_DataSource);
	mp_XVar->set_model(mrp_XVar);
	mp_YVar->set_model(mrp_YVar);
	mp_DataSource->pack_start(m_DataSourceColumns.m_col_name);
	mp_XVar->pack_start(m_XVarColumns.m_col_name);
	mp_YVar->pack_start(m_YVarColumns.m_col_name);
	mp_DataSource->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	mp_XVar->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	mp_YVar->signal_changed().connect( sigc::mem_fun(*this, &GUI::on_analyze_changed));
	Gtk::TreeModel::Row row = *(mrp_DataSource->append());
	row[m_DataSourceColumns.m_col_name] = "Animals";
	row = *(mrp_DataSource->append());
	row[m_DataSourceColumns.m_col_name] = "Cells";
{'fraction_non_alphanumeric': 0.1454639175257732, 'fraction_numerical': 0.0006185567010309278, 'mean_word_length': 9.287380699893955, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6736103', 'n_tokens_mistral': 3651, 'n_tokens_neox': 3509, 'n_words': 437}