//------------------------------------------------------------------------------ int ColumnsModel::append_check_column(const int bec_tm_idx, const std::string& name, const Editable editable, const ToggleAction action) { Gtk::TreeModelColumn<bool>* col = new Gtk::TreeModelColumn<bool>; _columns.push_back(col); add(*col); add_bec_index_mapping(bec_tm_idx); int nr_of_cols; // If we have bec_tm_idx set to negative value it means that column added is not // directly mapped to a model. Handling of values set/get are done through // ListModelWrapper::_fake_column_value_getter/setter slot if (editable == EDITABLE) { nr_of_cols = _treeview->append_column_editable(base::replaceString(name, "_", "__"), *col); Gtk::CellRendererToggle* cell = (Gtk::CellRendererToggle*)(_treeview->get_column_cell_renderer(nr_of_cols - 1)); cell->property_activatable() = true; if (action == TOGGLE_BY_WRAPPER /* && bec_tm_idx >= 0 */) { cell->signal_toggled().connect(sigc::bind(sigc::mem_fun(*_tmw, &ListModelWrapper::after_cell_toggle /*<bool>*/ ), sigc::ref(*col))); } } else nr_of_cols = _treeview->append_column(base::replaceString(name, "_", "__"), *col); _treeview->get_column(nr_of_cols - 1)->set_resizable(true); return nr_of_cols; }
// tileset list window level_editor::tileset_list::tileset_list(window& _window, preferences& _preferences) : Gtk::Dialog("Tileset list", _window, false, false), m_window(_window), m_preferences(_preferences) { m_list_store = Gtk::ListStore::create(columns); m_tree_view.set_model(m_list_store); // Add editable "active" column m_tree_view.append_column("Active", columns.active); Gtk::CellRendererToggle* renderer = dynamic_cast<Gtk::CellRendererToggle*>(m_tree_view.get_column_cell_renderer(0)); // For some reason there's no set_activatable function for CellRendererToggle on gtkmm 2.16 windows Glib::PropertyProxy<bool> activatable = renderer->property_activatable(); activatable.set_value(true); renderer->signal_toggled().connect(sigc::mem_fun( this, &tileset_list::on_active_toggled)); m_tree_view.append_column("Image", columns.image); m_tree_view.append_column("Prefix", columns.prefix); m_tree_view.append_column("X", columns.x); m_tree_view.append_column("Y", columns.y); m_tree_view.append_column("Main", columns.main); Gtk::ScrolledWindow* scrolled = Gtk::manage(new Gtk::ScrolledWindow()); scrolled->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrolled->set_shadow_type(Gtk::SHADOW_IN); scrolled->add(m_tree_view); get_vbox()->pack_start(*scrolled); Gtk::Button* button_new = Gtk::manage(new Gtk::Button("New")); button_new->signal_clicked().connect(sigc::mem_fun(this, &tileset_list::on_new_clicked)); get_action_area()->pack_start(*button_new); Gtk::Button* button_edit = Gtk::manage(new Gtk::Button("Edit")); button_edit->signal_clicked().connect(sigc::mem_fun(this, &tileset_list::on_edit_clicked)); get_action_area()->pack_start(*button_edit); Gtk::Button* button_delete = Gtk::manage(new Gtk::Button("Delete")); button_delete->signal_clicked().connect(sigc::mem_fun(this, &tileset_list::on_delete_clicked)); get_action_area()->pack_start(*button_delete); add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE); set_default_size(400, 300); show_all_children(); }