Forgotten file committed.
3 NoteBookTab::NoteBookTab():mapwinexists(false)
5 gd_canvas=new GraphDisplayerCanvas(*this);
8 //connecting signals - controller character
9 mapstorage.signal_prop_ch().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::propertyChange));
10 mapstorage.signal_node_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewNodeMap));
11 mapstorage.signal_edge_map_ch().connect(sigc::mem_fun(*this, &NoteBookTab::registerNewEdgeMap));
16 void NoteBookTab::readFile(const std::string &file)
18 mapstorage.readFromFile(file);
19 mapstorage.file_name = file;
20 mapstorage.modified = false;
21 gd_canvas->drawGraph();
24 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
26 signal_title.emit(Glib::filename_display_basename(file));
29 void NoteBookTab::newFile()
31 if (mapstorage.modified)
33 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
34 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
35 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
36 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
37 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
38 switch (mdialog.run())
40 case Gtk::RESPONSE_CANCEL:
42 case Gtk::RESPONSE_REJECT:
44 case Gtk::RESPONSE_ACCEPT:
53 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
55 signal_title.emit("unsaved file");
58 void NoteBookTab::openFile()
60 if (mapstorage.modified)
62 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
63 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
64 mdialog.add_button("Close file _without Saving", Gtk::RESPONSE_REJECT);
65 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
66 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
67 switch (mdialog.run())
69 case Gtk::RESPONSE_CANCEL:
71 case Gtk::RESPONSE_REJECT:
73 case Gtk::RESPONSE_ACCEPT:
78 Gtk::FileChooserDialog fcdialog("Open File");
79 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
80 fcdialog.add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
81 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
85 Glib::ustring filename = fcdialog.get_filename();
86 if (!mapstorage.readFromFile(filename))
88 mapstorage.file_name = filename;
89 mapstorage.modified = false;
90 gd_canvas->drawGraph();
93 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
95 signal_title.emit(Glib::filename_display_basename(filename));
100 void NoteBookTab::saveFile()
102 if (mapstorage.file_name == "") {
107 mapstorage.writeToFile(mapstorage.file_name);
108 mapstorage.modified = false;
109 signal_title.emit(Glib::filename_display_basename(mapstorage.file_name));
113 void NoteBookTab::saveFileAs()
115 Gtk::FileChooserDialog fcdialog("Save File", Gtk::FILE_CHOOSER_ACTION_SAVE);
116 fcdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
117 fcdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
118 if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
120 Glib::ustring filename = fcdialog.get_filename();
121 mapstorage.file_name = filename;
122 mapstorage.writeToFile(filename);
123 mapstorage.modified = false;
124 signal_title.emit(Glib::filename_display_basename(filename));
128 void NoteBookTab::close()
130 if (mapstorage.modified)
132 Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
133 Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
134 mdialog.add_button("Close _without Saving", Gtk::RESPONSE_REJECT);
135 mdialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
136 mdialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
137 switch (mdialog.run())
139 case Gtk::RESPONSE_CANCEL:
141 case Gtk::RESPONSE_REJECT:
143 case Gtk::RESPONSE_ACCEPT:
152 mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
154 signal_title.emit("unsaved file");
157 void NoteBookTab::propertyChange(bool itisedge, int prop, std::string mapname)
159 mapstorage.changeActiveMap(itisedge, prop, mapname);
162 sigc::signal<void, NoteBookTab *, bool> NoteBookTab::signal_newmap_needed()
164 return signal_newmap;
167 void NoteBookTab::popupNewMapWin(bool itisedge, int prop)
170 signal_newmap.emit(this, itisedge);
173 std::string NoteBookTab::getActiveEdgeMap(int prop)
175 return mapstorage.getActiveEdgeMap(prop);
178 std::string NoteBookTab::getActiveNodeMap(int prop)
180 return mapstorage.getActiveNodeMap(prop);
183 void NoteBookTab::registerNewEdgeMap(std::string mapname)
187 mapwin->registerNewEdgeMap(mapname);
191 void NoteBookTab::registerNewNodeMap(std::string mapname)
195 mapwin->registerNewNodeMap(mapname);
199 void NoteBookTab::createMapWin(std::string name)
203 mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
209 void NoteBookTab::closeMapWin()
215 sigc::signal<void, std::string> NoteBookTab::signal_title_ch()