add view thumbnail size pref, rework vicon view popup, add view popup zoom scale
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / quit.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 "assets.h"
23 #include "mbuttons.h"
24 #include "confirmquit.h"
25 #include "errorbox.h"
26 #include "language.h"
27 #include "levelwindow.h"
28 #include "levelwindowgui.h"
29 #include "mainmenu.h"
30 #include "mwindow.h"
31 #include "mwindowgui.h"
32 #include "playback3d.h"
33 #include "preferences.h"
34 #include "quit.h"
35 #include "record.h"
36 #include "render.h"
37 #include "savefile.h"
38 #include "mainsession.h"
39 #include "videowindow.h"
40 #include "videowindowgui.h"
41
42
43 Quit::Quit(MWindow *mwindow)
44  : BC_MenuItem(_("Quit"), "q", 'q'), Thread()
45 {
46         this->mwindow = mwindow;
47 }
48
49 void Quit::create_objects(Save *save)
50 {
51         this->save = save;
52 }
53
54 int Quit::handle_event()
55 {
56
57 //printf("Quit::handle_event 1 %d\n", mwindow->session->changes_made);
58         Record *record = mwindow->gui->record;
59         if( !mwindow->preferences->perpetual_session &&
60             ( mwindow->session->changes_made || mwindow->render->in_progress ||
61               record->capturing || record->recording || record->writing_file ) ) {
62                 start();
63         }
64         else
65         {        // quit
66                 mwindow->quit();
67         }
68         return 0;
69 }
70
71 void Quit::run()
72 {
73         int result = 0;
74
75 // Test execution conditions
76         Record *record = mwindow->gui->record;
77         if( record->capturing || record->recording || record->writing_file ) {
78                 ErrorBox error(_(PROGRAM_NAME ": Error"),
79                         mwindow->gui->get_abs_cursor_x(1),
80                         mwindow->gui->get_abs_cursor_y(1));
81                 error.create_objects(_("Can't quit while a recording is in progress."));
82                 error.run_window();
83                 return;
84         }
85         else
86         if(mwindow->render->thread->running())
87         {
88                 ErrorBox error(_(PROGRAM_NAME ": Error"),
89                         mwindow->gui->get_abs_cursor_x(1),
90                         mwindow->gui->get_abs_cursor_y(1));
91                 error.create_objects(_("Can't quit while a render is in progress."));
92                 error.run_window();
93                 return;
94         }
95
96         ConfirmQuitWindow confirm(mwindow);
97         confirm.create_objects(_("Save edit list before exiting?"));
98         result = confirm.run_window();
99
100         switch( result ) {
101         case 0:         // quit
102                 if( mwindow->gui )
103                         mwindow->quit();
104                 break;
105
106         case 1:         // cancel
107                 break;
108
109         case 2:         // save
110                 save->save_before_quit();
111                 break;
112         }
113 }