From 5f25f8927d0670eabcbcb8ef1e71b7887c63b887 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Wed, 23 Nov 2005 17:00:04 +0000 Subject: [PATCH] Menu y actions para abrir un arbol. --- viewer/main.cpp | 21 +++++++++++++++++++++ viewer/view_btree.cpp | 2 +- viewer/view_btree.h | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/viewer/main.cpp b/viewer/main.cpp index a7bb924..144cdda 100644 --- a/viewer/main.cpp +++ b/viewer/main.cpp @@ -18,6 +18,7 @@ using namespace Gnome::Canvas; " " " " " " +" " " " " " " " @@ -39,6 +40,7 @@ using namespace Gnome::Canvas; ""; void nuevo_arbol (); +void abrir_arbol (); void agregar_clave (); void borrar_clave (); void ir_al_padre (); @@ -79,6 +81,7 @@ int main(int argc, char *argv[]) actiongroup->add( Gtk::Action::create("MenuFile", "_Arbol") ); actiongroup->add( Gtk::Action::create("Nuevo", Gtk::Stock::NEW), &nuevo_arbol); + actiongroup->add( Gtk::Action::create("Abrir", Gtk::Stock::OPEN), &abrir_arbol); actiongroup->add( Gtk::Action::create("Salir", Gtk::Stock::QUIT), Gtk::AccelKey ("q"), &Gtk::Main::quit); actiongroup->add( Gtk::Action::create("MenuNode", "_Nodo") ); actiongroup->add( Gtk::Action::create("Ir al Padre", Gtk::Stock::GO_BACK), Gtk::AccelKey ("b"), &ir_al_padre); @@ -112,6 +115,24 @@ int main(int argc, char *argv[]) return 0; } +void abrir_arbol () +{ + Gtk::FileChooserDialog dlg ("Abrir Arbol"); + + dlg.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + dlg.add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT); + if (dlg.run () == Gtk::RESPONSE_ACCEPT) { + Glib::ustring s = dlg.get_filename (); + std::string filename = s; + ViewBTree *ptree = ViewBTree::Open (real_canvas->root (), filename); + if (ptree != NULL) { + tree = Glib::RefPtr(ptree); + tree->signal_selected ().connect ( sigc::mem_fun (*real_frame, &ViewProperties::ShowItem) ); + tree->AddNode (0); + } + } +} + void nuevo_arbol () { real_canvas->set_scroll_region (0, 0, 5000, 5000); diff --git a/viewer/view_btree.cpp b/viewer/view_btree.cpp index d85a909..dab5404 100644 --- a/viewer/view_btree.cpp +++ b/viewer/view_btree.cpp @@ -31,7 +31,7 @@ ViewBTree::ViewBTree (Canvas::Group *parent, const std::string filename) last_visited = 0; } -ViewBTree* Open (Canvas::Group *parent, const std::string &filename) +ViewBTree* ViewBTree::Open (Canvas::Group *parent, const std::string &filename) { ViewBTree *tree = new ViewBTree (parent, filename); diff --git a/viewer/view_btree.h b/viewer/view_btree.h index f4e3c47..729f267 100644 --- a/viewer/view_btree.h +++ b/viewer/view_btree.h @@ -18,7 +18,7 @@ class ViewBTree : public Canvas::Group, public BTree { ViewBTree (Canvas::Group *parent, std::string filename, uint block_size, int tree_type, int type); ViewBTree (Canvas::Group *parent, const std::string filename); - static ViewBTree* Open (const std::string &filename); + static ViewBTree* Open (Canvas::Group *parent, const std::string &filename); void Clear (); void HighliteKey (Clave &k); -- 2.43.0