コード例 #1
0
ファイル: VRGuiUtils.cpp プロジェクト: AntonChalakov/polyvr
void eraseComboboxActive(string n) {
    Gtk::ComboBox* cb;
    VRGuiBuilder()->get_widget(n, cb);
    //Glib::RefPtr<Gtk::TreeModel> model = cb->get_model()
    GtkTreeModel* model = cb->get_model()->gobj();
    //model->erase(cb->get_active());

    gtk_list_store_remove(GTK_LIST_STORE(model), cb->get_active().gobj());
    cb->set_active(cb->get_model()->children().size() - 1);
}
コード例 #2
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) {
  const mforms::ToolBarItemType type = item->get_type();

  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr());
      if (type == mforms::SwitcherItem) {
        btn->set_label(label);
        btn->get_style_context()->add_class("SwitcherItem");
      } else
        btn->add_label(label);
      btn->set_name(label);
      break;
    }
    case mforms::TitleItem:
    case mforms::LabelItem: {
      Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr());
      if (lbl) {
        lbl->set_markup("<small>" + label + "</small>");
        lbl->set_name(label);
      }
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        ct->set_active_text(label);
      break;
    }
    case mforms::ColorSelectorItem: {
      Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
        if (model) {
          const Gtk::TreeModel::Children children = model->children();
          const Gtk::TreeIter last = children.end();
          Gtk::TreeRow row;

          for (Gtk::TreeIter it = children.begin(); it != last; ++it) {
            row = *it;
            if (row.get_value(color_combo_columns->color) == label) {
              combo->set_active(it);
              break;
            }
          }
        }
      }
      break;
    }
    case mforms::SearchFieldItem:
    case mforms::TextEntryItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        e->set_text(label);
      break;
    }
    case mforms::SeparatorItem:
    case mforms::ExpanderItem:
    case mforms::ImageBoxItem:
      break;
  }
}
コード例 #3
0
ファイル: VRGuiUtils.cpp プロジェクト: AntonChalakov/polyvr
void setComboboxLastActive(string n) { // TODO: google how to get N rows!
    Gtk::ComboBox* cb;
    VRGuiBuilder()->get_widget(n, cb);
    Glib::RefPtr<Gtk::TreeModel> model = cb->get_model();
    cb->set_active(model->children().size() - 1);
}