Audacity 3.2.0
ExtImportPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ExtImportPrefs.cpp
6
7 LRN
8
9*******************************************************************//*******************************************************************/
15
16
17
18#include "ExtImportPrefs.h"
19
20#include <wx/defs.h>
21#include <wx/listctrl.h>
22#include <wx/dnd.h>
23
24#include "Prefs.h"
25#include "ShuttleGui.h"
26#include "Import.h"
27#include "AudacityMessageBox.h"
28#include "../widgets/Grid.h"
29
30#define EXTIMPORT_MIME_SUPPORT 0
31
33{
42};
43
44BEGIN_EVENT_TABLE(ExtImportPrefs, PrefsPanel)
48 EVT_GRID_CELL_LEFT_CLICK (ExtImportPrefs::OnRuleTableCellClick)
49 EVT_GRID_EDITOR_HIDDEN (ExtImportPrefs::OnRuleTableEdit)
50 EVT_GRID_SELECT_CELL (ExtImportPrefs::OnRuleTableSelect)
51 EVT_GRID_RANGE_SELECT (ExtImportPrefs::OnRuleTableSelectRange)
59
60ExtImportPrefs::ExtImportPrefs(wxWindow * parent, wxWindowID winid)
61/* i18n-hint: Title of dialog governing "Extended", or "advanced,"
62 * audio file import options */
63: PrefsPanel(parent, winid, XO("Extended Import")), RuleTable(NULL),
64 PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
65 mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1)
66{
67 Populate();
68
69 // See bug #2315 for discussion
70 // This should be reviewed and (possibly) removed after wx3.1.3.
71 Bind(wxEVT_SHOW, &ExtImportPrefs::OnShow, this);
72}
74{
75}
76
78{
80}
81
83{
84 return XO("Preferences for ExtImport");
85}
86
88{
89 return "Extended_Import_Preferences";
90}
91
94{
95 // Ensure Importer has current items
97
98 //------------------------- Main section --------------------
99 // Now construct the GUI itself.
100 // Use 'eIsCreatingFromPrefs' so that the GUI is
101 // initialised with values from gPrefs.
104 // ----------------------- End of main section --------------
105}
106
108{
109 S.SetBorder(2);
110 S.StartScroller();
111
112 S.TieCheckBox(XXO("A&ttempt to use filter in OpenFile dialog first"),
113 {wxT("/ExtendedImport/OverrideExtendedImportByOpenFileDialogChoice"),
114 true});
115 S.StartStatic(XO("Rules to choose import filters"), 1);
116 {
117 S.SetSizerProportion(1);
118 S.StartHorizontalLay (wxEXPAND, 1);
119 {
120 bool fillRuleTable = false;
121 if (RuleTable == NULL)
122 {
124
125 RuleTable->SetColLabelSize(RuleTable->GetDefaultRowSize());
126#if EXTIMPORT_MIME_SUPPORT
127 RuleTable->CreateGrid (0, 2, wxGrid::wxGridSelectRows);
128#else
129 RuleTable->CreateGrid (0, 1, wxGrid::wxGridSelectRows);
130#endif
131 RuleTable->DisableDragColMove ();
132 RuleTable->DisableDragRowSize ();
133 RuleTable->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
134 RuleTable->SetColLabelValue (0, _("File extensions"));
135#if EXTIMPORT_MIME_SUPPORT
136 RuleTable->SetColLabelValue (1, _("Mime-types"));
137#endif
138 RuleTable->SetRowLabelSize (0);
139 RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
140 // call SetMinSize to enable scrolling on large content
141 RuleTable->Fit();
142 RuleTable->SetMinSize(RuleTable->GetSize());
143
144 ExtImportPrefsDropTarget *dragtarget1 {};
145 RuleTable->SetDropTarget (
146 dragtarget1 = safenew ExtImportPrefsDropTarget(
147 dragtext1 = safenew wxTextDataObject(wxT(""))
148 )
149 );
150 dragtarget1->SetPrefs (this);
151
152 RuleTable->EnableDragCell (true);
153 fillRuleTable = true;
154 }
155 S.Position(wxEXPAND | wxALL)
156 .AddWindow(RuleTable);
157
158 PluginList = S.Id(EIPPluginList).AddListControl(
159 { { XO("Importer order"), wxLIST_FORMAT_LEFT,
160 wxLIST_AUTOSIZE_USEHEADER } },
161 wxLC_REPORT | wxLC_SINGLE_SEL
162 );
163
164 if (fillRuleTable)
165 {
166 ExtImportPrefsDropTarget *dragtarget2 {};
167 PluginList->SetDropTarget (
168 dragtarget2 = safenew ExtImportPrefsDropTarget(
169 dragtext2 = safenew wxTextDataObject(wxT(""))
170 )
171 );
172 dragtarget2->SetPrefs (this);
173
174 auto &items = Importer::Get().GetImportItems();
175 {
176 int i = -1;
177 for (const auto &item : items)
178 AddItemToTable (++i, item.get());
179 }
180 if (!items.empty())
181 {
182 RuleTable->SelectRow(0);
183 RuleTable->SetGridCursor(0,0);
184 }
185 }
186 }
187 S.EndHorizontalLay();
188 S.StartHorizontalLay (wxSHRINK, 0);
189 {
190 MoveRuleUp = S.Id (EIPMoveRuleUp).AddButton(XXO("Move rule &up"));
191 MoveRuleDown = S.Id (EIPMoveRuleDown).AddButton(
192 XXO("Move rule &down"));
193 MoveFilterUp = S.Id (EIPMoveFilterUp).AddButton(
194 XXO("Move f&ilter up"));
195 MoveFilterDown = S.Id (EIPMoveFilterDown).AddButton(
196 XXO("Move &filter down"));
197 }
198 S.EndHorizontalLay();
199 S.StartHorizontalLay (wxSHRINK, 0);
200 {
201 AddRule = S.Id (EIPAddRule).AddButton(XXO("&Add new rule"));
202 DelRule = S.Id (EIPDelRule).AddButton(XXO("De&lete selected rule"));
203 }
204 S.EndHorizontalLay();
205 }
206 S.EndStatic();
207 S.EndScroller();
208
209 Layout();
210 Fit();
211 SetMinSize(GetSize());
212}
213
215{
218
220
221 return true;
222}
223
224// See bug #2315 for discussion. This should be reviewed
225// and (possibly) removed after wx3.1.3.
226void ExtImportPrefs::OnShow(wxShowEvent &event)
227{
228 event.Skip();
229 if (event.IsShown())
230 {
231 RuleTable->Refresh();
232 PluginList->Refresh();
233 }
234}
235
236void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event)
237{
238 for (int i = 0; i < 1; i++)
239 {
240#ifdef __WXMAC__
241 if (!mFakeKeyEvent && !wxGetKeyState(WXK_COMMAND))
242 break;
243#else
244 if (!mFakeKeyEvent && !wxGetKeyState(WXK_CONTROL))
245 break;
246#endif
247
248 if (DoOnPluginKeyDown (event.GetKeyCode()))
249 event.Skip();
250 }
251}
252
253void ExtImportPrefs::SwapPluginRows (int row1, int row2)
254{
255 wxString t, t2;
256 long d, d2;
257 ImportPlugin *ip1, *ip2;
258
259 auto &items = Importer::Get().GetImportItems();
260 ExtImportItem *item = NULL;
261 if( last_selected >= 0 )
262 item = items[last_selected].get();
263
264 t = PluginList->GetItemText (row1);
265 d = PluginList->GetItemData (row1);
266 d2 = PluginList->GetItemData (row2);
267 PluginList->SetItemText (row1, PluginList->GetItemText (row2));
268 PluginList->SetItemText (row2, t);
269 if (d == -1 || d2 == -1)
270 {
271 PluginList->SetItemData (row1, PluginList->GetItemData (row2));
272 PluginList->SetItemData (row2, d);
273 if( !item )
274 return;
275 if (d == -1)
276 {
277 item->divider = row2;
278 }
279 else if (d2 == -1)
280 {
281 item->divider = row1;
282 }
283 }
284 else
285 {
286 if( !item )
287 return;
288 ip1 = item->filter_objects[d];
289 ip2 = item->filter_objects[d2];
290 item->filter_objects[d] = ip2;
291 item->filter_objects[d2] = ip1;
292 t = item->filters[d];
293 t2 = item->filters[d2];
294 item->filters[d] = t2;
295 item->filters[d2] = t;
296 }
297}
298
300{
301 if (code != WXK_UP && code != WXK_DOWN)
302 return false;
303
304 long itemIndex = -1;
305 long itemIndex2 = -1;
306 itemIndex = PluginList->GetNextItem(itemIndex,
307 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
308 if (itemIndex == -1)
309 return false;
310
311 if (last_selected == -1)
312 return false;
313
314 auto &items = Importer::Get().GetImportItems();
315 ExtImportItem *item = items[last_selected].get();
316
317 if (code == WXK_UP && itemIndex == 0)
318 return false;
319 else if (code == WXK_DOWN && itemIndex == PluginList->GetItemCount() - 1)
320 return false;
321
322 if (code == WXK_UP)
323 {
324 itemIndex2 = itemIndex - 1;
325 }
326 else if (code == WXK_DOWN)
327 {
328 itemIndex2 = itemIndex + 1;
329 }
330 SwapPluginRows (itemIndex, itemIndex2);
331 if (mFakeKeyEvent)
332 {
333 PluginList->SetItemState (itemIndex, 0, wxLIST_STATE_SELECTED);
334 PluginList->SetItemState (itemIndex2, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
335 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
336 }
337 int fcount = item->filter_objects.size();
338 if (item->divider >= fcount)
339 {
340 item->divider = -1;
341 }
342 if (item->divider < -1)
343 item->divider = item->filter_objects.size() - 1;
344
345 return true;
346}
347
348
349void ExtImportPrefs::SwapRows (int row1, int row2)
350{
351 int t;
352 wxString ts;
353 if (row1 == row2)
354 return;
355 if (row1 > row2)
356 {
357 t = row1;
358 row1 = row2;
359 row2 = t;
360 }
361 auto &items = Importer::Get().GetImportItems();
362
363 auto &t1 = items[row1];
364 auto &t2 = items[row2];
365 std::swap(t1, t2);
366
367 for (int i = 0; i < RuleTable->GetNumberCols(); i++)
368 {
369 ts = RuleTable->GetCellValue (row2, i);
370 RuleTable->SetCellValue (row2, i, RuleTable->GetCellValue (row1, i));
371 RuleTable->SetCellValue (row1, i, ts);
372 }
373}
374
375void ExtImportPrefs::OnPluginBeginDrag(wxListEvent& WXUNUSED(event))
376{
377 wxDropSource dragSource(this);
378 dragtext2->SetText(wxT(""));
379 dragSource.SetData(*dragtext2);
381 if( mDragFocus == NULL )
382 return;
383 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
384 mDragFocus = NULL;
385 switch (result)
386 {
387 case wxDragCopy:
388 case wxDragMove:
389 case wxDragNone:
390 return;
391 break;
392 default:
393 break;
394 }
395}
396
398{
399 int mods = event.GetModifiers();
400 if (mods & wxMOD_CMD && (event.GetKeyCode() == WXK_UP ||
401 event.GetKeyCode() == WXK_DOWN))
402 {
403 DoOnRuleTableKeyDown (event.GetKeyCode());
404 }
405 else
406 {
407 event.Skip();
408 }
409}
410
412{
413 int selrow = RuleTable->GetGridCursorRow ();
414 wxString ts;
415 if (keycode == WXK_UP)
416 {
417 if (selrow <= 0)
418 return;
419 SwapRows (selrow - 1, selrow);
420 RuleTable->MoveCursorUp (false);
421 RuleTable->SelectRow (selrow - 1);
422 }
423 else if (keycode == WXK_DOWN)
424 {
425 if (selrow == RuleTable->GetNumberRows() - 1)
426 return;
427 SwapRows (selrow, selrow + 1);
428 RuleTable->MoveCursorDown (false);
429 RuleTable->SelectRow (selrow + 1);
430 }
431}
432
433void ExtImportPrefs::OnRuleTableSelect (wxGridEvent& event)
434{
435 int toprow;
436 event.Skip();
437 if (!event.Selecting() || mStopRecursiveSelection)
438 return;
439
440 toprow = event.GetRow();
441 if (toprow < 0)
442 return;
443
444 DoOnRuleTableSelect (toprow);
445}
446
447void ExtImportPrefs::OnRuleTableSelectRange (wxGridRangeSelectEvent& event)
448{
449 int toprow;
450 event.Skip();
451 if (!event.Selecting() || mStopRecursiveSelection)
452 return;
453
454 toprow = event.GetTopRow();
455 if (toprow < 0)
456 return;
457
458 DoOnRuleTableSelect (toprow);
460 RuleTable->SelectRow (toprow);
462 RuleTable->SetGridCursor (toprow, 0);
463}
464
466{
467 auto &items = Importer::Get().GetImportItems();
468
469 if (toprow < 0 || toprow >= (int)items.size())
470 {
471 return;
472 }
473
474 ExtImportItem *item = items[toprow].get();
475 PluginList->DeleteAllItems();
476
477 int fcount;
478 fcount = item->filters.size();
479 int shift = 0;
480 for (int i = 0; i < fcount; i++)
481 {
482 if (item->divider == i)
483 {
484 PluginList->InsertItem (i, _("Unused filters:"));
485 PluginList->SetItemData (i, -1);
486 shift = 1;
487 }
488 if (item->filter_objects[i] != NULL)
489 {
490 PluginList->InsertItem (i + shift,
491 item->filter_objects[i]->GetPluginFormatDescription().Translation());
492 }
493 else
494 {
495 PluginList->InsertItem (i + shift, item->filters[i]);
496 }
497 PluginList->SetItemData (i + shift, i);
498 }
499 if (item->divider == -1)
500 {
501 PluginList->InsertItem (fcount, _("Unused filters:"));
502 PluginList->SetItemData (fcount, -1);
503 }
504 wxListItem info;
505 info.SetId (0);
506 info.SetColumn (0);
507 info.SetStateMask (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
508 info.SetState (wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
509 info.SetMask (wxLIST_MASK_STATE);
510 PluginList->SetItem (info);
511 PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE);
512 last_selected = toprow;
513}
514
515void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event)
516{
517 int row = event.GetRow();
518 int col = event.GetCol();
519 auto &items = Importer::Get().GetImportItems();
520 ExtImportItem *item = items[row].get();
521 RuleTable->SaveEditControlValue();
522
523 wxString val = RuleTable->GetCellValue (row, col);
524 int fixSpaces = wxNO;
525 bool askedAboutSpaces = false;
526 wxArrayString vals;
527 wxString delims(wxT(":"));
528 Importer::Get().StringToList (val, delims, vals);
529 switch (col)
530 {
531 case 0:
532 item->extensions.clear();
533 break;
534 case 1:
535 item->mime_types.clear();
536 break;
537 }
538
539 for (size_t i = 0; i < vals.size(); i++)
540 {
541
542 wxString trimmed = vals[i];
543 trimmed.Trim().Trim(false);
544 if (trimmed != vals[i])
545 {
546 if (!askedAboutSpaces)
547 {
548 fixSpaces = AudacityMessageBox(
549 XO(
550"There are space characters (spaces, newlines, tabs or linefeeds) in one of \
551the items. They are likely to break the pattern matching. Unless you know \
552what you are doing, it is recommended to trim spaces. Do you want \
553Audacity to trim spaces for you?"),
554 XO("Spaces detected"),
555 wxYES_NO);
556 askedAboutSpaces = true;
557 }
558 if (fixSpaces != wxYES)
559 {
560 trimmed = vals[i];
561 }
562 else
563 {
564 vals[i] = trimmed;
565 }
566 }
567 switch (col)
568 {
569 case 0:
570 item->extensions.push_back(trimmed);
571 break;
572 case 1:
573 item->mime_types.push_back(trimmed);
574 break;
575 }
576 }
577 if (fixSpaces == wxYES)
578 {
579 wxString vals_as_string;
580 for (size_t i = 0; i < vals.size(); i++)
581 {
582 if (i > 0)
583 vals_as_string.Append (wxT(":"));
584 vals_as_string.Append (vals[i]);
585 }
586 RuleTable->SetCellValue (row, col, vals_as_string);
587 }
588
589 RuleTable->AutoSizeColumns ();
590}
591
593{
594 wxString extensions, mime_types;
595 if (item->extensions.size() > 0)
596 {
597 extensions.Append (item->extensions[0]);
598 for (unsigned int i = 1; i < item->extensions.size(); i++)
599 {
600 extensions.Append (wxT(":"));
601 extensions.Append (item->extensions[i]);
602 }
603 }
604 if (item->mime_types.size() > 0)
605 {
606 mime_types.Append (item->mime_types[0]);
607 for (unsigned int i = 1; i < item->mime_types.size(); i++)
608 {
609 mime_types.Append (wxT(":"));
610 mime_types.Append (item->mime_types[i]);
611 }
612 }
613
614 RuleTable->InsertRows (index, 1);
615 RuleTable->SetCellValue (index, 0, extensions);
616#if EXTIMPORT_MIME_SUPPORT
617 RuleTable->SetCellValue (index, 1, mime_types);
618#endif
619 RuleTable->AutoSizeColumns ();
620}
621
622void ExtImportPrefs::OnAddRule(wxCommandEvent& WXUNUSED(event))
623{
624 auto &items = Importer::Get().GetImportItems();
625 auto uitem = Importer::Get().CreateDefaultImportItem();
626 auto item = uitem.get();
627 items.push_back(std::move(uitem));
628 AddItemToTable (RuleTable->GetNumberRows (), item);
629
630 RuleTable->SelectRow(RuleTable->GetNumberRows () - 1);
631 RuleTable->SetGridCursor (RuleTable->GetNumberRows () - 1, 0);
632 RuleTable->SetFocus();
633}
634
635void ExtImportPrefs::OnDelRule(wxCommandEvent& WXUNUSED(event))
636{
637 if (last_selected < 0)
638 return;
639 auto &items = Importer::Get().GetImportItems();
640
641 int msgres = AudacityMessageBox (
642 XO("Do you really want to delete selected rule?"),
643 XO("Rule deletion confirmation"),
644 wxYES_NO,
645 RuleTable);
646 // Yes or no, there is no third!
647 if (msgres != wxYES)
648 return;
649
650 PluginList->DeleteAllItems();
651 items.erase (items.begin() + last_selected);
653 // This will change last_selected
654 RuleTable->DeleteRows (last_selected);
655 RuleTable->AutoSizeColumns ();
656 if (last_selected >= RuleTable->GetNumberRows ())
657 last_selected = RuleTable->GetNumberRows () - 1;
658 if (last_selected >= 0)
659 {
660 RuleTable->SelectRow(last_selected);
661 RuleTable->SetGridCursor (last_selected, 0);
662 }
663}
664
665void ExtImportPrefs::OnRuleMoveUp(wxCommandEvent& WXUNUSED(event))
666{
667 DoOnRuleTableKeyDown (WXK_UP);
668}
669
670void ExtImportPrefs::OnRuleMoveDown(wxCommandEvent& WXUNUSED(event))
671{
672 DoOnRuleTableKeyDown (WXK_DOWN);
673}
674
676{
677 wxListEvent fakeevent(wxEVT_COMMAND_LIST_KEY_DOWN, EIPPluginList);
678 fakeevent.SetEventObject(this);
679 fakeevent.m_code = keycode;
680 mFakeKeyEvent = true;
681 GetEventHandler()->ProcessEvent (fakeevent);
682 mFakeKeyEvent = false;
683}
684
685void ExtImportPrefs::OnFilterMoveUp(wxCommandEvent& WXUNUSED(event))
686{
687 FakeOnPluginKeyDown (WXK_UP);
688}
689
690void ExtImportPrefs::OnFilterMoveDown(wxCommandEvent& WXUNUSED(event))
691{
692 FakeOnPluginKeyDown (WXK_DOWN);
693}
694
695
697{
698 int row = event.GetRow();
699 RuleTable->SelectRow (row, false);
700 RuleTable->SetGridCursor (row, 0);
701
702 wxDropSource dragSource(this);
703 dragtext1->SetText(wxT(""));
704 dragSource.SetData(*dragtext1);
706 wxDragResult result = dragSource.DoDragDrop(wxDrag_DefaultMove);
707 mDragFocus = NULL;
708 switch (result)
709 {
710 case wxDragCopy: /* copy the data */
711 case wxDragMove:
712 case wxDragNone:
713 return;
714 break;
715 default: /* do nothing */ break;
716 }
717
718 event.Skip();
719}
720
722 : wxDropTarget(dataObject)
723{
724 mPrefs = NULL;
725}
726
728{
729}
730
732{
733 mPrefs = prefs;
734}
735
736wxDragResult ExtImportPrefsDropTarget::OnData(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
737 wxDragResult def)
738{
739 return def;
740}
741
742#if defined(__WXMSW__)
743/* wxListCtrl::FindItem() in wxPoint()-taking mode works only for lists in
744 * Small/Large-icon mode
745 * wxListCtrl::HitTest() on Windows only hits item label rather than its whole
746 * row, which makes it difficult to drag over items with short or non-existent
747 * labels.
748 */
749long wxCustomFindItem(wxListCtrl *list, int x, int y)
750{
751 long count = list->GetItemCount();
752 wxRect r;
753 for (long i = 0; i < count; i++)
754 {
755 if (list->GetItemRect (i, r))
756 {
757 if (r.Contains (x, y))
758 return i;
759 }
760 }
761 return -1;
762}
763#endif
764
765bool ExtImportPrefsDropTarget::OnDrop(wxCoord x, wxCoord y)
766{
767 if (mPrefs == NULL)
768 return false;
769 wxListCtrl *PluginList = mPrefs->GetPluginList();
770 Grid *RuleTable = mPrefs->GetRuleTable();
771 if (mPrefs->GetDragFocus() == RuleTable)
772 {
773 if (RuleTable->YToRow(
774 RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y) == wxNOT_FOUND)
775 return false;
776 }
777 else if (mPrefs->GetDragFocus() == PluginList)
778 {
779#if defined(__WXMSW__)
780 long item = wxCustomFindItem (PluginList, x, y);
781#else
782 int flags = 0;
783 long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
784#endif
785 if (item < 0)
786 return false;
787 }
788
789 return true;
790}
791
792wxDragResult ExtImportPrefsDropTarget::OnEnter(wxCoord x, wxCoord y,
793 wxDragResult def)
794{
795 return OnDragOver(x, y, def);
796}
797
798wxDragResult ExtImportPrefsDropTarget::OnDragOver(wxCoord x, wxCoord y,
799 wxDragResult WXUNUSED(def))
800{
801 if (mPrefs == NULL)
802 return wxDragNone;
803 wxListCtrl *PluginList = mPrefs->GetPluginList();
804 Grid *RuleTable = mPrefs->GetRuleTable();
805 if (mPrefs->GetDragFocus() == RuleTable)
806 {
807 int row;
808 row = RuleTable->YToRow(RuleTable->CalcUnscrolledPosition(wxPoint(x, y)).y);
809 if (row == wxNOT_FOUND)
810 return wxDragNone;
811
812
813 int cRow = RuleTable->GetGridCursorRow ();
814 if (row != cRow)
815 {
816 mPrefs->SwapRows (cRow, row);
817 RuleTable->SetGridCursor (row, 0);
818 RuleTable->SelectRow (row);
819 }
820 }
821 else if (mPrefs->GetDragFocus() == PluginList)
822 {
823#if defined(__WXMSW__)
824 long item = wxCustomFindItem (PluginList, x, y);
825#else
826 int flags = 0;
827 long item = PluginList->HitTest (wxPoint (x, y), flags, NULL);
828#endif
829 if (item < 0)
830 return wxDragNone;
831
832 long selected = -1;
833 selected = PluginList->GetNextItem(selected,
834 wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
835 if (selected == -1)
836 return wxDragNone;
837
838 if (item != selected)
839 {
840 mPrefs->SwapPluginRows(selected, item);
841 PluginList->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
842 PluginList->SetItemState (item, wxLIST_STATE_SELECTED,
843 wxLIST_STATE_SELECTED);
844 }
845 }
846 return wxDragMove;
847}
848
850{
851}
852
853namespace{
855 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
856 {
857 wxASSERT(parent); // to justify safenew
858 return safenew ExtImportPrefs(parent, winid);
859 },
860 false,
861 // Place as a lower level of the tree of pages:
862 { "ImportExport" }
863};
864}
wxT("CloseDown"))
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
ExtImportPrefsControls
@ EIPRuleTable
@ EIPAddRule
@ EIPMoveRuleDown
@ EIPPluginList
@ EIPDelRule
@ EIPMoveFilterDown
@ EIPMoveFilterUp
@ EIPMoveRuleUp
long wxCustomFindItem(wxListCtrl *list, int x, int y)
#define EXT_IMPORT_PREFS_PLUGIN_SYMBOL
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
MockedPrefs prefs
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
wxArrayString filters
Definition: Import.h:55
int divider
Definition: Import.h:64
wxArrayString extensions
Definition: Import.h:75
wxArrayString mime_types
Definition: Import.h:81
std::vector< ImportPlugin * > filter_objects
Definition: Import.h:69
ExtImportPrefsDropTarget(wxDataObject *dataObject=nullptr)
void SetPrefs(ExtImportPrefs *prefs)
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def)
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
ExtImportPrefs * mPrefs
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
bool OnDrop(wxCoord x, wxCoord y)
A PrefsPanel used to select extended import filter options.
wxButton * MoveFilterUp
Grid * GetRuleTable()
wxButton * MoveRuleUp
wxTextDataObject * dragtext2
void OnAddRule(wxCommandEvent &event)
wxTextDataObject * dragtext1
wxButton * MoveFilterDown
void OnRuleTableCellClick(wxGridEvent &event)
void OnFilterMoveDown(wxCommandEvent &event)
bool DoOnPluginKeyDown(int code)
void DoOnRuleTableKeyDown(int keycode)
TranslatableString GetDescription() const override
wxListCtrl * GetPluginList()
wxWindow * GetDragFocus()
void OnDelRule(wxCommandEvent &event)
wxButton * DelRule
void SwapPluginRows(int row1, int row2)
bool Commit() override
void OnRuleMoveUp(wxCommandEvent &event)
void OnRuleTableSelect(wxGridEvent &event)
void Populate()
Creates the dialog and its contents.
wxButton * MoveRuleDown
void PopulateOrExchange(ShuttleGui &S) override
void OnRuleTableKeyDown(wxKeyEvent &event)
void OnShow(wxShowEvent &event)
void OnPluginKeyDown(wxListEvent &event)
bool mStopRecursiveSelection
void OnPluginBeginDrag(wxListEvent &event)
void FakeOnPluginKeyDown(int keycode)
void OnRuleTableEdit(wxGridEvent &event)
wxButton * AddRule
void DoOnRuleTableSelect(int toprow)
void AddItemToTable(int index, const ExtImportItem *item)
void OnRuleTableSelectRange(wxGridRangeSelectEvent &event)
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
void SwapRows(int row1, int row2)
void OnFilterMoveUp(wxCommandEvent &event)
wxListCtrl * PluginList
ComponentInterfaceSymbol GetSymbol() const override
void OnRuleMoveDown(wxCommandEvent &event)
wxWindow * mDragFocus
static FormatterContext EmptyContext()
Supplies an accessible grid based on wxGrid.
Definition: Grid.h:190
Base class for FlacImportPlugin, LOFImportPlugin, MP3ImportPlugin, OggImportPlugin and PCMImportPlugi...
Definition: ImportPlugin.h:67
static Importer & Get()
Definition: Import.cpp:103
void StringToList(wxString &str, wxString &delims, wxArrayString &list, wxStringTokenizerMode mod=wxTOKEN_RET_EMPTY_ALL)
Definition: Import.cpp:291
void WriteImportItems()
Definition: Import.cpp:410
ExtImportItems & GetImportItems()
Definition: Import.h:169
std::unique_ptr< ExtImportItem > CreateDefaultImportItem()
Definition: Import.cpp:471
void ReadImportItems()
Definition: Import.cpp:299
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634