From f7ec7a8ca343b38dc0ced56ea1d5091c8208effa Mon Sep 17 00:00:00 2001 From: aferrero2707 Date: Sun, 30 Aug 2015 16:35:32 +0200 Subject: [PATCH] Opening a layer map that is already opened activates the corresponding tab instead of adding a new one. --- src/gui/layerwidget.cc | 25 +++++++++++++++++++++++++ src/gui/layerwidget.hh | 1 + 2 files changed, 26 insertions(+) diff --git a/src/gui/layerwidget.cc b/src/gui/layerwidget.cc index 6f46dfc7c..7bed7a112 100644 --- a/src/gui/layerwidget.cc +++ b/src/gui/layerwidget.cc @@ -332,6 +332,12 @@ void PF::LayerWidget::on_row_activated( const Gtk::TreeModel::Path& path, Gtk::T std::cout<<"Activated IMap column of row "<get_name()<get_imap_layers()) ); + if( tab_id >= 0 ) { + notebook.set_current_page( tab_id ); + return; + } + LayerTree* view = new LayerTree( editor, true ); //frame->add( *view ); @@ -374,6 +380,12 @@ void PF::LayerWidget::on_row_activated( const Gtk::TreeModel::Path& path, Gtk::T std::cout<<"Activated OMap column of row "<get_name()<get_omap_layers()) ); + if( tab_id >= 0 ) { + notebook.set_current_page( tab_id ); + return; + } + LayerTree* view = new LayerTree( editor, true ); //frame->add( *view ); @@ -677,6 +689,19 @@ void PF::LayerWidget::insert_preset( std::string filename ) } +int PF::LayerWidget::get_map_tab( std::list* map_layers ) +{ + for( int i = notebook.get_n_pages()-1; i>=1; i-- ) { + Widget* page = notebook.get_nth_page(i); + LayerTree* view = dynamic_cast( page ); + if( !view ) continue; + std::list* view_layers = view->get_layers(); + if( view_layers == map_layers ) return i; + } + return -1; +} + + void PF::LayerWidget::close_map_tabs( Layer* l ) { diff --git a/src/gui/layerwidget.hh b/src/gui/layerwidget.hh index 6f21e4e87..a37025795 100644 --- a/src/gui/layerwidget.hh +++ b/src/gui/layerwidget.hh @@ -88,6 +88,7 @@ class LayerWidget : public Gtk::VBox void detach_controls( Layer* l ); void detach_controls( std::list& layers ); + int get_map_tab( std::list* map_layers ); void close_map_tabs( Layer* l ); public: