Initial attempt at i18n support using gettext
[synfig.git] / synfig-studio / trunk / src / gtkmm / state_draw.cpp
index 844b198..457cd5b 100644 (file)
@@ -62,6 +62,8 @@
 #include <gtkmm/scale.h>
 #include <sigc++/connection.h>
 
+#include "general.h"
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -521,10 +523,7 @@ StateDraw_Context::refresh_tool_options()
        )->signal_clicked().connect(
                sigc::mem_fun(
                        *this,
-                       &StateDraw_Context::fill_last_stroke
-               )
-       );
-
+                       &StateDraw_Context::fill_last_stroke));
 }
 
 Smach::event_result
@@ -589,7 +588,8 @@ StateDraw_Context::event_mouse_down_handler(const Smach::event& x)
                }
 
        case BUTTON_RIGHT: // Intercept the right-button click to short-circuit the pop-up menu
-               return Smach::RESULT_ACCEPT;
+               if (!getenv("SYNFIG_ENABLE_POPUP_MENU_IN_ALL_TOOLS"))
+                       return Smach::RESULT_ACCEPT;
 
        default:
                return Smach::RESULT_OK;
@@ -1001,8 +1001,11 @@ StateDraw_Context::new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline
                }
        }
 
-       // Create the layer
+       last_stroke=value_node;
+       last_stroke_id=get_id();
+
        {
+               // Create the layer(s)
                Layer::Handle layer;
                Canvas::Handle canvas(get_canvas_view()->get_canvas());
                int depth(0);
@@ -1015,6 +1018,12 @@ StateDraw_Context::new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline
                        canvas=layer->get_canvas();
                }
 
+               // fill_last_stroke() will take care of clearing the selection if we're calling it
+               if(get_outline_flag() && get_region_flag())
+                       fill_last_stroke();
+               else
+                       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+
                //int number(synfig::UniqueID().get_uid());
 
                synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
@@ -1068,12 +1077,6 @@ StateDraw_Context::new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline
                //refresh_ducks();
        }
 
-       last_stroke=value_node;
-       last_stroke_id=get_id();
-
-       if(get_outline_flag() && get_region_flag())
-               fill_last_stroke();
-
        increment_id();
        return Smach::RESULT_ACCEPT;
 }
@@ -1944,7 +1947,18 @@ StateDraw_Context::fill_last_stroke()
 
        synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
 
-       layer=get_canvas_interface()->add_layer("region");
+       Canvas::Handle canvas(get_canvas_view()->get_canvas());
+       int depth(0);
+
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       layer=get_canvas_interface()->add_layer_to("region", canvas, depth);
        assert(layer);
        layer->set_param("color",synfigapp::Main::get_background_color());
        layer->set_description(last_stroke_id + _(" Region"));