Replace the DirBrowserRemoteInterface by slots to reduce coupling by using ad-hoc yet type-safe collaborations.
This commit is contained in:
@@ -24,9 +24,8 @@
|
||||
#ifdef WIN32
|
||||
#include "windirmonitor.h"
|
||||
#endif
|
||||
#include "dirbrowserremoteinterface.h"
|
||||
|
||||
class DirBrowser : public Gtk::VBox, public DirBrowserRemoteInterface
|
||||
class DirBrowser : public Gtk::VBox
|
||||
#ifdef WIN32
|
||||
, public WinDirChangeListener
|
||||
#endif
|
||||
|
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* This file is part of RawTherapee.
|
||||
*
|
||||
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
|
||||
*
|
||||
* RawTherapee is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* RawTherapee is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef _DIRBROWSERREMOTEINTERFACE_
|
||||
#define _DIRBROWSERREMOTEINTERFACE_
|
||||
|
||||
#include <glibmm.h>
|
||||
|
||||
class DirBrowserRemoteInterface
|
||||
{
|
||||
|
||||
public:
|
||||
virtual void selectDir (Glib::ustring dir) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -43,7 +43,6 @@ FileCatalog::FileCatalog (CoarsePanel* cp, ToolBar* tb, FilePanel* filepanel) :
|
||||
selectedDirectoryId(1),
|
||||
listener(NULL),
|
||||
fslistener(NULL),
|
||||
dirlistener(NULL),
|
||||
hasValidCurrentEFS(false),
|
||||
filterPanel(NULL),
|
||||
previewsToLoad(0),
|
||||
@@ -2042,8 +2041,8 @@ void FileCatalog::buttonBrowsePathPressed ()
|
||||
// handle shortcuts in the BrowsePath -- END
|
||||
|
||||
// validate the path
|
||||
if (safe_file_test(BrowsePathValue, Glib::FILE_TEST_IS_DIR) && dirlistener) {
|
||||
dirlistener->selectDir (BrowsePathValue);
|
||||
if (safe_file_test(BrowsePathValue, Glib::FILE_TEST_IS_DIR) && selectDir) {
|
||||
selectDir (BrowsePathValue);
|
||||
} else
|
||||
// error, likely path not found: show red arrow
|
||||
{
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#ifdef WIN32
|
||||
#include "windirmonitor.h"
|
||||
#endif
|
||||
#include "dirbrowserremoteinterface.h"
|
||||
#include "filebrowser.h"
|
||||
#include "exiffiltersettings.h"
|
||||
#include <giomm.h>
|
||||
@@ -67,6 +66,8 @@ class FileCatalog : public Gtk::VBox,
|
||||
, public WinDirChangeListener
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
typedef sigc::slot<void, const Glib::ustring&> DirSelectionSlot;
|
||||
|
||||
private:
|
||||
FilePanel* filepanel;
|
||||
@@ -82,7 +83,7 @@ private:
|
||||
FileSelectionListener* listener;
|
||||
FileSelectionChangeListener* fslistener;
|
||||
ImageAreaToolListener* iatlistener;
|
||||
DirBrowserRemoteInterface* dirlistener;
|
||||
DirSelectionSlot selectDir;
|
||||
|
||||
Gtk::HBox* buttonBar;
|
||||
Gtk::HBox* hbToolBar1;
|
||||
@@ -242,10 +243,7 @@ public:
|
||||
{
|
||||
iatlistener = l;
|
||||
}
|
||||
void setDirBrowserRemoteInterface (DirBrowserRemoteInterface* l)
|
||||
{
|
||||
dirlistener = l;
|
||||
}
|
||||
void setDirSelector (const DirSelectionSlot& selectDir);
|
||||
|
||||
void setFilterPanel (FilterPanel* fpanel);
|
||||
void setExportPanel (ExportPanel* expanel);
|
||||
@@ -310,4 +308,9 @@ public:
|
||||
|
||||
};
|
||||
|
||||
inline void FileCatalog::setDirSelector (const FileCatalog::DirSelectionSlot& selectDir)
|
||||
{
|
||||
this->selectDir = selectDir;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -59,15 +59,15 @@ FilePanel::FilePanel () : parent(NULL)
|
||||
ribbonPane->set_size_request(50, 150);
|
||||
dirpaned->pack2 (*ribbonPane, true, true);
|
||||
|
||||
placesBrowser->setDirBrowserRemoteInterface (dirBrowser);
|
||||
recentBrowser->setDirBrowserRemoteInterface (dirBrowser);
|
||||
DirBrowser::DirSelectionSignal dirSelected = dirBrowser->dirSelected ();
|
||||
dirSelected.connect (sigc::mem_fun (fileCatalog, &FileCatalog::dirSelected));
|
||||
dirSelected.connect (sigc::mem_fun (recentBrowser, &RecentBrowser::dirSelected));
|
||||
dirSelected.connect (sigc::mem_fun (placesBrowser, &PlacesBrowser::dirSelected));
|
||||
dirSelected.connect (sigc::mem_fun (tpc, &BatchToolPanelCoordinator::dirSelected));
|
||||
fileCatalog->setDirSelector (sigc::mem_fun (dirBrowser, &DirBrowser::selectDir));
|
||||
placesBrowser->setDirSelector (sigc::mem_fun (dirBrowser, &DirBrowser::selectDir));
|
||||
recentBrowser->setDirSelector (sigc::mem_fun (dirBrowser, &DirBrowser::selectDir));
|
||||
fileCatalog->setFileSelectionListener (this);
|
||||
fileCatalog->setDirBrowserRemoteInterface (dirBrowser);
|
||||
|
||||
rightBox = Gtk::manage ( new Gtk::HBox () );
|
||||
rightBox->set_size_request(50, 100);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "guiutils.h"
|
||||
#include "rtimage.h"
|
||||
|
||||
PlacesBrowser::PlacesBrowser () : listener (NULL)
|
||||
PlacesBrowser::PlacesBrowser ()
|
||||
{
|
||||
|
||||
scrollw = Gtk::manage (new Gtk::ScrolledWindow ());
|
||||
@@ -286,8 +286,8 @@ void PlacesBrowser::selectionChanged ()
|
||||
drives[i]->poll_for_media ();
|
||||
break;
|
||||
}
|
||||
} else if (listener) {
|
||||
listener->selectDir (iter->get_value (placesColumns.root));
|
||||
} else if (selectDir) {
|
||||
selectDir (iter->get_value (placesColumns.root));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,14 @@
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <giomm.h>
|
||||
#include "dirbrowserremoteinterface.h"
|
||||
#include "multilangmgr.h"
|
||||
|
||||
class PlacesBrowser : public Gtk::VBox
|
||||
{
|
||||
public:
|
||||
typedef sigc::slot<void, const Glib::ustring&> DirSelectionSlot;
|
||||
|
||||
private:
|
||||
|
||||
class PlacesColumns : public Gtk::TreeModel::ColumnRecord
|
||||
{
|
||||
@@ -49,7 +52,7 @@ class PlacesBrowser : public Gtk::VBox
|
||||
Gtk::TreeView* treeView;
|
||||
Glib::RefPtr<Gtk::ListStore> placesModel;
|
||||
Glib::RefPtr<Gio::VolumeMonitor> vm;
|
||||
DirBrowserRemoteInterface* listener;
|
||||
DirSelectionSlot selectDir;
|
||||
Glib::ustring lastSelectedDir;
|
||||
Gtk::Button* add;
|
||||
Gtk::Button* del;
|
||||
@@ -58,10 +61,7 @@ public:
|
||||
|
||||
PlacesBrowser ();
|
||||
|
||||
void setDirBrowserRemoteInterface (DirBrowserRemoteInterface* l)
|
||||
{
|
||||
listener = l;
|
||||
}
|
||||
void setDirSelector (const DirSelectionSlot& selectDir);
|
||||
void dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile);
|
||||
|
||||
void refreshPlacesList ();
|
||||
@@ -74,6 +74,11 @@ public:
|
||||
void delPressed ();
|
||||
};
|
||||
|
||||
inline void PlacesBrowser::setDirSelector (const PlacesBrowser::DirSelectionSlot& selectDir)
|
||||
{
|
||||
this->selectDir = selectDir;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -22,7 +22,7 @@
|
||||
|
||||
using namespace rtengine;
|
||||
|
||||
RecentBrowser::RecentBrowser () : listener (NULL)
|
||||
RecentBrowser::RecentBrowser ()
|
||||
{
|
||||
|
||||
recentDirs = Gtk::manage (new MyComboBoxText ());
|
||||
@@ -46,8 +46,8 @@ void RecentBrowser::selectionChanged ()
|
||||
|
||||
Glib::ustring sel = recentDirs->get_active_text ();
|
||||
|
||||
if (sel != "" && listener) {
|
||||
listener->selectDir (sel);
|
||||
if (!sel.empty() && selectDir) {
|
||||
selectDir (sel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,30 +20,34 @@
|
||||
#define _RECENTBROWSER_
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "dirbrowserremoteinterface.h"
|
||||
#include "multilangmgr.h"
|
||||
#include "guiutils.h"
|
||||
|
||||
class RecentBrowser : public Gtk::VBox
|
||||
{
|
||||
public:
|
||||
typedef sigc::slot<void, const Glib::ustring&> DirSelectionSlot;
|
||||
|
||||
private:
|
||||
Gtk::ComboBoxText* recentDirs;
|
||||
sigc::connection conn;
|
||||
DirBrowserRemoteInterface* listener;
|
||||
DirSelectionSlot selectDir;
|
||||
|
||||
public:
|
||||
|
||||
RecentBrowser ();
|
||||
|
||||
void setDirBrowserRemoteInterface (DirBrowserRemoteInterface* l)
|
||||
{
|
||||
listener = l;
|
||||
}
|
||||
void setDirSelector (const DirSelectionSlot& selectDir);
|
||||
|
||||
void selectionChanged ();
|
||||
void dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile);
|
||||
};
|
||||
|
||||
inline void RecentBrowser::setDirSelector (const RecentBrowser::DirSelectionSlot& selectDir)
|
||||
{
|
||||
this->selectDir = selectDir;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user