Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / synfigapp / canvasinterface.cpp
index da1a802..cfc5db6 100644 (file)
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2009 Carlos A. Sosa Navarro
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -52,6 +53,7 @@
 #include "instance.h"
 
 #include "actions/layeradd.h"
+#include "actions/layerremove.h"
 #include "actions/valuedescconvert.h"
 #include "actions/valuenodeadd.h"
 #include "actions/editmodeset.h"
@@ -214,10 +216,12 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas
        layer->set_canvas(canvas);
 
        // Apply some defaults
-       if(layer->set_param("fg",synfigapp::Main::get_foreground_color()))
-               layer->set_param("bg",synfigapp::Main::get_background_color());
+       if(layer->set_param("fg",synfigapp::Main::get_outline_color()))
+               layer->set_param("bg",synfigapp::Main::get_fill_color());
+       else if (name == "outline")
+               layer->set_param("color",synfigapp::Main::get_outline_color());
        else
-               layer->set_param("color",synfigapp::Main::get_foreground_color());
+               layer->set_param("color",synfigapp::Main::get_fill_color());
 
        layer->set_param("width",synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc()));
        layer->set_param("gradient",synfigapp::Main::get_gradient());
@@ -300,7 +304,7 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas
        // Action to move the layer (if necessary)
        if(depth>0)
        {
-               Action::Handle  action(Action::create("layer_move"));
+               Action::Handle  action(Action::create("LayerMove"));
 
                assert(action);
                if(!action)
@@ -463,7 +467,7 @@ CanvasInterface::generate_param_list(const std::list<synfigapp::ValueDesc> &valu
 void
 CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc)
 {
-       Action::Handle  action(Action::create("canvas_rend_desc_set"));
+       Action::Handle  action(Action::create("CanvasRendDescSet"));
 
        assert(action);
        if(!action)
@@ -480,7 +484,7 @@ CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc)
 void
 CanvasInterface::set_name(const synfig::String &x)
 {
-       Action::Handle  action(Action::create("canvas_name_set"));
+       Action::Handle  action(Action::create("CanvasNameSet"));
 
        assert(action);
        if(!action)
@@ -499,7 +503,7 @@ CanvasInterface::set_name(const synfig::String &x)
 void
 CanvasInterface::set_description(const synfig::String &x)
 {
-       Action::Handle  action(Action::create("canvas_description_set"));
+       Action::Handle  action(Action::create("CanvasDescriptionSet"));
 
        assert(action);
        if(!action)
@@ -516,7 +520,7 @@ CanvasInterface::set_description(const synfig::String &x)
 void
 CanvasInterface::set_id(const synfig::String &x)
 {
-       Action::Handle  action(Action::create("canvas_id_set"));
+       Action::Handle  action(Action::create("CanvasIdSet"));
 
        assert(action);
        if(!action)
@@ -576,6 +580,33 @@ CanvasInterface::import(const synfig::String &filename, synfig::String &errors,
        if (ext.size()) ext = ext.substr(1); // skip initial '.'
        std::transform(ext.begin(),ext.end(),ext.begin(),&::tolower);
 
+       if(ext=="svg"){//I don't like it, but worse is nothing
+               Layer::Handle _new_layer(add_layer_to("PasteCanvas",get_canvas()));
+               Layer::Handle _aux_layer(add_layer_to("svg_layer",get_canvas()));
+               if(_aux_layer){
+                       _aux_layer->set_param("filename",ValueBase(filename));
+                       _new_layer->set_param("canvas",ValueBase(_aux_layer->get_param("canvas")));
+                       //remove aux layer
+                       Action::Handle  action(Action::LayerRemove::create());
+                       assert(action);
+                       if(!action)
+                               return 0;
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
+                       action->set_param("layer",_aux_layer);
+                       if(!action->is_ready()){
+                               get_ui_interface()->error(_("Action Not Ready"));
+                               return 0;
+                       }
+                       if(!get_instance()->perform_action(action)){
+                               get_ui_interface()->error(_("Action Failed."));
+                               return 0;
+                       }
+               }
+               signal_layer_new_description()(_new_layer,filename);
+               return true;
+       }
+
        // If this is a SIF file, then we need to do things slightly differently
        if(ext=="sif" || ext=="sifz")try
        {
@@ -688,7 +719,7 @@ CanvasInterface::waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Wayp
 void
 CanvasInterface::waypoint_duplicate(ValueNode::Handle value_node,synfig::Waypoint waypoint)
 {
-       Action::Handle  action(Action::create("waypoint_set_smart"));
+       Action::Handle  action(Action::create("WaypointSetSmart"));
 
        assert(action);
        if(!action)
@@ -717,7 +748,7 @@ CanvasInterface::waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoin
 void
 CanvasInterface::waypoint_remove(ValueNode::Handle value_node,synfig::Waypoint waypoint)
 {
-       Action::Handle  action(Action::create("waypoint_remove"));
+       Action::Handle  action(Action::create("WaypointRemove"));
 
        assert(action);
        if(!action)
@@ -741,7 +772,7 @@ CanvasInterface::auto_export(synfig::ValueNode::Handle /*value_node*/)
        if(value_node->is_exported())
                return;
 
-       Action::Handle  action(Action::create("value_node_add"));
+       Action::Handle  action(Action::create("ValueNodeAdd"));
 
        assert(action);
        if(!action)
@@ -768,7 +799,7 @@ CanvasInterface::auto_export(const ValueDesc& /*value_desc*/)
        if(value_desc.is_exported())
                return;
 
-       Action::Handle  action(Action::create("value_desc_export"));
+       Action::Handle  action(Action::create("ValueDescExport"));
 
        assert(action);
        if(!action)
@@ -815,7 +846,7 @@ CanvasInterface::change_value(synfigapp::ValueDesc value_desc,synfig::ValueBase
        { synfig::warning("Can't get canvas from value desc...?"); }
 #endif
 
-       synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_set"));
+       synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescSet"));
        if(!action)
        {
                return false;