Glib::ustring MemberList::getSelectMemberid() { Glib::RefPtr<Gtk::TreeSelection> selection = get_selection(); if (!selection->count_selected_rows()) return Glib::ustring(); Gtk::TreeModel::iterator iter = selection->get_selected(); return (*iter)[columns.mid]; }
void Settings_window::on_section_changed_callback(void) { Glib::RefPtr<Gtk::TreeView::Selection> selection = this->sections_view.get_selection(); // При сворачивании строк в одну выделение снимается (несмотря на то, что // для Gtk::TreeView::Selection установлен режим Gtk::SELECTION_SINGLE). if(selection->count_selected_rows()) { this->sections_notebook.set_current_page( selection->get_selected()->get_value( this->sections_view.model_columns.id ) ); } }
void LivePathEffectEditor::on_effect_selection_changed() { Glib::RefPtr<Gtk::TreeSelection> sel = effectlist_view.get_selection(); if (sel->count_selected_rows () == 0) return; Gtk::TreeModel::iterator it = sel->get_selected(); LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef]; if (lperef && current_lpeitem) { if (lperef->lpeobject->get_lpe()) { lpe_list_locked = true; // prevent reload of the list which would lose selection sp_lpe_item_set_current_path_effect(current_lpeitem, lperef); showParams(*lperef->lpeobject->get_lpe()); } } }
void WelcomeWindow::join_match_click() { int page = m_match_lists->get_current_page(); if( page == -1 ) { m_status_lobby->push("Please select a match, and try again"); return; } TreeView *view = (TreeView*)m_match_lists->get_nth_page( page ); if( view == NULL ) { m_status_lobby->push("Please select a match, and try again"); return; } MatchListColumns columns; Glib::RefPtr<Gtk::TreeSelection> select = view->get_selection(); if( select->count_selected_rows() != 1) { m_status_lobby->push("Please select a match, and try again"); return; } TreeModel::iterator iter = select->get_selected(); TreeModel::Row row = *( iter ); int matchID = row[columns.m_matchID]; vector<PlayerDescription> playerDescriptions; playerDescriptions = JoinMatch(matchID, m_currentMatch); if( playerDescriptions.size() > 0 ) { m_currentMatch.m_ID = matchID; LaunchMatchLobbyPane(playerDescriptions); } else { m_currentMatch.m_ID = 0; m_status_lobby->push("Failed to join match. Is it full?"); return; } }
int DlgPropiedades::getOpcion(Gtk::TreeView * tr) /* Pasándole un treeView, devuelve la opción seleccionada si la hay, o un -1 en otro caso */ { int toret = -1; if ( tr != NULL ) { Glib::RefPtr<Gtk::TreeSelection> selected = tr->get_selection(); std::vector<Gtk::TreeModel::Path> selectedRows = selected->get_selected_rows(); if ( selected->count_selected_rows() > 0 ) { std::vector<Gtk::TreeModel::Path>::const_iterator it = selectedRows.begin() ; toret = *( (*it).begin() ); } } return toret; }
void ukwd_wiring_dialog::on_delete_clicked() { Glib::RefPtr<Gtk::ListStore> m; Gtk::TreeView *t = NULL; ref_xml->get_widget("stecker_treeview" + name_post_fix, t); Glib::RefPtr<Gtk::TreeSelection> selection = t->get_selection(); if (selection->count_selected_rows() != 0) { // A connection is selected m = m.cast_dynamic(t->get_model()); Gtk::TreeModel::iterator iter = selection->get_selected(); // Test is fixed connection is selected for removal if ( (((*iter)[plugboard_cols.first]) != "J") and (((*iter)[plugboard_cols.second]) != "Y") ) { // No! -> delete the selected connection remove_plug((*iter)[plugboard_cols.first], (*iter)[plugboard_cols.second]); num_plugs--; update_plug_counter(); m->erase(iter); } else { // Yes! -> error message Gtk::MessageDialog msg(*dialog, "The connection J, Y is fixed and cannot be removed.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msg.set_title("Enigma"); msg.run(); } } else { // No connection is selected Gtk::MessageDialog msg(*dialog, "Nothing selected to delete.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msg.set_title("Enigma"); msg.run(); } }
bool MemberList::on_button_press_event(GdkEventButton * ev) { bool result = Gtk::TreeView::on_button_press_event(ev); Glib::RefPtr < Gtk::TreeSelection > selection = this->get_selection(); Gtk::TreeModel::iterator iter = selection->get_selected(); if (!selection->count_selected_rows()) return result; Gtk::TreeModel::Path path(iter); Gtk::TreeViewColumn * tvc; int cx, cy; /** get_path_at_pos() 是为确认鼠标是否在选择行上点击的*/ if (!this-> get_path_at_pos((int) ev->x, (int) ev->y, path, tvc, cx, cy)) return FALSE; Glib::ustring name = (*iter)[columns.mid]; if ((ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS)) { std::cout << "双击" << name << std::endl; } else if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3)) { std::cout << "右击" << name << std::endl; } }