X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fmodule.cpp;h=5d6400399013eb9a425524b73d508e540804fcfe;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=f893b74e963041eae2c9ce48877918be4685ce39;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/module.cpp b/synfig-core/trunk/src/synfig/module.cpp index f893b74..5d64003 100644 --- a/synfig-core/trunk/src/synfig/module.cpp +++ b/synfig-core/trunk/src/synfig/module.cpp @@ -1,27 +1,28 @@ -/* === S I N F G =========================================================== */ -/*! \file module.cpp +/* === S Y N F I G ========================================================= */ +/*! \file synfig/module.cpp ** \brief writeme ** -** $Id: module.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package 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 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package 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. ** \endlegal */ /* ========================================================================= */ /* === H E A D E R S ======================================================= */ -#define SINFG_NO_ANGLE +#define SYNFIG_NO_ANGLE #ifdef USING_PCH # include "pch.h" @@ -32,8 +33,12 @@ #include "module.h" #include "general.h" -#include #include + +#ifndef USE_CF_BUNDLES +#include +#endif + #endif /* === M A C R O S ========================================================= */ @@ -42,19 +47,20 @@ using namespace std; using namespace etl; -using namespace sinfg; +using namespace synfig; -Module::Book *sinfg::Module::book_; +Module::Book *synfig::Module::book_; /* === P R O C E D U R E S ================================================= */ bool Module::subsys_init(const String &prefix) { - #ifndef SINFG_LTDL_NO_STATIC +#ifndef USE_CF_BUNDLES + #ifndef SYNFIG_LTDL_NO_STATIC //LTDL_SET_PRELOADED_SYMBOLS(); #endif - + if(lt_dlinit()) { error(_("Errors on lt_dlinit()")); @@ -63,17 +69,18 @@ Module::subsys_init(const String &prefix) } lt_dladdsearchdir("."); - lt_dladdsearchdir("~/.sinfg/modules"); - lt_dladdsearchdir((prefix+"/lib/sinfg/modules").c_str()); + if(getenv("HOME")) + lt_dladdsearchdir(strprintf("%s/.synfig/modules", getenv("HOME")).c_str()); + lt_dladdsearchdir((prefix+"/lib/synfig/modules").c_str()); #ifdef LIBDIR - lt_dladdsearchdir(LIBDIR"/sinfg/modules"); + lt_dladdsearchdir(LIBDIR"/synfig/modules"); #endif #ifdef __APPLE__ - lt_dladdsearchdir("/Library/Frameworks/sinfg.framework/Resources/modules"); + lt_dladdsearchdir("/Library/Frameworks/synfig.framework/Resources/modules"); #endif - lt_dladdsearchdir("/usr/local/lib/sinfg/modules"); + lt_dladdsearchdir("/usr/local/lib/synfig/modules"); lt_dladdsearchdir("."); - +#endif book_=new Book; return true; } @@ -82,15 +89,22 @@ bool Module::subsys_stop() { delete book_; - + +#ifndef USE_CF_BUNDLES lt_dlexit(); +#endif return true; } -bool -register_default_modules() +void +Module::register_default_modules(ProgressCallback *callback) { - return true; + #define REGISTER_MODULE(module) if (!Register(module, callback)) \ + throw std::runtime_error(strprintf(_("Unable to load module '%s'"), module)) + REGISTER_MODULE("lyr_freetype"); + REGISTER_MODULE("mod_geometry"); + REGISTER_MODULE("mod_gradient"); + REGISTER_MODULE("mod_particle"); } Module::Book& @@ -100,29 +114,30 @@ Module::book() } void -sinfg::Module::Register(Module::Handle mod) +synfig::Module::Register(Module::Handle mod) { book()[mod->Name()]=mod; } bool -sinfg::Module::Register(const String &module_name, ProgressCallback *callback) +synfig::Module::Register(const String &module_name, ProgressCallback *callback) { +#ifndef USE_CF_BUNDLES lt_dlhandle module; if(callback)callback->task(strprintf(_("Attempting to register \"%s\""),module_name.c_str())); module=lt_dlopenext((string("lib")+module_name).c_str()); if(!module)module=lt_dlopenext(module_name.c_str()); - + if(!module) { - if(callback)callback->error(strprintf(_("Unable to find module \"%s\" (%s)"),module_name.c_str(),lt_dlerror())); + if(callback)callback->warning(strprintf(_("Unable to find module \"%s\" (%s)"),module_name.c_str(),lt_dlerror())); return false; } if(callback)callback->task(strprintf(_("Found module \"%s\""),module_name.c_str())); - + Module::constructor_type constructor=NULL; Handle mod; @@ -147,7 +162,7 @@ sinfg::Module::Register(const String &module_name, ProgressCallback *callback) // if(callback)callback->task(string("looking for -> lib")+module_name+"_LTX_new_instance()"); constructor=(Module::constructor_type )lt_dlsym(module,(string("_")+module_name+"_LTX_new_instance").c_str()); } - + if(constructor) { // if(callback)callback->task(strprintf("Executing callback for \"%s\"",module_name.c_str())); @@ -173,6 +188,7 @@ sinfg::Module::Register(const String &module_name, ProgressCallback *callback) } if(callback)callback->task(strprintf(_("Success for \"%s\""),module_name.c_str())); - - return false; + +#endif + return true; }