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, int is_clips, 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 const char *get_idxbl_title(Indexable *idxbl);
91 int add_patterns(ArrayList<Indexable*> *drag_assets);
98 class BinFolders : public ArrayList<BinFolder *>
103 void save_xml(FileXML *file);
104 int load_xml(FileXML *file);
105 double matches_indexable(int folder, Indexable *idxbl);
106 void copy_from(BinFolders *that);
107 void clear() { remove_all_objects(); }
110 class BinFolderFilter
116 void update_enabled(int type);
117 void update_target(int type);
118 void update_op(int type);
119 void update_value(const char *text);
120 void save_xml(FileXML *file);
121 int load_xml(FileXML *file);
123 BinFolderEnabled *enabled;
124 BinFolderTarget *target;
126 BinFolderValue *value;
129 class BinFolderEnabled : public BC_ListBoxItem
132 BinFolderEnabled(BinFolderFilter *filter, int type);
133 virtual ~BinFolderEnabled();
134 void update(int type);
136 BinFolderFilter *filter;
138 static const char *types[];
141 class BinFolderEnabledType : public BC_MenuItem
144 BinFolderEnabledType(int no);
145 ~BinFolderEnabledType();
149 class BinFolderEnabledPopup : public BC_PopupMenu
152 BinFolderEnabledPopup(BinFolderList *folder_list);
153 void create_objects();
154 void activate_menu(BC_ListBoxItem *item);
156 BinFolderList *folder_list;
157 BinFolderEnabled *enabled;
160 class BinFolderTarget : public BC_ListBoxItem
163 BinFolderTarget(BinFolderFilter *filter, int type);
164 virtual ~BinFolderTarget();
166 virtual void save_xml(FileXML *file) = 0;
167 virtual void load_xml(FileXML *file) = 0;
168 virtual void copy_from(BinFolderTarget *that) = 0;
169 virtual BC_Window *new_gui(ModifyTargetThread *thread) = 0;
171 BinFolderFilter *filter;
174 static const char *types[];
177 class BinFolderTargetPatterns : public BinFolderTarget
180 BinFolderTargetPatterns(BinFolderFilter *filter);
181 ~BinFolderTargetPatterns();
183 void save_xml(FileXML *file);
184 void load_xml(FileXML *file);
185 void copy_from(BinFolderTarget *that);
186 BC_Window *new_gui(ModifyTargetThread *thread);
187 void update(const char *text);
192 class BinFolderTargetFileSize : public BinFolderTarget
195 BinFolderTargetFileSize(BinFolderFilter *filter);
196 ~BinFolderTargetFileSize();
198 void save_xml(FileXML *file);
199 void load_xml(FileXML *file);
200 void copy_from(BinFolderTarget *that);
201 BC_Window *new_gui(ModifyTargetThread *thread);
202 void update(int64_t file_size, double around);
207 class BinFolderTargetTime : public BinFolderTarget
210 BinFolderTargetTime(BinFolderFilter *filter);
211 ~BinFolderTargetTime();
213 void save_xml(FileXML *file);
214 void load_xml(FileXML *file);
215 void copy_from(BinFolderTarget *that);
216 BC_Window *new_gui(ModifyTargetThread *thread);
217 void update(int64_t mtime, double around);
222 class BinFolderTargetTrackType : public BinFolderTarget
225 BinFolderTargetTrackType(BinFolderFilter *filter);
226 ~BinFolderTargetTrackType();
228 void save_xml(FileXML *file);
229 void load_xml(FileXML *file);
230 void copy_from(BinFolderTarget *that);
231 BC_Window *new_gui(ModifyTargetThread *thread);
232 void update(int data_types);
237 class BinFolderTargetWidth : public BinFolderTarget
240 BinFolderTargetWidth(BinFolderFilter *filter);
241 ~BinFolderTargetWidth();
243 void save_xml(FileXML *file);
244 void load_xml(FileXML *file);
245 void copy_from(BinFolderTarget *that);
246 BC_Window *new_gui(ModifyTargetThread *thread);
247 void update(int width, double around);
252 class BinFolderTargetHeight : public BinFolderTarget
255 BinFolderTargetHeight(BinFolderFilter *filter);
256 ~BinFolderTargetHeight();
258 void save_xml(FileXML *file);
259 void load_xml(FileXML *file);
260 void copy_from(BinFolderTarget *that);
261 BC_Window *new_gui(ModifyTargetThread *thread);
262 void update(int height, double around);
267 class BinFolderTargetFramerate : public BinFolderTarget
270 BinFolderTargetFramerate(BinFolderFilter *filter);
271 ~BinFolderTargetFramerate();
273 void save_xml(FileXML *file);
274 void load_xml(FileXML *file);
275 void copy_from(BinFolderTarget *that);
276 BC_Window *new_gui(ModifyTargetThread *thread);
277 void update(double framerate, double around);
282 class BinFolderTargetSamplerate : public BinFolderTarget
285 BinFolderTargetSamplerate(BinFolderFilter *filter);
286 ~BinFolderTargetSamplerate();
288 void save_xml(FileXML *file);
289 void load_xml(FileXML *file);
290 void copy_from(BinFolderTarget *that);
291 BC_Window *new_gui(ModifyTargetThread *thread);
292 void update(int samplerate, double around);
297 class BinFolderTargetChannels : public BinFolderTarget
300 BinFolderTargetChannels(BinFolderFilter *filter);
301 ~BinFolderTargetChannels();
303 void save_xml(FileXML *file);
304 void load_xml(FileXML *file);
305 void copy_from(BinFolderTarget *that);
306 BC_Window *new_gui(ModifyTargetThread *thread);
307 void update(int channels, double around);
312 class BinFolderTargetDuration : public BinFolderTarget
315 BinFolderTargetDuration(BinFolderFilter *filter);
316 ~BinFolderTargetDuration();
318 void save_xml(FileXML *file);
319 void load_xml(FileXML *file);
320 void copy_from(BinFolderTarget *that);
321 BC_Window *new_gui(ModifyTargetThread *thread);
322 void update(int64_t duration, double around);
327 class BinFolderTargetType : public BC_MenuItem
330 BinFolderTargetType(int no);
331 ~BinFolderTargetType();
336 class BinFolderTargetPopup : public BC_PopupMenu
339 BinFolderTargetPopup(BinFolderList *folder_list);
340 void create_objects();
341 void activate_menu(BC_ListBoxItem *item);
343 BinFolderList *folder_list;
344 BinFolderTarget *target;
348 class BinFolderOp : public BC_ListBoxItem
351 BinFolderOp(BinFolderFilter *filter, int type);
352 virtual ~BinFolderOp();
354 double compare(BinFolderTarget *target, Indexable *idxbl);
355 virtual double test(BinFolderTarget *target, Indexable *idxbl);
356 double around(double v, double a);
357 double around(const char *ap, const char *bp);
359 void copy_from(BinFolderOp *that);
361 BinFolderFilter *filter;
363 static const char *types[];
366 class BinFolderOpType : public BC_MenuItem
369 BinFolderOpType(int no);
375 class BinFolderOpPopup : public BC_PopupMenu
378 BinFolderOpPopup(BinFolderList *folder_list);
379 void create_objects();
380 void activate_menu(BC_ListBoxItem *item);
382 BinFolderList *folder_list;
387 class BinFolderOpAround : public BinFolderOp
390 BinFolderOpAround(BinFolderFilter *filter)
391 : BinFolderOp(filter, FOLDER_OP_AROUND) {}
392 ~BinFolderOpAround() {}
393 double test(BinFolderTarget *target, Indexable *idxbl);
396 class BinFolderOpEQ : public BinFolderOp
399 BinFolderOpEQ(BinFolderFilter *filter)
400 : BinFolderOp(filter, FOLDER_OP_EQ) {}
402 double test(BinFolderTarget *target, Indexable *idxbl);
405 class BinFolderOpGT : public BinFolderOp
408 BinFolderOpGT(BinFolderFilter *filter)
409 : BinFolderOp(filter, FOLDER_OP_GT) {}
411 double test(BinFolderTarget *target, Indexable *idxbl);
414 class BinFolderOpGE : public BinFolderOp
417 BinFolderOpGE(BinFolderFilter *filter)
418 : BinFolderOp(filter, FOLDER_OP_GE) {}
420 double test(BinFolderTarget *target, Indexable *idxbl);
423 class BinFolderOpNE : public BinFolderOp
426 BinFolderOpNE(BinFolderFilter *filter)
427 : BinFolderOp(filter, FOLDER_OP_NE) {}
429 double test(BinFolderTarget *target, Indexable *idxbl);
432 class BinFolderOpLT : public BinFolderOp
435 BinFolderOpLT(BinFolderFilter *filter)
436 : BinFolderOp(filter, FOLDER_OP_LT) {}
438 double test(BinFolderTarget *target, Indexable *idxbl);
441 class BinFolderOpLE : public BinFolderOp
444 BinFolderOpLE(BinFolderFilter *filter)
445 : BinFolderOp(filter, FOLDER_OP_LE) {}
447 double test(BinFolderTarget *target, Indexable *idxbl);
450 class BinFolderOpMatches : public BinFolderOp
453 BinFolderOpMatches(BinFolderFilter *filter)
454 : BinFolderOp(filter, FOLDER_OP_MATCHES) {}
455 ~BinFolderOpMatches() {}
456 double test(BinFolderTarget *target, Indexable *idxbl);
459 class BinFolderValue : public BC_ListBoxItem
462 BinFolderValue(BinFolderFilter *filter, const char *text);
463 virtual ~BinFolderValue();
465 void update(const char *text);
467 BinFolderFilter *filter;
471 class BinFolderList : public BC_ListBox
474 BinFolderList(BinFolder *folder, MWindow *mwindow,
475 ModifyFolderGUI *window, int x, int y, int w, int h);
477 void create_objects();
480 int handle_event(int column);
481 int selection_changed();
482 int column_resize_event();
484 void save_defaults(BC_Hash *defaults);
485 void load_defaults(BC_Hash *defaults);
486 void move_filter(int src, int dst);
488 int drag_start_event();
489 int drag_motion_event();
490 int drag_stop_event();
495 ModifyFolderGUI *window;
496 ArrayList<BC_ListBoxItem *>list_items[FOLDER_COLUMNS];
497 const char *list_titles[FOLDER_COLUMNS];
498 int list_width[FOLDER_COLUMNS];
500 BinFolderEnabledPopup *enabled_popup;
501 BinFolderOpPopup *op_popup;
502 BinFolderTargetPopup *target_popup;
504 ModifyTargetThread *modify_target;
507 class BinFolderAddFilter : public BC_GenericButton
510 BinFolderAddFilter(BinFolderList *folder_list, int x, int y);
511 ~BinFolderAddFilter();
513 BinFolderList *folder_list;
516 class BinFolderDelFilter : public BC_GenericButton
519 BinFolderDelFilter(BinFolderList *folder_list, int x, int y);
520 ~BinFolderDelFilter();
522 BinFolderList *folder_list;
525 class BinFolderApplyFilter : public BC_GenericButton
528 BinFolderApplyFilter(BinFolderList *folder_list, int x, int y);
529 ~BinFolderApplyFilter();
531 BinFolderList *folder_list;
534 class NewFolderGUI : public BC_Window
537 NewFolderGUI(NewFolderThread *thread, int x, int y, int w, int h);
539 void create_objects();
540 const char *get_text();
542 NewFolderThread *thread;
543 BinFolderList *folder_list;
544 BC_TextBox *text_box;
547 class NewFolderThread : public BC_DialogThread
550 NewFolderThread(AWindowGUI *agui);
552 BC_Window *new_gui();
553 void handle_done_event(int result);
554 void handle_close_event(int result);
555 void start(int x, int y, int w, int h, int is_clips);
560 NewFolderGUI *window;
564 class ModifyFolderGUI : public BC_Window
567 ModifyFolderGUI(ModifyFolderThread *thread, int x, int y, int w, int h);
569 void create_objects();
570 int resize_event(int w, int h);
571 const char *get_text();
572 int receive_custom_xatoms(xatom_event *event);
573 void async_update_filters();
574 void update_filters();
576 ModifyFolderThread *thread;
577 BinFolderList *folder_list;
578 BinFolderAddFilter *add_filter;
579 BinFolderDelFilter *del_filter;
580 BinFolderApplyFilter *apply_filter;
581 BC_Title *text_title;
582 BC_TextBox *text_box;
583 Atom modify_folder_xatom;
584 BC_OKButton *ok_button;
585 BC_CancelButton *cancel_button;
588 class ModifyFolderThread : public BC_DialogThread
591 ModifyFolderThread(AWindowGUI *agui);
592 ~ModifyFolderThread();
593 BC_Window *new_gui();
594 void handle_done_event(int result);
595 void handle_close_event(int result);
596 void start(BinFolder *folder, int x, int y, int w, int h);
600 BinFolder *original, *folder;
601 ModifyFolderGUI *window;
605 class ModifyTargetGUI : public BC_Window
608 ModifyTargetGUI(ModifyTargetThread *thread, int allow_resize=0);
610 virtual void create_objects() {}
611 virtual void update() {}
612 virtual int resize_event(int w, int h);
613 void create_objects(BC_TextBox *&text_box);
615 ModifyTargetThread *thread;
618 class ModifyTargetThread : public BC_DialogThread
621 ModifyTargetThread(BinFolderList *folder_list);
622 ~ModifyTargetThread();
623 BC_Window *new_gui();
624 void handle_done_event(int result);
625 void handle_close_event(int result);
626 void start(BinFolderTarget *target, int x, int y, int w, int h);
629 BinFolderList *folder_list;
630 BinFolderTarget *target;
631 ModifyTargetGUI *window;
634 class ModifyTargetPatternsGUI : public ModifyTargetGUI
637 ModifyTargetPatternsGUI(ModifyTargetThread *thread);
638 ~ModifyTargetPatternsGUI();
639 void create_objects();
640 int resize_event(int w, int h);
643 BC_ScrollTextBox *scroll_text_box;
644 BC_OKButton *ok_button;
645 BC_CancelButton *cancel_button;
649 class ModifyTargetFileSizeGUI : public ModifyTargetGUI
652 ModifyTargetFileSizeGUI(ModifyTargetThread *thread);
653 ~ModifyTargetFileSizeGUI();
654 void create_objects();
657 BC_TextBox *text_box;
660 class ModifyTargetTimeGUI : public ModifyTargetGUI
663 ModifyTargetTimeGUI(ModifyTargetThread *thread);
664 ~ModifyTargetTimeGUI();
665 void create_objects();
668 BC_TextBox *text_box;
671 class ModifyTargetTrackTypeGUI : public ModifyTargetGUI
674 ModifyTargetTrackTypeGUI(ModifyTargetThread *thread);
675 ~ModifyTargetTrackTypeGUI();
676 void create_objects();
679 BC_TextBox *text_box;
682 class ModifyTargetWidthGUI : public ModifyTargetGUI
685 ModifyTargetWidthGUI(ModifyTargetThread *thread);
686 ~ModifyTargetWidthGUI();
687 void create_objects();
690 BC_TextBox *text_box;
693 class ModifyTargetHeightGUI : public ModifyTargetGUI
696 ModifyTargetHeightGUI(ModifyTargetThread *thread);
697 ~ModifyTargetHeightGUI();
698 void create_objects();
701 BC_TextBox *text_box;
704 class ModifyTargetFramerateGUI : public ModifyTargetGUI
707 ModifyTargetFramerateGUI(ModifyTargetThread *thread);
708 ~ModifyTargetFramerateGUI();
709 void create_objects();
712 BC_TextBox *text_box;
715 class ModifyTargetSamplerateGUI : public ModifyTargetGUI
718 ModifyTargetSamplerateGUI(ModifyTargetThread *thread);
719 ~ModifyTargetSamplerateGUI();
720 void create_objects();
723 BC_TextBox *text_box;
726 class ModifyTargetChannelsGUI : public ModifyTargetGUI
729 ModifyTargetChannelsGUI(ModifyTargetThread *thread);
730 ~ModifyTargetChannelsGUI();
731 void create_objects();
734 BC_TextBox *text_box;
737 class ModifyTargetDurationGUI : public ModifyTargetGUI
740 ModifyTargetDurationGUI(ModifyTargetThread *thread);
741 ~ModifyTargetDurationGUI();
742 void create_objects();
745 BC_TextBox *text_box;