diff -r 8dd6160ff699 -r b61682f0ee96 gui/main_win.cc --- a/gui/main_win.cc Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/main_win.cc Wed Nov 30 13:24:23 2005 +0000 @@ -1,9 +1,8 @@ #include "main_win.h" #include "icons/guipixbufs.h" -MainWin::MainWin() +MainWin::MainWin():mapwinexists(false) { - mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); gd_canvas=new GraphDisplayerCanvas(*this); set_title ("unsaved file - " + prog_name); @@ -105,7 +104,7 @@ ag->add( Gtk::Action::create("ShowMenu", "_Show") ); ag->add( Gtk::Action::create("ShowMaps", "_Maps"), - sigc::mem_fun(*(this->mapwin), &MapWin::show)); + sigc::mem_fun(*this, &MainWin::createMapWin)); Gtk::RadioAction::Group tool_group; ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), @@ -212,7 +211,10 @@ mapstorage.file_name = file; mapstorage.modified = false; gd_canvas->drawGraph(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title(Glib::filename_display_basename(file) + " - " + prog_name); } @@ -238,7 +240,10 @@ } gd_canvas->clear(); mapstorage.clear(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title("unsaved file - " + prog_name); } @@ -275,7 +280,10 @@ mapstorage.file_name = filename; mapstorage.modified = false; gd_canvas->drawGraph(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title(Glib::filename_display_basename(filename) + " - " + prog_name); } } @@ -332,7 +340,10 @@ } gd_canvas->clear(); mapstorage.clear(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title("unsaved file - " + prog_name); } @@ -359,10 +370,32 @@ void MainWin::registerNewEdgeMap(std::string mapname) { - mapwin->registerNewEdgeMap(mapname); + if(mapwinexists) + { + mapwin->registerNewEdgeMap(mapname); + } } void MainWin::registerNewNodeMap(std::string mapname) { - mapwin->registerNewNodeMap(mapname); + if(mapwinexists) + { + mapwin->registerNewNodeMap(mapname); + } } + +void MainWin::createMapWin() +{ + if(!mapwinexists) + { + mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); + mapwin->show(); + mapwinexists=true; + } +} + +void MainWin::closeMapWin() +{ + mapwinexists=false; + delete mapwin; +}