Proper check for rawzor libraries.
[rawtherapee-fixes.git] / rtgui / filepanel.cc
blobd7c7aba2dfa10e808902d9e7d27f9b982dfa6723
1 /*
2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #include <filepanel.h>
20 #include <rtwindow.h>
22 int fbinit (void* data) {
24 gdk_threads_enter ();
25 ((FilePanel*)data)->init ();
26 gdk_threads_leave ();
28 return 0;
31 FilePanel::FilePanel () : parent(NULL) {
33 dirpaned = new Gtk::HPaned ();
34 dirpaned->set_position (options.dirBrowserWidth);
36 dirBrowser = new DirBrowser ();
37 placesBrowser = new PlacesBrowser ();
38 recentBrowser = new RecentBrowser ();
40 placespaned = new Gtk::VPaned ();
41 placespaned->set_position (options.dirBrowserHeight);
43 Gtk::VBox* obox = Gtk::manage (new Gtk::VBox ());
44 obox->pack_start (*recentBrowser, Gtk::PACK_SHRINK, 4);
45 obox->pack_start (*dirBrowser);
47 placespaned->pack1 (*placesBrowser, false, true);
48 placespaned->pack2 (*obox, true, true);
50 dirpaned->pack1 (*placespaned, Gtk::SHRINK);
52 tpc = new BatchToolPanelCoordinator (this);
53 fileCatalog = new FileCatalog (tpc->coarse, tpc->getToolBar());
54 dirpaned->pack2 (*fileCatalog, Gtk::EXPAND|Gtk::SHRINK);
56 placesBrowser->setDirBrowserRemoteInterface (dirBrowser);
57 recentBrowser->setDirBrowserRemoteInterface (dirBrowser);
58 dirBrowser->addDirSelectionListener (fileCatalog);
59 dirBrowser->addDirSelectionListener (recentBrowser);
60 dirBrowser->addDirSelectionListener (placesBrowser);
61 fileCatalog->setFileSelectionListener (this);
63 rightBox = new Gtk::HBox ();
64 rightNotebook = new Gtk::Notebook ();
65 Gtk::VBox* taggingBox = new Gtk::VBox ();
67 history = new History (false);
69 tpc->addPParamsChangeListener (history);
70 history->setProfileChangeListener (tpc);
72 Gtk::ScrolledWindow* sFilterPanel = new Gtk::ScrolledWindow();
73 filterPanel = new FilterPanel ();
74 sFilterPanel->add (*filterPanel);
75 sFilterPanel->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
77 fileCatalog->setFilterPanel (filterPanel);
78 fileCatalog->setImageAreaToolListener (tpc);
80 //------------------
82 rightNotebook->set_tab_pos (Gtk::POS_LEFT);
84 Gtk::Label* devLab = new Gtk::Label ("Develop");
85 devLab->set_angle (90);
86 Gtk::Label* filtLab = new Gtk::Label ("Filter");
87 filtLab->set_angle (90);
88 Gtk::Label* tagLab = new Gtk::Label ("Tagging");
89 tagLab->set_angle (90);
91 Gtk::VPaned* tpcPaned = new Gtk::VPaned ();
92 tpcPaned->pack1 (*tpc->toolPanelNotebook, true, true);
93 tpcPaned->pack2 (*history, true, true);
95 rightNotebook->append_page (*tpcPaned, *devLab);
96 rightNotebook->append_page (*sFilterPanel, *filtLab);
97 rightNotebook->append_page (*taggingBox, *tagLab);
99 rightBox->pack_start (*rightNotebook);
101 pack1(*dirpaned, true, true);
102 pack2(*rightBox, false, true);
104 fileCatalog->setFileSelectionChangeListener (tpc);
106 fileCatalog->setFileSelectionListener (this);
107 g_idle_add (fbinit, this);
109 show_all ();
112 void FilePanel::on_realize () {
114 Gtk::HPaned::on_realize ();
115 rightBox->set_size_request (options.browserToolPanelWidth, -1);
118 void FilePanel::init () {
120 dirBrowser->fillDirTree ();
121 placesBrowser->refreshPlacesList ();
123 if (argv1!="")
124 dirBrowser->open (argv1);
125 else {
126 if (options.startupDir==STARTUPDIR_HOME)
127 dirBrowser->open (Glib::get_home_dir());
128 else if (options.startupDir==STARTUPDIR_CURRENT)
129 dirBrowser->open (argv0);
130 else if (options.startupDir==STARTUPDIR_CUSTOM || options.startupDir==STARTUPDIR_LAST)
131 dirBrowser->open (options.startupPath);
135 bool FilePanel::fileSelected (Thumbnail* thm) {
137 if (!parent)
138 return false;
140 // try to open the file
141 bool succ = false;
142 fileCatalog->setEnabled (false);
143 rtengine::InitialImage* isrc = EditorPanel::loadImage (thm);
144 if (isrc) {
145 EditorPanel* epanel = Gtk::manage (new EditorPanel (thm, isrc));
146 parent->addEditorPanel (epanel);
147 succ = true;
149 else {
150 Glib::ustring msg_ = Glib::ustring("<b>") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n</b>";
151 Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
152 msgd.run ();
154 fileCatalog->setEnabled (true);
155 return succ;
158 void FilePanel::saveOptions () {
160 options.dirBrowserWidth = dirpaned->get_position ();
161 options.dirBrowserHeight = placespaned->get_position ();
162 options.browserToolPanelWidth = rightBox->get_width ();
163 if (options.startupDir==STARTUPDIR_LAST && fileCatalog->lastSelectedDir ()!="")
164 options.startupPath = fileCatalog->lastSelectedDir ();
165 fileCatalog->closeDir ();
168 void FilePanel::open (const Glib::ustring& d) {
170 if (Glib::file_test (d, Glib::FILE_TEST_IS_DIR))
171 dirBrowser->open (d.c_str());
172 else if (Glib::file_test (d, Glib::FILE_TEST_EXISTS))
173 dirBrowser->open (Glib::path_get_dirname(d), Glib::path_get_basename(d));
176 bool FilePanel::addBatchQueueJob (BatchQueueEntry* bqe) {
178 if (parent)
179 parent->addBatchQueueJob (bqe);
182 void FilePanel::optionsChanged () {
184 tpc->optionsChanged ();
185 fileCatalog->refreshAll ();