Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

quit.C

Go to the documentation of this file.
00001 #include "assets.h"
00002 #include "mbuttons.h"
00003 #include "confirmquit.h"
00004 #include "errorbox.h"
00005 #include "levelwindow.h"
00006 #include "levelwindowgui.h"
00007 #include "mainmenu.h"
00008 #include "mwindow.h"
00009 #include "mwindowgui.h"
00010 #include "quit.h"
00011 #include "record.h"
00012 #include "render.h"
00013 #include "savefile.h"
00014 #include "mainsession.h"
00015 #include "videowindow.h"
00016 #include "videowindowgui.h"
00017 
00018 #include <unistd.h>
00019 #include <libintl.h>
00020 #define _(String) gettext(String)
00021 #define gettext_noop(String) String
00022 #define N_(String) gettext_noop (String)
00023 
00024 Quit::Quit(MWindow *mwindow)
00025  : BC_MenuItem(_("Quit"), "q", 'q'), Thread() 
00026 { 
00027         this->mwindow = mwindow; 
00028 }
00029 int Quit::create_objects(Save *save)
00030 { 
00031         this->save = save; 
00032         return 0;
00033 }
00034 
00035 int Quit::handle_event() 
00036 {
00037 
00038 //printf("Quit::handle_event 1 %d\n", mwindow->session->changes_made);
00039         if(mwindow->session->changes_made ||
00040                 mwindow->gui->mainmenu->record->current_state ||
00041                 mwindow->render->in_progress) 
00042         {
00043                 start();
00044         }
00045         else 
00046         {        // quit
00047                 mwindow->gui->unlock_window();
00048                 mwindow->interrupt_indexes();
00049                 mwindow->gui->set_done(0);
00050                 mwindow->gui->lock_window();
00051         }
00052         return 0;
00053 }
00054 
00055 void Quit::run()
00056 {
00057         int result = 0;
00058 // Test execution conditions
00059         if(mwindow->gui->mainmenu->record->current_state == RECORD_CAPTURING)
00060         {
00061                 ErrorBox error(PROGRAM_NAME ": Error", 
00062                         mwindow->gui->get_abs_cursor_x(1), 
00063                         mwindow->gui->get_abs_cursor_y(1));
00064                 error.create_objects(_("Can't quit while a recording is in progress."));
00065                 error.run_window();
00066                 return;
00067         }
00068         else
00069         if(mwindow->render->running())
00070         {
00071                 ErrorBox error(PROGRAM_NAME ": Error", 
00072                         mwindow->gui->get_abs_cursor_x(1), 
00073                         mwindow->gui->get_abs_cursor_y(1));
00074                 error.create_objects(_("Can't quit while a render is in progress."));
00075                 error.run_window();
00076                 return;
00077         }
00078 
00079 
00080 //printf("Quit::run 1\n");
00081 
00082 // Quit
00083         {
00084 //printf("Quit::run 2\n");
00085                 ConfirmQuitWindow confirm(mwindow);
00086 //printf("Quit::run 2\n");
00087                 confirm.create_objects(_("Save edit list before exiting?"));
00088 //printf("Quit::run 2\n");
00089                 result = confirm.run_window();
00090 //printf("Quit::run 2\n");
00091         }
00092 //printf("Quit::run 3\n");
00093 
00094         switch(result)
00095         {
00096                 case 0:          // quit
00097                         if(mwindow->gui)
00098                         {
00099                                 mwindow->interrupt_indexes();
00100 // Last command in program
00101                                 mwindow->gui->set_done(0);
00102                         }
00103                         break;
00104 
00105                 case 1:        // cancel
00106                         return;
00107                         break;
00108 
00109                 case 2:           // save
00110                         save->save_before_quit(); 
00111                         return;
00112                         break;
00113         }
00114 }

Generated on Sun Jan 8 13:38:59 2006 for Cinelerra-svn by  doxygen 1.4.4