示例#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));
    }
}