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"
30 #include "filesystem.h"
32 #include "indexable.h"
34 #include "mwindow.inc"
48 FOLDER_ENABLED_AND_NOT,
49 FOLDER_ENABLED_OR_NOT,
52 FOLDER_TARGET_PATTERNS,
53 FOLDER_TARGET_FILE_SIZE,
54 FOLDER_TARGET_MOD_TIME,
55 FOLDER_TARGET_TRACK_TYPE,
58 FOLDER_TARGET_FRAMERATE,
59 FOLDER_TARGET_SAMPLERATE,
60 FOLDER_TARGET_CHANNELS,
61 FOLDER_TARGET_DURATION,
65 FOLDER_OP_EQ, FOLDER_OP_GE, FOLDER_OP_GT,
66 FOLDER_OP_NE, FOLDER_OP_LE, FOLDER_OP_LT,
70 class BinFolderFilters : public ArrayList<BinFolderFilter *>
74 ~BinFolderFilters() { remove_all_objects(); }
75 void copy_from(BinFolderFilters *filters);
76 void clear() { remove_all_objects(); }
82 BinFolder(int awindow_folder, int is_clips, const char *title);
83 BinFolder(BinFolder &that);
86 BinFolderFilters filters;
87 void save_xml(FileXML *file);
88 int load_xml(FileXML *file);
89 double matches_indexable(Indexable *idxbl);
90 void copy_from(BinFolder *that);
91 const char *get_idxbl_title(Indexable *idxbl);
92 int add_patterns(ArrayList<Indexable*> *drag_assets, int use_basename);
99 class BinFolders : public ArrayList<BinFolder *>
104 void save_xml(FileXML *file);
105 int load_xml(FileXML *file);
106 double matches_indexable(int folder, Indexable *idxbl);
107 void copy_from(BinFolders *that);
108 void clear() { remove_all_objects(); }
111 class BinFolderFilter
117 void update_enabled(int type);
118 void update_target(int type);
119 void update_op(int type);
120 void update_value(const char *text);
121 void save_xml(FileXML *file);
122 int load_xml(FileXML *file);
124 BinFolderEnabled *enabled;
125 BinFolderTarget *target;
127 BinFolderValue *value;
130 class BinFolderEnabled : public BC_ListBoxItem
133 BinFolderEnabled(BinFolderFilter *filter, int type);
134 virtual ~BinFolderEnabled();
135 void update(int type);
137 BinFolderFilter *filter;
139 static const char *types[];
142 class BinFolderEnabledType : public BC_MenuItem
145 BinFolderEnabledType(int no);
146 ~BinFolderEnabledType();
150 class BinFolderEnabledPopup : public BC_PopupMenu
153 BinFolderEnabledPopup(BinFolderList *folder_list);
154 void create_objects();
155 void activate_menu(BC_ListBoxItem *item);
157 BinFolderList *folder_list;
158 BinFolderEnabled *enabled;
161 class BinFolderTarget : public BC_ListBoxItem
164 BinFolderTarget(BinFolderFilter *filter, int type);
165 virtual ~BinFolderTarget();
167 virtual void save_xml(FileXML *file) = 0;
168 virtual void load_xml(FileXML *file) = 0;
169 virtual void copy_from(BinFolderTarget *that) = 0;
170 virtual BC_Window *new_gui(ModifyTargetThread *thread) = 0;
172 BinFolderFilter *filter;
175 static const char *types[];
178 class BinFolderTargetPatterns : public BinFolderTarget
181 BinFolderTargetPatterns(BinFolderFilter *filter);
182 ~BinFolderTargetPatterns();
184 void save_xml(FileXML *file);
185 void load_xml(FileXML *file);
186 void copy_from(BinFolderTarget *that);
187 BC_Window *new_gui(ModifyTargetThread *thread);
188 void update(const char *text);
193 class BinFolderTargetFileSize : public BinFolderTarget
196 BinFolderTargetFileSize(BinFolderFilter *filter);
197 ~BinFolderTargetFileSize();
199 void save_xml(FileXML *file);
200 void load_xml(FileXML *file);
201 void copy_from(BinFolderTarget *that);
202 BC_Window *new_gui(ModifyTargetThread *thread);
203 void update(int64_t file_size, double around);
208 class BinFolderTargetTime : public BinFolderTarget
211 BinFolderTargetTime(BinFolderFilter *filter);
212 ~BinFolderTargetTime();
214 void save_xml(FileXML *file);
215 void load_xml(FileXML *file);
216 void copy_from(BinFolderTarget *that);
217 BC_Window *new_gui(ModifyTargetThread *thread);
218 void update(int64_t mtime, double around);
223 class BinFolderTargetTrackType : public BinFolderTarget
226 BinFolderTargetTrackType(BinFolderFilter *filter);
227 ~BinFolderTargetTrackType();
229 void save_xml(FileXML *file);
230 void load_xml(FileXML *file);
231 void copy_from(BinFolderTarget *that);
232 BC_Window *new_gui(ModifyTargetThread *thread);
233 void update(int data_types);
238 class BinFolderTargetWidth : public BinFolderTarget
241 BinFolderTargetWidth(BinFolderFilter *filter);
242 ~BinFolderTargetWidth();
244 void save_xml(FileXML *file);
245 void load_xml(FileXML *file);
246 void copy_from(BinFolderTarget *that);
247 BC_Window *new_gui(ModifyTargetThread *thread);
248 void update(int width, double around);
253 class BinFolderTargetHeight : public BinFolderTarget
256 BinFolderTargetHeight(BinFolderFilter *filter);
257 ~BinFolderTargetHeight();
259 void save_xml(FileXML *file);
260 void load_xml(FileXML *file);
261 void copy_from(BinFolderTarget *that);
262 BC_Window *new_gui(ModifyTargetThread *thread);
263 void update(int height, double around);
268 class BinFolderTargetFramerate : public BinFolderTarget
271 BinFolderTargetFramerate(BinFolderFilter *filter);
272 ~BinFolderTargetFramerate();
274 void save_xml(FileXML *file);
275 void load_xml(FileXML *file);
276 void copy_from(BinFolderTarget *that);
277 BC_Window *new_gui(ModifyTargetThread *thread);
278 void update(double framerate, double around);
283 class BinFolderTargetSamplerate : public BinFolderTarget
286 BinFolderTargetSamplerate(BinFolderFilter *filter);
287 ~BinFolderTargetSamplerate();
289 void save_xml(FileXML *file);
290 void load_xml(FileXML *file);
291 void copy_from(BinFolderTarget *that);
292 BC_Window *new_gui(ModifyTargetThread *thread);
293 void update(int samplerate, double around);
298 class BinFolderTargetChannels : public BinFolderTarget
301 BinFolderTargetChannels(BinFolderFilter *filter);
302 ~BinFolderTargetChannels();
304 void save_xml(FileXML *file);
305 void load_xml(FileXML *file);
306 void copy_from(BinFolderTarget *that);
307 BC_Window *new_gui(ModifyTargetThread *thread);
308 void update(int channels, double around);
313 class BinFolderTargetDuration : public BinFolderTarget
316 BinFolderTargetDuration(BinFolderFilter *filter);
317 ~BinFolderTargetDuration();
319 void save_xml(FileXML *file);
320 void load_xml(FileXML *file);
321 void copy_from(BinFolderTarget *that);
322 BC_Window *new_gui(ModifyTargetThread *thread);
323 void update(int64_t duration, double around);
328 class BinFolderTargetType : public BC_MenuItem
331 BinFolderTargetType(int no);
332 ~BinFolderTargetType();
337 class BinFolderTargetPopup : public BC_PopupMenu
340 BinFolderTargetPopup(BinFolderList *folder_list);
341 void create_objects();
342 void activate_menu(BC_ListBoxItem *item);
344 BinFolderList *folder_list;
345 BinFolderTarget *target;
349 class BinFolderOp : public BC_ListBoxItem
352 BinFolderOp(BinFolderFilter *filter, int type);
353 virtual ~BinFolderOp();
355 double compare(BinFolderTarget *target, Indexable *idxbl);
356 virtual double test(BinFolderTarget *target, Indexable *idxbl);
357 double around(double v, double a);
358 double around(const char *ap, const char *bp);
360 void copy_from(BinFolderOp *that);
362 BinFolderFilter *filter;
364 static const char *types[];
367 class BinFolderOpType : public BC_MenuItem
370 BinFolderOpType(int no);
376 class BinFolderOpPopup : public BC_PopupMenu
379 BinFolderOpPopup(BinFolderList *folder_list);
380 void create_objects();
381 void activate_menu(BC_ListBoxItem *item);
383 BinFolderList *folder_list;
388 class BinFolderOpAround : public BinFolderOp
391 BinFolderOpAround(BinFolderFilter *filter)
392 : BinFolderOp(filter, FOLDER_OP_AROUND) {}
393 ~BinFolderOpAround() {}
394 double test(BinFolderTarget *target, Indexable *idxbl);
397 class BinFolderOpEQ : public BinFolderOp
400 BinFolderOpEQ(BinFolderFilter *filter)
401 : BinFolderOp(filter, FOLDER_OP_EQ) {}
403 double test(BinFolderTarget *target, Indexable *idxbl);
406 class BinFolderOpGT : public BinFolderOp
409 BinFolderOpGT(BinFolderFilter *filter)
410 : BinFolderOp(filter, FOLDER_OP_GT) {}
412 double test(BinFolderTarget *target, Indexable *idxbl);
415 class BinFolderOpGE : public BinFolderOp
418 BinFolderOpGE(BinFolderFilter *filter)
419 : BinFolderOp(filter, FOLDER_OP_GE) {}
421 double test(BinFolderTarget *target, Indexable *idxbl);
424 class BinFolderOpNE : public BinFolderOp
427 BinFolderOpNE(BinFolderFilter *filter)
428 : BinFolderOp(filter, FOLDER_OP_NE) {}
430 double test(BinFolderTarget *target, Indexable *idxbl);
433 class BinFolderOpLT : public BinFolderOp
436 BinFolderOpLT(BinFolderFilter *filter)
437 : BinFolderOp(filter, FOLDER_OP_LT) {}
439 double test(BinFolderTarget *target, Indexable *idxbl);
442 class BinFolderOpLE : public BinFolderOp
445 BinFolderOpLE(BinFolderFilter *filter)
446 : BinFolderOp(filter, FOLDER_OP_LE) {}
448 double test(BinFolderTarget *target, Indexable *idxbl);
451 class BinFolderOpMatches : public BinFolderOp
454 BinFolderOpMatches(BinFolderFilter *filter)
455 : BinFolderOp(filter, FOLDER_OP_MATCHES) {}
456 ~BinFolderOpMatches() {}
457 double test(BinFolderTarget *target, Indexable *idxbl);
460 class BinFolderValue : public BC_ListBoxItem
463 BinFolderValue(BinFolderFilter *filter, const char *text);
464 virtual ~BinFolderValue();
466 void update(const char *text);
468 BinFolderFilter *filter;
472 class BinFolderList : public BC_ListBox
475 BinFolderList(BinFolder *folder, MWindow *mwindow,
476 ModifyFolderGUI *window, int x, int y, int w, int h);
478 void create_objects();
481 int handle_event(int column);
482 int selection_changed();
483 int column_resize_event();
485 void save_defaults(BC_Hash *defaults);
486 void load_defaults(BC_Hash *defaults);
487 void move_filter(int src, int dst);
489 int drag_start_event();
490 int drag_motion_event();
491 int drag_stop_event();
496 ModifyFolderGUI *window;
497 ArrayList<BC_ListBoxItem *>list_items[FOLDER_COLUMNS];
498 const char *list_titles[FOLDER_COLUMNS];
499 int list_width[FOLDER_COLUMNS];
501 BinFolderEnabledPopup *enabled_popup;
502 BinFolderOpPopup *op_popup;
503 BinFolderTargetPopup *target_popup;
505 ModifyTargetThread *modify_target;
508 class BinFolderAddFilter : public BC_GenericButton
511 BinFolderAddFilter(BinFolderList *folder_list, int x, int y);
512 ~BinFolderAddFilter();
514 BinFolderList *folder_list;
517 class BinFolderDelFilter : public BC_GenericButton
520 BinFolderDelFilter(BinFolderList *folder_list, int x, int y);
521 ~BinFolderDelFilter();
523 BinFolderList *folder_list;
526 class BinFolderApplyFilter : public BC_GenericButton
529 BinFolderApplyFilter(BinFolderList *folder_list, int x, int y);
530 ~BinFolderApplyFilter();
532 BinFolderList *folder_list;
535 class NewFolderGUI : public BC_Window
538 NewFolderGUI(NewFolderThread *thread, int x, int y, int w, int h);
540 void create_objects();
541 const char *get_text();
543 NewFolderThread *thread;
544 BinFolderList *folder_list;
545 BC_TextBox *text_box;
548 class NewFolderThread : public BC_DialogThread
551 NewFolderThread(AWindowGUI *agui);
553 BC_Window *new_gui();
554 void handle_done_event(int result);
555 void handle_close_event(int result);
556 void start(int x, int y, int w, int h, int is_clips);
561 NewFolderGUI *window;
565 class ModifyFolderGUI : public BC_Window
568 ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h);
570 void create_objects();
571 int resize_event(int w, int h);
572 const char *get_text();
573 int receive_custom_xatoms(xatom_event *event);
574 void async_update_filters();
575 void update_filters();
577 ModifyFolderThread *thread;
578 BinFolderList *folder_list;
579 BinFolderAddFilter *add_filter;
580 BinFolderDelFilter *del_filter;
581 BinFolderApplyFilter *apply_filter;
582 BC_Title *text_title;
583 BC_TextBox *text_box;
584 Atom modify_folder_xatom;
585 BC_OKButton *ok_button;
586 BC_CancelButton *cancel_button;
589 class ModifyFolderThread : public BC_DialogThread
592 ModifyFolderThread(AWindowGUI *agui);
593 ~ModifyFolderThread();
594 BC_Window *new_gui();
595 void handle_done_event(int result);
596 void handle_close_event(int result);
597 void start(BinFolder *folder, int x, int y, int w, int h);
601 BinFolder *original, *folder;
602 ModifyFolderGUI *window;
607 class ModifyTargetGUI : public BC_Window
610 ModifyTargetGUI(ModifyTargetThread *thread, int allow_resize=0);
612 virtual void create_objects() {}
613 virtual void update() {}
614 virtual int resize_event(int w, int h);
615 void create_objects(BC_TextBox *&text_box);
617 ModifyTargetThread *thread;
620 class ModifyTargetThread : public BC_DialogThread
623 ModifyTargetThread(BinFolderList *folder_list);
624 ~ModifyTargetThread();
625 BC_Window *new_gui();
626 void handle_done_event(int result);
627 void handle_close_event(int result);
628 void start(BinFolderTarget *target, int x, int y, int w, int h);
631 BinFolderList *folder_list;
632 BinFolderTarget *target;
633 ModifyTargetGUI *window;
636 class ModifyTargetPatternsGUI : public ModifyTargetGUI
639 ModifyTargetPatternsGUI(ModifyTargetThread *thread);
640 ~ModifyTargetPatternsGUI();
641 void create_objects();
642 int resize_event(int w, int h);
645 BC_ScrollTextBox *scroll_text_box;
646 BC_OKButton *ok_button;
647 BC_CancelButton *cancel_button;
651 class ModifyTargetFileSizeGUI : public ModifyTargetGUI
654 ModifyTargetFileSizeGUI(ModifyTargetThread *thread);
655 ~ModifyTargetFileSizeGUI();
656 void create_objects();
659 BC_TextBox *text_box;
662 class ModifyTargetTimeGUI : public ModifyTargetGUI
665 ModifyTargetTimeGUI(ModifyTargetThread *thread);
666 ~ModifyTargetTimeGUI();
667 void create_objects();
670 BC_TextBox *text_box;
673 class ModifyTargetTrackTypeGUI : public ModifyTargetGUI
676 ModifyTargetTrackTypeGUI(ModifyTargetThread *thread);
677 ~ModifyTargetTrackTypeGUI();
678 void create_objects();
681 BC_TextBox *text_box;
684 class ModifyTargetWidthGUI : public ModifyTargetGUI
687 ModifyTargetWidthGUI(ModifyTargetThread *thread);
688 ~ModifyTargetWidthGUI();
689 void create_objects();
692 BC_TextBox *text_box;
695 class ModifyTargetHeightGUI : public ModifyTargetGUI
698 ModifyTargetHeightGUI(ModifyTargetThread *thread);
699 ~ModifyTargetHeightGUI();
700 void create_objects();
703 BC_TextBox *text_box;
706 class ModifyTargetFramerateGUI : public ModifyTargetGUI
709 ModifyTargetFramerateGUI(ModifyTargetThread *thread);
710 ~ModifyTargetFramerateGUI();
711 void create_objects();
714 BC_TextBox *text_box;
717 class ModifyTargetSamplerateGUI : public ModifyTargetGUI
720 ModifyTargetSamplerateGUI(ModifyTargetThread *thread);
721 ~ModifyTargetSamplerateGUI();
722 void create_objects();
725 BC_TextBox *text_box;
728 class ModifyTargetChannelsGUI : public ModifyTargetGUI
731 ModifyTargetChannelsGUI(ModifyTargetThread *thread);
732 ~ModifyTargetChannelsGUI();
733 void create_objects();
736 BC_TextBox *text_box;
739 class ModifyTargetDurationGUI : public ModifyTargetGUI
742 ModifyTargetDurationGUI(ModifyTargetThread *thread);
743 ~ModifyTargetDurationGUI();
744 void create_objects();
747 BC_TextBox *text_box;