EntityChooser::EntityChooser() : gtkutil::DialogElement(), // create an Element without label _entityStore(Gtk::ListStore::create(_listColumns)) { Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 6)); _widgets[WIDGET_TOPLEVEL] = vbox; // Initialise the base class DialogElement::setValueWidget(_widgets[WIDGET_TOPLEVEL]); Gtk::TreeView* treeView = Gtk::manage(new Gtk::TreeView(_entityStore)); _widgets[WIDGET_TREEVIEW] = treeView; treeView->set_headers_visible(false); // Use the TreeModel's full string search function treeView->set_search_equal_func(sigc::ptr_fun(>kutil::TreeModel::equalFuncStringContains)); // Head Name column treeView->append_column("", _listColumns.name); // Set the tree store to sort on this column _entityStore->set_sort_column_id(_listColumns.name, Gtk::SORT_ASCENDING); _selection = treeView->get_selection(); _selection->signal_changed().connect(sigc::mem_fun(*this, &EntityChooser::onSelectionChanged)); // Scrolled Frame vbox->pack_start(*Gtk::manage(new gtkutil::ScrolledFrame(*treeView)), true, true, 0); populateEntityList(); }
// Create the objects panel (for manipulating the target_addobjectives objects) void ObjectivesEditor::setupEntitiesPanel() { // Tree view listing the target_addobjectives entities Gtk::TreeView* entityList = gladeWidget<Gtk::TreeView>( "entitiesTreeView" ); entityList->set_model(_objectiveEntityList); entityList->set_headers_visible(false); entityList->get_selection()->signal_changed().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onEntitySelectionChanged) ); // Active-at-start column (checkbox) Gtk::CellRendererToggle* startToggle = Gtk::manage(new Gtk::CellRendererToggle); startToggle->signal_toggled().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onStartActiveCellToggled) ); Gtk::TreeViewColumn* startCol = Gtk::manage(new Gtk::TreeViewColumn(_("Start"))); startCol->add_attribute(startToggle->property_active(), _objEntityColumns.startActive); entityList->append_column(*startCol); // Name column entityList->append_column(*Gtk::manage(new gtkutil::TextColumn("", _objEntityColumns.displayName))); // Connect button signals Gtk::Button* addButton = gladeWidget<Gtk::Button>("createEntityButton"); addButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onAddEntity) ); Gtk::Button* delButton = gladeWidget<Gtk::Button>("deleteEntityButton"); delButton->set_sensitive(false); // disabled at start delButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onDeleteEntity) ); }
// Create the main objective editing widgets void ObjectivesEditor::setupObjectivesPanel() { // Tree view Gtk::TreeView* objList = gladeWidget<Gtk::TreeView>( "objectivesTreeView" ); objList->set_model(_objectiveList); objList->set_headers_visible(true); objList->get_selection()->signal_changed().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onObjectiveSelectionChanged) ); // Key and value text columns objList->append_column(*Gtk::manage( new gtkutil::TextColumn("#", _objectiveColumns.objNumber, false))); objList->append_column(*Gtk::manage( new gtkutil::TextColumn(_("Description"), _objectiveColumns.description, false))); objList->append_column(*Gtk::manage( new gtkutil::TextColumn(_("Diff."), _objectiveColumns.difficultyLevel, false))); Gtk::Button* addButton = gladeWidget<Gtk::Button>("addObjButton"); addButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onAddObjective) ); Gtk::Button* editObjButton = gladeWidget<Gtk::Button>( "editObjButton" ); editObjButton->set_sensitive(false); // not enabled without selection editObjButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onEditObjective) ); Gtk::Button* moveUpObjButton = gladeWidget<Gtk::Button>( "objMoveUpButton" ); moveUpObjButton->set_sensitive(false); // not enabled without selection moveUpObjButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onMoveUpObjective) ); Gtk::Button* moveDownObjButton = gladeWidget<Gtk::Button>( "objMoveDownButton" ); moveDownObjButton->set_sensitive(false); // not enabled without selection moveDownObjButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onMoveDownObjective) ); Gtk::Button* delObjButton = gladeWidget<Gtk::Button>( "delObjButton" ); delObjButton->set_sensitive(false); // not enabled without selection delObjButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onDeleteObjective) ); Gtk::Button* clearObjButton = gladeWidget<Gtk::Button>( "clearObjectivesButton" ); clearObjButton->set_sensitive(false); // requires >0 objectives clearObjButton->signal_clicked().connect( sigc::mem_fun(*this, &ObjectivesEditor::_onClearObjectives) ); }