search fixes, preset fixes, ladspa icon logging, igor pref theme, drag btn rollover
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formatpopup.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "bcsignals.h"
23 #include "file.h"
24 #include "filesystem.h"
25 #include "ffmpeg.h"
26 #include "formatpopup.h"
27 #include "language.h"
28 #include "pluginserver.h"
29
30
31
32 FormatPopup::FormatPopup(int x, int y, int do_audio, int do_video, int use_brender)
33  : BC_ListBox(x, y, 200, 200, LISTBOX_TEXT, 0, 0, 0, 1, 0, 1)
34 {
35         this->plugindb = plugindb;
36         this->do_audio = do_audio;
37         this->do_video = do_video;
38         this->use_brender = use_brender;
39         set_tooltip(_("Change file format"));
40 }
41
42 void FormatPopup::post_item(int format)
43 {
44         if( (do_audio && File::renders_audio(format)) ||
45             (do_video && File::renders_video(format)) )
46                 format_items.append(new BC_ListBoxItem(File::formattostr(format)));
47 }
48
49 void FormatPopup::create_objects()
50 {
51         if(!use_brender) {
52                 post_item(FILE_FFMPEG);
53                 post_item(FILE_AC3);
54                 post_item(FILE_AIFF);
55                 post_item(FILE_AU);
56                 post_item(FILE_FLAC);
57                 post_item(FILE_JPEG);
58         }
59
60         post_item(FILE_JPEG_LIST);
61
62         if(!use_brender) {
63 #ifdef HAVE_OPENEXR
64                 post_item(FILE_EXR);
65                 post_item(FILE_EXR_LIST);
66 #endif
67                 post_item(FILE_WAV);
68                 post_item(FILE_RAWDV);
69                 post_item(FILE_AMPEG);
70                 post_item(FILE_VMPEG);
71                 post_item(FILE_VORBIS);
72                 post_item(FILE_OGG);
73                 post_item(FILE_PCM);
74                 post_item(FILE_PNG);
75         }
76
77         format_items.append(new BC_ListBoxItem(_(PNG_LIST_NAME)));
78
79         if(!use_brender)
80         {
81                 format_items.append(new BC_ListBoxItem(_(TGA_NAME)));
82         }
83
84         format_items.append(new BC_ListBoxItem(_(TGA_LIST_NAME)));
85
86         if(!use_brender)
87         {
88                 format_items.append(new BC_ListBoxItem(_(TIFF_NAME)));
89         }
90
91         format_items.append(new BC_ListBoxItem(_(TIFF_LIST_NAME)));
92         update(&format_items, 0, 0, 1);
93 }
94
95 FormatPopup::~FormatPopup()
96 {
97         format_items.remove_all_objects();
98 }
99
100 int FormatPopup::handle_event()
101 {
102         return 1;
103 }
104
105
106 FFMPEGPopup::FFMPEGPopup(ArrayList<PluginServer*> *plugindb, int x, int y)
107  : BC_ListBox(x, y, 100, 200, LISTBOX_TEXT, 0, 0, 0, 1, 0, 1)
108 {
109         this->plugindb = plugindb;
110         set_tooltip(_("Set ffmpeg file type"));
111 }
112
113 void FFMPEGPopup::create_objects()
114 {
115         static const char *dirs[] = { "audio", "video", };
116         for( int i=0; i<(int)(sizeof(dirs)/sizeof(dirs[0])); ++i ) {
117                 FileSystem fs;
118                 char option_path[BCTEXTLEN];
119                 FFMPEG::set_option_path(option_path, dirs[i]);
120                 fs.update(option_path);
121                 int total_files = fs.total_files();
122                 for( int j=0; j<total_files; ++j ) {
123                         const char *name = fs.get_entry(j)->get_name();
124                         const char *ext = strrchr(name,'.');
125                         if( !ext ) continue;
126                         if( !strcmp("dfl", ++ext) ) continue;
127                         if( !strcmp("opts", ext) ) continue;
128                         int k = ffmpeg_types.size();
129                         while( --k >= 0 && strcmp(ffmpeg_types[k]->get_text(), ext) );
130                         if( k >= 0 ) continue;
131                         ffmpeg_types.append(new BC_ListBoxItem(ext));
132                 }
133         }
134
135         update(&ffmpeg_types, 0, 0, 1);
136 }
137
138 FFMPEGPopup::~FFMPEGPopup()
139 {
140         ffmpeg_types.remove_all_objects();
141 }
142
143 int FFMPEGPopup::handle_event()
144 {
145         return 0;
146 }
147
148