2 #include "confirmsave.h"
5 #include "mwindowgui.h"
10 ConfirmSave::ConfirmSave()
14 ConfirmSave::~ConfirmSave()
18 int ConfirmSave::test_file(MWindow *mwindow, char *path)
20 ArrayList<char*> paths;
22 int result = test_files(mwindow, &paths);
27 int ConfirmSave::test_files(MWindow *mwindow,
28 ArrayList<char*> *paths)
31 ArrayList<BC_ListBoxItem*> list;
34 for(int i = 0; i < paths->total; i++)
36 char *path = paths->values[i];
37 if(file = fopen(path, "r"))
40 list.append(new BC_ListBoxItem(path));
48 ConfirmSaveWindow window(mwindow, &list);
49 window.create_objects();
50 result = window.run_window();
54 printf("The following files exist.\n");
55 for(int i = 0; i < list.total; i++)
57 printf(" %s\n", list.values[i]->get_text());
59 printf("It's so hard to configure non-interactive rendering that\n"
60 "we'll assume you didn't want to overwrite them and crash here.\n");
63 list.remove_all_objects();
68 list.remove_all_objects();
83 ConfirmSaveWindow::ConfirmSaveWindow(MWindow *mwindow,
84 ArrayList<BC_ListBoxItem*> *list)
85 : BC_Window(PROGRAM_NAME ": File Exists",
86 mwindow->gui->get_abs_cursor_x(1) - 160,
87 mwindow->gui->get_abs_cursor_y(1) - 120,
94 ConfirmSaveWindow::~ConfirmSaveWindow()
99 int ConfirmSaveWindow::create_objects()
102 add_subwindow(title = new BC_Title(5,
104 _("The following files exist. Overwrite them?")));
106 add_subwindow(listbox = new BC_ListBox(x,
113 add_subwindow(new BC_OKButton(this));
115 add_subwindow(new BC_CancelButton(this));
119 int ConfirmSaveWindow::resize_event(int w, int h)
122 title->reposition_window(x, y);
124 listbox->reposition_window(x,