open file from command line
authorladanyi
Sun, 07 Aug 2005 18:06:41 +0000
changeset 161678704393218d
parent 1615 b42385baaf3a
child 1617 c17d61f77319
open file from command line
gui/graph-displayer.cc
gui/main_win.cc
gui/main_win.h
     1.1 --- a/gui/graph-displayer.cc	Sun Aug 07 16:35:15 2005 +0000
     1.2 +++ b/gui/graph-displayer.cc	Sun Aug 07 18:06:41 2005 +0000
     1.3 @@ -43,6 +43,12 @@
     1.4    Gtk::Main app(argc, argv);
     1.5  
     1.6    MainWin mainwin("Displayed Graph");
     1.7 +
     1.8 +  if ((argc == 2) && (Glib::file_test(argv[1], Glib::FILE_TEST_IS_REGULAR)))
     1.9 +  {
    1.10 +    mainwin.readFile(argv[1]);
    1.11 +  }
    1.12 +  
    1.13    app.run(mainwin);
    1.14  
    1.15    return 0;
     2.1 --- a/gui/main_win.cc	Sun Aug 07 16:35:15 2005 +0000
     2.2 +++ b/gui/main_win.cc	Sun Aug 07 18:06:41 2005 +0000
     2.3 @@ -133,6 +133,15 @@
     2.4    show_all_children();
     2.5  }
     2.6  
     2.7 +void MainWin::readFile(const std::string &file)
     2.8 +{
     2.9 +  mapstorage.readFromFile(file);
    2.10 +  mapstorage.file_name = file;
    2.11 +  mapstorage.modified = false;
    2.12 +  gd_canvas.drawGraph();
    2.13 +  mapwin.update();
    2.14 +}
    2.15 +
    2.16  void MainWin::newFile()
    2.17  {
    2.18    if (mapstorage.modified)
     3.1 --- a/gui/main_win.h	Sun Aug 07 16:35:15 2005 +0000
     3.2 +++ b/gui/main_win.h	Sun Aug 07 18:06:41 2005 +0000
     3.3 @@ -22,6 +22,8 @@
     3.4  
     3.5    MapStorage mapstorage;
     3.6  
     3.7 +  void readFile(const std::string &);
     3.8 +
     3.9  protected:
    3.10    ///Window of map-showing setup. Its type is \ref MapWin
    3.11    MapWin mapwin;