void SFTPTreeView::OnAddBookmark(wxAuiToolBarEvent& event) { if ( event.IsDropDownClicked() ) { // Show the menu const wxArrayString &bookmarks = m_account.GetBookmarks(); wxMenu menu; for(size_t i=0; i<bookmarks.GetCount(); ++i) { menu.Append(ID_SFTP_BOOKMARK_FIRST+i, bookmarks.Item(i)); } menu.AppendSeparator(); menu.Append(ID_SFTP_BOOKMARK_SETTINGS, _("Manage bookmarks...")); wxPoint pt = event.GetItemRect().GetBottomLeft(); pt.y++; int sel = m_auibar->GetPopupMenuSelectionFromUser( menu, pt ); if ( sel >= ID_SFTP_BOOKMARK_FIRST && sel <= ID_SFTP_BOOKMARK_LAST ) { // A bookmark was selected CallAfter( &SFTPTreeView::DoBuildTree, bookmarks.Item(sel - ID_SFTP_BOOKMARK_FIRST) ); } else if ( sel == ID_SFTP_BOOKMARK_SETTINGS ) { // Bookmark settings CallAfter( &SFTPTreeView::ManageBookmarks ); } } else { try { // sanity if ( !m_sftp || !m_sftp->IsConnected() ) { return; } // Get the current selection MyClientDataVect_t selections = GetSelectionsItemData(); if ( selections.size() != 1 ) return; MyClientData* cd = selections.at(0); CHECK_PTR_RET( cd ); if ( !cd->IsFolder() ) return; m_account.AddBookmark( cd->GetFullPath() ); SFTPSettings settings; settings.Load(); settings.UpdateAccount( m_account ); settings.Save(); } catch (clException &e) { ::wxMessageBox(e.What(), "SFTP", wxICON_ERROR|wxOK|wxCENTER); } } }
void SFTPTreeView::ManageBookmarks() { SFTPManageBookmarkDlg dlg(NULL, m_account.GetBookmarks()); if(dlg.ShowModal() == wxID_OK) { m_account.SetBookmarks(dlg.GetBookmarks()); SFTPSettings settings; settings.Load(); settings.UpdateAccount(m_account); settings.Save(); } }