예제 #1
0
void
gv_rotate_tool_set_layer(GvRotateTool *tool, GvShapeLayer *layer)
{
    if (GV_TOOL(tool)->view == NULL)
    {
	g_warning("gv_rotate_tool_set_layer(): inactive tool");
	return;
    }

    if( layer != NULL && gv_data_is_read_only( GV_DATA(layer) ) )
    {
        g_warning( "gv_rotate_tool_set_layer(): layer is read-only" );
        return;
    }

    gv_rotate_tool_terminate( tool );
    tool->shape_id = -1;

    /* Disconnect from the previous layer (for draw) */
    if (tool->layer)
    {
        tool->rrmode = RRMODE_DISPLAY;

        /** TODO: Not sure that we need to unselect ... try to remove later */

	gv_shape_layer_clear_selection(GV_SHAPE_LAYER(tool->layer));
	gtk_signal_disconnect_by_data(GTK_OBJECT(tool->layer), (gpointer)tool);
	gv_view_area_queue_draw(GV_TOOL(tool)->view);
    }
 
    if( layer == NULL )
        tool->layer = NULL;
    else
        tool->layer = GV_SHAPES_LAYER(layer);

    if (layer)
    {
	gv_view_area_set_active_layer(GV_TOOL(tool)->view, GTK_OBJECT(layer));
	
        /* Redraw when the layer draws */
	gtk_signal_connect_object_after(GTK_OBJECT(layer), "draw",
					GTK_SIGNAL_FUNC(gv_rotate_tool_draw),
					GTK_OBJECT(tool));
        /* Recover if layer destroyed */
        gtk_signal_connect(
            GTK_OBJECT(layer), "destroy", 
            GTK_SIGNAL_FUNC(gv_rotate_tool_layer_destroy),
            GTK_OBJECT(tool));
    }
}
예제 #2
0
void
gv_rect_tool_set_layer(GvRectTool *tool, GvShapeLayer *layer)
{
    if (GV_TOOL(tool)->view == NULL)
    {
        g_warning("gv_rect_tool_set_layer(): inactive tool");
        return;
    }

    if( layer != NULL && gv_data_is_read_only( GV_DATA(layer) ) )
    {
        g_warning( "gv_rect_tool_set_layer(): layer is read-only" );
        return;
    }

    /* Disconnect from the previous layer (for draw) */
    if (tool->layer)
    {
        if (tool->drawing)
            tool->drawing = FALSE;

        gv_shape_layer_clear_selection(GV_SHAPE_LAYER(tool->layer));
        g_signal_handlers_disconnect_matched (tool->layer, G_SIGNAL_MATCH_DATA,
                                                0, 0, NULL, NULL, tool);
        gv_view_area_queue_draw(GV_TOOL(tool)->view);
    }

    if( layer == NULL )
        tool->layer = NULL;
    else
        tool->layer = GV_SHAPES_LAYER(layer);

    if (layer)
    {
        gv_view_area_set_active_layer(GV_TOOL(tool)->view, G_OBJECT(layer));

        /* Redraw when the layer draws */
        g_signal_connect_object(layer, "draw",
                                G_CALLBACK(gv_rect_tool_draw),
                                GV_TOOL(tool), G_CONNECT_SWAPPED | G_CONNECT_AFTER);

        /* recover if layer destroyed */
        g_signal_connect_swapped(layer, "teardown",
                                G_CALLBACK(gv_rect_tool_layer_destroy),
                                tool);
    }
}
예제 #3
0
파일: gvpointtool.c 프로젝트: Onjrew/OpenEV
void
gv_point_tool_set_layer(GvPointTool *tool, GvShapeLayer *layer)
{
    if (GV_TOOL(tool)->view == NULL)
    {
	g_warning("gv_point_tool_set_layer(): inactive tool");
	return;
    }

    if( layer != NULL 
        && !GV_IS_POINT_LAYER(layer) && !GV_IS_SHAPES_LAYER(layer) )
    {
        g_warning( "gv_point_tool_set_layer(): not a point capable layer" );
        return;
    }

    if( layer != NULL && gv_data_is_read_only( GV_DATA(layer) ) )
    {
        g_warning( "gv_point_tool_set_layer(): layer is read-only" );
        return;
    }

    /* Disconnect from the previous layer */
    if (tool->layer)
    {
	gv_shape_layer_clear_selection(GV_SHAPE_LAYER(tool->layer));
	gv_view_area_queue_draw(GV_TOOL(tool)->view);
        gtk_signal_disconnect_by_data( GTK_OBJECT(tool->layer), 
                                       GTK_OBJECT(tool) );
    }
    
    tool->layer = layer;

    if (layer)
    {
	gv_view_area_set_active_layer(GV_TOOL(tool)->view, GTK_OBJECT(layer));
        gtk_signal_connect(
            GTK_OBJECT(layer), "destroy", 
            GTK_SIGNAL_FUNC(gv_point_tool_layer_destroy),
            GTK_OBJECT(tool));
    }
}