Beispiel #1
0
void AwesomeBar::populate_results(const std::vector<unicode>& to_add) {
    Pango::FontDescription desc("sans-serif 12");

    displayed_files_.clear();
    for(auto file: to_add) {
        auto to_display = file.slice(window_.project_path().length() + 1, nullptr);
        Gtk::Label* label = Gtk::manage(new Gtk::Label(to_display.encode()));
        label->set_margin_top(10);
        label->set_margin_bottom(10);
        label->set_margin_left(10);
        label->set_margin_right(10);
        label->set_alignment(0, 0.5);
        label->set_hexpand(false);
        label->set_line_wrap_mode(Pango::WRAP_CHAR);
        label->set_ellipsize(Pango::ELLIPSIZE_MIDDLE);
        label->set_line_wrap(true);
        label->override_font(desc);
        list_.append(*label);
        displayed_files_.push_back(file);
    }

    list_.show_all();
    if(!list_.get_children().empty()) {
        list_revealer_.set_reveal_child(true);
        about_to_focus = true;
        list_.select_row(*list_.get_row_at_index(0));
    }
}
App2::EnergiesGrid::EnergiesGrid(App2::Assistant *assistant) :
	assistant(assistant) {

	Gtk::Label *label = new Gtk::Label("Select at least one XMI-MSIM input-file that describes the excitation conditions that the samples and pure element standards were exposed to. All input-files require non-matching excitation energies.");
	attach(*label, 0, 0, 2, 1);
	set_column_spacing(5);
	set_row_spacing(5);
	set_row_homogeneous(false);
	set_column_homogeneous(false);
	label->set_hexpand();
	label->set_margin_bottom(10);
	label->set_margin_top(10);
	label->set_line_wrap();
	label->set_justify(Gtk::JUSTIFY_LEFT);
	
	open_button.set_image_from_icon_name("document-open");
	open_button.set_vexpand(false);
	open_button.set_hexpand(false);
	open_button.set_valign(Gtk::ALIGN_CENTER);
	attach(open_button, 0, 1, 1, 1);
	
	model = Gtk::ListStore::create(columns);
	model->set_sort_column(3, Gtk::SORT_ASCENDING);
	tv.set_model(model);
	tv.append_column("Filename", columns.col_filename_base);
	tv.append_column_numeric("Energy (keV)", columns.col_bam_file_xmsi_energy, "%g");
	//alignment
	tv.get_column_cell_renderer(1)->set_alignment(0.5, 0.5); 
	tv.get_column(0)->set_expand();
	sw.add(tv);
	sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	attach(sw, 1, 1, 1, 1);
	sw.set_vexpand();
	sw.set_hexpand();
	open_button.signal_clicked().connect(sigc::mem_fun(*this, &App2::EnergiesGrid::on_open_button_clicked));
	tv.signal_key_press_event().connect(sigc::mem_fun(*this, &App2::EnergiesGrid::on_backspace_clicked));
	tv.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);

	show_all_children();
}