diff --git a/src/interface.cpp b/src/interface.cpp
index dd725477c5772aead5d1e7493cc1d956a1b75d35..3ff25c8fbf03ba213148e8124c010a12b268852c 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
// Added for color drag-n-drop
#include "display/sp-canvas.h"
#include "color.h"
-#include "svg/svg.h"
+#include "svg/svg-color.h"
#include "desktop-style.h"
#include "style.h"
PNG_DATA,
JPEG_DATA,
IMAGE_DATA,
+ APP_X_INKY_COLOR,
APP_X_COLOR
} ui_drop_target_info;
{"image/svg", 0, SVG_DATA},
{"image/png", 0, PNG_DATA},
{"image/jpeg", 0, JPEG_DATA},
+ {"application/x-inkscape-color", 0, APP_X_INKY_COLOR},
{"application/x-color", 0, APP_X_COLOR}
};
// checkitem_toggled, checkitem_update, 0);
sp_ui_menu_append_check_item_from_verb(m, view, _("Commands Bar"), _("Show or hide the Commands bar (under the menu)"), "commands",
checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("Tool Controls"), _("Show or hide the Tool Controls panel"), "toppanel",
+ sp_ui_menu_append_check_item_from_verb(m, view, _("Tool Controls Bar"), _("Show or hide the Tool Controls bar"), "toppanel",
checkitem_toggled, checkitem_update, 0);
sp_ui_menu_append_check_item_from_verb(m, view, _("_Toolbox"), _("Show or hide the main toolbox (on the left)"), "toolbox",
checkitem_toggled, checkitem_update, 0);
checkitem_toggled, checkitem_update, Inkscape::Verb::get(SP_VERB_TOGGLE_SCROLLBARS));
sp_ui_menu_append_check_item_from_verb(m, view, _("_Statusbar"), _("Show or hide the statusbar (at the bottom of the window)"), "statusbar",
checkitem_toggled, checkitem_update, 0);
- sp_ui_menu_append_check_item_from_verb(m, view, _("_Panels"), _("Show or hide the panels"), "panels",
+ sp_ui_menu_append_check_item_from_verb(m, view, _("_Palette"), _("Show or hide the color palette"), "panels",
checkitem_toggled, checkitem_update, 0);
}
gpointer user_data)
{
switch (info) {
+ case APP_X_INKY_COLOR:
+ {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ int destX = 0;
+ int destY = 0;
+ gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
+ NR::Point where( sp_canvas_window_to_world( desktop->canvas, NR::Point( destX, destY ) ) );
+
+ SPItem *item = desktop->item_at_point( where, true );
+ if ( item )
+ {
+ if ( data->length >= 8 ) {
+ gchar c[64] = {0};
+ // Careful about endian issues.
+ guint16* dataVals = (guint16*)data->data;
+ sp_svg_write_color( c, 64,
+ SP_RGBA32_U_COMPOSE(
+ 0x0ff & (dataVals[0] >> 8),
+ 0x0ff & (dataVals[1] >> 8),
+ 0x0ff & (dataVals[2] >> 8),
+ 0xff // can't have transparency in the color itself
+ //0x0ff & (data->data[3] >> 8),
+ ));
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property( css, (drag_context->action != GDK_ACTION_MOVE) ? "fill":"stroke", c );
+
+ sp_desktop_apply_css_recursive( item, css, true );
+ item->updateRepr();
+
+ if ( data->length > 14 ) {
+ int flags = dataVals[4];
+
+ // piggie-backed palette entry info
+ int index = dataVals[5];
+ Glib::ustring palName;
+ for ( int i = 0; i < dataVals[6]; i++ ) {
+ palName += (gunichar)dataVals[7+i];
+ }
+
+ // Now hook in a magic tag of some sort.
+ if ( !palName.empty() && (flags & 1) ) {
+ gchar* str = g_strdup_printf("%d|", index);
+ palName.insert( 0, str );
+ g_free(str);
+ str = 0;
+
+ sp_object_setAttribute( SP_OBJECT(item),
+ (drag_context->action != GDK_ACTION_MOVE) ? "inkscape:x-fill-tag":"inkscape:x-stroke-tag",
+ palName.c_str(),
+ false );
+ item->updateRepr();
+ }
+ }
+
+ SPDocument *doc = SP_ACTIVE_DOCUMENT;
+ sp_document_done( doc );
+ }
+ }
+ }
+ break;
+
case APP_X_COLOR:
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
//0x0ff & (data->data[3] >> 8),
));
SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property( css, (true) ? "fill":"stroke", c );
+ sp_repr_css_set_property( css, (drag_context->action != GDK_ACTION_MOVE) ? "fill":"stroke", c );
sp_desktop_apply_css_recursive( item, css, true );
item->updateRepr();