Move image loader helper functions from safegtk to RTImage module.
This commit is contained in:
@@ -38,41 +38,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Pixbuf> safe_create_from_file(const Glib::ustring& filename)
|
|
||||||
{
|
|
||||||
Glib::RefPtr<Gdk::Pixbuf> res;
|
|
||||||
Glib::ustring path = RTImage::findIconAbsolutePath(filename);
|
|
||||||
|
|
||||||
if (path.length()) {
|
|
||||||
try {
|
|
||||||
res = Gdk::Pixbuf::create_from_file (path);
|
|
||||||
} catch (Glib::Exception& ex) {
|
|
||||||
printf ("ERROR: (ustring) File \"%s\" not found.\n", ex.what().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cairo::RefPtr<Cairo::ImageSurface> safe_create_from_png(const Glib::ustring& filename)
|
|
||||||
{
|
|
||||||
Cairo::RefPtr<Cairo::ImageSurface> res;
|
|
||||||
Glib::ustring path = RTImage::findIconAbsolutePath(filename);
|
|
||||||
|
|
||||||
if (path.length()) {
|
|
||||||
// files_test need a std::string which (as stated in its proto) but will only work if
|
|
||||||
// we use the Glib::ustring filename !?
|
|
||||||
try {
|
|
||||||
// create_from_png need a std::string converted from UTF8 with safe_locale_from_utf8
|
|
||||||
res = Cairo::ImageSurface::create_from_png (safe_locale_from_utf8(path));
|
|
||||||
} catch (...) {
|
|
||||||
printf("ERROR: (ustring) File \"%s\" not found.\n", path.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
|
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gio::FileInfo> info;
|
Glib::RefPtr<Gio::FileInfo> info;
|
||||||
|
@@ -5,9 +5,6 @@
|
|||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include <giomm.h>
|
#include <giomm.h>
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Pixbuf> safe_create_from_file(const Glib::ustring& filename);
|
|
||||||
Cairo::RefPtr<Cairo::ImageSurface> safe_create_from_png(const Glib::ustring& filename);
|
|
||||||
|
|
||||||
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file);
|
Glib::RefPtr<Gio::FileInfo> safe_query_file_info (Glib::RefPtr<Gio::File> &file);
|
||||||
void safe_build_file_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ustring> &names, const Glib::ustring &directory = "", const std::vector<Glib::ustring> *extensions = NULL);
|
void safe_build_file_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ustring> &names, const Glib::ustring &directory = "", const std::vector<Glib::ustring> *extensions = NULL);
|
||||||
void safe_build_subdir_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ustring> &subDirs, bool add_hidden);
|
void safe_build_subdir_list (Glib::RefPtr<Gio::File> &dir, std::vector<Glib::ustring> &subDirs, bool add_hidden);
|
||||||
|
@@ -17,8 +17,9 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "batchqueuebuttonset.h"
|
#include "batchqueuebuttonset.h"
|
||||||
|
|
||||||
#include "multilangmgr.h"
|
#include "multilangmgr.h"
|
||||||
#include "../rtengine/safegtk.h"
|
#include "rtimage.h"
|
||||||
|
|
||||||
extern Glib::ustring argv0;
|
extern Glib::ustring argv0;
|
||||||
|
|
||||||
@@ -32,9 +33,9 @@ BatchQueueButtonSet::BatchQueueButtonSet (BatchQueueEntry* myEntry)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!iconsLoaded) {
|
if (!iconsLoaded) {
|
||||||
cancelIcon = safe_create_from_png ("gtk-close.png");
|
cancelIcon = RTImage::createFromPng ("gtk-close.png");
|
||||||
headIcon = safe_create_from_png ("toleftend.png");
|
headIcon = RTImage::createFromPng ("toleftend.png");
|
||||||
tailIcon = safe_create_from_png ("torightend.png");
|
tailIcon = RTImage::createFromPng ("torightend.png");
|
||||||
iconsLoaded = true;
|
iconsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,13 +17,14 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "batchqueueentry.h"
|
#include "batchqueueentry.h"
|
||||||
#include "thumbbrowserbase.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "threadutils.h"
|
#include "threadutils.h"
|
||||||
#include "../rtengine/safegtk.h"
|
#include "rtimage.h"
|
||||||
#include "multilangmgr.h"
|
#include "multilangmgr.h"
|
||||||
|
#include "thumbbrowserbase.h"
|
||||||
|
|
||||||
bool BatchQueueEntry::iconsLoaded(false);
|
bool BatchQueueEntry::iconsLoaded(false);
|
||||||
Glib::RefPtr<Gdk::Pixbuf> BatchQueueEntry::savedAsIcon;
|
Glib::RefPtr<Gdk::Pixbuf> BatchQueueEntry::savedAsIcon;
|
||||||
@@ -46,7 +47,7 @@ BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!iconsLoaded) {
|
if (!iconsLoaded) {
|
||||||
savedAsIcon = safe_create_from_file ("gtk-save.png");
|
savedAsIcon = RTImage::createFromFile ("gtk-save.png");
|
||||||
iconsLoaded = true;
|
iconsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,19 +16,21 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include "cropwindow.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "cropwindow.h"
|
|
||||||
#include "options.h"
|
|
||||||
#include "guiutils.h"
|
|
||||||
#include "threadutils.h"
|
|
||||||
#include "../rtengine/mytime.h"
|
#include "../rtengine/mytime.h"
|
||||||
#include "imagearea.h"
|
|
||||||
#include "cursormanager.h"
|
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
#include "../rtengine/rt_math.h"
|
#include "../rtengine/rt_math.h"
|
||||||
#include "../rtengine/dcrop.h"
|
#include "../rtengine/dcrop.h"
|
||||||
|
|
||||||
|
#include "guiutils.h"
|
||||||
|
#include "threadutils.h"
|
||||||
|
#include "rtimage.h"
|
||||||
|
#include "cursormanager.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "imagearea.h"
|
||||||
|
|
||||||
using namespace rtengine;
|
using namespace rtengine;
|
||||||
|
|
||||||
struct ZoomStep {
|
struct ZoomStep {
|
||||||
@@ -84,11 +86,11 @@ CropWindow::CropWindow (ImageArea* parent, rtengine::StagedImageProcessor* ipc_,
|
|||||||
|
|
||||||
titleHeight = ih;
|
titleHeight = ih;
|
||||||
|
|
||||||
bZoomOut = new LWButton (safe_create_from_png ("gtk-zoom-out-small.png"), 0, NULL, LWButton::Left, LWButton::Center, "Zoom Out");
|
bZoomOut = new LWButton (RTImage::createFromPng ("gtk-zoom-out-small.png"), 0, NULL, LWButton::Left, LWButton::Center, "Zoom Out");
|
||||||
bZoomIn = new LWButton (safe_create_from_png ("gtk-zoom-in-small.png"), 1, NULL, LWButton::Left, LWButton::Center, "Zoom In");
|
bZoomIn = new LWButton (RTImage::createFromPng ("gtk-zoom-in-small.png"), 1, NULL, LWButton::Left, LWButton::Center, "Zoom In");
|
||||||
bZoom100 = new LWButton (safe_create_from_png ("gtk-zoom-100-small.png"), 2, NULL, LWButton::Left, LWButton::Center, "Zoom 100/%");
|
bZoom100 = new LWButton (RTImage::createFromPng ("gtk-zoom-100-small.png"), 2, NULL, LWButton::Left, LWButton::Center, "Zoom 100/%");
|
||||||
//bZoomFit = new LWButton (safe_create_from_png ("gtk-zoom-fit.png"), 3, NULL, LWButton::Left, LWButton::Center, "Zoom Fit");
|
//bZoomFit = new LWButton (RTImage::createFromPng ("gtk-zoom-fit.png"), 3, NULL, LWButton::Left, LWButton::Center, "Zoom Fit");
|
||||||
bClose = new LWButton (safe_create_from_png ("gtk-close-small.png"), 4, NULL, LWButton::Right, LWButton::Center, "Close");
|
bClose = new LWButton (RTImage::createFromPng ("gtk-close-small.png"), 4, NULL, LWButton::Right, LWButton::Center, "Close");
|
||||||
|
|
||||||
buttonSet.add (bZoomOut);
|
buttonSet.add (bZoomOut);
|
||||||
buttonSet.add (bZoomIn);
|
buttonSet.add (bZoomIn);
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "cursormanager.h"
|
#include "cursormanager.h"
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
|
|
||||||
CursorManager cursorManager;
|
CursorManager cursorManager;
|
||||||
@@ -41,14 +41,14 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWin)
|
|||||||
cAdd = new Gdk::Cursor (Gdk::PLUS);
|
cAdd = new Gdk::Cursor (Gdk::PLUS);
|
||||||
cWait = new Gdk::Cursor (Gdk::CLOCK);
|
cWait = new Gdk::Cursor (Gdk::CLOCK);
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::Pixbuf> hand = safe_create_from_file("cross.png");
|
Glib::RefPtr<Gdk::Pixbuf> hand = RTImage::createFromFile ("cross.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> close_hand = safe_create_from_file("closedhand.png");
|
Glib::RefPtr<Gdk::Pixbuf> close_hand = RTImage::createFromFile ("closedhand.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> wbpick = safe_create_from_file("gtk-color-picker-small.png");
|
Glib::RefPtr<Gdk::Pixbuf> wbpick = RTImage::createFromFile ("gtk-color-picker-small.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> empty = safe_create_from_file("empty.png");
|
Glib::RefPtr<Gdk::Pixbuf> empty = RTImage::createFromFile ("empty.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> move2D = safe_create_from_file("move-2D.png");
|
Glib::RefPtr<Gdk::Pixbuf> move2D = RTImage::createFromFile ("move-2D.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> move1DH = safe_create_from_file("move-1D-h.png");
|
Glib::RefPtr<Gdk::Pixbuf> move1DH = RTImage::createFromFile ("move-1D-h.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> move1DV = safe_create_from_file("move-1D-v.png");
|
Glib::RefPtr<Gdk::Pixbuf> move1DV = RTImage::createFromFile ("move-1D-v.png");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> moveRotate = safe_create_from_file("move-rotate.png");
|
Glib::RefPtr<Gdk::Pixbuf> moveRotate = RTImage::createFromFile ("move-rotate.png");
|
||||||
|
|
||||||
cHand = hand ? new Gdk::Cursor (cAdd->get_display(), hand, 10, 10) : new Gdk::Cursor (Gdk::HAND2);
|
cHand = hand ? new Gdk::Cursor (cAdd->get_display(), hand, 10, 10) : new Gdk::Cursor (Gdk::HAND2);
|
||||||
cClosedHand = close_hand ? new Gdk::Cursor (cAdd->get_display(), close_hand, 10, 10) : new Gdk::Cursor (Gdk::HAND2);
|
cClosedHand = close_hand ? new Gdk::Cursor (cAdd->get_display(), close_hand, 10, 10) : new Gdk::Cursor (Gdk::HAND2);
|
||||||
|
@@ -72,13 +72,13 @@ DirBrowser::DirBrowser () : dirTreeModel(),
|
|||||||
void DirBrowser::fillDirTree ()
|
void DirBrowser::fillDirTree ()
|
||||||
{
|
{
|
||||||
|
|
||||||
openfolder = safe_create_from_file ("gtk-open.png");
|
openfolder = RTImage::createFromFile ("gtk-open.png");
|
||||||
closedfolder = safe_create_from_file ("folder.png");
|
closedfolder = RTImage::createFromFile ("folder.png");
|
||||||
icdrom = safe_create_from_file ("drive-optical.png");
|
icdrom = RTImage::createFromFile ("drive-optical.png");
|
||||||
ifloppy = safe_create_from_file ("drive-removable-media.png");
|
ifloppy = RTImage::createFromFile ("drive-removable-media.png");
|
||||||
ihdd = safe_create_from_file ("drive-harddisk.png");
|
ihdd = RTImage::createFromFile ("drive-harddisk.png");
|
||||||
iremovable = safe_create_from_file ("media-usb.png");
|
iremovable = RTImage::createFromFile ("media-usb.png");
|
||||||
inetwork = safe_create_from_file ("network.png");
|
inetwork = RTImage::createFromFile ("network.png");
|
||||||
|
|
||||||
//Create the Tree model:
|
//Create the Tree model:
|
||||||
dirTreeModel = Gtk::TreeStore::create(dtColumns);
|
dirTreeModel = Gtk::TreeStore::create(dtColumns);
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "exifpanel.h"
|
#include "exifpanel.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
|
|
||||||
@@ -47,9 +47,9 @@ ExifPanel::ExifPanel () : idata(NULL)
|
|||||||
exifTreeModel = Gtk::TreeStore::create(exifColumns);
|
exifTreeModel = Gtk::TreeStore::create(exifColumns);
|
||||||
exifTree->set_model (exifTreeModel);
|
exifTree->set_model (exifTreeModel);
|
||||||
|
|
||||||
delicon = safe_create_from_file ("gtk-close.png");
|
delicon = RTImage::createFromFile ("gtk-close.png");
|
||||||
keepicon = safe_create_from_file ("gtk-apply.png");
|
keepicon = RTImage::createFromFile ("gtk-apply.png");
|
||||||
editicon = safe_create_from_file ("gtk-add.png");
|
editicon = RTImage::createFromFile ("gtk-add.png");
|
||||||
|
|
||||||
Gtk::TreeView::Column *viewcol = Gtk::manage(new Gtk::TreeView::Column ("Field Name"));
|
Gtk::TreeView::Column *viewcol = Gtk::manage(new Gtk::TreeView::Column ("Field Name"));
|
||||||
Gtk::CellRendererPixbuf* render_pb = Gtk::manage(new Gtk::CellRendererPixbuf ());
|
Gtk::CellRendererPixbuf* render_pb = Gtk::manage(new Gtk::CellRendererPixbuf ());
|
||||||
|
@@ -17,16 +17,17 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "filebrowserentry.h"
|
#include "filebrowserentry.h"
|
||||||
#include "thumbbrowserbase.h"
|
|
||||||
#include "cursormanager.h"
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "threadutils.h"
|
#include "threadutils.h"
|
||||||
#include "../rtengine/safegtk.h"
|
#include "rtimage.h"
|
||||||
|
#include "cursormanager.h"
|
||||||
|
#include "thumbbrowserbase.h"
|
||||||
#include "inspector.h"
|
#include "inspector.h"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#define CROPRESIZEBORDER 4
|
#define CROPRESIZEBORDER 4
|
||||||
|
|
||||||
bool FileBrowserEntry::iconsLoaded(false);
|
bool FileBrowserEntry::iconsLoaded(false);
|
||||||
@@ -51,9 +52,9 @@ FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname)
|
|||||||
scale = 1;
|
scale = 1;
|
||||||
|
|
||||||
if (!iconsLoaded) {
|
if (!iconsLoaded) {
|
||||||
editedIcon = safe_create_from_file ("edited.png");
|
editedIcon = RTImage::createFromFile ("edited.png");
|
||||||
recentlySavedIcon = safe_create_from_file ("recent-save.png");
|
recentlySavedIcon = RTImage::createFromFile ("recent-save.png");
|
||||||
enqueuedIcon = safe_create_from_file ("processing.png");
|
enqueuedIcon = RTImage::createFromFile ("processing.png");
|
||||||
iconsLoaded = true;
|
iconsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,8 +17,9 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "filethumbnailbuttonset.h"
|
#include "filethumbnailbuttonset.h"
|
||||||
|
|
||||||
|
#include "rtimage.h"
|
||||||
#include "multilangmgr.h"
|
#include "multilangmgr.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
|
|
||||||
extern Glib::ustring argv0;
|
extern Glib::ustring argv0;
|
||||||
|
|
||||||
@@ -41,19 +42,19 @@ FileThumbnailButtonSet::FileThumbnailButtonSet (FileBrowserEntry* myEntry)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!iconsLoaded) {
|
if (!iconsLoaded) {
|
||||||
unRankIcon = safe_create_from_png ("ratednotg.png");
|
unRankIcon = RTImage::createFromPng ("ratednotg.png");
|
||||||
rankIcon = safe_create_from_png ("rated.png");
|
rankIcon = RTImage::createFromPng ("rated.png");
|
||||||
gRankIcon = safe_create_from_png ("grayrated.png");
|
gRankIcon = RTImage::createFromPng ("grayrated.png");
|
||||||
trashIcon = safe_create_from_png ("trash-thumbnail.png");
|
trashIcon = RTImage::createFromPng ("trash-thumbnail.png");
|
||||||
unTrashIcon = safe_create_from_png ("undelete-thumbnail.png");
|
unTrashIcon = RTImage::createFromPng ("undelete-thumbnail.png");
|
||||||
processIcon = safe_create_from_png ("processing-thumbnail.png");
|
processIcon = RTImage::createFromPng ("processing-thumbnail.png");
|
||||||
|
|
||||||
colorLabelIcon_0 = safe_create_from_png ("cglabel0.png"); //("nocolorlabel.png");
|
colorLabelIcon_0 = RTImage::createFromPng ("cglabel0.png"); //("nocolorlabel.png");
|
||||||
colorLabelIcon_1 = safe_create_from_png ("clabel1.png");
|
colorLabelIcon_1 = RTImage::createFromPng ("clabel1.png");
|
||||||
colorLabelIcon_2 = safe_create_from_png ("clabel2.png");
|
colorLabelIcon_2 = RTImage::createFromPng ("clabel2.png");
|
||||||
colorLabelIcon_3 = safe_create_from_png ("clabel3.png");
|
colorLabelIcon_3 = RTImage::createFromPng ("clabel3.png");
|
||||||
colorLabelIcon_4 = safe_create_from_png ("clabel4.png");
|
colorLabelIcon_4 = RTImage::createFromPng ("clabel4.png");
|
||||||
colorLabelIcon_5 = safe_create_from_png ("clabel5.png");
|
colorLabelIcon_5 = RTImage::createFromPng ("clabel5.png");
|
||||||
iconsLoaded = true;
|
iconsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
258
rtgui/rtimage.cc
258
rtgui/rtimage.cc
@@ -19,151 +19,179 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
|
|
||||||
extern Glib::ustring argv0;
|
#include "options.h"
|
||||||
extern Options options;
|
|
||||||
|
|
||||||
std::vector<Glib::ustring> imagesPaths;
|
namespace
|
||||||
std::map<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> > pixBufMap; // List of image buffers in order to live update them on theme switch and to avoid a lot of file accesses
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RTImage is a derived class of Gtk::Image, in order to handle theme related iconsets
|
|
||||||
*/
|
|
||||||
RTImage::RTImage(Glib::ustring fileName, Glib::ustring rtlFileName) : Gtk::Image()
|
|
||||||
{
|
{
|
||||||
Glib::ustring mapKey;
|
|
||||||
|
|
||||||
if (rtlFileName.length()) {
|
std::vector<Glib::ustring> imagePaths;
|
||||||
if (get_direction() == Gtk::TEXT_DIR_RTL) {
|
std::map<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf>> pixbufCache;
|
||||||
mapKey = rtlFileName;
|
|
||||||
} else {
|
bool loadIconSet(const Glib::ustring& iconSet)
|
||||||
mapKey = fileName;
|
{
|
||||||
}
|
try {
|
||||||
} else {
|
|
||||||
mapKey = fileName;
|
Glib::KeyFile keyFile;
|
||||||
|
keyFile.load_from_file (iconSet);
|
||||||
|
|
||||||
|
auto iconSetDir = keyFile.get_string ("General", "Iconset");
|
||||||
|
|
||||||
|
if (!iconSetDir.empty ()) {
|
||||||
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "actions"));
|
||||||
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir));
|
||||||
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "devices"));
|
||||||
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "places"));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> >::iterator it;
|
iconSetDir = keyFile.get_string ("General", "FallbackIconset");
|
||||||
it = pixBufMap.find(mapKey);
|
|
||||||
|
|
||||||
if (it != pixBufMap.end()) {
|
if (!iconSetDir.empty ()) {
|
||||||
set(it->second);
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "actions"));
|
||||||
} else {
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir));
|
||||||
Glib::RefPtr<Gdk::Pixbuf> tempPixPuf = Gdk::Pixbuf::create_from_file(findIconAbsolutePath(mapKey));
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "devices"));
|
||||||
pixBufMap.insert(std::pair<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> >(mapKey, tempPixPuf));
|
imagePaths.push_back (Glib::build_filename (argv0, "images", iconSetDir, "places"));
|
||||||
set(tempPixPuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} catch (const Glib::Exception& exception) {
|
||||||
|
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
std::cerr << "Failed to load icon set \"" << iconSet << "\": " << exception.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RTImage::RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName) : Gtk::Image()
|
||||||
|
{
|
||||||
|
Glib::ustring imageName;
|
||||||
|
|
||||||
|
if (!rtlFileName.empty () && get_direction () == Gtk::TEXT_DIR_RTL) {
|
||||||
|
imageName = rtlFileName;
|
||||||
|
} else {
|
||||||
|
imageName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeImage (imageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RTImage::changeImage (const Glib::ustring& imageName)
|
||||||
|
{
|
||||||
|
clear ();
|
||||||
|
|
||||||
|
auto iterator = pixbufCache.find (imageName);
|
||||||
|
|
||||||
|
if (iterator == pixbufCache.end ()) {
|
||||||
|
const auto imagePath = findIconAbsolutePath (imageName);
|
||||||
|
const auto pixbuf = Gdk::Pixbuf::create_from_file (imagePath);
|
||||||
|
|
||||||
|
iterator = pixbufCache.emplace (imageName, pixbuf).first;
|
||||||
|
}
|
||||||
|
|
||||||
|
set(iterator->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTImage::updateImages()
|
void RTImage::updateImages()
|
||||||
{
|
{
|
||||||
std::map<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> >::iterator it;
|
for (auto& entry : pixbufCache) {
|
||||||
|
const auto imagePath = findIconAbsolutePath (entry.first);
|
||||||
for (it = pixBufMap.begin(); it != pixBufMap.end(); ++it) {
|
entry.second = Gdk::Pixbuf::create_from_file (imagePath);
|
||||||
Glib::ustring fullPath = findIconAbsolutePath(it->first);
|
|
||||||
it->second = Gdk::Pixbuf::create_from_file(fullPath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DONE (was TODO: Maybe this could be optimized: in order to avoid looking up for an icon file in the filesystem on each popupmenu selection, maybe we could find a way to copy the image data from another RTImage)
|
Glib::ustring RTImage::findIconAbsolutePath (const Glib::ustring& iconName)
|
||||||
void RTImage::changeImage(Glib::ustring &newImage)
|
|
||||||
{
|
{
|
||||||
clear();
|
try {
|
||||||
std::map<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> >::iterator it;
|
|
||||||
it = pixBufMap.find(newImage);
|
|
||||||
|
|
||||||
if (it != pixBufMap.end()) {
|
for (const auto& imagePath : imagePaths) {
|
||||||
set(it->second);
|
const auto iconPath = Glib::build_filename(imagePath, iconName);
|
||||||
|
|
||||||
|
if (Glib::file_test(iconPath, Glib::FILE_TEST_IS_REGULAR)) {
|
||||||
|
return iconPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(const Glib::Exception&) {}
|
||||||
|
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
std::cerr << "Icon \"" << iconName << "\" could not be found!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Glib::ustring();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RTImage::setPaths (const Options& options)
|
||||||
|
{
|
||||||
|
Glib::ustring iconSet;
|
||||||
|
|
||||||
|
// Either use the system icon set or the one specified in the options.
|
||||||
|
if (options.useSystemTheme) {
|
||||||
|
iconSet = Glib::build_filename (argv0, "themes", "system.iconset");
|
||||||
} else {
|
} else {
|
||||||
Glib::ustring fullPath = findIconAbsolutePath(newImage);
|
iconSet = Glib::build_filename (argv0, "themes", options.theme + ".iconset");
|
||||||
Glib::RefPtr<Gdk::Pixbuf> tempPixPuf = Gdk::Pixbuf::create_from_file(fullPath);
|
|
||||||
pixBufMap.insert(std::pair<Glib::ustring, Glib::RefPtr<Gdk::Pixbuf> >(newImage, tempPixPuf));
|
|
||||||
set(tempPixPuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imagePaths.clear ();
|
||||||
|
|
||||||
|
if (!loadIconSet (iconSet)) {
|
||||||
|
// If the preferred icon set is unavailable, fall back to the default icon set.
|
||||||
|
loadIconSet (Glib::build_filename (argv0, "themes", "Default.iconset"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The images folder is the second fallback solution.
|
||||||
|
imagePaths.push_back (Glib::build_filename(argv0, "images"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring RTImage::findIconAbsolutePath(const Glib::ustring &iconFName)
|
Glib::RefPtr<Gdk::Pixbuf> RTImage::createFromFile (const Glib::ustring& fileName)
|
||||||
{
|
{
|
||||||
Glib::ustring path;
|
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < imagesPaths.size(); i++) {
|
|
||||||
path = Glib::build_filename(imagesPaths[i], iconFName);
|
|
||||||
|
|
||||||
if (safe_file_test(path, Glib::FILE_TEST_EXISTS)) {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\"%s\" not found!\n", iconFName.c_str());
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void RTImage::setPaths(Options &opt)
|
|
||||||
{
|
|
||||||
Glib::ustring configFilename;
|
|
||||||
rtengine::SafeKeyFile keyFile;
|
|
||||||
bool hasKeyFile = true;
|
|
||||||
|
|
||||||
imagesPaths.clear();
|
|
||||||
|
|
||||||
// system theme will use the theme set in system.iconset
|
|
||||||
if (opt.useSystemTheme) {
|
|
||||||
configFilename = Glib::build_filename(argv0, Glib::build_filename("themes", "system.iconset"));
|
|
||||||
}
|
|
||||||
// Gtk theme will use the theme set in it's *.iconset fiel, if it exists
|
|
||||||
else {
|
|
||||||
configFilename = Glib::build_filename(argv0, Glib::build_filename("themes", Glib::ustring::format(opt.theme, ".iconset")));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!safe_file_test(configFilename, Glib::FILE_TEST_EXISTS) || !keyFile.load_from_file (configFilename)) {
|
|
||||||
// ...otherwise fallback to the iconset set in default.iconset
|
|
||||||
configFilename = Glib::build_filename(argv0, Glib::build_filename("themes", "Default.iconset"));
|
|
||||||
|
|
||||||
if (!keyFile.load_from_file (configFilename)) {
|
const auto filePath = findIconAbsolutePath (fileName);
|
||||||
hasKeyFile = false;
|
|
||||||
|
if (!filePath.empty ()) {
|
||||||
|
pixbuf = Gdk::Pixbuf::create_from_file (filePath);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Glib::Error &err) {
|
} catch (const Glib::Exception& exception) {
|
||||||
|
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("RTImage::setPaths / Error code %d while reading values from \"%s\":\n%s\n", err.code(), configFilename.c_str(), err.what().c_str());
|
std::cerr << "Failed to load image \"" << fileName << "\": " << exception.what() << std::endl;
|
||||||
}
|
|
||||||
} catch (...) {
|
|
||||||
if (options.rtSettings.verbose) {
|
|
||||||
printf("RTImage::setPaths / Unknown exception while trying to load \"%s\"!\n", configFilename.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasKeyFile && keyFile.has_group ("General")) {
|
|
||||||
Glib::ustring iSet;
|
|
||||||
|
|
||||||
if (keyFile.has_key ("General", "Iconset")) {
|
|
||||||
iSet = keyFile.get_string ("General", "Iconset");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iSet.length()) {
|
return pixbuf;
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "actions"))));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", iSet)));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "devices"))));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "places"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
iSet.clear();
|
|
||||||
|
|
||||||
if (keyFile.has_key ("General", "FallbackIconset")) {
|
|
||||||
iSet = keyFile.get_string ("General", "FallbackIconset");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (iSet.length()) {
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "actions"))));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", iSet)));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "devices"))));
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, Glib::build_filename("images", Glib::build_filename(iSet, "places"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The images/ folder is the second fallback solution
|
|
||||||
imagesPaths.push_back (Glib::build_filename(argv0, "images"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cairo::RefPtr<Cairo::ImageSurface> RTImage::createFromPng (const Glib::ustring& fileName)
|
||||||
|
{
|
||||||
|
Cairo::RefPtr<Cairo::ImageSurface> surface;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
const auto filePath = findIconAbsolutePath (fileName);
|
||||||
|
|
||||||
|
if (!filePath.empty()) {
|
||||||
|
surface = Cairo::ImageSurface::create_from_png (Glib::locale_from_utf8 (filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (const Glib::Exception& exception) {
|
||||||
|
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
std::cerr << "Failed to load PNG \"" << fileName << "\": " << exception.what() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -19,17 +19,26 @@
|
|||||||
#ifndef _RTIMAGE_
|
#ifndef _RTIMAGE_
|
||||||
#define _RTIMAGE_
|
#define _RTIMAGE_
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm/image.h>
|
||||||
#include "options.h"
|
|
||||||
|
|
||||||
|
class Options;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A derived class of Gtk::Image in order to handle theme-related icon sets.
|
||||||
|
*/
|
||||||
class RTImage : public Gtk::Image
|
class RTImage : public Gtk::Image
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RTImage(Glib::ustring fileName, Glib::ustring rtlFileName = "");
|
RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName = Glib::ustring());
|
||||||
static void setPaths(Options &opt);
|
|
||||||
static void updateImages();
|
void changeImage (const Glib::ustring& imageName);
|
||||||
void changeImage(Glib::ustring &newImage);
|
static void updateImages ();
|
||||||
static Glib::ustring findIconAbsolutePath(const Glib::ustring &iconFName);
|
|
||||||
|
static Glib::ustring findIconAbsolutePath (const Glib::ustring& iconName);
|
||||||
|
static void setPaths (const Options& options);
|
||||||
|
|
||||||
|
static Glib::RefPtr<Gdk::Pixbuf> createFromFile (const Glib::ustring& fileName);
|
||||||
|
static Cairo::RefPtr<Cairo::ImageSurface> createFromPng (const Glib::ustring& fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -17,10 +17,14 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "splash.h"
|
#include "splash.h"
|
||||||
#include "multilangmgr.h"
|
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
|
|
||||||
#include "../rtengine/safegtk.h"
|
#include "../rtengine/safegtk.h"
|
||||||
|
|
||||||
|
#include "multilangmgr.h"
|
||||||
|
#include "rtimage.h"
|
||||||
|
|
||||||
extern Glib::ustring argv0;
|
extern Glib::ustring argv0;
|
||||||
extern Glib::ustring creditsPath;
|
extern Glib::ustring creditsPath;
|
||||||
extern Glib::ustring licensePath;
|
extern Glib::ustring licensePath;
|
||||||
@@ -29,8 +33,7 @@ extern Glib::ustring versionSuffixString;
|
|||||||
|
|
||||||
SplashImage::SplashImage ()
|
SplashImage::SplashImage ()
|
||||||
{
|
{
|
||||||
|
pixbuf = RTImage::createFromFile ("splash.png");
|
||||||
pixbuf = safe_create_from_file ("splash.png");
|
|
||||||
set_size_request (pixbuf->get_width(), pixbuf->get_height());
|
set_size_request (pixbuf->get_width(), pixbuf->get_height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,10 +17,11 @@
|
|||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "whitebalance.h"
|
#include "whitebalance.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "rtimage.h"
|
#include "rtimage.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "../rtengine/safegtk.h"
|
|
||||||
|
|
||||||
#define MINTEMP 1500 //1200
|
#define MINTEMP 1500 //1200
|
||||||
#define MAXTEMP 60000 //12000
|
#define MAXTEMP 60000 //12000
|
||||||
@@ -42,19 +43,19 @@ Glib::RefPtr<Gdk::Pixbuf> WhiteBalance::wbCameraPB, WhiteBalance::wbAutoPB, Whit
|
|||||||
|
|
||||||
void WhiteBalance::init ()
|
void WhiteBalance::init ()
|
||||||
{
|
{
|
||||||
wbPixbufs[WBT_CAMERA] = safe_create_from_file("wb-camera.png");
|
wbPixbufs[WBT_CAMERA] = RTImage::createFromFile ("wb-camera.png");
|
||||||
wbPixbufs[WBT_AUTO] = safe_create_from_file("wb-auto.png");
|
wbPixbufs[WBT_AUTO] = RTImage::createFromFile ("wb-auto.png");
|
||||||
wbPixbufs[WBT_DAYLIGHT] = safe_create_from_file("wb-sun.png");
|
wbPixbufs[WBT_DAYLIGHT] = RTImage::createFromFile ("wb-sun.png");
|
||||||
wbPixbufs[WBT_CLOUDY] = safe_create_from_file("wb-cloudy.png");
|
wbPixbufs[WBT_CLOUDY] = RTImage::createFromFile ("wb-cloudy.png");
|
||||||
wbPixbufs[WBT_SHADE] = safe_create_from_file("wb-shade.png");
|
wbPixbufs[WBT_SHADE] = RTImage::createFromFile ("wb-shade.png");
|
||||||
wbPixbufs[WBT_WATER] = safe_create_from_file("wb-water.png");
|
wbPixbufs[WBT_WATER] = RTImage::createFromFile ("wb-water.png");
|
||||||
// wbPixbufs[WBT_WATER2] = safe_create_from_file("wb-water.png");
|
// wbPixbufs[WBT_WATER2] = RTImage::createFromFile ("wb-water.png");
|
||||||
wbPixbufs[WBT_TUNGSTEN] = safe_create_from_file("wb-tungsten.png");
|
wbPixbufs[WBT_TUNGSTEN] = RTImage::createFromFile ("wb-tungsten.png");
|
||||||
wbPixbufs[WBT_FLUORESCENT] = safe_create_from_file("wb-fluorescent.png");
|
wbPixbufs[WBT_FLUORESCENT] = RTImage::createFromFile ("wb-fluorescent.png");
|
||||||
wbPixbufs[WBT_LAMP] = safe_create_from_file("wb-lamp.png");
|
wbPixbufs[WBT_LAMP] = RTImage::createFromFile ("wb-lamp.png");
|
||||||
wbPixbufs[WBT_FLASH] = safe_create_from_file("wb-flash.png");
|
wbPixbufs[WBT_FLASH] = RTImage::createFromFile ("wb-flash.png");
|
||||||
wbPixbufs[WBT_LED] = safe_create_from_file("wb-led.png");
|
wbPixbufs[WBT_LED] = RTImage::createFromFile ("wb-led.png");
|
||||||
wbPixbufs[WBT_CUSTOM] = safe_create_from_file("wb-custom.png");
|
wbPixbufs[WBT_CUSTOM] = RTImage::createFromFile ("wb-custom.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WhiteBalance::cleanup ()
|
void WhiteBalance::cleanup ()
|
||||||
|
Reference in New Issue
Block a user