26 #include "kdecoration_plugins_p.h"
28 #include <tdeconfig.h>
30 #include <tdelocale.h>
31 #include <klibloader.h>
37 #include "kdecorationfactory.h"
39 KDecorationPlugins::KDecorationPlugins( TDEConfig* cfg )
45 pluginStr(
"twin_undefined " ),
50 KDecorationPlugins::~KDecorationPlugins()
54 assert( fact != NULL );
60 assert( old_fact != NULL );
62 old_library->unload();
66 bool KDecorationPlugins::reset(
unsigned long changed )
68 TQString oldPlugin = pluginStr;
69 config->reparseConfiguration();
71 if(( !loadPlugin(
"" ) && library )
72 || oldPlugin == pluginStr )
74 assert( fact != NULL );
75 ret = fact->reset( changed );
77 return ret || oldPlugin != pluginStr;
80 KDecorationFactory* KDecorationPlugins::factory()
86 KDecoration* KDecorationPlugins::createDecoration( KDecorationBridge* bridge )
89 return fact->createDecoration( bridge );
94 bool KDecorationPlugins::loadPlugin( TQString nameStr )
96 if( nameStr.isEmpty())
98 TDEConfigGroupSaver saver( config,
"Style" );
99 nameStr = config->readEntry(
"PluginLib", defaultPlugin );
102 KLibrary *oldLibrary = library;
103 KDecorationFactory* oldFactory = fact;
105 TQString path = KLibLoader::findLibrary(TQFile::encodeName(nameStr));
110 nameStr = defaultPlugin;
111 path = KLibLoader::findLibrary(TQFile::encodeName(nameStr));
117 error( i18n(
"No window decoration plugin library was found." ));
122 if(pluginStr == nameStr)
126 library = KLibLoader::self()->library(TQFile::encodeName(path));
131 kdDebug() <<
" could not load library, try default plugin again" << endl;
132 nameStr = defaultPlugin;
133 if ( pluginStr == nameStr )
135 path = KLibLoader::findLibrary(TQFile::encodeName(nameStr));
137 library = KLibLoader::self()->library(TQFile::encodeName(path));
142 error( i18n(
"The default decoration plugin is corrupt "
143 "and could not be loaded." ));
148 if( library->hasSymbol(
"create_factory"))
150 void* create_func = library->symbol(
"create_factory");
152 create_ptr = (KDecorationFactory* (*)())create_func;
156 error( i18n(
"The library %1 is not a TWin plugin." ).arg( path ));
161 fact->checkRequirements(
this );
166 TQString catalogue = nameStr;
167 catalogue.replace(
"twin3_",
"twin_" );
168 TDEGlobal::locale()->insertCatalogue( catalogue );
170 TDEGlobal::locale()->insertCatalogue(
"twin_lib" );
172 TDEGlobal::locale()->insertCatalogue(
"twin_clients" );
174 TDEGlobal::locale()->insertCatalogue(
"twin_art_clients" );
176 old_library = oldLibrary;
177 old_fact = oldFactory;
182 void KDecorationPlugins::destroyPreviousPlugin()
189 old_library->unload();
194 void KDecorationPlugins::error(
const TQString& )
This is the base class for a decoration object.