fullscreen segv fix, popup for 4opts preview, renderfarm print fix, pan widget upgrad...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mainsession.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 "auto.h"
23 #include "bcdisplayinfo.h"
24 #include "clip.h"
25 #include "bchash.h"
26 #include "edit.h"
27 #include "edits.h"
28 #include "edl.h"
29 #include "edlsession.h"
30 #include "guicast.h"
31 #include "indexable.h"
32 #include "language.h"
33 #include "localsession.h"
34 #include "mainsession.h"
35 #include "meterpanel.h"
36 #include "mwindow.h"
37 #include "mwindowgui.h"
38 #include "plugin.h"
39
40 MainSession::MainSession(MWindow *mwindow)
41 {
42         this->mwindow = mwindow;
43         changes_made = 0;
44         filename[0] = 0;
45 //      playback_cursor_visible = 0;
46 //      is_playing_back = 0;
47         track_highlighted = 0;
48         plugin_highlighted = 0;
49         pluginset_highlighted = 0;
50         edit_highlighted = 0;
51         current_operation = NO_OPERATION;
52         drag_pluginservers = new ArrayList<PluginServer*>;
53         drag_plugin = 0;
54         drag_assets = new ArrayList<Indexable*>;
55         drag_auto_gang = new ArrayList<Auto*>;
56         drag_clips = new ArrayList<EDL*>;
57         drag_edits = new ArrayList<Edit*>;
58         drag_edit = 0;
59         drag_group = 0;
60         drag_group_edit = 0;
61         drag_group_position = 0;
62         drag_group_first_track = 0;
63         group_number = 1;
64         clip_number = 1;
65         brender_end = 0;
66         cwindow_controls = 1;
67         trim_edits = 0;
68         current_tip = -1;
69         selected_zwindow = -1;
70         actual_frame_rate = 0;
71         title_bar_alpha = 0;
72         window_config = 0;
73         a_x11_host[0] = 0;
74         b_x11_host[0] = 0;
75         record_scope = 0;
76
77         drag_auto = 0;
78         drag_button = 0;
79         drag_handle = 0;
80         drag_position = 0;
81         drag_start = 0;
82         drag_origin_x = drag_origin_y = 0;
83         drag_start_percentage = 0;
84         drag_start_position = 0;
85         cwindow_output_x = cwindow_output_y = 0;
86         batchrender_x = batchrender_y = batchrender_w = batchrender_h = 0;
87         lwindow_x = lwindow_y = lwindow_w = lwindow_h = 0;
88         mwindow_x = mwindow_y = mwindow_w = mwindow_h = 0;
89         vwindow_x = vwindow_y = vwindow_w = vwindow_h = 0;
90         cwindow_x = cwindow_y = cwindow_w = cwindow_h = 0;
91         ctool_x = ctool_y = 0;
92         awindow_x = awindow_y = awindow_w = awindow_h = 0;
93         bwindow_w = bwindow_h = 0;
94         rmonitor_x = rmonitor_y = rmonitor_w = rmonitor_h = 0;
95         rwindow_x = rwindow_y = rwindow_w = rwindow_h = 0;
96         gwindow_x = gwindow_y = 0;
97         cswindow_x = cswindow_y = cswindow_w = cswindow_h = 0;
98         swindow_x = swindow_y = swindow_w = swindow_h = 0;
99         ewindow_w = ewindow_h = 0;
100         channels_x = channels_y = 0;
101         picture_x = picture_y = 0;
102         scope_x = scope_y = scope_w = scope_h = 0;
103         histogram_x = histogram_y = histogram_w = histogram_h = 0;
104         use_hist = 0;
105         use_wave = 0;
106         use_vector = 0;
107         use_hist_parade = 0;
108         use_wave_parade = 0;
109         afolders_w = 0;
110         show_vwindow = show_awindow = show_cwindow = show_gwindow = show_lwindow = 0;
111         plugindialog_w = plugindialog_h = 0;
112 //      presetdialog_w = presetdialog_h = 0;
113         keyframedialog_w = keyframedialog_h = 0;
114         keyframedialog_column1 = 0;
115         keyframedialog_column2 = 0;
116         keyframedialog_all = 0;
117         menueffect_w = menueffect_h = 0;
118         transitiondialog_w = transitiondialog_h = 0;
119 }
120
121 MainSession::~MainSession()
122 {
123         delete drag_pluginservers;
124         delete drag_assets;
125         delete drag_auto_gang;
126         delete drag_clips;
127         delete drag_edits;
128         if( drag_group )
129                 drag_group->remove_user();
130 }
131
132 void MainSession::boundaries()
133 {
134         lwindow_x = MAX(0, lwindow_x);
135         lwindow_y = MAX(0, lwindow_y);
136         mwindow_x = MAX(0, mwindow_x);
137         mwindow_y = MAX(0, mwindow_y);
138         cwindow_x = MAX(0, cwindow_x);
139         cwindow_y = MAX(0, cwindow_y);
140         vwindow_x = MAX(0, vwindow_x);
141         vwindow_y = MAX(0, vwindow_y);
142         awindow_x = MAX(0, awindow_x);
143         awindow_y = MAX(0, awindow_y);
144         gwindow_x = MAX(0, gwindow_x);
145         gwindow_y = MAX(0, gwindow_y);
146         rwindow_x = MAX(0, rwindow_x);
147         rwindow_y = MAX(0, rwindow_y);
148         rmonitor_x = MAX(0, rmonitor_x);
149         rmonitor_y = MAX(0, rmonitor_y);
150         CLAMP(cwindow_controls, 0, 1);
151 }
152
153 void MainSession::save_x11_host(int play_config, const char *x11_host)
154 {
155         strcpy(!play_config ? a_x11_host : b_x11_host, x11_host);
156 }
157
158 // set default x11 host, window_config, return screens
159 int MainSession::set_default_x11_host(int win_config)
160 {
161         if( win_config < 0 ) win_config = window_config;
162         const char *x11_host = win_config!=1 ? a_x11_host : b_x11_host;
163         BC_DisplayInfo display_info(x11_host,0);
164         int screen = display_info.get_screen();
165         if( screen < 0 && strcmp(a_x11_host, b_x11_host) ) {
166                 win_config = win_config==1 ? 0 : 1;
167                 x11_host = win_config!=1 ? a_x11_host : b_x11_host;
168                 display_info.init_window(x11_host,0);
169                 screen = display_info.get_screen();
170         }
171         if( screen < 0 ) {
172                 x11_host = "";
173                 display_info.init_window(x11_host,1);
174         }
175         int screens = 1;
176         if( display_info.get_screen_count() > 1 )
177                 screens = strcmp(a_x11_host, b_x11_host) != 0 ? 2 : 1;
178         window_config = win_config;
179         BC_Window::set_default_x11_host(x11_host);
180         return screens;
181 }
182
183 void MainSession::default_window_positions(int window_config)
184 {
185 // 0 - all windows on a, playback_config a
186 // 1 - all windows on b, playback_config b
187 // 2 - all windows on a, except composer on b, playback_config b
188         int screens = set_default_x11_host(window_config);
189         mwindow->set_screens(screens);
190
191         BC_DisplayInfo display_info(BC_Window::get_default_x11_host());
192 // Get defaults based on root window size
193         int root_x = 0;
194         int root_y = 0;
195         int root_w = display_info.get_root_w();
196         int root_h = display_info.get_root_h();
197
198         int border_left = display_info.get_left_border();
199         int border_right = display_info.get_right_border();
200         int border_top = display_info.get_top_border();
201         int border_bottom = display_info.get_bottom_border();
202
203         int dual_head = screens > 1 ? 1 : 0;
204         int right_w = root_w;
205 // Wider than 16:9, narrower than dual head
206         if( screens < 2 && (float)root_w / root_h > 1.8) {
207                 dual_head = 1;
208                 switch( root_h ) {
209                 case 600:  right_w = 800;   break;
210                 case 720:  right_w = 1280;  break;
211                 case 1024: right_w = 1280;  break;
212                 case 1200: right_w = 1600;  break;
213                 case 1080: right_w = 1920;  break;
214                 default:   right_w = root_w/2;  break;
215                 }
216                 if( window_config == 1 ) {
217                         root_x = root_w - right_w;
218                         root_w = right_w;
219                 }
220                 else {
221                         // use same aspect ratio to compute left height
222                         root_w -= right_w;
223                         root_h = (root_w*root_h) / right_w;
224                 }
225         }
226
227         vwindow_x = root_x;
228         vwindow_y = root_y;
229         vwindow_w = root_w / 2 - border_left - border_right;
230         vwindow_h = root_h * 6 / 10 - border_top - border_bottom;
231
232         int b_root_w = root_w;
233         int b_root_h = root_h;
234         if( !dual_head || window_config != 2 ) {
235                 cwindow_x = root_x + root_w / 2;
236                 cwindow_y = root_y;
237                 cwindow_w = vwindow_w;
238                 cwindow_h = vwindow_h;
239         }
240         else {
241 // Get defaults based on root window size
242                 BC_DisplayInfo b_display_info(b_x11_host);
243                 b_root_w = b_display_info.get_root_w();
244                 b_root_h = b_display_info.get_root_h();
245                 cwindow_x = 50;
246                 cwindow_y = 50;
247                 cwindow_w = b_root_w-100;
248                 cwindow_h = b_root_h-100;
249         }
250
251         ctool_x = cwindow_x + cwindow_w / 2;
252         ctool_y = cwindow_y + cwindow_h / 2;
253
254         mwindow_x = root_x;
255         mwindow_y = vwindow_y + vwindow_h + border_top + border_bottom;
256         mwindow_w = root_w * 2 / 3 - border_left - border_right;
257         mwindow_h = root_h - mwindow_y - border_top - border_bottom;
258
259         awindow_x = mwindow_x + border_left + border_right + mwindow_w;
260         awindow_y = mwindow_y;
261         awindow_w = root_x + root_w - awindow_x - border_left - border_right;
262         awindow_h = mwindow_h;
263
264         bwindow_w = 600;
265         bwindow_h = 360;
266
267         ewindow_w = 640;
268         ewindow_h = 240;
269
270         channels_x = 0;
271         channels_y = 0;
272         picture_x = 0;
273         picture_y = 0;
274         scope_x = 0;
275         scope_y = 0;
276         scope_w = 640;
277         scope_h = 320;
278         histogram_x = 0;
279         histogram_y = 0;
280         histogram_w = 320;
281         histogram_h = 480;
282         record_scope = 0;
283         use_hist = 1;
284         use_wave = 1;
285         use_vector = 1;
286         use_hist_parade = 1;
287         use_wave_parade = 1;
288
289         if(mwindow->edl)
290                 lwindow_w = MeterPanel::get_meters_width(mwindow->theme,
291                         mwindow->edl->session->audio_channels,
292                         1);
293         else
294                 lwindow_w = 100;
295
296         lwindow_y = 0;
297         lwindow_x = root_w - lwindow_w;
298         lwindow_h = mwindow_y;
299
300         rwindow_x = root_x;
301         rwindow_y = root_y;
302         rwindow_h = 500;
303         rwindow_w = 650;
304
305         cswindow_x = root_x;
306         cswindow_y = root_y;
307         cswindow_w = 1280;
308         cswindow_h = 600;
309
310         if( !dual_head || window_config != 2 ) {
311                 rmonitor_x = rwindow_x + rwindow_w + 10;
312                 rmonitor_y = rwindow_y;
313                 rmonitor_w = root_x + root_w - rmonitor_x;
314                 rmonitor_h = rwindow_h;
315         }
316         else {
317                 rmonitor_x = cswindow_x = 50;
318                 rmonitor_y = cswindow_y = 50;
319                 rmonitor_w = b_root_w-100;
320                 rmonitor_h = b_root_h-100;
321                 if( cswindow_w < rmonitor_w ) cswindow_w = rmonitor_w;
322                 if( cswindow_h < rmonitor_h ) cswindow_h = rmonitor_h;
323         }
324
325         swindow_x = root_x;
326         swindow_y = root_y;
327         swindow_w = 600;
328         swindow_h = 400;
329
330         batchrender_w = 750;
331         batchrender_h = 400;
332         batchrender_x = root_w / 2 - batchrender_w / 2;
333         batchrender_y = root_h / 2 - batchrender_h / 2;
334 }
335
336 int MainSession::load_defaults(BC_Hash *defaults)
337 {
338 // Setup main windows
339         strcpy(a_x11_host, defaults->get("A_X11_HOST", a_x11_host));
340         strcpy(b_x11_host, defaults->get("B_X11_HOST", b_x11_host));
341         window_config = defaults->get("WINDOW_CONFIG", window_config);
342         default_window_positions(window_config);
343
344         vwindow_x = defaults->get("VWINDOW_X", vwindow_x);
345         vwindow_y = defaults->get("VWINDOW_Y", vwindow_y);
346         vwindow_w = defaults->get("VWINDOW_W", vwindow_w);
347         vwindow_h = defaults->get("VWINDOW_H", vwindow_h);
348
349
350         cwindow_x = defaults->get("CWINDOW_X", cwindow_x);
351         cwindow_y = defaults->get("CWINDOW_Y", cwindow_y);
352         cwindow_w = defaults->get("CWINDOW_W", cwindow_w);
353         cwindow_h = defaults->get("CWINDOW_H", cwindow_h);
354
355         ctool_x = defaults->get("CTOOL_X", ctool_x);
356         ctool_y = defaults->get("CTOOL_Y", ctool_y);
357
358         gwindow_x = defaults->get("GWINDOW_X", gwindow_x);
359         gwindow_y = defaults->get("GWINDOW_Y", gwindow_y);
360
361         mwindow_x = defaults->get("MWINDOW_X", mwindow_x);
362         mwindow_y = defaults->get("MWINDOW_Y", mwindow_y);
363         mwindow_w = defaults->get("MWINDOW_W", mwindow_w);
364         mwindow_h = defaults->get("MWINDOW_H", mwindow_h);
365
366         lwindow_x = defaults->get("LWINDOW_X", lwindow_x);
367         lwindow_y = defaults->get("LWINDOW_Y", lwindow_y);
368         lwindow_w = defaults->get("LWINDOW_W", lwindow_w);
369         lwindow_h = defaults->get("LWINDOW_H", lwindow_h);
370
371
372         awindow_x = defaults->get("AWINDOW_X", awindow_x);
373         awindow_y = defaults->get("AWINDOW_Y", awindow_y);
374         awindow_w = defaults->get("AWINDOW_W", awindow_w);
375         awindow_h = defaults->get("AWINDOW_H", awindow_h);
376
377         ewindow_w = defaults->get("EWINDOW_W", ewindow_w);
378         ewindow_h = defaults->get("EWINDOW_H", ewindow_h);
379
380         channels_x = defaults->get("CHANNELS_X", channels_x);
381         channels_y = defaults->get("CHANNELS_Y", channels_y);
382         picture_x = defaults->get("PICTURE_X", picture_x);
383         picture_y = defaults->get("PICTURE_Y", picture_y);
384         scope_x = defaults->get("SCOPE_X", scope_x);
385         scope_y = defaults->get("SCOPE_Y", scope_y);
386         scope_w = defaults->get("SCOPE_W", scope_w);
387         scope_h = defaults->get("SCOPE_H", scope_h);
388         histogram_x = defaults->get("HISTOGRAM_X", histogram_x);
389         histogram_y = defaults->get("HISTOGRAM_Y", histogram_y);
390         histogram_w = defaults->get("HISTOGRAM_W", histogram_w);
391         histogram_h = defaults->get("HISTOGRAM_H", histogram_h);
392         record_scope = defaults->get("RECORD_SCOPE", record_scope);
393         use_hist = defaults->get("USE_HIST", use_hist);
394         use_wave = defaults->get("USE_WAVE", use_wave);
395         use_vector = defaults->get("USE_VECTOR", use_vector);
396         use_hist_parade = defaults->get("USE_HIST_PARADE", use_hist_parade);
397         use_wave_parade = defaults->get("USE_WAVE_PARADE", use_wave_parade);
398
399 //printf("MainSession::load_defaults 1\n");
400
401 // Other windows
402         afolders_w = defaults->get("ABINS_W", 200);
403
404         bwindow_w = defaults->get("BWINDOW_W", bwindow_w);
405         bwindow_h = defaults->get("BWINDOW_H", bwindow_h);
406
407         rwindow_x = defaults->get("RWINDOW_X", rwindow_x);
408         rwindow_y = defaults->get("RWINDOW_Y", rwindow_y);
409         rwindow_w = defaults->get("RWINDOW_W", rwindow_w);
410         rwindow_h = defaults->get("RWINDOW_H", rwindow_h);
411
412         cswindow_x = defaults->get("CSWINDOW_X", cswindow_x);
413         cswindow_y = defaults->get("CSWINDOW_Y", cswindow_y);
414         cswindow_w = defaults->get("CSWINDOW_W", cswindow_w);
415         cswindow_h = defaults->get("CSWINDOW_H", cswindow_h);
416
417         swindow_x = defaults->get("SWINDOW_X", swindow_x);
418         swindow_y = defaults->get("SWINDOW_Y", swindow_y);
419         swindow_w = defaults->get("SWINDOW_W", swindow_w);
420         swindow_h = defaults->get("SWINDOW_H", swindow_h);
421
422         rmonitor_x = defaults->get("RMONITOR_X", rmonitor_x);
423         rmonitor_y = defaults->get("RMONITOR_Y", rmonitor_y);
424         rmonitor_w = defaults->get("RMONITOR_W", rmonitor_w);
425         rmonitor_h = defaults->get("RMONITOR_H", rmonitor_h);
426
427         batchrender_x = defaults->get("BATCHRENDER_X", batchrender_x);
428         batchrender_y = defaults->get("BATCHRENDER_Y", batchrender_y);
429         batchrender_w = defaults->get("BATCHRENDER_W", batchrender_w);
430         batchrender_h = defaults->get("BATCHRENDER_H", batchrender_h);
431
432         show_vwindow = defaults->get("SHOW_VWINDOW", 1);
433         show_awindow = defaults->get("SHOW_AWINDOW", 1);
434         show_cwindow = defaults->get("SHOW_CWINDOW", 1);
435         show_lwindow = defaults->get("SHOW_LWINDOW", 0);
436         show_gwindow = defaults->get("SHOW_GWINDOW", 0);
437
438         cwindow_controls = defaults->get("CWINDOW_CONTROLS", cwindow_controls);
439
440         plugindialog_w = defaults->get("PLUGINDIALOG_W", 510);
441         plugindialog_h = defaults->get("PLUGINDIALOG_H", 415);
442 //      presetdialog_w = defaults->get("PRESETDIALOG_W", 510);
443 //      presetdialog_h = defaults->get("PRESETDIALOG_H", 415);
444         keyframedialog_w = defaults->get("KEYFRAMEDIALOG_W", 320);
445         keyframedialog_h = defaults->get("KEYFRAMEDIALOG_H", 415);
446         keyframedialog_column1 = defaults->get("KEYFRAMEDIALOG_COLUMN1", 150);
447         keyframedialog_column2 = defaults->get("KEYFRAMEDIALOG_COLUMN2", 100);
448         keyframedialog_all = defaults->get("KEYFRAMEDIALOG_ALL", 0);
449         menueffect_w = defaults->get("MENUEFFECT_W", 580);
450         menueffect_h = defaults->get("MENUEFFECT_H", 350);
451         transitiondialog_w = defaults->get("TRANSITIONDIALOG_W", 320);
452         transitiondialog_h = defaults->get("TRANSITIONDIALOG_H", 512);
453
454         current_tip = defaults->get("CURRENT_TIP", current_tip);
455         actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
456         title_bar_alpha = defaults->get("TITLE_BAR_ALPHA", (float)1);
457
458         boundaries();
459         return 0;
460 }
461
462 int MainSession::save_defaults(BC_Hash *defaults)
463 {
464         defaults->update("A_X11_HOST", a_x11_host);
465         defaults->update("B_X11_HOST", b_x11_host);
466         defaults->update("WINDOW_CONFIG", window_config);
467 // Window positions
468         defaults->update("MWINDOW_X", mwindow_x);
469         defaults->update("MWINDOW_Y", mwindow_y);
470         defaults->update("MWINDOW_W", mwindow_w);
471         defaults->update("MWINDOW_H", mwindow_h);
472
473         defaults->update("LWINDOW_X", lwindow_x);
474         defaults->update("LWINDOW_Y", lwindow_y);
475         defaults->update("LWINDOW_W", lwindow_w);
476         defaults->update("LWINDOW_H", lwindow_h);
477
478         defaults->update("VWINDOW_X", vwindow_x);
479         defaults->update("VWINDOW_Y", vwindow_y);
480         defaults->update("VWINDOW_W", vwindow_w);
481         defaults->update("VWINDOW_H", vwindow_h);
482
483         defaults->update("CWINDOW_X", cwindow_x);
484         defaults->update("CWINDOW_Y", cwindow_y);
485         defaults->update("CWINDOW_W", cwindow_w);
486         defaults->update("CWINDOW_H", cwindow_h);
487
488         defaults->update("CTOOL_X", ctool_x);
489         defaults->update("CTOOL_Y", ctool_y);
490
491         defaults->update("GWINDOW_X", gwindow_x);
492         defaults->update("GWINDOW_Y", gwindow_y);
493
494         defaults->update("AWINDOW_X", awindow_x);
495         defaults->update("AWINDOW_Y", awindow_y);
496         defaults->update("AWINDOW_W", awindow_w);
497         defaults->update("AWINDOW_H", awindow_h);
498
499         defaults->update("BWINDOW_W", bwindow_w);
500         defaults->update("BWINDOW_H", bwindow_h);
501
502         defaults->update("EWINDOW_W", ewindow_w);
503         defaults->update("EWINDOW_H", ewindow_h);
504
505         defaults->update("CHANNELS_X", channels_x);
506         defaults->update("CHANNELS_Y", channels_y);
507         defaults->update("PICTURE_X", picture_x);
508         defaults->update("PICTURE_Y", picture_y);
509         defaults->update("SCOPE_X", scope_x);
510         defaults->update("SCOPE_Y", scope_y);
511         defaults->update("SCOPE_W", scope_w);
512         defaults->update("SCOPE_H", scope_h);
513         defaults->update("HISTOGRAM_X", histogram_x);
514         defaults->update("HISTOGRAM_Y", histogram_y);
515         defaults->update("HISTOGRAM_W", histogram_w);
516         defaults->update("HISTOGRAM_H", histogram_h);
517         defaults->update("RECORD_SCOPE", record_scope);
518         defaults->update("USE_HIST", use_hist);
519         defaults->update("USE_WAVE", use_wave);
520         defaults->update("USE_VECTOR", use_vector);
521         defaults->update("USE_HIST_PARADE", use_hist_parade);
522         defaults->update("USE_WAVE_PARADE", use_wave_parade);
523
524         defaults->update("ABINS_W", afolders_w);
525
526         defaults->update("RMONITOR_X", rmonitor_x);
527         defaults->update("RMONITOR_Y", rmonitor_y);
528         defaults->update("RMONITOR_W", rmonitor_w);
529         defaults->update("RMONITOR_H", rmonitor_h);
530
531         defaults->update("RWINDOW_X", rwindow_x);
532         defaults->update("RWINDOW_Y", rwindow_y);
533         defaults->update("RWINDOW_W", rwindow_w);
534         defaults->update("RWINDOW_H", rwindow_h);
535
536         defaults->update("CSWINDOW_X", cswindow_x);
537         defaults->update("CSWINDOW_Y", cswindow_y);
538         defaults->update("CSWINDOW_W", cswindow_w);
539         defaults->update("CSWINDOW_H", cswindow_h);
540
541         defaults->update("SWINDOW_X", swindow_x);
542         defaults->update("SWINDOW_Y", swindow_y);
543         defaults->update("SWINDOW_W", swindow_w);
544         defaults->update("SWINDOW_H", swindow_h);
545
546         defaults->update("BATCHRENDER_X", batchrender_x);
547         defaults->update("BATCHRENDER_Y", batchrender_y);
548         defaults->update("BATCHRENDER_W", batchrender_w);
549         defaults->update("BATCHRENDER_H", batchrender_h);
550
551         defaults->update("SHOW_VWINDOW", show_vwindow);
552         defaults->update("SHOW_AWINDOW", show_awindow);
553         defaults->update("SHOW_CWINDOW", show_cwindow);
554         defaults->update("SHOW_LWINDOW", show_lwindow);
555         defaults->update("SHOW_GWINDOW", show_gwindow);
556
557         defaults->update("CWINDOW_CONTROLS", cwindow_controls);
558
559         defaults->update("PLUGINDIALOG_W", plugindialog_w);
560         defaults->update("PLUGINDIALOG_H", plugindialog_h);
561 //      defaults->update("PRESETDIALOG_W", presetdialog_w);
562 //      defaults->update("PRESETDIALOG_H", presetdialog_h);
563         defaults->update("KEYFRAMEDIALOG_W", keyframedialog_w);
564         defaults->update("KEYFRAMEDIALOG_H", keyframedialog_h);
565         defaults->update("KEYFRAMEDIALOG_COLUMN1", keyframedialog_column1);
566         defaults->update("KEYFRAMEDIALOG_COLUMN2", keyframedialog_column2);
567         defaults->update("KEYFRAMEDIALOG_ALL", keyframedialog_all);
568
569         defaults->update("MENUEFFECT_W", menueffect_w);
570         defaults->update("MENUEFFECT_H", menueffect_h);
571
572         defaults->update("TRANSITIONDIALOG_W", transitiondialog_w);
573         defaults->update("TRANSITIONDIALOG_H", transitiondialog_h);
574
575         defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
576         defaults->update("TITLE_BAR_ALPHA", title_bar_alpha);
577         defaults->update("CURRENT_TIP", current_tip);
578
579
580         return 0;
581 }
582
583 Track *MainSession::drag_handle_track()
584 {
585         Track *track = 0;
586         switch( current_operation ) {
587         case DRAG_EDITHANDLE1:
588         case DRAG_EDITHANDLE2:
589                 track = drag_edit->edits->track;
590                 break;
591         case DRAG_PLUGINHANDLE1:
592         case DRAG_PLUGINHANDLE2:
593                 track = drag_plugin->edits->track;
594                 break;
595         }
596         return track;
597 }
598
599 void MainSession::update_clip_number()
600 {
601         int clip_no = 0;
602         for( int i=mwindow->edl->clips.size(); --i>=0; ) {
603                 EDL *clip_edl = mwindow->edl->clips[i];
604                 int no = 0;
605                 if( sscanf(clip_edl->local_session->clip_title,_("Clip %d"),&no) == 1 )
606                         if( no > clip_no ) clip_no = no;
607         }
608         clip_number = clip_no+1;
609 }
610
611 int MainSession::load_file(const char *path)
612 {
613         int ret = 1;
614         FILE *fp = fopen(path,"r");
615         if( fp ) {
616                 BC_Hash defaults;
617                 defaults.load_file(fp);
618                 load_defaults(&defaults);
619                 fclose(fp);
620                 ret = 0;
621         }
622         return ret;
623 }
624
625 int MainSession::save_file(const char *path)
626 {
627         int ret = 1;
628         FILE *fp = fopen(path,"w");
629         if( fp ) {
630                 BC_Hash defaults;
631                 save_defaults(&defaults);
632                 defaults.save_file(fp);
633                 fclose(fp);
634                 ret = 0;
635         }
636         return ret;
637 }
638