equal
deleted
inserted
replaced
1 #include "main_win.h" |
1 #include "main_win.h" |
2 #include "guipixbufs.h" |
2 #include "guipixbufs.h" |
3 |
3 |
4 MainWin::MainWin(const std::string& title) : |
4 MainWin::MainWin() : |
5 mapwin("Map Setup", mapstorage, gd_canvas), |
5 mapwin("Map Setup", mapstorage, gd_canvas), |
6 newmapwin("Creating new map", gd_canvas), gd_canvas(mapstorage, mapwin, (Gtk::Window *)this) |
6 newmapwin("Creating new map", gd_canvas), gd_canvas(mapstorage, mapwin, (Gtk::Window *)this) |
7 { |
7 { |
8 set_title (title); |
8 set_title ("unsaved file - " + prog_name); |
9 set_default_size(WIN_WIDTH,WIN_HEIGHT); |
9 set_default_size(WIN_WIDTH,WIN_HEIGHT); |
10 add(vbox); |
10 add(vbox); |
11 |
11 |
12 |
12 |
13 // custom icons for the toolbar |
13 // custom icons for the toolbar |
207 mapstorage.readFromFile(file); |
207 mapstorage.readFromFile(file); |
208 mapstorage.file_name = file; |
208 mapstorage.file_name = file; |
209 mapstorage.modified = false; |
209 mapstorage.modified = false; |
210 gd_canvas.drawGraph(); |
210 gd_canvas.drawGraph(); |
211 mapwin.update(); |
211 mapwin.update(); |
|
212 set_title(Glib::filename_display_basename(file) + " - " + prog_name); |
212 } |
213 } |
213 |
214 |
214 void MainWin::newFile() |
215 void MainWin::newFile() |
215 { |
216 { |
216 if (mapstorage.modified) |
217 if (mapstorage.modified) |
232 } |
233 } |
233 } |
234 } |
234 gd_canvas.clear(); |
235 gd_canvas.clear(); |
235 mapstorage.clear(); |
236 mapstorage.clear(); |
236 mapwin.update(); |
237 mapwin.update(); |
|
238 set_title("unsaved file - " + prog_name); |
237 } |
239 } |
238 |
240 |
239 void MainWin::openFile() |
241 void MainWin::openFile() |
240 { |
242 { |
241 if (mapstorage.modified) |
243 if (mapstorage.modified) |
254 case Gtk::RESPONSE_ACCEPT: |
256 case Gtk::RESPONSE_ACCEPT: |
255 saveFile(); |
257 saveFile(); |
256 break; |
258 break; |
257 } |
259 } |
258 } |
260 } |
259 gd_canvas.clear(); |
|
260 mapstorage.clear(); |
|
261 Gtk::FileChooserDialog fcdialog("Open File"); |
261 Gtk::FileChooserDialog fcdialog("Open File"); |
262 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
262 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); |
263 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); |
263 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); |
264 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT) |
264 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT) |
265 { |
265 { |
|
266 gd_canvas.clear(); |
|
267 mapstorage.clear(); |
266 Glib::ustring filename = fcdialog.get_filename(); |
268 Glib::ustring filename = fcdialog.get_filename(); |
267 if (!mapstorage.readFromFile(filename)) |
269 if (!mapstorage.readFromFile(filename)) |
268 { |
270 { |
269 mapstorage.file_name = filename; |
271 mapstorage.file_name = filename; |
270 mapstorage.modified = false; |
272 mapstorage.modified = false; |
271 gd_canvas.drawGraph(); |
273 gd_canvas.drawGraph(); |
272 mapwin.update(); |
274 mapwin.update(); |
|
275 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); |
273 } |
276 } |
274 } |
277 } |
275 } |
278 } |
276 |
279 |
277 void MainWin::saveFile() |
280 void MainWin::saveFile() |
281 } |
284 } |
282 else |
285 else |
283 { |
286 { |
284 mapstorage.writeToFile(mapstorage.file_name); |
287 mapstorage.writeToFile(mapstorage.file_name); |
285 mapstorage.modified = false; |
288 mapstorage.modified = false; |
|
289 set_title(Glib::filename_display_basename(mapstorage.file_name) + " - " + |
|
290 prog_name); |
286 } |
291 } |
287 } |
292 } |
288 |
293 |
289 void MainWin::saveFileAs() |
294 void MainWin::saveFileAs() |
290 { |
295 { |
295 { |
300 { |
296 Glib::ustring filename = fcdialog.get_filename(); |
301 Glib::ustring filename = fcdialog.get_filename(); |
297 mapstorage.file_name = filename; |
302 mapstorage.file_name = filename; |
298 mapstorage.writeToFile(filename); |
303 mapstorage.writeToFile(filename); |
299 mapstorage.modified = false; |
304 mapstorage.modified = false; |
|
305 set_title(Glib::filename_display_basename(filename) + " - " + prog_name); |
300 } |
306 } |
301 } |
307 } |
302 |
308 |
303 void MainWin::close() |
309 void MainWin::close() |
304 { |
310 { |
321 } |
327 } |
322 } |
328 } |
323 gd_canvas.clear(); |
329 gd_canvas.clear(); |
324 mapstorage.clear(); |
330 mapstorage.clear(); |
325 mapwin.update(); |
331 mapwin.update(); |
326 } |
332 set_title("unsaved file - " + prog_name); |
|
333 } |