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 window.raise_window();
51 result = window.run_window();
55 printf("The following files exist.\n");
56 for(int i = 0; i < list.total; i++)
58 printf(" %s\n", list.values[i]->get_text());
60 printf("It's so hard to configure non-interactive rendering that\n"
61 "we'll assume you didn't want to overwrite them and crash here.\n");
64 list.remove_all_objects();
69 list.remove_all_objects();
84 ConfirmSaveWindow::ConfirmSaveWindow(MWindow *mwindow,
85 ArrayList<BC_ListBoxItem*> *list)
86 : BC_Window(PROGRAM_NAME ": File Exists",
87 mwindow->gui->get_abs_cursor_x(1) - 160,
88 mwindow->gui->get_abs_cursor_y(1) - 120,
95 ConfirmSaveWindow::~ConfirmSaveWindow()
100 int ConfirmSaveWindow::create_objects()
103 add_subwindow(new BC_OKButton(this));
104 add_subwindow(new BC_CancelButton(this));
106 add_subwindow(title = new BC_Title(x,
108 _("The following files exist. Overwrite them?")));
110 add_subwindow(listbox = new BC_ListBox(x,
113 get_h() - y - BC_OKButton::calculate_h() - 10,
117 add_subwindow(new BC_OKButton(this));
119 add_subwindow(new BC_CancelButton(this));
123 int ConfirmSaveWindow::resize_event(int w, int h)
126 title->reposition_window(x, y);
128 listbox->reposition_window(x,
143 // c-file-style: "linux"