From fd703018ee505f643f866aa4e0cc3f1bebf7aa7d Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Mon, 1 Mar 2010 22:10:16 -0800 Subject: Cleanup on id access. (bzr r9127) --- src/interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interface.cpp') diff --git a/src/interface.cpp b/src/interface.cpp index b29b91d18..9c1870019 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1098,7 +1098,7 @@ sp_ui_context_menu(Inkscape::UI::View::View *view, SPItem *item) if ( group && group != dt->currentLayer() ) { /* TRANSLATORS: #%s is the id of the group e.g. , not a number. */ - gchar *label=g_strdup_printf(_("Enter group #%s"), SP_OBJECT_ID(group)); + gchar *label=g_strdup_printf(_("Enter group #%s"), group->getId()); GtkWidget *w = gtk_menu_item_new_with_label(label); g_free(label); g_object_set_data(G_OBJECT(w), "group", group); @@ -1316,7 +1316,7 @@ sp_ui_drag_data_received(GtkWidget *widget, const GSList *gradients = sp_document_get_resource_list(doc, "gradient"); for (const GSList *item = gradients; item; item = item->next) { SPGradient* grad = SP_GRADIENT(item->data); - if ( color.descr == grad->id ) { + if ( color.descr == grad->getId() ) { if ( grad->has_stops ) { matches = grad; break; @@ -1325,7 +1325,7 @@ sp_ui_drag_data_received(GtkWidget *widget, } if (matches) { colorspec = "url(#"; - colorspec += matches->id; + colorspec += matches->getId(); colorspec += ")"; } else { gchar* tmp = g_strdup_printf("#%02x%02x%02x", r, g, b); -- cgit v1.2.3 From 6d833eac6f8775095c3c0a0979a6dcab1e4f5c3c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 5 Mar 2010 00:34:30 +0100 Subject: Improve behavior when pasting, DnDing and importing bitmap images (bzr r9143) --- src/interface.cpp | 62 +++++++++++++++++++------------------------------------ 1 file changed, 21 insertions(+), 41 deletions(-) (limited to 'src/interface.cpp') diff --git a/src/interface.cpp b/src/interface.cpp index 9c1870019..cb021db18 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -23,7 +23,9 @@ #include #include "inkscape-private.h" +#include "extension/db.h" #include "extension/effect.h" +#include "extension/input.h" #include "widgets/icon.h" #include "preferences.h" #include "path-prefix.h" @@ -1454,48 +1456,26 @@ sp_ui_drag_data_received(GtkWidget *widget, case PNG_DATA: case JPEG_DATA: case IMAGE_DATA: { - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); - Inkscape::XML::Node *newImage = xml_doc->createElement("svg:image"); - gchar *atom_name = gdk_atom_name(data->type); - - // this formula taken from Glib docs - guint needed_size = data->length * 4 / 3 + data->length * 4 / (3 * 72) + 7; - needed_size += 5 + 8 + strlen(atom_name); // 5 bytes for data:, 8 for ;base64, - - gchar *buffer = (gchar *) g_malloc(needed_size), *buf_work = buffer; - buf_work += g_sprintf(buffer, "data:%s;base64,", atom_name); - - gint state = 0, save = 0; - g_base64_encode_step(data->data, data->length, TRUE, buf_work, &state, &save); - g_base64_encode_close(TRUE, buf_work, &state, &save); - - newImage->setAttribute("xlink:href", buffer); - g_free(buffer); - - GError *error = NULL; - GdkPixbufLoader *loader = gdk_pixbuf_loader_new_with_mime_type( gdk_atom_name(data->type), &error ); - if ( loader ) { - error = NULL; - if ( gdk_pixbuf_loader_write( loader, data->data, data->length, &error) ) { - GdkPixbuf *pbuf = gdk_pixbuf_loader_get_pixbuf(loader); - if ( pbuf ) { - char tmp[1024]; - int width = gdk_pixbuf_get_width(pbuf); - int height = gdk_pixbuf_get_height(pbuf); - snprintf( tmp, sizeof(tmp), "%d", width ); - newImage->setAttribute("width", tmp); - - snprintf( tmp, sizeof(tmp), "%d", height ); - newImage->setAttribute("height", tmp); - } - } - } - g_free(atom_name); + const char *mime = (info == JPEG_DATA ? "image/jpeg" : "image/png"); - // Add it to the current layer - desktop->currentLayer()->appendChildRepr(newImage); - - Inkscape::GC::release(newImage); + Inkscape::Extension::DB::InputList o; + Inkscape::Extension::db.get_input_list(o); + Inkscape::Extension::DB::InputList::const_iterator i = o.begin(); + while (i != o.end() && strcmp( (*i)->get_mimetype(), mime ) != 0) { + ++i; + } + Inkscape::Extension::Extension *ext = *i; + bool save = ext->get_param_bool("link"); + ext->set_param_bool("link", false); + ext->set_gui(false); + + gchar *filename = g_build_filename( g_get_tmp_dir(), "inkscape-dnd-import", NULL ); + g_file_set_contents(filename, reinterpret_cast(data->data), data->length, NULL); + file_import(doc, filename, ext); + g_free(filename); + + ext->set_param_bool("link", save); + ext->set_gui(true); sp_document_done( doc , SP_VERB_NONE, _("Drop bitmap image")); break; -- cgit v1.2.3 From fae67e1661842bd514929aa41ce21528ae56c571 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 17 Mar 2010 18:21:55 -0700 Subject: Changed the embed/link dialog to use radio buttons instead of a checkbox to make the link/embed effect clearer. (bzr r9202) --- src/interface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interface.cpp') diff --git a/src/interface.cpp b/src/interface.cpp index cb021db18..1a6da5635 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1465,8 +1465,8 @@ sp_ui_drag_data_received(GtkWidget *widget, ++i; } Inkscape::Extension::Extension *ext = *i; - bool save = ext->get_param_bool("link"); - ext->set_param_bool("link", false); + bool save = (strcmp(ext->get_param_optiongroup("link"), "embed") == 0); + ext->set_param_optiongroup("link", "embed"); ext->set_gui(false); gchar *filename = g_build_filename( g_get_tmp_dir(), "inkscape-dnd-import", NULL ); @@ -1474,7 +1474,7 @@ sp_ui_drag_data_received(GtkWidget *widget, file_import(doc, filename, ext); g_free(filename); - ext->set_param_bool("link", save); + ext->set_param_optiongroup("link", save ? "embed" : "link"); ext->set_gui(true); sp_document_done( doc , SP_VERB_NONE, _("Drop bitmap image")); -- cgit v1.2.3