main_win.cc
branchgui
changeset 102 25a4698cbe0c
parent 100 ad84ee331106
child 103 3a263e57e1d9
equal deleted inserted replaced
28:5f96b390bfa4 29:cfddb973fcab
    70   p_icon_factory->add_default();
    70   p_icon_factory->add_default();
    71   
    71   
    72   ag=Gtk::ActionGroup::create();
    72   ag=Gtk::ActionGroup::create();
    73 
    73 
    74   ag->add( Gtk::Action::create("FileMenu", "_File") );
    74   ag->add( Gtk::Action::create("FileMenu", "_File") );
    75   ag->add( Gtk::Action::create("FileNewTab", "New _Tab"),
    75   ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
    76       sigc::mem_fun(*this, &MainWin::newTab));
    76       sigc::mem_fun(*this, &MainWin::newTab));
    77   ag->add( Gtk::Action::create("FileCloseTab", "_Close Tab"),
       
    78       sigc::mem_fun(*this, &MainWin::closeTab));
       
    79   ag->add( Gtk::Action::create("FileNew", Gtk::Stock::NEW),
       
    80       sigc::mem_fun(*this, &MainWin::newFile));
       
    81   ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
    77   ag->add( Gtk::Action::create("FileOpen", Gtk::Stock::OPEN),
    82       sigc::mem_fun(*this, &MainWin::openFile));
    78       sigc::mem_fun(*this, &MainWin::openFile));
       
    79   ag->add( Gtk::Action::create("FileClearTab", "Clear Tab"),
       
    80       sigc::mem_fun(*this, &MainWin::newFile));
    83   ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
    81   ag->add( Gtk::Action::create("FileSave", Gtk::Stock::SAVE),
    84       sigc::mem_fun(*this, &MainWin::saveFile));
    82       sigc::mem_fun(*this, &MainWin::saveFile));
    85   ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
    83   ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
    86       sigc::mem_fun(*this, &MainWin::saveFileAs));
    84       sigc::mem_fun(*this, &MainWin::saveFileAs));
    87   ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
    85   ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
    88       sigc::mem_fun(*this, &MainWin::close));
    86       sigc::mem_fun(*this, &MainWin::closeTab));
    89   ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
    87   ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
    90       sigc::mem_fun(*this, &MainWin::hide));
    88       sigc::mem_fun(*this, &MainWin::hide));
    91 
    89 
    92   ag->add( Gtk::Action::create("ViewMenu", "_View") );
    90   ag->add( Gtk::Action::create("ViewMenu", "_View") );
    93   ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
    91   ag->add( Gtk::Action::create("ViewZoomIn", Gtk::Stock::ZOOM_IN),
   130 
   128 
   131     Glib::ustring ui_info =
   129     Glib::ustring ui_info =
   132       "<ui>"
   130       "<ui>"
   133       "  <menubar name='MenuBar'>"
   131       "  <menubar name='MenuBar'>"
   134       "    <menu action='FileMenu'>"
   132       "    <menu action='FileMenu'>"
   135       "      <menuitem action='FileNewTab'/>"
       
   136       "      <menuitem action='FileCloseTab'/>"
       
   137       "      <menuitem action='FileNew'/>"
   133       "      <menuitem action='FileNew'/>"
   138       "      <menuitem action='FileOpen'/>"
   134       "      <menuitem action='FileOpen'/>"
       
   135       "      <menuitem action='FileClearTab'/>"
   139       "      <menuitem action='FileSave'/>"
   136       "      <menuitem action='FileSave'/>"
   140       "      <menuitem action='FileSaveAs'/>"
   137       "      <menuitem action='FileSaveAs'/>"
   141       "      <menuitem action='Close'/>"
   138       "      <menuitem action='Close'/>"
   142       "      <menuitem action='Quit'/>"
   139       "      <menuitem action='Quit'/>"
   143       "    </menu>"
   140       "    </menu>"
   235 
   232 
   236 void MainWin::closeTab()
   233 void MainWin::closeTab()
   237 {
   234 {
   238   if(active_tab!=-1)
   235   if(active_tab!=-1)
   239     {
   236     {
       
   237       if (tabs[active_tab]->mapstorage.modified)
       
   238 	{
       
   239 	  Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 
       
   240 				     Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
       
   241 	  mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
       
   242 	  mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
       
   243 	  mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
       
   244 	  switch (mdialog.run())
       
   245 	    {
       
   246 	    case Gtk::RESPONSE_CANCEL:
       
   247 	      return;
       
   248 	    case Gtk::RESPONSE_REJECT:
       
   249 	      break;
       
   250 	    case Gtk::RESPONSE_ACCEPT:
       
   251 	      tabs[active_tab]->saveFile();
       
   252 	      break;
       
   253 	    }
       
   254 	}
   240       //tabs vector will be decreased with the deleted value
   255       //tabs vector will be decreased with the deleted value
   241       int size=tabs.size();
   256       int size=tabs.size();
   242       if(size>1)
   257       if(size>1)
   243 	{
   258 	{
   244 	  for(int i=active_tab+1;i<size;i++)
   259 	  for(int i=active_tab+1;i<size;i++)