void EditChainsDialog::OnRemove(wxCommandEvent & WXUNUSED(event)) { long item = mChains->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (item == -1) { return; } wxString name = mChains->GetItemText(item); wxMessageDialog m(this, /*i18n-hint: %s will be replaced by the name of a file.*/ wxString::Format(_("Are you sure you want to delete %s?"), name.c_str()), GetTitle(), wxYES_NO | wxICON_QUESTION); if (m.ShowModal() == wxID_NO) { return; } mBatchCommands.DeleteChain(name); if (item >= (mChains->GetItemCount() - 1) && item >= 0) { item--; } mActiveChain = mChains->GetItemText(item); PopulateChains(); }
/// Creates the dialog and its contents. void EditChainsDialog::Populate() { //------------------------- Main section -------------------- ShuttleGui S(this, eIsCreating); PopulateOrExchange(S); // ----------------------- End of main section -------------- // Get and validate the currently active chain mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT("")); // Go populate the chains list. PopulateChains(); // We have a bare list. We need to add columns and content. PopulateList(); // Layout and set minimum size of window Layout(); Fit(); SetSizeHints(GetSize()); // Size and place window SetSize(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5); Center(); // Set the column size for the chains list. wxSize sz = mChains->GetClientSize(); mChains->SetColumnWidth(0, sz.x); // Size columns properly FitColumns(); }
void EditChainsDialog::OnChainsEndEdit(wxListEvent &event) { if (event.IsEditCancelled()) { return; } wxString newname = event.GetLabel(); mBatchCommands.RenameChain(mActiveChain, newname); mActiveChain = newname; PopulateChains(); }
void EditChainsDialog::OnAdd(wxCommandEvent & WXUNUSED(event)) { while (true) { wxTextEntryDialog d(this, _("Enter name of new chain"), _("Name of new chain")); d.SetName(d.GetTitle()); wxString name; if (d.ShowModal() == wxID_CANCEL) { return; } name = d.GetValue().Strip(wxString::both); if (name.Length() == 0) { wxMessageBox(_("Name must not be blank"), GetTitle(), wxOK | wxICON_ERROR, this); continue; } if (name.Contains(wxFILE_SEP_PATH) || name.Contains(wxFILE_SEP_PATH_UNIX)) { /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/ wxMessageBox(wxString::Format(_("Names may not contain '%c' and '%c'"), wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX), GetTitle(), wxOK | wxICON_ERROR, this); continue; } mBatchCommands.AddChain(name); mActiveChain = name; PopulateChains(); break; } }
void EditChainsDialog::OnAdd(wxCommandEvent &event) { while (true) { wxTextEntryDialog d(this, _("Enter name of new chain"), GetTitle()); wxString name; if (d.ShowModal() == wxID_CANCEL) { return; } name = d.GetValue().Strip(wxString::both); if (name.Length() == 0) { wxMessageBox(_("Name must not be blank"), GetTitle(), wxOK | wxICON_ERROR, this); continue; } if (name.Contains(wxFILE_SEP_PATH) || name.Contains(wxFILE_SEP_PATH_UNIX)) { wxMessageBox(wxString::Format(_("Names may not contain '%c' and '%c'"), wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX), GetTitle(), wxOK | wxICON_ERROR, this); continue; } mBatchCommands.AddChain(name); mActiveChain = name; PopulateChains(); break; } }