/* * This file is part of RawTherapee. * * Copyright (c) 2004-2010 Gabor Horvath * Copyright (c) 2011 Jean-Christophe FRISCH * * 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 . */ #include "rtimage.h" #include "../rtengine/safegtk.h" #include "../rtengine/safekeyfile.h" extern Glib::ustring argv0; extern Options options; std::vector imagesPaths; std::vector imagesList; // List of images in order to live update them on theme switch /* * 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 path; if (rtlFileName.length()) { const Gtk::TextDirection dir = get_direction(); if (dir == Gtk::TEXT_DIR_RTL) path = findIconAbsolutePath(rtlFileName); else path = findIconAbsolutePath(fileName); } else path = findIconAbsolutePath(fileName); set(path); imagesList.push_back(this); } RTImage::~RTImage() { // Remove the image from the global images list std::vector::iterator i = std::find (imagesList.begin(), imagesList.end(), this); if (i!=imagesList.end()) imagesList.erase(i); } void RTImage::updateImages() { for (unsigned int i=0; iproperty_file(); Glib::ustring fileName = Glib::path_get_basename(oldPath); imagesList[i]->clear(); Glib::ustring fullPath = findIconAbsolutePath(fileName); imagesList[i]->set(fullPath); } } // 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 void RTImage::changeImage(Glib::ustring &newImage) { clear(); Glib::ustring fullPath = findIconAbsolutePath(newImage); set(fullPath); } Glib::ustring RTImage::findIconAbsolutePath(const Glib::ustring &iconFName) { Glib::ustring path; for (unsigned int i=0; i