string getComboboxText(string cbn) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(cbn, cb); char* name = gtk_combo_box_get_active_text(cb->gobj()); if (name == 0) return ""; return string (name); }
//------------------------------------------------------------------------------ void DbMySQLTableEditor::do_refresh_form_data() { refresh_table_page(); _columns_page->refresh(); _indexes_page->refresh(); _fks_page->refresh(); _triggers_page->refresh(); _part_page->refresh(); _opts_page->refresh(); if (!is_editing_live_object()) { Gtk::Notebook *notebook; xml()->get_widget("mysql_editor_notebook", notebook); _privs_page->refresh(); } else { Gtk::ComboBox *cbox = 0; xml()->get_widget("schema_combo", cbox); if (cbox) { fill_combo_from_string_list(cbox, _be->get_all_schema_names()); cbox->set_active(0); } } }
void Settings::get_shrink_from_gui (Builder &builder) { // Slicing.ShrinkQuality Gtk::ComboBox *combo = NULL; builder->get_widget ("Slicing.ShrinkQuality", combo); if (combo) Slicing.ShrinkQuality = combo->get_active_row_number (); }
void Settings::set_shrink_to_gui (Builder &builder) { // Slicing.ShrinkQuality Gtk::ComboBox *combo = NULL; builder->get_widget ("Slicing.ShrinkQuality", combo); if (combo) combo->set_active (Slicing.ShrinkQuality); }
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); }
inline bool singleValueMode() { Gtk::TreeModel::iterator iter = _comboBox.get_active(); if (!iter) return true; std::tr1::shared_ptr<Attribute> ptr = (*iter)[_modelColumns.m_ptr]; return !ptr; }
// scene updated, get cameras and nav presets void VRGuiBits::update() { // update camera liststore VRScene* scene = VRSceneManager::get()->getActiveScene(); setLabel("label24", "Project: None"); if (scene == 0) return; vector<VRCamera*> cams = scene->getCameraMap(); Glib::RefPtr<Gtk::ListStore> store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("cameras")); store->clear(); int active; for (uint i=0; i<cams.size(); i++) { if (cams[i] == scene->getActiveCamera()) active = i; Gtk::ListStore::Row row = *store->append(); gtk_list_store_set (store->gobj(), row.gobj(), 0, cams[i]->getName().c_str(), -1); } // set active cam active Gtk::ComboBox* cb; VRGuiBuilder()->get_widget("combobox4", cb); cb->set_active(active); // update nav_presets liststore map<string, VRNavPreset*>::iterator itr; map<string, VRNavPreset*> presets = scene->getPresets(); store = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("nav_presets")); store->clear(); for (itr = presets.begin(); itr != presets.end(); itr++) { Gtk::ListStore::Row row = *store->append(); gtk_list_store_set (store->gobj(), row.gobj(), 0, itr->first.c_str(), -1); //if (itr->second) itr->second->setScene(scene); } // set first element active VRGuiBuilder()->get_widget("combobox9", cb); cb->set_active(0); // update setup and project label cout << " now running: " << scene->getName() << endl; setLabel("label24", "Project: " + scene->getName()); }
inline virtual void updateGui() { _singleValueLabel.set_visible(false); for (size_t i(0); i < 4; ++i) _scalarvalues[i].hide(); bool singlevalmode = singleValueMode(); if (_components && singlevalmode) { _singleValueLabel.set_visible(true); for (size_t i(0); i < _components; ++i) _scalarvalues[i].show(); } _componentSelect.clear_items(); if (singlevalmode || !_enableDataFiltering) _componentSelect.set_visible(false); else { _componentSelect.set_visible(true); Gtk::TreeModel::iterator iter = _comboBox.get_active(); std::tr1::shared_ptr<Attribute> ptr = (*iter)[_modelColumns.m_ptr]; _componentSelect.append_text("Raw Data"); _componentSelect.append_text("Magnitude"); _componentSelect.append_text("X"); if (ptr->components() > 1) _componentSelect.append_text("Y"); if (ptr->components() > 2) _componentSelect.append_text("Z"); if (ptr->components() > 3) _componentSelect.append_text("W"); //Default to coloring using the magnitude _componentSelect.set_active(1); } for (size_t i(0); i < _components; ++i) _scalarvalues[i].set_sensitive(singlevalmode); }
//------------------------------------------------------------------------------ void mforms::gtk::ToolBarImpl::set_selector_items(ToolBarItem *item, const std::vector<std::string> &values) { if (item->get_type() == mforms::SelectorItem || item->get_type() == mforms::FlatSelectorItem) { Gtk::ComboBoxText *w = cast<Gtk::ComboBoxText *>(item->get_data_ptr()); if (w) { w->set_data("ignore_signal", (void *)1); #if ((GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 24) || GTKMM_MAJOR_VERSION > 2) w->remove_all(); #else w->clear_items(); #endif const int size = values.size(); for (int i = 0; i < size; ++i) w->append(values[i]); if (w->get_active_row_number() < 0 && !values.empty()) w->set_active_text(values[0]); w->set_data("ignore_signal", 0); } } else if (item->get_type() == mforms::ColorSelectorItem) { Gtk::ComboBox *w = cast<Gtk::ComboBox *>(item->get_data_ptr()); if (w) { w->set_data("ignore_signal", (void *)1); Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*color_combo_columns); const int size = values.size(); for (int i = 0; i < size; ++i) { Gtk::TreeRow row = *model->append(); Gdk::Color color(values[i]); Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 16, 14); pixbuf->fill((guint32)color.get_red() << 24 | (guint32)color.get_green() << 16 | (guint32)color.get_blue() << 8); row[color_combo_columns->color] = values[i]; row[color_combo_columns->image] = pixbuf; } w->set_model(model); if (w->get_active_row_number() < 0) w->set_active(0); w->set_data("ignore_signal", 0); } } }
void DimensionManager::onColumnClicked() { printf("DimensionManager::onColumnClicked()\n"); //FIXME: BUG: this method is currently very unreliably called, it should actually be called when the user selects another column, it is ATM however also called when the table content changed programmatically causing the dialog below to popup at undesired times ! //HACK: Prevents that onColumnClicked() gets called multiple times or at times where it is not desired if (ignoreColumnClicked) { ignoreColumnClicked = false; return; } #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 18) || GTKMM_MAJOR_VERSION > 2 // prevents app to crash if this dialog is closed if (!get_visible()) return; #else # warning Your GTKMM version is too old; dimension manager dialog might crash when changing a dimension type ! #endif #if (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION >= 8) || GTKMM_MAJOR_VERSION > 3 if (!is_visible()) return; #endif Gtk::TreeModel::Path path; Gtk::TreeViewColumn* focus_column; treeView.get_cursor(path, focus_column); //const int row = path[0]; if (focus_column == treeView.get_column(0)) { Gtk::TreeModel::iterator it = treeView.get_model()->get_iter(path); if (!it) return; Gtk::TreeModel::Row row = *it; gig::dimension_t oldType = row[tableModel.m_type]; Gtk::Dialog dialog(_("Change Dimension"), true /*modal*/); int oldTypeIndex = -1; Glib::RefPtr<Gtk::ListStore> refComboModel = Gtk::ListStore::create(comboModel); for (int i = 0x01, count = 0; i < 0xff; i++) { Glib::ustring sType = dimTypeAsString(static_cast<gig::dimension_t>(i)); if (i == oldType) oldTypeIndex = count; if (sType.find("Unknown") != 0) { Gtk::TreeModel::Row row = *(refComboModel->append()); row[comboModel.m_type_id] = i; row[comboModel.m_type_name] = sType; count++; } } Gtk::Table table(1, 2); Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); Gtk::ComboBox comboDimType; comboDimType.set_model(refComboModel); comboDimType.pack_start(comboModel.m_type_id); comboDimType.pack_start(comboModel.m_type_name); table.attach(labelDimType, 0, 1, 0, 1); table.attach(comboDimType, 1, 2, 0, 1); dialog.get_vbox()->pack_start(table); dialog.add_button(_("_OK"), 0); dialog.add_button(_("_Cancel"), 1); dialog.show_all_children(); comboDimType.set_active(oldTypeIndex); if (!dialog.run()) { // OK selected ... ignoreColumnClicked = true; Gtk::TreeModel::iterator iterType = comboDimType.get_active(); if (!iterType) return; Gtk::TreeModel::Row rowType = *iterType; if (!rowType) return; int iTypeID = rowType[comboModel.m_type_id]; gig::dimension_t newType = static_cast<gig::dimension_t>(iTypeID); if (newType == oldType) return; //printf("change 0x%x -> 0x%x\n", oldType, newType); // assemble the list of regions where the selected dimension type // shall be changed std::vector<gig::Region*> vRegions; if (allRegions()) { gig::Instrument* instr = (gig::Instrument*)region->GetParent(); for (gig::Region* rgn = instr->GetFirstRegion(); rgn; rgn = instr->GetNextRegion()) { if (rgn->GetDimensionDefinition(oldType)) vRegions.push_back(rgn); } } else vRegions.push_back(region); std::set<Glib::ustring> errors; for (uint iRgn = 0; iRgn < vRegions.size(); ++iRgn) { gig::Region* region = vRegions[iRgn]; try { // notify everybody that we're going to update the region region_to_be_changed_signal.emit(region); // change the dimension type on that region region->SetDimensionType(oldType, newType); // let everybody know there was a change region_changed_signal.emit(region); } catch (RIFF::Exception e) { // notify that the changes are over (i.e. to avoid dead locks) region_changed_signal.emit(region); Glib::ustring txt = _("Could not alter dimension: ") + e.Message; if (vRegions.size() == 1) { // show error message directly Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); msg.run(); } else { // remember error, they are shown after all regions have been processed errors.insert(txt); } } } // update all GUI elements refreshManager(); if (!errors.empty()) { Glib::ustring txt = _( "The following errors occurred while trying to change the dimension type on all regions:" ); txt += "\n\n"; for (std::set<Glib::ustring>::const_iterator it = errors.begin(); it != errors.end(); ++it) { txt += "-> " + *it + "\n"; } txt += "\n"; txt += _( "You might also want to check the console for further warnings and " "error messages." ); Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); msg.run(); } } } }
bool addWidgets(Gtk::Box* iBox) { if (mBox != NULL) return false; mBox = Gtk::manage(new Gtk::VBox()); Gtk::Box* box = Gtk::manage(new Gtk::HBox()); mToggleButton = Gtk::manage(new Gtk::ToggleButton(" ")); Gdk::Color color; color.set_rgb_p(mAttributes.mColor[0], mAttributes.mColor[1], mAttributes.mColor[2]); mToggleButton->modify_bg(Gtk::STATE_ACTIVE, color); color.set_rgb_p((mAttributes.mColor[0]+1)/2, (mAttributes.mColor[1]+1)/2, (mAttributes.mColor[2]+1)/2); mToggleButton->modify_bg(Gtk::STATE_PRELIGHT, color); color.set_rgb_p(0.8, 0.8, 0.8); mToggleButton->modify_bg(Gtk::STATE_NORMAL, color); mToggleButton->signal_toggled().connect (sigc::mem_fun(*this, &Helper::onToggleButton)); mToggleButton->set_active(true); box->pack_start(*(mToggleButton), false, false); Gtk::Label* label = Gtk::manage(new Gtk::Label(mAttributes.mLabel)); box->pack_start(*label, false, false); if (mViewId != 1) { Gtk::Button* cancelButton = Gtk::manage(new Gtk::Button("X")); box->pack_start(*cancelButton, false, false); cancelButton->signal_clicked().connect (sigc::mem_fun(*this, &Helper::onRemoveButton)); } Gtk::Button* button = Gtk::manage(new Gtk::Button("save")); button->signal_clicked().connect (sigc::mem_fun(*this, &Helper::onSaveButton)); box->pack_start(*button, false, false); mBox->pack_start(*box, false, false); box = Gtk::manage(new Gtk::HBox()); std::vector<int> ids; std::vector<std::string> labels; ids = { MeshRenderer::ColorModeFlat, MeshRenderer::ColorModeHeight, MeshRenderer::ColorModeRange, MeshRenderer::ColorModeNormal, MeshRenderer::ColorModeCamera }; labels = { "Flat", "Height", "Range", "Normal", "Camera" }; Gtk::ComboBox* combo = gtkmm::RendererBase::createCombo(mAttributes.mColorMode, labels, ids); combo->signal_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*combo, false, false); ids = { MeshRenderer::MeshModePoints, MeshRenderer::MeshModeWireframe, MeshRenderer::MeshModeFilled }; labels = { "Points", "Wireframe", "Filled" }; combo = gtkmm::RendererBase::createCombo(mAttributes.mMeshMode, labels, ids); combo->signal_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*combo, false, false); Gtk::HScale* slider = gtkmm::RendererBase::createSlider(mAttributes.mPointSize, 0.1, 10, 0.1); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); mBox->pack_start(*box, false, false); box = Gtk::manage(new Gtk::HBox()); label = Gtk::manage(new Gtk::Label("Z Rng")); box->pack_start(*label,false,false); slider = gtkmm::RendererBase::createSlider(mAttributes.mMinZ, -1, 2, 0.01); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); slider = gtkmm::RendererBase::createSlider(mAttributes.mMaxZ, -1, 2, 0.01); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); mBox->pack_start(*box, false, false); mBox->pack_start(*Gtk::manage(new Gtk::HSeparator())); mBox->show_all(); iBox->pack_start(*mBox, false, false); return true; }
void on_combobox_changed() { ::Gtk::TreeModel::iterator iter = _comboBox.get_active(); if (iter) _mode = ((*iter)[m_Columns.m_col_id]); _signal_changed.emit(); }
PluginDisplay::PluginDisplay(gx_engine::GxMachineBase& machine_, Glib::RefPtr<Gdk::Pixbuf> icon, sigc::slot<void, bool, bool> finished_callback_) : machine(machine_), pluginlist(), current_plugin(0), old_state(0), bld(), change_count(0), actiongroup(Gtk::ActionGroup::create("ladspa_window")), uimanager(), enum_liststore(new EnumListStore), port_liststore(new PortListStore), plugin_liststore(new PluginListStore), masteridx_liststore(new MasterIdxListStore), on_reordered_conn(), display_type_list(), display_type_list_sr(), output_type_list(), finished_callback(finished_callback_) { std::vector<std::string> old_not_found; machine.load_ladspalist(old_not_found, pluginlist); bld = gx_gui::GxBuilder::create_from_file(machine.get_options().get_builder_filepath("ladspaliste.glade")); bld->get_toplevel("window1", window); bld->find_widget("treeview1", treeview1); bld->find_widget("treeview2", treeview2); bld->find_widget("treeview3", treeview3); bld->find_widget("ladspa_category", ladspa_category); bld->find_widget("ladspa_maker", ladspa_maker); bld->find_widget("ladspa_uniqueid", ladspa_uniqueid); bld->find_widget("search_entry", search_entry); bld->find_widget("combobox_mono_stereo", combobox_mono_stereo); bld->find_widget("selected_only", selected_only); bld->find_widget("changed_only", changed_only); bld->find_widget("ladspa_only", ladspa_only); bld->find_widget("lv2_only", lv2_only); bld->find_widget("show_all", show_all); bld->find_widget("details_box", details_box); bld->find_widget("plugin_name", plugin_name); bld->find_widget("plugin_category", plugin_category); bld->find_widget("plugin_quirks", plugin_quirks); bld->find_widget("master_slider_idx", master_slider_idx); bld->find_widget("master_slider_name", master_slider_name); bld->find_widget("cellrenderer_master", cellrenderer_master); bld->find_widget("cellrenderer_newrow", cellrenderer_newrow); bld->find_widget("cellrenderer_caption", cellrenderer_caption); bld->find_widget("cellrenderer_active", cellrenderer_active); bld->find_widget("cellrenderer_category", cellrenderer_category); bld->find_widget("cellrenderer_quirks", cellrenderer_quirks); set_title(); actiongroup->add(Gtk::Action::create("FileMenuAction",_("_File"))); save_action = Gtk::Action::create("SaveAction", _("_Ok")); actiongroup->add(save_action, sigc::mem_fun(this, &PluginDisplay::on_save)); apply_action = Gtk::Action::create("ApplyAction", _("_Apply")); actiongroup->add(apply_action, sigc::mem_fun(this, &PluginDisplay::on_apply)); quit_action = Gtk::Action::create("QuitAction", _("_Quit")); actiongroup->add(quit_action, sigc::mem_fun(this, &PluginDisplay::on_quit)); select_all_action = Gtk::Action::create("SelectAllAction", _("_Select All")); actiongroup->add(select_all_action, sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_select_all), true)); select_none_action = Gtk::Action::create("SelectNoneAction", _("Select _None")); actiongroup->add(select_none_action, sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_select_all), false)); actiongroup->add(Gtk::Action::create("ViewMenuAction", _("_View"))); Glib::RefPtr<Gtk::Action> act = Gtk::Action::create("FindAction", _("_Find")); actiongroup->add(act, sigc::mem_fun(this, &PluginDisplay::on_find)); uimanager = Gtk::UIManager::create(); uimanager->insert_action_group(actiongroup, 0); uimanager->add_ui_from_string(menudef); //uimanager->get_widget("/ladspalist"); //Gtk::HBox *ww; bld->find_widget("menubox", ww); ww->pack_start(*uimanager->get_widget("/ladspalist")); window->add_accel_group(uimanager->get_accel_group()); window->signal_delete_event().connect(sigc::mem_fun(this, &PluginDisplay::on_delete_event)); bld->find_widget("show_details", show_details); show_details->signal_clicked().connect(sigc::mem_fun(this, &PluginDisplay::on_show_details)); treeview3->get_selection()->set_mode(Gtk::SELECTION_BROWSE); treeview3->set_model(enum_liststore); Gtk::CellRendererText *r; bld->find_widget("cellrenderer_label", r); r->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_label_edited)); Gtk::TreeViewColumn *c; bld->find_widget("treeviewcolumn_label", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_label)); bld->find_widget("dry_wet_button", dry_wet_button); dry_wet_button->signal_clicked().connect(sigc::mem_fun(this, &PluginDisplay::on_add_dry_wet_controller)); // dry_wet_button->set_active(current_plugin->add_wet_dry); Glib::RefPtr<Gtk::TreeSelection> sel = treeview2->get_selection(); sel->set_mode(Gtk::SELECTION_BROWSE); sel->signal_changed().connect(sigc::mem_fun(this, &PluginDisplay::on_parameter_selection_changed)); on_reordered_conn = port_liststore->signal_row_deleted().connect(sigc::mem_fun(this, &PluginDisplay::on_reordered)); treeview2->set_model(port_liststore); CellRendererComboDerived *rd; bld->find_widget_derived("cellrenderer_type", rd, sigc::ptr_fun(CellRendererComboDerived::create_from_builder)); rd->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_type_edited)); bld->find_widget("treeviewcolumn_type", c); c->set_cell_data_func(*rd, sigc::mem_fun(this, &PluginDisplay::display_type)); bld->find_widget_derived("cellrenderer_step", rd, sigc::ptr_fun(CellRendererComboDerived::create_from_builder)); rd->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_step_edited)); bld->find_widget("treeviewcolumn_step", c); c->set_cell_data_func(*rd, sigc::mem_fun(this, &PluginDisplay::display_step)); cellrenderer_newrow->signal_toggled().connect(sigc::mem_fun(this, &PluginDisplay::on_newrow_toggled)); Gtk::Label *label = new Gtk::Label("N"); label->set_tooltip_text(_("start a new row of controls in the rackbox unit")); label->show(); bld->find_widget("treeviewcolumn_newrow", c); c->set_widget(*manage(label)); c->set_cell_data_func(*cellrenderer_newrow, sigc::mem_fun(this, &PluginDisplay::display_newrow)); cellrenderer_caption->signal_toggled().connect(sigc::mem_fun(this, &PluginDisplay::on_caption_toggled)); label = new Gtk::Label("C"); label->set_tooltip_text(_("display the name as caption above the control")); label->show(); bld->find_widget("treeviewcolumn_caption", c); c->set_widget(*manage(label)); c->set_cell_data_func(*cellrenderer_caption, sigc::mem_fun(this, &PluginDisplay::display_caption)); bld->find_widget("cellrenderer_name", r); r->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_name_edited)); bld->find_widget("treeviewcolumn_name", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_name)); bld->find_widget("cellrenderer_dflt", r); r->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_dflt_edited)); bld->find_widget("treeviewcolumn_dflt", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_default)); bld->find_widget("cellrenderer_low", r); r->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_low_edited)); bld->find_widget("treeviewcolumn_low", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_lower)); bld->find_widget("cellrenderer_up", r); r->signal_edited().connect(sigc::mem_fun(this, &PluginDisplay::on_up_edited)); bld->find_widget("treeviewcolumn_up", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_upper)); bld->find_widget("cellrenderer_idx", r); bld->find_widget("treeviewcolumn_idx", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_idx)); bld->find_widget("treeviewcolumn_SR", c); label = new Gtk::Label("SR"); label->set_tooltip_text(_("marked rows: range depends on samplerate; using 44100 as fixed value")); label->show(); c->set_widget(*manage(label)); Gtk::CellRendererToggle *t; bld->find_widget("cellrenderer_SR", t); c->set_cell_data_func(*t, sigc::mem_fun(this, &PluginDisplay::display_SR)); Gtk::TreeModelColumnRecord recdef; Gtk::TreeModelColumn<Glib::ustring> strcol; Gtk::TreeModelColumn<DisplayType> intcol; recdef.add(strcol); recdef.add(intcol); display_type_list = Gtk::ListStore::create(recdef); append_displaytype(display_type_list, tp_scale); append_displaytype(display_type_list, tp_scale_log); append_displaytype(display_type_list, tp_toggle); append_displaytype(display_type_list, tp_int); append_displaytype(display_type_list, tp_enum); append_displaytype(display_type_list, tp_none); display_type_list_sr = Gtk::ListStore::create(recdef); append_displaytype(display_type_list_sr, tp_scale); append_displaytype(display_type_list_sr, tp_scale_log); append_displaytype(display_type_list_sr, tp_none); output_type_list = Gtk::ListStore::create(recdef); append_displaytype(output_type_list, tp_display); append_displaytype(output_type_list, tp_display_toggle); append_displaytype(output_type_list, tp_none); treeview1->signal_row_activated().connect(sigc::mem_fun(this, &PluginDisplay::on_row_activated)); treeview1->set_search_equal_func(sigc::mem_fun(this,&PluginDisplay::search_equal)); Gtk::Entry *e; bld->find_widget("search_entry", e); e->signal_activate().connect(sigc::mem_fun(this, &PluginDisplay::on_search_entry_activate)); treeview1->set_search_entry(*e); sel = treeview1->get_selection(); sel->set_mode(Gtk::SELECTION_BROWSE); sel->signal_changed().connect(sigc::mem_fun(this, &PluginDisplay::selection_changed)); treeview1->set_model(plugin_liststore); cellrenderer_active->signal_toggled().connect(sigc::mem_fun(this, &PluginDisplay::on_active_toggled)); bld->find_widget("cellrenderer_ladspa", r); bld->find_widget("treeviewcolumn_ladspa", c); c->set_cell_data_func(*r, sigc::mem_fun(this, &PluginDisplay::display_ladspa)); Gtk::ComboBox *cb; bld->find_widget("plugin_category", cb); cb->set_cell_data_func(*cellrenderer_category, sigc::mem_fun(this, &PluginDisplay::display_category)); bld->find_widget("plugin_quirks", cb); cb->set_cell_data_func(*cellrenderer_quirks, sigc::mem_fun(this, &PluginDisplay::display_quirks)); master_slider_idx->set_cell_data_func(*cellrenderer_master, sigc::mem_fun(this, &PluginDisplay::display_master_idx)); master_slider_idx->signal_changed().connect(sigc::mem_fun(this, &PluginDisplay::set_master_text)); selected_only->signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_view_changed), selected_only)); changed_only->signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_view_changed), changed_only)); ladspa_only->signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_view_changed), ladspa_only)); lv2_only->signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_view_changed), lv2_only)); show_all->signal_toggled().connect(sigc::bind(sigc::mem_fun(this, &PluginDisplay::on_view_changed), show_all)); bld->find_widget("combobox_mono_stereo", cb); cb->signal_changed().connect(sigc::mem_fun(this, &PluginDisplay::on_mono_stereo_changed)); cb->set_active(0); Gtk::Button *b; bld->find_widget("reset_changes", b); b->signal_clicked().connect(sigc::mem_fun(this, &PluginDisplay::on_delete_changes)); bld->find_widget("master_slider_idx", cb); cb->set_model(masteridx_liststore); bld->find_widget("button_cancel", b); gtk_activatable_set_related_action(GTK_ACTIVATABLE(b->gobj()), actiongroup->get_action("QuitAction")->gobj()); bld->find_widget("button_apply", b); gtk_activatable_set_related_action(GTK_ACTIVATABLE(b->gobj()), actiongroup->get_action("ApplyAction")->gobj()); bld->find_widget("button_save", b); gtk_activatable_set_related_action(GTK_ACTIVATABLE(b->gobj()), actiongroup->get_action("SaveAction")->gobj()); bld->find_widget("select_all", b); gtk_activatable_set_related_action(GTK_ACTIVATABLE(b->gobj()), actiongroup->get_action("SelectAllAction")->gobj()); bld->find_widget("select_none", b); gtk_activatable_set_related_action(GTK_ACTIVATABLE(b->gobj()), actiongroup->get_action("SelectNoneAction")->gobj()); window->set_icon(icon); window->show(); }
//------------------------------------------------------------------------------ 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; } }
void setComboboxCallback(string b, void (* fkt)(GtkComboBox*, gpointer)) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(b, cb); g_signal_connect (cb->gobj(), "changed", G_CALLBACK(fkt), NULL); }
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); }
void Settings::connect_to_ui (Builder &builder) { // connect gcode configurable text sections GCode.m_impl->connectToUI (builder); // first setup ranges on spinbuttons ... for (uint i = 0; i < G_N_ELEMENTS (spin_ranges); i++) { Gtk::SpinButton *spin = NULL; builder->get_widget (spin_ranges[i].widget, spin); if (!spin) std::cerr << "missing spin button of name '" << spin_ranges[i].widget << "'\n"; else { spin->set_range (spin_ranges[i].min, spin_ranges[i].max); spin->set_increments (spin_ranges[i].inc, spin_ranges[i].inc_page); } } // Ranges on [HV]Range widgets for (uint i = 0; i < G_N_ELEMENTS (ranges); i++) { Gtk::Range *range = NULL; builder->get_widget (ranges[i].widget, range); if (!range) std::cerr << "missing range slider of name '" << ranges[i].widget << "'\n"; else { range->set_range (ranges[i].min, ranges[i].max); range->set_increments (ranges[i].inc, ranges[i].inc_page); } } // connect widget / values from our table for (uint i = 0; i < G_N_ELEMENTS (settings); i++) { const char *glade_name = settings[i].glade_name; if (!glade_name) continue; switch (settings[i].type) { case T_BOOL: { Gtk::CheckButton *check = NULL; builder->get_widget (glade_name, check); if (check) check->signal_toggled().connect (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder)); break; } case T_INT: case T_FLOAT: { Gtk::Widget *w = NULL; builder->get_widget (glade_name, w); if (!w) { std::cerr << "Missing user interface item " << glade_name << "\n"; break; } Gtk::SpinButton *spin = dynamic_cast<Gtk::SpinButton *>(w); if (spin) { spin->signal_value_changed().connect (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder)); break; } Gtk::Range *range = dynamic_cast<Gtk::Range *>(w); if (range) { range->signal_value_changed().connect (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder)); break; } break; } case T_STRING: // unimplemented break; default: break; } } // Slicing.ShrinkQuality Gtk::ComboBox *combo = NULL; builder->get_widget ("Slicing.ShrinkQuality", combo); if (combo) { Glib::RefPtr<Gtk::ListStore> model; Gtk::TreeModelColumnRecord record; Gtk::TreeModelColumn<Glib::ustring> column; record.add (column); model = Gtk::ListStore::create(record); model->append()->set_value (0, Glib::ustring("Fast")); model->append()->set_value (0, Glib::ustring("Logick")); combo->set_model (model); combo->pack_start (column); combo->signal_changed().connect (sigc::bind(sigc::mem_fun(*this, &Settings::get_shrink_from_gui), builder)); } // Colour selectors for (uint i = 0; i < G_N_ELEMENTS (colour_selectors); i++) { const char *glade_name = colour_selectors[i].glade_name; Gdk::Color c; Gtk::ColorButton *w = NULL; if (!glade_name) continue; builder->get_widget (glade_name, w); if (!w) continue; w->signal_color_set().connect (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_colour_from_gui), i), builder)); } // Serial port speed Gtk::ComboBoxEntry *portspeed = NULL; builder->get_widget ("Hardware.SerialSpeed", portspeed); if (portspeed) { const guint32 speeds[] = { 9600, 19200, 38400, 57600, 115200, 230400, 576000 }; Glib::RefPtr<Gtk::ListStore> model; Gtk::TreeModelColumnRecord record; Gtk::TreeModelColumn<Glib::ustring> column; record.add (column); model = Gtk::ListStore::create(record); for (guint i = 0; i < G_N_ELEMENTS(speeds); i++) { std::ostringstream val; val << speeds[i]; model->append()->set_value (0, Glib::ustring(val.str())); } portspeed->set_model (model); portspeed->set_text_column (0); portspeed->signal_changed().connect (sigc::bind(sigc::mem_fun(*this, &Settings::get_port_speed_from_gui), builder)); } /* Update UI with defaults */ m_signal_update_settings_gui.emit(); }
int getComboboxI(string cbn) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(cbn, cb); int i = gtk_combo_box_get_active(cb->gobj()); return i; }
void setComboboxCallback(string b, sigc::slot<void> sig) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(b, cb); cb->signal_changed().connect(sig); }
Gtk::TreeModel::Row getComboboxRow(string cbn) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(cbn.c_str(), cb); return *cb->get_active(); }
void setComboboxSensitivity(string cb, bool b) { Gtk::ComboBox* tab; VRGuiBuilder()->get_widget(cb, tab); tab->set_sensitive(b); }
void DimensionManager::addDimension() { Gtk::Dialog dialog(_("New Dimension"), true /*modal*/); // add dimension type combo box to the dialog Glib::RefPtr<Gtk::ListStore> refComboModel = Gtk::ListStore::create(comboModel); for (int i = 0x01; i < 0xff; i++) { Glib::ustring sType = dimTypeAsString(static_cast<gig::dimension_t>(i)); if (sType.find("Unknown") != 0) { Gtk::TreeModel::Row row = *(refComboModel->append()); row[comboModel.m_type_id] = i; row[comboModel.m_type_name] = sType; } } Gtk::Table table(2, 2); Gtk::Label labelDimType(_("Dimension:"), Gtk::ALIGN_START); Gtk::ComboBox comboDimType; comboDimType.set_model(refComboModel); comboDimType.pack_start(comboModel.m_type_id); comboDimType.pack_start(comboModel.m_type_name); Gtk::Label labelZones(_("Zones:"), Gtk::ALIGN_START); table.attach(labelDimType, 0, 1, 0, 1); table.attach(comboDimType, 1, 2, 0, 1); table.attach(labelZones, 0, 1, 1, 2); dialog.get_vbox()->pack_start(table); // number of zones: use a combo box with fix values for gig // v2 and a spin button for v3 Gtk::ComboBoxText comboZones; Gtk::SpinButton spinZones; bool version2 = false; if (region) { gig::File* file = (gig::File*)region->GetParent()->GetParent(); version2 = file->pVersion && file->pVersion->major == 2; } if (version2) { for (int i = 1; i <= 5; i++) { char buf[3]; sprintf(buf, "%d", 1 << i); #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 comboZones.append_text(buf); #else comboZones.append(buf); #endif } table.attach(comboZones, 1, 2, 1, 2); } else { spinZones.set_increments(1, 8); spinZones.set_numeric(true); spinZones.set_range(2, 128); spinZones.set_value(2); table.attach(spinZones, 1, 2, 1, 2); } dialog.add_button(_("_OK"), 0); dialog.add_button(_("_Cancel"), 1); dialog.show_all_children(); if (!dialog.run()) { // OK selected ... Gtk::TreeModel::iterator iterType = comboDimType.get_active(); if (!iterType) return; Gtk::TreeModel::Row rowType = *iterType; if (!rowType) return; int iTypeID = rowType[comboModel.m_type_id]; gig::dimension_t type = static_cast<gig::dimension_t>(iTypeID); gig::dimension_def_t dim; dim.dimension = type; if (version2) { if (comboZones.get_active_row_number() < 0) return; dim.bits = comboZones.get_active_row_number() + 1; dim.zones = 1 << dim.bits; } else { dim.zones = spinZones.get_value_as_int(); dim.bits = zoneCountToBits(dim.zones); } // assemble the list of regions where the selected dimension shall be // added to std::vector<gig::Region*> vRegions; if (allRegions()) { gig::Instrument* instr = (gig::Instrument*)region->GetParent(); for (gig::Region* rgn = instr->GetFirstRegion(); rgn; rgn = instr->GetNextRegion()) { if (!rgn->GetDimensionDefinition(type)) vRegions.push_back(rgn); } } else vRegions.push_back(region); std::set<Glib::ustring> errors; for (uint iRgn = 0; iRgn < vRegions.size(); ++iRgn) { gig::Region* region = vRegions[iRgn]; try { printf( "Adding dimension (type=0x%x, bits=%d, zones=%d)\n", dim.dimension, dim.bits, dim.zones ); // notify everybody that we're going to update the region region_to_be_changed_signal.emit(region); // add the new dimension to the region // (implicitly creates new dimension regions) region->AddDimension(&dim); // let everybody know there was a change region_changed_signal.emit(region); } catch (RIFF::Exception e) { // notify that the changes are over (i.e. to avoid dead locks) region_changed_signal.emit(region); Glib::ustring txt = _("Could not add dimension: ") + e.Message; if (vRegions.size() == 1) { // show error message directly Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); msg.run(); } else { // remember error, they are shown after all regions have been processed errors.insert(txt); } } } // update all GUI elements refreshManager(); if (!errors.empty()) { Glib::ustring txt = _( "The following errors occurred while trying to create the dimension on all regions:" ); txt += "\n\n"; for (std::set<Glib::ustring>::const_iterator it = errors.begin(); it != errors.end(); ++it) { txt += "-> " + *it + "\n"; } txt += "\n"; txt += _( "You might also want to check the console for further warnings and " "error messages." ); Gtk::MessageDialog msg(*this, txt, false, Gtk::MESSAGE_ERROR); msg.run(); } } }
//------------------------------------------------------------------------------ bool mforms::gtk::ToolBarImpl::create_tool_item(mforms::ToolBarItem *item, ToolBarItemType type) { Gtk::Widget *w = 0; switch (type) { case mforms::TextActionItem: case mforms::ActionItem: case mforms::SwitcherItem: { Gtk::Button *btn = Gtk::manage(new Gtk::Button()); btn->set_focus_on_click(false); btn->set_border_width(0); btn->set_relief(Gtk::RELIEF_NONE); btn->signal_clicked().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item)); if (type == mforms::SwitcherItem) btn->set_always_show_image(true); w = btn; break; } case mforms::SegmentedToggleItem: case mforms::ToggleItem: { Gtk::ToggleButton *btn = Gtk::manage(new Gtk::ToggleButton()); btn->set_focus_on_click(false); btn->set_relief(Gtk::RELIEF_NONE); btn->signal_toggled().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item)); btn->set_inconsistent(false); w = btn; break; } case mforms::SeparatorItem: { Gtk::Separator *sep = new Gtk::Separator(Gtk::ORIENTATION_VERTICAL); w = sep; break; } case mforms::SearchFieldItem: { #if GTK_VERSION_GE(2, 16) Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); w = entry; entry->set_icon_from_stock(Gtk::Stock::FIND); #else Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); w = hbox; Gtk::Image *image = Gtk::manage(new Gtk::Image(Gtk::Stock::FIND, Gtk::ICON_SIZE_MENU)); Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); hbox->pack_start(*image, false, true); hbox->pack_start(*entry, true, true); hbox->set_data("entry", entry); hbox->show_all(); #endif entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item)); break; } case mforms::TextEntryItem: { Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); w = hbox; Gtk::Entry *entry = Gtk::manage(new Gtk::Entry()); hbox->pack_start(*entry, true, true); hbox->set_data("entry", entry); hbox->show_all(); entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item)); break; } case mforms::FlatSelectorItem: case mforms::SelectorItem: { Gtk::ComboBoxText *ct = Gtk::manage(new Gtk::ComboBoxText()); ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item)); w = ct; break; } case mforms::ColorSelectorItem: { if (!color_combo_columns) { color_combo_columns = new ColorComboColumns(); } Gtk::ComboBox *ct = Gtk::manage(new Gtk::ComboBox()); ct->pack_start(color_combo_columns->image); ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item)); w = ct; break; } case mforms::ExpanderItem: case mforms::LabelItem: { Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5)); w = label; break; } case mforms::ImageBoxItem: { Gtk::Image *image = Gtk::manage(new Gtk::Image()); w = image; break; } case mforms::TitleItem: { Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5)); w = label; auto provider = Gtk::CssProvider::create(); provider->load_from_data("* { color: #333; font-weight: bold; }"); w->get_style_context()->add_provider(provider, GTK_STYLE_PROVIDER_PRIORITY_USER); break; } } if (w) { w->show(); } else logError("create_tool_item, widget is 0 for passed type %i\n", type); item->set_data(w); return w != 0; }
void setCombobox(string n, int i) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(n, cb); cb->set_active(i); }
Gtk::TreeModel::iterator getComboboxIter(string cbn) { Gtk::ComboBox* cb; VRGuiBuilder()->get_widget(cbn.c_str(), cb); return cb->get_active(); }