gui/main_win.cc
author alpar
Mon, 24 Oct 2005 08:11:21 +0000
changeset 1735 41e96cd91d6d
parent 1659 ab1e97b7b2b7
child 1777 a70cee06ae9c
permissions -rw-r--r--
New version of XML reader/writer.
Now, there are only a single XmlIo class both for reading and writing.
ladanyi@1606
     1
#include "main_win.h"
alpar@1659
     2
#include "icons/guipixbufs.h"
ladanyi@1442
     3
ladanyi@1650
     4
MainWin::MainWin() :
hegyi@1733
     5
  newmapwin("Creating new map", gd_canvas),
hegyi@1733
     6
  mapwin("Map Setup", mapstorage, gd_canvas, newmapwin),
hegyi@1733
     7
  gd_canvas(mapstorage, mapwin, (Gtk::Window *)this)
ladanyi@1442
     8
{
ladanyi@1650
     9
  set_title ("unsaved file - " + prog_name);
ladanyi@1442
    10
  set_default_size(WIN_WIDTH,WIN_HEIGHT);
ladanyi@1442
    11
  add(vbox);
ladanyi@1442
    12
ladanyi@1634
    13
ladanyi@1634
    14
  // custom icons for the toolbar
ladanyi@1634
    15
ladanyi@1634
    16
  Glib::RefPtr<Gtk::IconFactory> p_icon_factory = Gtk::IconFactory::create();
ladanyi@1634
    17
 
ladanyi@1635
    18
  Glib::RefPtr<Gdk::Pixbuf> p_move_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    19
      2328, gui_icons_move);
ladanyi@1635
    20
  Glib::RefPtr<Gdk::Pixbuf> p_addnode_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    21
      2328, gui_icons_addnode);
ladanyi@1635
    22
  Glib::RefPtr<Gdk::Pixbuf> p_addlink_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    23
      2328, gui_icons_addlink);
ladanyi@1635
    24
  Glib::RefPtr<Gdk::Pixbuf> p_delete_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    25
      2328, gui_icons_delete);
ladanyi@1635
    26
  Glib::RefPtr<Gdk::Pixbuf> p_editlink_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    27
      2328, gui_icons_editlink);
ladanyi@1635
    28
  Glib::RefPtr<Gdk::Pixbuf> p_editnode_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    29
      2328, gui_icons_editnode);
ladanyi@1635
    30
  Glib::RefPtr<Gdk::Pixbuf> p_newmap_pixbuf = Gdk::Pixbuf::create_from_inline(
ladanyi@1635
    31
      2328, gui_icons_newmap);
ladanyi@1634
    32
ladanyi@1634
    33
  Gtk::IconSource move_icon_source;
ladanyi@1635
    34
  move_icon_source.set_pixbuf(p_move_pixbuf);
ladanyi@1634
    35
  Gtk::IconSet move_icon_set;
ladanyi@1634
    36
  move_icon_set.add_source(move_icon_source);
ladanyi@1634
    37
  p_icon_factory->add(Gtk::StockID("gd-move"), move_icon_set);
ladanyi@1634
    38
ladanyi@1634
    39
  Gtk::IconSource addnode_icon_source;
ladanyi@1635
    40
  addnode_icon_source.set_pixbuf(p_addnode_pixbuf);
ladanyi@1634
    41
  Gtk::IconSet addnode_icon_set;
ladanyi@1634
    42
  addnode_icon_set.add_source(addnode_icon_source);
ladanyi@1634
    43
  p_icon_factory->add(Gtk::StockID("gd-addnode"), addnode_icon_set);
ladanyi@1634
    44
ladanyi@1634
    45
  Gtk::IconSource addlink_icon_source;
ladanyi@1635
    46
  addlink_icon_source.set_pixbuf(p_addlink_pixbuf);
ladanyi@1634
    47
  Gtk::IconSet addlink_icon_set;
ladanyi@1634
    48
  addlink_icon_set.add_source(addlink_icon_source);
ladanyi@1634
    49
  p_icon_factory->add(Gtk::StockID("gd-addlink"), addlink_icon_set);
ladanyi@1634
    50
ladanyi@1634
    51
  Gtk::IconSource delete_icon_source;
ladanyi@1635
    52
  delete_icon_source.set_pixbuf(p_delete_pixbuf);
ladanyi@1634
    53
  Gtk::IconSet delete_icon_set;
ladanyi@1634
    54
  delete_icon_set.add_source(delete_icon_source);
ladanyi@1634
    55
  p_icon_factory->add(Gtk::StockID("gd-delete"), delete_icon_set);
ladanyi@1634
    56
ladanyi@1634
    57
  Gtk::IconSource editlink_icon_source;
ladanyi@1635
    58
  editlink_icon_source.set_pixbuf(p_editlink_pixbuf);
ladanyi@1634
    59
  Gtk::IconSet editlink_icon_set;
ladanyi@1634
    60
  editlink_icon_set.add_source(editlink_icon_source);
ladanyi@1634
    61
  p_icon_factory->add(Gtk::StockID("gd-editlink"), editlink_icon_set);
ladanyi@1634
    62
ladanyi@1634
    63
  Gtk::IconSource editnode_icon_source;
ladanyi@1635
    64
  editnode_icon_source.set_pixbuf(p_editnode_pixbuf);
ladanyi@1634
    65
  Gtk::IconSet editnode_icon_set;
ladanyi@1634
    66
  editnode_icon_set.add_source(editnode_icon_source);
ladanyi@1634
    67
  p_icon_factory->add(Gtk::StockID("gd-editnode"), editnode_icon_set);
ladanyi@1634
    68
ladanyi@1634
    69
  Gtk::IconSource newmap_icon_source;
ladanyi@1635
    70
  newmap_icon_source.set_pixbuf(p_newmap_pixbuf);
ladanyi@1634
    71
  Gtk::IconSet newmap_icon_set;
ladanyi@1634
    72
  newmap_icon_set.add_source(newmap_icon_source);
ladanyi@1634
    73
  p_icon_factory->add(Gtk::StockID("gd-newmap"), newmap_icon_set);
ladanyi@1634
    74
ladanyi@1634
    75
  p_icon_factory->add_default();
ladanyi@1634
    76
  
ladanyi@1634
    77
ladanyi@1442
    78
  ag=Gtk::ActionGroup::create();
ladanyi@1442
    79
ladanyi@1442
    80
  ag->add( Gtk::Action::create("FileMenu", "_File") );
ladanyi@1442
    81
  ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
ladanyi@1442
    82
      sigc::mem_fun(*this, &MainWin::newFile));
ladanyi@1442
    83
  ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
ladanyi@1442
    84
      sigc::mem_fun(*this, &MainWin::openFile));
ladanyi@1442
    85
  ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
ladanyi@1442
    86
      sigc::mem_fun(*this, &MainWin::saveFile));
ladanyi@1442
    87
  ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
ladanyi@1442
    88
      sigc::mem_fun(*this, &MainWin::saveFileAs));
ladanyi@1606
    89
  ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
ladanyi@1606
    90
      sigc::mem_fun(*this, &MainWin::close));
ladanyi@1606
    91
  ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
hegyi@1598
    92
      sigc::mem_fun(*this, &MainWin::hide));
ladanyi@1442
    93
ladanyi@1442
    94
  ag->add( Gtk::Action::create("ViewMenu", "_View") );
ladanyi@1442
    95
  ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
ladanyi@1442
    96
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomIn));
ladanyi@1442
    97
  ag->add( Gtk::Action::create("ViewZoomOut", Gtk::Stock::ZOOM_OUT),
ladanyi@1442
    98
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomOut));
ladanyi@1442
    99
  ag->add( Gtk::Action::create("ViewZoomFit", Gtk::Stock::ZOOM_FIT),
ladanyi@1442
   100
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoomFit));
ladanyi@1442
   101
  ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
ladanyi@1442
   102
      sigc::mem_fun(this->gd_canvas, &GraphDisplayerCanvas::zoom100));
ladanyi@1442
   103
  
ladanyi@1442
   104
  ag->add( Gtk::Action::create("ShowMenu", "_Show") );
ladanyi@1442
   105
  ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
hegyi@1598
   106
      sigc::mem_fun(this->mapwin, &MapWin::show));
ladanyi@1442
   107
ladanyi@1606
   108
  Gtk::RadioAction::Group tool_group;
ladanyi@1634
   109
  ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
ladanyi@1606
   110
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
ladanyi@1634
   111
  ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
hegyi@1502
   112
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 1) );
ladanyi@1634
   113
  ag->add( Gtk::RadioAction::create(tool_group, "CreateEdge", Gtk::StockID("gd-addlink"), "Create edge"),
hegyi@1502
   114
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 2) );
ladanyi@1634
   115
  ag->add( Gtk::RadioAction::create(tool_group, "EraseItem", Gtk::StockID("gd-delete"), "Delete"),
hegyi@1502
   116
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
ladanyi@1634
   117
ladanyi@1634
   118
  ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), "Edit edge map"),
hegyi@1550
   119
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
ladanyi@1634
   120
  ag->add( Gtk::RadioAction::create(tool_group, "EditNodeMap", Gtk::StockID("gd-editnode"), "Edit node map"),
hegyi@1550
   121
      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
ladanyi@1634
   122
ladanyi@1634
   123
  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
hegyi@1592
   124
      sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) );
hegyi@1502
   125
ladanyi@1442
   126
  uim=Gtk::UIManager::create();
ladanyi@1442
   127
  uim->insert_action_group(ag);
ladanyi@1442
   128
  add_accel_group(uim->get_accel_group());
ladanyi@1442
   129
ladanyi@1657
   130
  /*
ladanyi@1657
   131
      "      <menuitem action='ViewZoomFit' />"
ladanyi@1657
   132
      "    <toolitem action='ViewZoomFit' />"
ladanyi@1657
   133
   */
ladanyi@1657
   134
ladanyi@1442
   135
  try
ladanyi@1442
   136
  {
ladanyi@1442
   137
ladanyi@1442
   138
    Glib::ustring ui_info =
ladanyi@1442
   139
      "<ui>"
ladanyi@1442
   140
      "  <menubar name='MenuBar'>"
ladanyi@1442
   141
      "    <menu action='FileMenu'>"
ladanyi@1442
   142
      "      <menuitem action='FileNew'/>"
ladanyi@1442
   143
      "      <menuitem action='FileOpen'/>"
ladanyi@1442
   144
      "      <menuitem action='FileSave'/>"
ladanyi@1442
   145
      "      <menuitem action='FileSaveAs'/>"
ladanyi@1606
   146
      "      <menuitem action='Close'/>"
ladanyi@1606
   147
      "      <menuitem action='Quit'/>"
ladanyi@1442
   148
      "    </menu>"
ladanyi@1442
   149
      "    <menu action='ViewMenu'>"
ladanyi@1442
   150
      "      <menuitem action='ViewZoomIn' />"
ladanyi@1442
   151
      "      <menuitem action='ViewZoomOut' />"
ladanyi@1442
   152
      "      <menuitem action='ViewZoom100' />"
ladanyi@1442
   153
      "    </menu>"
ladanyi@1442
   154
      "    <menu action='ShowMenu'>"
ladanyi@1442
   155
      "      <menuitem action='ShowMaps'/>"
ladanyi@1442
   156
      "    </menu>"
ladanyi@1442
   157
      "  </menubar>"
ladanyi@1442
   158
      "  <toolbar name='ToolBar'>"
ladanyi@1442
   159
      "    <toolitem action='FileNew' />"
ladanyi@1442
   160
      "    <toolitem action='FileOpen' />"
ladanyi@1442
   161
      "    <toolitem action='FileSave' />"
ladanyi@1606
   162
      "    <toolitem action='Close' />"
ladanyi@1442
   163
      "    <separator />"
ladanyi@1442
   164
      "    <toolitem action='ViewZoomIn' />"
ladanyi@1442
   165
      "    <toolitem action='ViewZoomOut' />"
ladanyi@1442
   166
      "    <toolitem action='ViewZoom100' />"
hegyi@1502
   167
      "    <separator />"
ladanyi@1606
   168
      "    <toolitem action='MoveItem' />"
hegyi@1502
   169
      "    <toolitem action='CreateNode' />"
hegyi@1502
   170
      "    <toolitem action='CreateEdge' />"
hegyi@1502
   171
      "    <toolitem action='EraseItem' />"
hegyi@1550
   172
      "    <toolitem action='EditEdgeMap' />"
hegyi@1550
   173
      "    <toolitem action='EditNodeMap' />"
ladanyi@1634
   174
      "    <separator />"
hegyi@1592
   175
      "    <toolitem action='AddMap' />"
ladanyi@1442
   176
      "  </toolbar>"
ladanyi@1442
   177
      "</ui>";
ladanyi@1442
   178
ladanyi@1442
   179
    uim->add_ui_from_string(ui_info);
ladanyi@1442
   180
ladanyi@1442
   181
  }
ladanyi@1442
   182
  catch(const Glib::Error& ex)
ladanyi@1442
   183
  {
ladanyi@1442
   184
    std::cerr << "building menus failed: " <<  ex.what();
ladanyi@1442
   185
  }
ladanyi@1442
   186
ladanyi@1442
   187
  Gtk::Widget* menubar = uim->get_widget("/MenuBar");
ladanyi@1442
   188
  if (menubar){
ladanyi@1442
   189
    vbox.pack_start(*menubar, Gtk::PACK_SHRINK);
ladanyi@1442
   190
  }
ladanyi@1442
   191
ladanyi@1442
   192
  Gtk::Widget* toolbar = uim->get_widget("/ToolBar");
ladanyi@1442
   193
  if (toolbar)
ladanyi@1442
   194
  {
ladanyi@1442
   195
    static_cast<Gtk::Toolbar*>(toolbar)->set_toolbar_style(Gtk::TOOLBAR_ICONS);
ladanyi@1442
   196
    vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
ladanyi@1442
   197
  }
ladanyi@1442
   198
ladanyi@1442
   199
  Gtk::ScrolledWindow* pScrolledWindow = manage(new Gtk::ScrolledWindow());
ladanyi@1442
   200
  pScrolledWindow->add(gd_canvas);
ladanyi@1442
   201
  vbox.pack_start(*pScrolledWindow);
hegyi@1601
   202
hegyi@1601
   203
  tooltips.set_tip(*(uim->get_widget("/ToolBar/CreateNode")),"Create Node");
hegyi@1601
   204
  tooltips.enable();
ladanyi@1442
   205
ladanyi@1442
   206
  show_all_children();
ladanyi@1442
   207
}
ladanyi@1442
   208
ladanyi@1616
   209
void MainWin::readFile(const std::string &file)
ladanyi@1616
   210
{
ladanyi@1616
   211
  mapstorage.readFromFile(file);
ladanyi@1616
   212
  mapstorage.file_name = file;
ladanyi@1616
   213
  mapstorage.modified = false;
ladanyi@1616
   214
  gd_canvas.drawGraph();
ladanyi@1616
   215
  mapwin.update();
ladanyi@1650
   216
  set_title(Glib::filename_display_basename(file) + " - " + prog_name);
ladanyi@1616
   217
}
ladanyi@1616
   218
ladanyi@1442
   219
void MainWin::newFile()
ladanyi@1442
   220
{
ladanyi@1606
   221
  if (mapstorage.modified)
ladanyi@1606
   222
  {
ladanyi@1615
   223
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
ladanyi@1615
   224
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   225
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   226
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   227
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   228
    switch (mdialog.run())
ladanyi@1606
   229
    {
ladanyi@1606
   230
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   231
        return;
ladanyi@1606
   232
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   233
        break;
ladanyi@1606
   234
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   235
        saveFile();
ladanyi@1606
   236
        break;
ladanyi@1606
   237
    }
ladanyi@1606
   238
  }
ladanyi@1606
   239
  gd_canvas.clear();
ladanyi@1606
   240
  mapstorage.clear();
ladanyi@1606
   241
  mapwin.update();
ladanyi@1650
   242
  set_title("unsaved file - " + prog_name);
ladanyi@1442
   243
}
ladanyi@1442
   244
ladanyi@1442
   245
void MainWin::openFile()
ladanyi@1442
   246
{
ladanyi@1606
   247
  if (mapstorage.modified)
ladanyi@1606
   248
  {
ladanyi@1615
   249
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 
ladanyi@1615
   250
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   251
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   252
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   253
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   254
    switch (mdialog.run())
ladanyi@1606
   255
    {
ladanyi@1606
   256
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   257
        return;
ladanyi@1606
   258
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   259
        break;
ladanyi@1606
   260
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   261
        saveFile();
ladanyi@1606
   262
        break;
ladanyi@1606
   263
    }
ladanyi@1606
   264
  }
ladanyi@1606
   265
  Gtk::FileChooserDialog fcdialog("Open File");
ladanyi@1606
   266
  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   267
  fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   268
  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
ladanyi@1606
   269
  {
ladanyi@1650
   270
    gd_canvas.clear();
ladanyi@1650
   271
    mapstorage.clear();
ladanyi@1606
   272
    Glib::ustring filename = fcdialog.get_filename();
ladanyi@1645
   273
    if (!mapstorage.readFromFile(filename))
ladanyi@1645
   274
    {
ladanyi@1645
   275
      mapstorage.file_name = filename;
ladanyi@1645
   276
      mapstorage.modified = false;
ladanyi@1645
   277
      gd_canvas.drawGraph();
ladanyi@1645
   278
      mapwin.update();
ladanyi@1650
   279
      set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
ladanyi@1645
   280
    }
ladanyi@1606
   281
  }
ladanyi@1442
   282
}
ladanyi@1442
   283
ladanyi@1442
   284
void MainWin::saveFile()
ladanyi@1442
   285
{
ladanyi@1606
   286
  if (mapstorage.file_name == "") {
ladanyi@1606
   287
    saveFileAs();
ladanyi@1606
   288
  }
ladanyi@1606
   289
  else
ladanyi@1606
   290
  {
ladanyi@1606
   291
    mapstorage.writeToFile(mapstorage.file_name);
ladanyi@1606
   292
    mapstorage.modified = false;
ladanyi@1650
   293
    set_title(Glib::filename_display_basename(mapstorage.file_name) + " - " +
ladanyi@1650
   294
        prog_name);
ladanyi@1606
   295
  }
ladanyi@1442
   296
}
ladanyi@1442
   297
ladanyi@1442
   298
void MainWin::saveFileAs()
ladanyi@1442
   299
{
ladanyi@1606
   300
  Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
ladanyi@1606
   301
  fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   302
  fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   303
  if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
ladanyi@1606
   304
  {
ladanyi@1606
   305
    Glib::ustring filename = fcdialog.get_filename();
ladanyi@1606
   306
    mapstorage.file_name = filename;
ladanyi@1606
   307
    mapstorage.writeToFile(filename);
ladanyi@1606
   308
    mapstorage.modified = false;
ladanyi@1650
   309
    set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
ladanyi@1606
   310
  }
ladanyi@1442
   311
}
ladanyi@1606
   312
ladanyi@1606
   313
void MainWin::close()
ladanyi@1606
   314
{
ladanyi@1606
   315
  if (mapstorage.modified)
ladanyi@1606
   316
  {
ladanyi@1615
   317
    Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
ladanyi@1615
   318
        Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
ladanyi@1606
   319
    mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
ladanyi@1606
   320
    mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
ladanyi@1606
   321
    mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
ladanyi@1606
   322
    switch (mdialog.run())
ladanyi@1606
   323
    {
ladanyi@1606
   324
      case Gtk::RESPONSE_CANCEL:
ladanyi@1606
   325
        return;
ladanyi@1606
   326
      case Gtk::RESPONSE_REJECT:
ladanyi@1606
   327
        break;
ladanyi@1606
   328
      case Gtk::RESPONSE_ACCEPT:
ladanyi@1606
   329
        saveFile();
ladanyi@1606
   330
        break;
ladanyi@1606
   331
    }
ladanyi@1606
   332
  }
ladanyi@1606
   333
  gd_canvas.clear();
ladanyi@1606
   334
  mapstorage.clear();
ladanyi@1606
   335
  mapwin.update();
ladanyi@1650
   336
  set_title("unsaved file - " + prog_name);
ladanyi@1606
   337
}