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