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

confirmsave.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "confirmsave.h"
00003 #include "language.h"
00004 #include "mwindow.h"
00005 #include "mwindowgui.h"
00006 
00007 
00008 
00009 
00010 ConfirmSave::ConfirmSave()
00011 {
00012 }
00013 
00014 ConfirmSave::~ConfirmSave()
00015 {
00016 }
00017 
00018 int ConfirmSave::test_file(MWindow *mwindow, char *path)
00019 {
00020         ArrayList<char*> paths;
00021         paths.append(path);
00022         int result = test_files(mwindow, &paths);
00023         paths.remove_all();
00024         return result;
00025 }
00026 
00027 int ConfirmSave::test_files(MWindow *mwindow, 
00028         ArrayList<char*> *paths)
00029 {
00030         FILE *file;
00031         ArrayList<BC_ListBoxItem*> list;
00032         int result = 0;
00033 
00034         for(int i = 0; i < paths->total; i++)
00035         {
00036                 char *path = paths->values[i];
00037                 if(file = fopen(path, "r"))
00038                 {
00039                         fclose(file);
00040                         list.append(new BC_ListBoxItem(path));
00041                 }
00042         }
00043 
00044         if(list.total)
00045         {
00046                 if(mwindow)
00047                 {
00048                         ConfirmSaveWindow window(mwindow, &list);
00049                         window.create_objects();
00050                         result = window.run_window();
00051                 }
00052                 else
00053                 {
00054                         printf("The following files exist.\n");
00055                         for(int i = 0; i < list.total; i++)
00056                         {
00057                                 printf("    %s\n", list.values[i]->get_text());
00058                         }
00059                         printf("It's so hard to configure non-interactive rendering that\n"
00060                                 "we'll assume you didn't want to overwrite them and crash here.\n");
00061                         result = 1;
00062                 }
00063                 list.remove_all_objects();
00064                 return result;
00065         }
00066         else
00067         {
00068                 list.remove_all_objects();
00069                 return 0;
00070         }
00071 
00072         return result;
00073 }
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 ConfirmSaveWindow::ConfirmSaveWindow(MWindow *mwindow, 
00084         ArrayList<BC_ListBoxItem*> *list)
00085  : BC_Window(PROGRAM_NAME ": File Exists", 
00086                 mwindow->gui->get_abs_cursor_x(1) - 160, 
00087                 mwindow->gui->get_abs_cursor_y(1) - 120, 
00088                 320, 
00089                 320)
00090 {
00091         this->list = list;
00092 }
00093 
00094 ConfirmSaveWindow::~ConfirmSaveWindow()
00095 {
00096 }
00097 
00098 
00099 int ConfirmSaveWindow::create_objects()
00100 {
00101         int x = 10, y = 10;
00102         add_subwindow(new BC_OKButton(this));
00103         add_subwindow(new BC_CancelButton(this));
00104 
00105         add_subwindow(title = new BC_Title(x, 
00106                 y, 
00107                 _("The following files exist.  Overwrite them?")));
00108         y += 30;
00109         add_subwindow(listbox = new BC_ListBox(x, 
00110                 y, 
00111                 get_w() - x - 10,
00112                 get_h() - y - BC_OKButton::calculate_h() - 10,
00113                 LISTBOX_TEXT,
00114                 list));
00115         y = get_h() - 40;
00116         add_subwindow(new BC_OKButton(this));
00117         x = get_w() - 100;
00118         add_subwindow(new BC_CancelButton(this));
00119         return 0;
00120 }
00121 
00122 int ConfirmSaveWindow::resize_event(int w, int h)
00123 {
00124         int x = 10, y = 10;
00125         title->reposition_window(x, y);
00126         y += 30;
00127         listbox->reposition_window(x,
00128                 y,
00129                 w - x - 10,
00130                 h - y - 50);
00131         return 1;
00132 }
00133 
00134 
00135 
00136 
00137 
00138 

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