all repos — fluxbox @ c613a57c64b43e02fbbfc16a15e7d4604466f1e6

custom fork of the fluxbox windowmanager

resourceValue and findResource
fluxgen fluxgen
commit

c613a57c64b43e02fbbfc16a15e7d4604466f1e6

parent

72df5cf1bc6f5b5c12454daf951bed87c5cc48dc

2 files changed, 24 insertions(+), 8 deletions(-)

jump to
M src/FbTk/Resource.ccsrc/FbTk/Resource.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Resource.cc,v 1.3 2003/12/19 17:08:25 fluxgen Exp $ +// $Id: Resource.cc,v 1.4 2003/12/19 18:25:39 fluxgen Exp $ #include "XrmDatabaseHelper.hh" #include "Resource.hh"

@@ -143,17 +143,31 @@ m_filename = filename;

return true; } -void ResourceManager::setResourceValue(const std::string &resname, const std::string &value) { - // find resource name +Resource_base *ResourceManager::findResource(const std::string &resname) { + // find resource name ResourceList::iterator i = m_resourcelist.begin(); ResourceList::iterator i_end = m_resourcelist.end(); for (; i != i_end; ++i) { if ((*i)->name() == resname || - (*i)->altName() == resname) { - (*i)->setFromString(value.c_str()); - return; - } + (*i)->altName() == resname) + return *i; } + return 0; +} + +string ResourceManager::resourceValue(const std::string &resname) { + Resource_base *res = findResource(resname); + if (res != 0) + return res->getString(); + + return ""; +} + +void ResourceManager::setResourceValue(const std::string &resname, const std::string &value) { + Resource_base *res = findResource(resname); + if (res != 0) + res->setFromString(value.c_str()); + } void ResourceManager::ensureXrmIsInitialize() {
M src/FbTk/Resource.hhsrc/FbTk/Resource.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Resource.hh,v 1.6 2003/12/19 17:08:25 fluxgen Exp $ +// $Id: Resource.hh,v 1.7 2003/12/19 18:25:39 fluxgen Exp $ #ifndef FBTK_RESOURCE_HH #define FBTK_RESOURCE_HH

@@ -97,6 +97,8 @@ void removeResource(Resource<T> &r) {

m_resourcelist.remove(&r); } + Resource_base *findResource(const std::string &resourcename); + std::string resourceValue(const std::string &resourcename); void setResourceValue(const std::string &resourcename, const std::string &value); // this marks the database as "in use" and will avoid reloading