Ejemplo n.º 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));
    }
}
Ejemplo n.º 2
0
    Gtk::Grid *SmartChessWindow::createSuboptionsArea() {
        const int SUBOPTIONS_ROWS = 3;
        const int SUBOPTIONS_COLS = 3;
        const int MARGIN = 1;

        mSubOptionsGrid = Gtk::manage(new Gtk::Grid());
        mSubOptionsGrid->set_vexpand();
        mSubOptionsGrid->set_hexpand(false);
        mSubOptionsGrid->set_column_homogeneous(true);
        mSubOptionsGrid->insert_column(0);

        for(auto i : IntRange(SUBOPTIONS_COLS))
            mSubOptionsGrid->insert_column(i);

        for(auto i : IntRange(SUBOPTIONS_ROWS))
            mSubOptionsGrid->insert_row(i);

        Gtk::Label* p1 = Gtk::manage(new Gtk::Label("Player 1"));
        p1->set_margin_left(MARGIN);
        p1->set_margin_right(MARGIN);
        mSubOptionsGrid->attach(*p1, 0, 0, 1, 1);

        Gtk::Label* vs = Gtk::manage(new Gtk::Label("V.S."));
        vs->set_margin_left(MARGIN);
        vs->set_margin_right(MARGIN);
        mSubOptionsGrid->attach(*vs, 1, 0, 1, 1);

        Gtk::Label* p2 = Gtk::manage(new Gtk::Label("Player 2"));
        p2->set_margin_left(MARGIN);
        p2->set_margin_right(MARGIN);
        mSubOptionsGrid->attach(*p2, 2, 0, 1, 1);

        mCbt1 = Gtk::manage(new Gtk::ComboBoxText());
        mCbt1->append("Human");
        mCbt1->append("A.I.");
        mCbt1->set_active(0);
        mSubOptionsGrid->attach(*mCbt1, 0, 1, 1, 1);

        mCbt2 = Gtk::manage(new Gtk::ComboBoxText());
        mCbt2->append("Human");
        mCbt2->append("A.I.");
        mCbt2->set_active(1);
        mSubOptionsGrid->attach(*mCbt2, 2, 1, 1, 1);

        rcg1 = Gtk::manage(new GRadioColorGroup());
        mSubOptionsGrid->attach(*rcg1, 0, 2, 1, 1);

        rcg2 = Gtk::manage(new GRadioColorGroup());
        mSubOptionsGrid->attach(*rcg2, 2, 2, 1, 1);

        rcg1->signalClickedWhite().connect(sigc::mem_fun(rcg2, &GRadioColorGroup::setBlack));
        rcg1->signalClickedBlack().connect(sigc::mem_fun(rcg2, &GRadioColorGroup::setWhite));
        rcg2->signalClickedWhite().connect(sigc::mem_fun(rcg1, &GRadioColorGroup::setBlack));
        rcg2->signalClickedBlack().connect(sigc::mem_fun(rcg1, &GRadioColorGroup::setWhite));
        rcg1->setWhite();
        rcg2->setBlack();
        return mSubOptionsGrid;
    }