4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "arraylist.h"
26 #include "awindowgui.inc"
27 #include "binfolder.inc"
29 #include "filesystem.h"
31 #include "indexable.h"
33 #include "mwindow.inc"
47 FOLDER_ENABLED_AND_NOT,
48 FOLDER_ENABLED_OR_NOT,
51 FOLDER_TARGET_PATTERNS,
52 FOLDER_TARGET_FILE_SIZE,
53 FOLDER_TARGET_MOD_TIME,
54 FOLDER_TARGET_TRACK_TYPE,
57 FOLDER_TARGET_FRAMERATE,
58 FOLDER_TARGET_SAMPLERATE,
59 FOLDER_TARGET_CHANNELS,
60 FOLDER_TARGET_DURATION,
64 FOLDER_OP_EQ, FOLDER_OP_GE, FOLDER_OP_GT,
65 FOLDER_OP_NE, FOLDER_OP_LE, FOLDER_OP_LT,
69 class BinFolderFilters : public ArrayList<BinFolderFilter *>
73 ~BinFolderFilters() { remove_all_objects(); }
74 void copy_from(BinFolderFilters *filters);
75 void clear() { remove_all_objects(); }
81 BinFolder(int awindow_folder, const char *title);
82 BinFolder(BinFolder &that);
85 BinFolderFilters filters;
86 void save_xml(FileXML *file);
87 int load_xml(FileXML *file);
88 double matches_indexable(Indexable *idxbl);
89 void copy_from(BinFolder *that);
90 void add_patterns(ArrayList<Indexable*> *drag_assets);
96 class BinFolders : public ArrayList<BinFolder *>
101 void save_xml(FileXML *file);
102 int load_xml(FileXML *file);
103 double matches_indexable(int folder, Indexable *idxbl);
104 void copy_from(BinFolders *that);
105 void clear() { remove_all_objects(); }
108 class BinFolderFilter
114 void update_enabled(int type);
115 void update_target(int type);
116 void update_op(int type);
117 void update_value(const char *text);
118 void save_xml(FileXML *file);
119 int load_xml(FileXML *file);
121 BinFolderEnabled *enabled;
122 BinFolderTarget *target;
124 BinFolderValue *value;
127 class BinFolderEnabled : public BC_ListBoxItem
130 BinFolderEnabled(BinFolderFilter *filter, int type);
131 virtual ~BinFolderEnabled();
132 void update(int type);
134 BinFolderFilter *filter;
136 static const char *types[];
139 class BinFolderEnabledType : public BC_MenuItem
142 BinFolderEnabledType(int no);
143 ~BinFolderEnabledType();
147 class BinFolderEnabledPopup : public BC_PopupMenu
150 BinFolderEnabledPopup(BinFolderList *folder_list);
151 void create_objects();
152 void activate_menu(BC_ListBoxItem *item);
154 BinFolderList *folder_list;
155 BinFolderEnabled *enabled;
158 class BinFolderTarget : public BC_ListBoxItem
161 BinFolderTarget(BinFolderFilter *filter, int type);
162 virtual ~BinFolderTarget();
164 virtual void save_xml(FileXML *file) = 0;
165 virtual void load_xml(FileXML *file) = 0;
166 virtual void copy_from(BinFolderTarget *that) = 0;
167 virtual BC_Window *new_gui(ModifyTargetThread *thread) = 0;
169 BinFolderFilter *filter;
172 static const char *types[];
175 class BinFolderTargetPatterns : public BinFolderTarget
178 BinFolderTargetPatterns(BinFolderFilter *filter);
179 ~BinFolderTargetPatterns();
181 void save_xml(FileXML *file);
182 void load_xml(FileXML *file);
183 void copy_from(BinFolderTarget *that);
184 BC_Window *new_gui(ModifyTargetThread *thread);
185 void update(const char *text);
190 class BinFolderTargetFileSize : public BinFolderTarget
193 BinFolderTargetFileSize(BinFolderFilter *filter);
194 ~BinFolderTargetFileSize();
196 void save_xml(FileXML *file);
197 void load_xml(FileXML *file);
198 void copy_from(BinFolderTarget *that);
199 BC_Window *new_gui(ModifyTargetThread *thread);
200 void update(int64_t file_size, double around);
205 class BinFolderTargetTime : public BinFolderTarget
208 BinFolderTargetTime(BinFolderFilter *filter);
209 ~BinFolderTargetTime();
211 void save_xml(FileXML *file);
212 void load_xml(FileXML *file);
213 void copy_from(BinFolderTarget *that);
214 BC_Window *new_gui(ModifyTargetThread *thread);
215 void update(int64_t mtime, double around);
220 class BinFolderTargetTrackType : public BinFolderTarget
223 BinFolderTargetTrackType(BinFolderFilter *filter);
224 ~BinFolderTargetTrackType();
226 void save_xml(FileXML *file);
227 void load_xml(FileXML *file);
228 void copy_from(BinFolderTarget *that);
229 BC_Window *new_gui(ModifyTargetThread *thread);
230 void update(int data_types);
235 class BinFolderTargetWidth : public BinFolderTarget
238 BinFolderTargetWidth(BinFolderFilter *filter);
239 ~BinFolderTargetWidth();
241 void save_xml(FileXML *file);
242 void load_xml(FileXML *file);
243 void copy_from(BinFolderTarget *that);
244 BC_Window *new_gui(ModifyTargetThread *thread);
245 void update(int width, double around);
250 class BinFolderTargetHeight : public BinFolderTarget
253 BinFolderTargetHeight(BinFolderFilter *filter);
254 ~BinFolderTargetHeight();
256 void save_xml(FileXML *file);
257 void load_xml(FileXML *file);
258 void copy_from(BinFolderTarget *that);
259 BC_Window *new_gui(ModifyTargetThread *thread);
260 void update(int height, double around);
265 class BinFolderTargetFramerate : public BinFolderTarget
268 BinFolderTargetFramerate(BinFolderFilter *filter);
269 ~BinFolderTargetFramerate();
271 void save_xml(FileXML *file);
272 void load_xml(FileXML *file);
273 void copy_from(BinFolderTarget *that);
274 BC_Window *new_gui(ModifyTargetThread *thread);
275 void update(double framerate, double around);
280 class BinFolderTargetSamplerate : public BinFolderTarget
283 BinFolderTargetSamplerate(BinFolderFilter *filter);
284 ~BinFolderTargetSamplerate();
286 void save_xml(FileXML *file);
287 void load_xml(FileXML *file);
288 void copy_from(BinFolderTarget *that);
289 BC_Window *new_gui(ModifyTargetThread *thread);
290 void update(int samplerate, double around);
295 class BinFolderTargetChannels : public BinFolderTarget
298 BinFolderTargetChannels(BinFolderFilter *filter);
299 ~BinFolderTargetChannels();
301 void save_xml(FileXML *file);
302 void load_xml(FileXML *file);
303 void copy_from(BinFolderTarget *that);
304 BC_Window *new_gui(ModifyTargetThread *thread);
305 void update(int channels, double around);
310 class BinFolderTargetDuration : public BinFolderTarget
313 BinFolderTargetDuration(BinFolderFilter *filter);
314 ~BinFolderTargetDuration();
316 void save_xml(FileXML *file);
317 void load_xml(FileXML *file);
318 void copy_from(BinFolderTarget *that);
319 BC_Window *new_gui(ModifyTargetThread *thread);
320 void update(int64_t duration, double around);
325 class BinFolderTargetType : public BC_MenuItem
328 BinFolderTargetType(int no);
329 ~BinFolderTargetType();
334 class BinFolderTargetPopup : public BC_PopupMenu
337 BinFolderTargetPopup(BinFolderList *folder_list);
338 void create_objects();
339 void activate_menu(BC_ListBoxItem *item);
341 BinFolderList *folder_list;
342 BinFolderTarget *target;
346 class BinFolderOp : public BC_ListBoxItem
349 BinFolderOp(BinFolderFilter *filter, int type);
350 virtual ~BinFolderOp();
352 double compare(BinFolderTarget *target, Indexable *idxbl);
353 virtual double test(BinFolderTarget *target, Indexable *idxbl);
354 double around(double v, double a);
355 double around(const char *ap, const char *bp);
357 void copy_from(BinFolderOp *that);
359 BinFolderFilter *filter;
361 static const char *types[];
364 class BinFolderOpType : public BC_MenuItem
367 BinFolderOpType(int no);
373 class BinFolderOpPopup : public BC_PopupMenu
376 BinFolderOpPopup(BinFolderList *folder_list);
377 void create_objects();
378 void activate_menu(BC_ListBoxItem *item);
380 BinFolderList *folder_list;
385 class BinFolderOpAround : public BinFolderOp
388 BinFolderOpAround(BinFolderFilter *filter)
389 : BinFolderOp(filter, FOLDER_OP_AROUND) {}
390 ~BinFolderOpAround() {}
391 double test(BinFolderTarget *target, Indexable *idxbl);
394 class BinFolderOpEQ : public BinFolderOp
397 BinFolderOpEQ(BinFolderFilter *filter)
398 : BinFolderOp(filter, FOLDER_OP_EQ) {}
400 double test(BinFolderTarget *target, Indexable *idxbl);
403 class BinFolderOpGT : public BinFolderOp
406 BinFolderOpGT(BinFolderFilter *filter)
407 : BinFolderOp(filter, FOLDER_OP_GT) {}
409 double test(BinFolderTarget *target, Indexable *idxbl);
412 class BinFolderOpGE : public BinFolderOp
415 BinFolderOpGE(BinFolderFilter *filter)
416 : BinFolderOp(filter, FOLDER_OP_GE) {}
418 double test(BinFolderTarget *target, Indexable *idxbl);
421 class BinFolderOpNE : public BinFolderOp
424 BinFolderOpNE(BinFolderFilter *filter)
425 : BinFolderOp(filter, FOLDER_OP_NE) {}
427 double test(BinFolderTarget *target, Indexable *idxbl);
430 class BinFolderOpLT : public BinFolderOp
433 BinFolderOpLT(BinFolderFilter *filter)
434 : BinFolderOp(filter, FOLDER_OP_LT) {}
436 double test(BinFolderTarget *target, Indexable *idxbl);
439 class BinFolderOpLE : public BinFolderOp
442 BinFolderOpLE(BinFolderFilter *filter)
443 : BinFolderOp(filter, FOLDER_OP_LE) {}
445 double test(BinFolderTarget *target, Indexable *idxbl);
448 class BinFolderOpMatches : public BinFolderOp
451 BinFolderOpMatches(BinFolderFilter *filter)
452 : BinFolderOp(filter, FOLDER_OP_MATCHES) {}
453 ~BinFolderOpMatches() {}
454 double test(BinFolderTarget *target, Indexable *idxbl);
457 class BinFolderValue : public BC_ListBoxItem
460 BinFolderValue(BinFolderFilter *filter, const char *text);
461 virtual ~BinFolderValue();
463 void update(const char *text);
465 BinFolderFilter *filter;
469 class BinFolderList : public BC_ListBox
472 BinFolderList(BinFolder *folder, MWindow *mwindow,
473 ModifyFolderGUI *window, int x, int y, int w, int h);
475 void create_objects();
478 int handle_event(int column);
479 int selection_changed();
480 int column_resize_event();
482 void save_defaults(BC_Hash *defaults);
483 void load_defaults(BC_Hash *defaults);
484 void move_filter(int src, int dst);
486 int drag_start_event();
487 int drag_motion_event();
488 int drag_stop_event();
493 ModifyFolderGUI *window;
494 ArrayList<BC_ListBoxItem *>list_items[FOLDER_COLUMNS];
495 const char *list_titles[FOLDER_COLUMNS];
496 int list_width[FOLDER_COLUMNS];
498 BinFolderEnabledPopup *enabled_popup;
499 BinFolderOpPopup *op_popup;
500 BinFolderTargetPopup *target_popup;
502 ModifyTargetThread *modify_target;
505 class BinFolderAddFilter : public BC_GenericButton
508 BinFolderAddFilter(BinFolderList *folder_list, int x, int y);
509 ~BinFolderAddFilter();
511 BinFolderList *folder_list;
514 class BinFolderDelFilter : public BC_GenericButton
517 BinFolderDelFilter(BinFolderList *folder_list, int x, int y);
518 ~BinFolderDelFilter();
520 BinFolderList *folder_list;
523 class NewFolderGUI : public BC_Window
526 NewFolderGUI(NewFolderThread *thread, int x, int y, int w, int h);
528 void create_objects();
529 const char *get_text();
531 NewFolderThread *thread;
532 BinFolderList *folder_list;
533 BC_TextBox *text_box;
536 class NewFolderThread : public BC_DialogThread
539 NewFolderThread(AWindowGUI *agui);
541 BC_Window *new_gui();
542 void handle_done_event(int result);
543 void handle_close_event(int result);
544 void start(int x, int y, int w, int h);
548 NewFolderGUI *window;
552 class ModifyFolderGUI : public BC_Window
555 ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h);
557 void create_objects();
558 int resize_event(int w, int h);
559 const char *get_text();
560 int receive_custom_xatoms(xatom_event *event);
561 void async_update_filters();
562 void update_filters();
564 ModifyFolderThread *thread;
565 BinFolderList *folder_list;
566 BinFolderAddFilter *add_filter;
567 BinFolderDelFilter *del_filter;
568 BC_TextBox *text_box;
569 Atom modify_folder_xatom;
570 BC_OKButton *ok_button;
571 BC_CancelButton *cancel_button;
574 class ModifyFolderThread : public BC_DialogThread
577 ModifyFolderThread(AWindowGUI *agui);
578 ~ModifyFolderThread();
579 BC_Window *new_gui();
580 void handle_done_event(int result);
581 void handle_close_event(int result);
582 void start(BinFolder *folder, int x, int y, int w, int h);
586 BinFolder *original, *folder;
587 ModifyFolderGUI *window;
591 class ModifyTargetGUI : public BC_Window
594 ModifyTargetGUI(ModifyTargetThread *thread);
596 virtual void create_objects() {}
597 virtual void update() {}
598 void create_objects(BC_TextBox *&text_box);
600 ModifyTargetThread *thread;
603 class ModifyTargetThread : public BC_DialogThread
606 ModifyTargetThread(BinFolderList *folder_list);
607 ~ModifyTargetThread();
608 BC_Window *new_gui();
609 void handle_done_event(int result);
610 void handle_close_event(int result);
611 void start(BinFolderTarget *target, int x, int y, int w, int h);
614 BinFolderList *folder_list;
615 BinFolderTarget *target;
616 ModifyTargetGUI *window;
619 class ModifyTargetPatternsGUI : public ModifyTargetGUI
622 ModifyTargetPatternsGUI(ModifyTargetThread *thread);
623 ~ModifyTargetPatternsGUI();
624 void create_objects();
627 BC_ScrollTextBox *scroll_text_box;
630 class ModifyTargetFileSizeGUI : public ModifyTargetGUI
633 ModifyTargetFileSizeGUI(ModifyTargetThread *thread);
634 ~ModifyTargetFileSizeGUI();
635 void create_objects();
638 BC_TextBox *text_box;
641 class ModifyTargetTimeGUI : public ModifyTargetGUI
644 ModifyTargetTimeGUI(ModifyTargetThread *thread);
645 ~ModifyTargetTimeGUI();
646 void create_objects();
649 BC_TextBox *text_box;
652 class ModifyTargetTrackTypeGUI : public ModifyTargetGUI
655 ModifyTargetTrackTypeGUI(ModifyTargetThread *thread);
656 ~ModifyTargetTrackTypeGUI();
657 void create_objects();
660 BC_TextBox *text_box;
663 class ModifyTargetWidthGUI : public ModifyTargetGUI
666 ModifyTargetWidthGUI(ModifyTargetThread *thread);
667 ~ModifyTargetWidthGUI();
668 void create_objects();
671 BC_TextBox *text_box;
674 class ModifyTargetHeightGUI : public ModifyTargetGUI
677 ModifyTargetHeightGUI(ModifyTargetThread *thread);
678 ~ModifyTargetHeightGUI();
679 void create_objects();
682 BC_TextBox *text_box;
685 class ModifyTargetFramerateGUI : public ModifyTargetGUI
688 ModifyTargetFramerateGUI(ModifyTargetThread *thread);
689 ~ModifyTargetFramerateGUI();
690 void create_objects();
693 BC_TextBox *text_box;
696 class ModifyTargetSamplerateGUI : public ModifyTargetGUI
699 ModifyTargetSamplerateGUI(ModifyTargetThread *thread);
700 ~ModifyTargetSamplerateGUI();
701 void create_objects();
704 BC_TextBox *text_box;
707 class ModifyTargetChannelsGUI : public ModifyTargetGUI
710 ModifyTargetChannelsGUI(ModifyTargetThread *thread);
711 ~ModifyTargetChannelsGUI();
712 void create_objects();
715 BC_TextBox *text_box;
718 class ModifyTargetDurationGUI : public ModifyTargetGUI
721 ModifyTargetDurationGUI(ModifyTargetThread *thread);
722 ~ModifyTargetDurationGUI();
723 void create_objects();
726 BC_TextBox *text_box;