From 179fa413b047bede6e32109e2ce82437c5fb8d34 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Mon, 16 Jan 2006 02:36:01 +0000 Subject: moving trunk for module inkscape (bzr r1) --- src/extension/init.cpp | 243 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 src/extension/init.cpp (limited to 'src/extension/init.cpp') diff --git a/src/extension/init.cpp b/src/extension/init.cpp new file mode 100644 index 000000000..c913def61 --- /dev/null +++ b/src/extension/init.cpp @@ -0,0 +1,243 @@ +/* + * This is what gets executed to initialize all of the modules. For + * the internal modules this invovles executing their initialization + * functions, for external ones it involves reading their .spmodule + * files and bringing them into Sodipodi. + * + * Authors: + * Ted Gould + * + * Copyright (C) 2002-2004 Authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#include "path-prefix.h" + + +#include "inkscape.h" +#include + +#include "system.h" +#include "db.h" +#include "internal/svgz.h" +#include "internal/ps.h" +#ifdef WITH_GNOME_PRINT +# include "internal/gnome.h" +#endif +#ifdef WIN32 +# include "internal/win32.h" +#endif +#include "internal/ps-out.h" +#include "internal/pov-out.h" +#include "internal/latex-pstricks-out.h" +#include "internal/latex-pstricks.h" +#include "internal/eps-out.h" +#include "internal/gdkpixbuf-input.h" +#include "internal/bluredge.h" +#include "internal/gimpgrad.h" +#include "internal/grid.h" +#include "prefs-utils.h" +#include "io/sys.h" + +extern gboolean inkscape_app_use_gui( Inkscape::Application const *app ); + +namespace Inkscape { +namespace Extension { + +/** This is the extention that all files are that are pulled from + the extension directory and parsed */ +#define SP_MODULE_EXTENSION "inx" + +static void build_module_from_dir(gchar const *dirname); +static void check_extensions(); + +/** + * \return none + * \brief Examines the given string preference and checks to see + * that at least one of the registered extensions matches + * it. If not, a default is assigned. + * \param pref_path Preference path to load + * \param pref_attr Attribute to load from the preference + * \param pref_default Default string to set + * \param extension_family List of extensions to search + */ +static void +update_pref(gchar const *pref_path, gchar const *pref_attr, + gchar const *pref_default) // , GSList *extension_family) +{ + gchar const *pref = prefs_get_string_attribute(pref_path,pref_attr); + /* + gboolean missing=TRUE; + for (GSList *list = extension_family; list; list = g_slist_next(list)) { + g_assert( list->data ); + + Inkscape::Extension *extension; + extension = reinterpret_cast(list->data); + + if (!strcmp(extension->get_id(),pref)) missing=FALSE; + } + */ + if (!Inkscape::Extension::db.get( pref ) /*missing*/) { + prefs_set_string_attribute(pref_path, pref_attr, pref_default); + } +} + +/** + * Invokes the init routines for internal modules. + * + * This should be a list of all the internal modules that need to initialized. This is just a + * convinent place to put them. Also, this function calls build_module_from_dir to parse the + * Inkscape extensions directory. + */ +void +init() +{ + /* TODO: Change to Internal */ + Internal::Svg::init(); + Internal::Svgz::init(); + Internal::PsOutput::init(); + Internal::EpsOutput::init(); + Internal::PrintPS::init(); +#ifdef WITH_GNOME_PRINT + Internal::PrintGNOME::init(); +#endif +#ifdef WIN32 + Internal::PrintWin32::init(); +#endif + Internal::PovOutput::init(); + Internal::PrintLatex::init(); + Internal::LatexOutput::init(); + + /* Effects */ + Internal::BlurEdge::init(); + Internal::GimpGrad::init(); + Internal::Grid::init(); + + /* Load search path for extensions */ + if (Inkscape::Extension::Extension::search_path.size() == 0) + { + Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions")); + Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR)); + } + + for (unsigned int i=0; ideactivated() && !in_plug->check()) { + in_plug->deactivate(); + (*count)++; + } +} + +static void +check_extensions() +{ + int count = 1; + bool anyfail = false; + // int pass = 0; + + Inkscape::Extension::Extension::error_file_open(); + while (count != 0) { + // printf("Check extensions pass %d\n", pass++); + count = 0; + db.foreach(check_extensions_internal, (gpointer)&count); + if (count != 0) anyfail = true; + } + Inkscape::Extension::Extension::error_file_close(); +} + +} } /* namespace Inkscape::Extension */ + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : -- cgit v1.2.3