//-------------------------------------------------------------------------------- void DbMySQLTableEditorFKPage::fkcol_cell_editing_started(Gtk::CellEditable *cell, const Glib::ustring &path) { bec::NodeId node(path); if (node.is_valid()) _fk_node = node; Gtk::CellRendererCombo* rend = static_cast<Gtk::CellRendererCombo*>(_fk_columns_tv->get_column_cell_renderer(2)); const std::vector<std::string> list = _be->get_fks()->get_columns()->get_ref_columns_list(_fk_node, false); Glib::RefPtr<Gtk::ListStore> model = Glib::RefPtr<Gtk::ListStore>::cast_static(rend->property_model().get_value()); recreate_model_from_string_list(model, list); }
void setCellRendererCombo(string treeviewcolumn, string combolist, Gtk::TreeModelColumnBase& col, sigc::slot<void, const Glib::ustring&, const Gtk::TreeModel::iterator& > sig) { Glib::RefPtr<Gtk::ListStore> combo_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(combolist.c_str())); Gtk::CellRendererCombo* renderer = new Gtk::CellRendererCombo(); renderer->property_has_entry() = false; renderer->property_model() = combo_list; renderer->property_text_column() = 0; renderer->property_editable() = true; Glib::RefPtr<Gtk::TreeView::Column> column = Glib::RefPtr<Gtk::TreeView::Column>::cast_static(VRGuiBuilder()->get_object(treeviewcolumn.c_str())); column->pack_start(*renderer); column->add_attribute(renderer->property_text(), col); renderer->signal_changed().connect(sig); }
void setCellRendererCombo(string treeviewcolumn, string combolist, Gtk::TreeModelColumnBase& col, void (* fkt)(GtkCellRendererCombo*, gchar*, GtkTreeIter*, gpointer)) { Glib::RefPtr<Gtk::ListStore> combo_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(combolist.c_str())); Gtk::CellRendererCombo* renderer = new Gtk::CellRendererCombo(); renderer->property_has_entry() = false; renderer->property_model() = combo_list; renderer->property_text_column() = 0; renderer->property_editable() = true; Glib::RefPtr<Gtk::TreeView::Column> column = Glib::RefPtr<Gtk::TreeView::Column>::cast_static(VRGuiBuilder()->get_object(treeviewcolumn.c_str())); column->pack_start(*renderer); column->add_attribute(renderer->property_text(), col); g_signal_connect (renderer->gobj(), "changed", G_CALLBACK (fkt), NULL); }
//------------------------------------------------------------------------------ const StringColumn& ColumnsModel::append_combo_column(const int bec_tm_idx ,const std::string &name ,Glib::RefPtr<Gtk::ListStore> list_w ,const Editable editable ,bool popup_only) { Gtk::TreeModelColumn<Glib::ustring> *choosen = new Gtk::TreeModelColumn<Glib::ustring>; _columns.push_back(choosen); add(*choosen); add_bec_index_mapping(bec_tm_idx); Gtk::TreeView::Column *col = Gtk::manage(new Gtk::TreeViewColumn(bec::replace_string(name, "_", "__"))); Gtk::CellRendererCombo *cell = Gtk::manage(new Gtk::CellRendererCombo); col->pack_start(*cell); col->add_attribute(cell->property_text(), *choosen); cell->property_model() = list_w; cell->property_text_column() = 0; cell->property_editable() = editable; cell->property_has_entry() = !popup_only; Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel> > *model_col = new Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel> >(); add_bec_index_mapping(bec_tm_idx); add(*model_col); const int nr_of_cols = _treeview->append_column(*col); _columns.push_back(model_col); _treeview->get_column(nr_of_cols-1)->set_resizable(true); if ( editable == EDITABLE ) { Gtk::CellRendererText *cell = (Gtk::CellRendererText*)(_treeview->get_column_cell_renderer(nr_of_cols - 1)); cell->signal_edited().connect(sigc::bind (sigc::mem_fun(*_tmw ,&ListModelWrapper::after_cell_edit<Glib::ustring> ) , sigc::ref(*choosen) ) ); } return *choosen; }
//------------------------------------------------------------------------------ void DbMySQLTableEditorFKPage::update_fk_details() { ::bec::FKConstraintListBE *fk_be = _be->get_fks(); fk_be->refresh(); ::bec::FKConstraintColumnsListBE *fk_columns_be = fk_be->get_columns(); fk_columns_be->refresh(); std::string text; if (_fk_node.is_valid()) fk_be->get_field(_fk_node, ::bec::FKConstraintListBE::OnUpdate, text); set_selected_combo_item(_fk_update_combo, text); if (_fk_node.is_valid()) fk_be->get_field(_fk_node, ::bec::FKConstraintListBE::OnDelete, text); set_selected_combo_item(_fk_delete_combo, text); if (_fk_node.is_valid()) fk_be->get_field(_fk_node, ::bec::FKConstraintListBE::Comment, text); Gtk::TextView *fk_comment(0); _xml->get_widget("fk_comment", fk_comment); fk_comment->get_buffer()->set_text(text); Gtk::Label *label; _xml->get_widget("fk_index_name", label); if (_fk_node.is_valid()) fk_be->get_field(_fk_node, ::bec::FKConstraintListBE::Index, text); else text = ""; label->set_text(text); ssize_t model_only= 0; if (_fk_node.is_valid()) fk_be->get_field(_fk_node, ::bec::FKConstraintListBE::ModelOnly, model_only); _fk_model_only->set_active(model_only!=0); // Update columns _fk_columns_tv->unset_model(); if ( fk_columns_be->count() >= 1 && _fk_node.is_valid() && _fk_node.back() < _be->get_fks()->real_count()) { _fk_columns_tv->remove_all_columns(); _fk_columns_model = ListModelWrapper::create(fk_columns_be, _fk_columns_tv, "FKColumnsModel"); _fk_columns_model->model().append_check_column(bec::FKConstraintColumnsListBE::Enabled, "", EDITABLE); _fk_columns_model->model().append_string_column(bec::FKConstraintColumnsListBE::Column, "Column", RO, NO_ICON); const std::vector<std::string> list; _fk_columns_model->model().append_combo_column(::bec::FKConstraintColumnsListBE::RefColumn ,"Referenced Column" ,model_from_string_list(list) ,EDITABLE ,true); _fk_columns_tv->set_model(_fk_columns_model); // Connect signal so we can fill referenced columns combobox cell with correct values _fkcol_cell_edit_conn.disconnect(); Gtk::CellRendererCombo* rend = static_cast<Gtk::CellRendererCombo*>(_fk_columns_tv->get_column_cell_renderer(2)); if ( rend ) { _fkcol_cell_edit_conn = rend->signal_editing_started(). connect(sigc::mem_fun(this, &DbMySQLTableEditorFKPage::fkcol_cell_editing_started) ); } else g_message("REND is 0!"); _fk_update_combo->set_sensitive(true); _fk_delete_combo->set_sensitive(true); fk_comment->set_sensitive(true); _fk_model_only->set_sensitive(true); } else { _fk_update_combo->set_sensitive(false); _fk_delete_combo->set_sensitive(false); fk_comment->set_sensitive(false); _fk_model_only->set_sensitive(false); } }
ModulePropertyWindow::ModulePropertyWindow(MainWindow* parent, Manager* manager, ApplicationWindow* appWnd) : m_pModule(NULL) { m_pParent = parent; m_pManager = manager; m_pModule = NULL; m_pAppWindow = appWnd; /* Create a new scrolled window, with scrollbars only if needed */ set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); add(m_TreeView); /* create tree store */ m_refTreeModel = Gtk::TreeStore::create(m_Columns); m_TreeView.set_model(m_refTreeModel); //Add the Model’s column to the View’s columns: Gtk::CellRendererText* itemRenderer = Gtk::manage(new Gtk::CellRendererText()); itemRenderer->property_editable() = false; Gtk::TreeViewColumn* itemCol = Gtk::manage(new Gtk::TreeViewColumn("Property", *itemRenderer)); itemCol->add_attribute(*itemRenderer, "foreground-gdk", m_Columns.m_col_color_item); itemCol->add_attribute(*itemRenderer, "text", m_Columns.m_col_name); itemCol->set_resizable(true); m_TreeView.append_column(*itemCol); Gtk::CellRendererCombo* valueRenderer = Gtk::manage(new Gtk::CellRendererCombo()); Gtk::TreeView::Column* valueCol = Gtk::manage(new Gtk::TreeView::Column("Value")); valueCol->pack_start(*valueRenderer); valueCol->add_attribute(*valueRenderer, "foreground-gdk", m_Columns.m_col_color_value); //valueCol->set_resizable(true); valueCol->add_attribute(*valueRenderer, "editable", m_Columns.m_col_editable); //Make this View column represent the m_col_itemchosen model column: #ifdef GLIBMM_PROPERTIES_ENABLED valueCol->add_attribute(valueRenderer->property_text(), m_Columns.m_col_value); #else pColumn->add_attribute(*valueRenderer, "text", m_Columns.m_col_value); #endif #ifdef GLIBMM_PROPERTIES_ENABLED valueCol->add_attribute(valueRenderer->property_model(), m_Columns.m_col_choices); #else valueCol->add_attribute(*valueRenderer, "model", m_Columns.m_col_choices); #endif #ifdef GLIBMM_PROPERTIES_ENABLED valueRenderer->property_text_column() = 0; #else valueRenderer->set_property("text_column", 0); #endif valueRenderer->signal_edited().connect( sigc::mem_fun(*this, &ModulePropertyWindow::onCellEdited) ); m_TreeView.append_column(*valueCol); m_TreeView.set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_BOTH); m_TreeView.set_rules_hint(true); show_all_children(); }