From 6f5eb6b371a6933f22f5c3f6e1b3496fffea201b Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Mon, 3 Oct 2011 19:04:44 +0200 Subject: [PATCH] Fixed image should not open multiple times see issue 1024 --- rtgui/editwindow.cc | 17 ++++++++++------- rtgui/editwindow.h | 1 + rtgui/filepanel.cc | 4 ++++ rtgui/rtwindow.cc | 16 ++++++++++++++++ rtgui/rtwindow.h | 1 + 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/rtgui/editwindow.cc b/rtgui/editwindow.cc index 9f6102a3c..1b996172c 100644 --- a/rtgui/editwindow.cc +++ b/rtgui/editwindow.cc @@ -115,13 +115,6 @@ void EditWindow::on_mainNB_switch_page(GtkNotebookPage* page, guint page_num) { } void EditWindow::addEditorPanel (EditorPanel* ep, const std::string &name) { - if (epanels.find(name)!=epanels.end()) { - // remove existing panel - mainNB->remove_page (*epanels[name]); - epanels.erase (name); - filesEdited.erase (name); - } - ep->setParent (parent); // construct closeable tab for the image @@ -162,6 +155,16 @@ void EditWindow::remEditorPanel (EditorPanel* ep) { // TODO: save options if wanted } +bool EditWindow::selectEditorPanel(const std::string &name) { + std::map::iterator iep = epanels.find(name); + + if (iep!=epanels.end()) { + mainNB->set_current_page (mainNB->page_num (*iep->second)); + return true; + } + return false; +} + bool EditWindow::keyPressed (GdkEventKey* event) { if(event->keyval == GDK_F11) { toggleFullscreen(); diff --git a/rtgui/editwindow.h b/rtgui/editwindow.h index d3beb703b..b1fbc2087 100644 --- a/rtgui/editwindow.h +++ b/rtgui/editwindow.h @@ -45,6 +45,7 @@ class EditWindow : public Gtk::Window { void addEditorPanel (EditorPanel* ep,const std::string &name); void remEditorPanel (EditorPanel* ep); + bool selectEditorPanel(const std::string &name); bool keyPressed (GdkEventKey* event); bool on_delete_event(GdkEventAny* event); diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index c34a36261..e939b95b8 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -150,6 +150,10 @@ bool FilePanel::fileSelected (Thumbnail* thm) { if (!parent) return false; + // Check if it's already open BEFORE loading the file + if (options.tabbedUI && parent->selectEditorPanel(Glib::path_get_basename (thm->getFileName()))) + return true; + // try to open the file bool loading = thm->imageLoad( true ); if( !loading ) return false; diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 9b7de0cc2..ef50bdb91 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -292,6 +292,22 @@ void RTWindow::remEditorPanel (EditorPanel* ep) { } } +bool RTWindow::selectEditorPanel(const std::string &name) { + if (EditWindow::isMultiDisplayEnabled()) { + EditWindow * wndEdit = EditWindow::getInstance(this); + if (wndEdit->selectEditorPanel(name)) return true; + } else { + std::map::iterator iep = epanels.find(name); + + if (iep!=epanels.end()) { + mainNB->set_current_page (mainNB->page_num (*iep->second)); + return true; + } + } + + return false; +} + bool RTWindow::keyPressed (GdkEventKey* event) { bool ctrl = event->state & GDK_CONTROL_MASK; diff --git a/rtgui/rtwindow.h b/rtgui/rtwindow.h index 39bb137f4..3fac27d1f 100644 --- a/rtgui/rtwindow.h +++ b/rtgui/rtwindow.h @@ -51,6 +51,7 @@ class RTWindow : public Gtk::Window, public rtengine::ProgressListener{ void addEditorPanel (EditorPanel* ep,const std::string &name); void remEditorPanel (EditorPanel* ep); + bool selectEditorPanel(const std::string &name); void addBatchQueueJob (BatchQueueEntry* bqe, bool head=false); void addBatchQueueJobs (std::vector &entries);