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