ValueComboBox::ValueComboBox(const std::vector<std::string>& iValues)
    {

        setValues(iValues);
        
        set_margin_bottom(20);
        
    }
Exemple #2
0
void ItemView::on_realize()
{
    Gtk::Widget::on_realize();

    fontTime.set_family(Resources::res->fontName);
    fontTime.set_weight(Pango::WEIGHT_NORMAL);

    fontTitle.set_family(Resources::res->fontName);
    fontTitle.set_weight(Pango::WEIGHT_ULTRALIGHT);

    fontDescription.set_family(Resources::res->fontName);
    fontDescription.set_weight(Pango::WEIGHT_ULTRALIGHT);

    this->add_events(Gdk::BUTTON_PRESS_MASK);
    this->add_events(Gdk::BUTTON_RELEASE_MASK);

    this->set_can_focus(true);

    set_size_request(-1, HEIGHT);
    set_margin_bottom(SPACE);
}
Exemple #3
0
void AwesomeBar::build_widgets() { 
    set_margin_left(20);
    set_margin_right(20);
    set_margin_top(20);
    set_margin_bottom(20);
    set_no_show_all();
    set_valign(Gtk::ALIGN_START);
    set_halign(Gtk::ALIGN_CENTER);

    entry_.set_width_chars(50);
    pack_start(entry_, false, false);

    entry_.signal_changed().connect([&]() {
        populate(entry_.get_text().c_str());
    });

    entry_.signal_activate().connect(sigc::mem_fun(this, &AwesomeBar::execute));
    entry_.signal_focus_out_event().connect([=](GdkEventFocus* evt) -> bool {
        // Horrible hack on old Gtk+

        auto minor_version = gtk_get_minor_version();
        if(about_to_focus && minor_version < 12) {
            about_to_focus = false;
            entry_.grab_focus();
            entry_.set_position(-1);
            return true;
        }
        entry_.hide();
        entry_.set_text("");
        return false;
    });

    entry_.signal_key_press_event().connect([=](GdkEventKey* evt) -> bool {
        if(evt->keyval == GDK_KEY_Down || evt->keyval == GDK_KEY_Up) {
            /*
             * If we key up or down, change the selection in the list but
             * return false so that we don't lose focus on the box
             */

            auto row = list_.get_selected_row();
            if(!row) {
                return false;
            }

            auto idx = row->get_index();

            idx += (evt->keyval == GDK_KEY_Down) ? 1 : -1;

            idx = std::max(idx, 0);
            idx = std::min(idx, (int32_t) displayed_files_.size());

            about_to_focus = true;
            list_.select_row(*list_.get_row_at_index(idx));

            return true;
        }

        return false;
    });

    Pango::FontDescription desc("sans-serif 16");
    entry_.override_font(desc);

    pack_start(list_revealer_, false, true, 0);

    list_window_.set_size_request(-1, 650);

    list_.set_activate_on_single_click(true);
    list_window_.add(list_);
    list_revealer_.add(list_window_);

    list_.set_hexpand(false);

    list_.signal_row_activated().connect([this](Gtk::ListBoxRow* row){
        auto idx = row->get_index();
        auto file = displayed_files_.at(idx);
        window_.open_document(file);
        hide();
    });
}