Example #1
0
synfigapp::Main::Main(const synfig::String &basepath, synfig::ProgressCallback *cb):
    synfig::Main(basepath,cb),
    ref_count_(synfigapp_ref_count_)
{
    if(ref_count_.count())
        return;

    synfigapp_ref_count_.reset();
    ref_count_=synfigapp_ref_count_;

    // Add initialization after this point

#ifdef ENABLE_NLS
    String locale_dir;
    locale_dir = etl::dirname(basepath)+ETL_DIRECTORY_SEPARATOR+"share"+ETL_DIRECTORY_SEPARATOR+"locale";
#ifdef WIN32
    locale_dir = Glib::locale_from_utf8(locale_dir);
#endif

    bindtextdomain(GETTEXT_PACKAGE, locale_dir.c_str() );
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
#endif

    action_main=new synfigapp::Action::Main();

    settings_.construct();

    signal_outline_color_changed_.construct();
    signal_fill_color_changed_.construct();
    signal_gradient_changed_.construct();
    //signal_opacity_changed_.construct();
    //signal_blend_method_changed_.construct();
    signal_interpolation_changed_.construct();

    set_outline_color(Color::black());
    set_fill_color(Color::white());
    set_gradient_default_colors();
    set_bline_width(Distance(1,Distance::SYSTEM_POINTS));
    //set_opacity(1.0);
    //set_blend_method(Color::BLEND_BY_LAYER);
}
Example #2
0
synfig::Main::Main(const synfig::String& basepath,ProgressCallback *cb):
	ref_count_(synfig_ref_count_)
{
	if(ref_count_.count())
		return;

	synfig_ref_count_.reset();
	ref_count_=synfig_ref_count_;

	// Add initialization after this point

#ifdef ENABLE_NLS
	String locale_dir;
	locale_dir = etl::dirname(basepath)+ETL_DIRECTORY_SEPARATOR+"share"+ETL_DIRECTORY_SEPARATOR+"locale";
#ifdef WIN32
	locale_dir = Glib::locale_from_utf8(locale_dir);
#endif

	bindtextdomain("synfig", locale_dir.c_str() );
	bind_textdomain_codeset("synfig", "UTF-8");
#endif

	String prefix=etl::dirname(basepath);

	unsigned int i;
#ifdef _DEBUG
#ifndef __APPLE__
	std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
#endif
#endif

#if defined(HAVE_SIGNAL_H) && defined(SIGPIPE)
	signal(SIGPIPE, broken_pipe_signal);
#endif

	//_config_search_path=new vector"string.h"();

	// Init the subsystems
	if(cb)cb->amount_complete(0, 100);

	if(cb)cb->task(_("Starting Subsystem \"Sound\""));
	if(!SoundProcessor::subsys_init())
		throw std::runtime_error(_("Unable to initialize subsystem \"Sound\""));

	if(cb)cb->task(_("Starting Subsystem \"Types\""));
	if(!Type::subsys_init())
		throw std::runtime_error(_("Unable to initialize subsystem \"Types\""));

	if(cb)cb->task(_("Starting Subsystem \"Modules\""));
	if(!Module::subsys_init(prefix))
	{
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"Modules\""));
	}

	if(cb)cb->task(_("Starting Subsystem \"Layers\""));
	if(!Layer::subsys_init())
	{
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"Layers\""));
	}

	if(cb)cb->task(_("Starting Subsystem \"Targets\""));
	if(!Target::subsys_init())
	{
		Layer::subsys_stop();
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"Targets\""));
	}

	if(cb)cb->task(_("Starting Subsystem \"Importers\""));
	if(!Importer::subsys_init())
	{
		Target::subsys_stop();
		Layer::subsys_stop();
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"Importers\""));
	}

	if(cb)cb->task(_("Starting Subsystem \"Cairo Importers\""));
	if(!CairoImporter::subsys_init())
	{
		Importer::subsys_stop();
		Target::subsys_stop();
		Layer::subsys_stop();
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"Cairo Importers\""));
	}

	if(cb)cb->task(_("Starting Subsystem \"ValueNodes\""));
	if(!ValueNode::subsys_init())
	{
		CairoImporter::subsys_stop();
		Importer::subsys_stop();
		Target::subsys_stop();
		Layer::subsys_stop();
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(_("Unable to initialize subsystem \"ValueNodes\""));
	}

	// Load up the list importer
	Importer::book()[String("lst")]=Importer::BookEntry(ListImporter::create, ListImporter::supports_file_system_wrapper__);
	CairoImporter::book()[String("lst")]=CairoImporter::BookEntry(CairoListImporter::create, CairoListImporter::supports_file_system_wrapper__);

	// Load up the modules
	std::list<String> modules_to_load;
	std::vector<String> locations;

	if(getenv("SYNFIG_MODULE_LIST"))
		locations.push_back(getenv("SYNFIG_MODULE_LIST"));
	else
	{
		locations.push_back("./"MODULE_LIST_FILENAME);
		if(getenv("HOME"))
			locations.push_back(strprintf("%s/.synfig/%s", getenv("HOME"), MODULE_LIST_FILENAME));
	#ifdef SYSCONFDIR
		locations.push_back(SYSCONFDIR"/"MODULE_LIST_FILENAME);
	#endif
		locations.push_back(prefix+ETL_DIRECTORY_SEPARATOR+"etc"+ETL_DIRECTORY_SEPARATOR+MODULE_LIST_FILENAME);
		locations.push_back("/usr/local/etc/"MODULE_LIST_FILENAME);
	#ifdef __APPLE__
		locations.push_back("/Library/Frameworks/synfig.framework/Resources/"MODULE_LIST_FILENAME);
		locations.push_back("/Library/Synfig/"MODULE_LIST_FILENAME);
		if(getenv("HOME"))
			locations.push_back(strprintf("%s/Library/Synfig/%s", getenv("HOME"), MODULE_LIST_FILENAME));
	#endif
	#ifdef WIN32
		locations.push_back("C:\\Program Files\\Synfig\\etc\\"MODULE_LIST_FILENAME);
	#endif
	}

	for(i=0;i<locations.size();i++)
		if(retrieve_modules_to_load(locations[i],modules_to_load))
		{
			synfig::info(_("Loading modules from %s"), locations[i].c_str());
			if(cb)cb->task(strprintf(_("Loading modules from %s"),locations[i].c_str()));
			break;
		}

	if (i == locations.size())
	{
		Importer::subsys_stop();
		CairoImporter::subsys_stop();
		Target::subsys_stop();
		Layer::subsys_stop();
		Module::subsys_stop();
		Type::subsys_stop();
		throw std::runtime_error(strprintf(_("Unable to open module list file '%s'"), MODULE_LIST_FILENAME));
	}

	std::list<String>::iterator iter;

	Module::register_default_modules(cb);

	for(i=0,iter=modules_to_load.begin();iter!=modules_to_load.end();++iter,i++)
	{
		Module::Register(*iter,cb);
		if(cb)cb->amount_complete((i+1)*100,modules_to_load.size()*100);
	}

	if(cb)cb->amount_complete(100, 100);
	if(cb)cb->task(_("DONE"));
}