X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftext-context.cpp;h=670a863acb01f6b10cfcb6ad710bf399b20655d9;hb=b93042846520d88136cc3f211ec0a4adc60780cf;hp=ba1960dd745218b79178109a31b14a8bbea45d27;hpb=524f20aac208f833c2e674a044d0f4cd273880e4;p=inkscape.git diff --git a/src/text-context.cpp b/src/text-context.cpp index ba1960dd7..670a863ac 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -39,9 +39,7 @@ #include "message-stack.h" #include "message-context.h" #include "pixmaps/cursor-text.xpm" -#include "pixmaps/cursor-text.pixbuf" #include "pixmaps/cursor-text-insert.xpm" -#include "pixmaps/cursor-text-insert.pixbuf" #include #include "object-edit.h" #include "xml/repr.h" @@ -125,11 +123,6 @@ sp_text_context_init(SPTextContext *tc) SPEventContext *event_context = SP_EVENT_CONTEXT(tc); event_context->cursor_shape = cursor_text_xpm; - event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline( - -1, - cursor_text_pixbuf, - FALSE, - NULL); event_context->hot_x = 7; event_context->hot_y = 7; @@ -443,14 +436,12 @@ sp_text_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) item_ungrouped = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE); if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) { sp_canvas_item_show(tc->indicator); - SP_CTRLRECT(tc->indicator)->setRectangle(sp_item_bbox_desktop(item_ungrouped)); + NR::Maybe ibbox = sp_item_bbox_desktop(item_ungrouped); + if (ibbox) { + SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox); + } ec->cursor_shape = cursor_text_insert_xpm; - ec->cursor_pixbuf = gdk_pixbuf_new_from_inline( - -1, - cursor_text_insert_pixbuf, - FALSE, - NULL); ec->hot_x = 7; ec->hot_y = 10; sp_event_context_update_cursor(ec); @@ -485,7 +476,8 @@ sp_text_context_setup_text(SPTextContext *tc) SPEventContext *ec = SP_EVENT_CONTEXT(tc); /* Create */ - Inkscape::XML::Node *rtext = sp_repr_new("svg:text"); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DESKTOP(ec)->doc()); + Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text"); rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create /* Set style */ @@ -495,13 +487,13 @@ sp_text_context_setup_text(SPTextContext *tc) sp_repr_set_svg_double(rtext, "y", tc->pdoc[NR::Y]); /* Create */ - Inkscape::XML::Node *rtspan = sp_repr_new("svg:tspan"); + Inkscape::XML::Node *rtspan = xml_doc->createElement("svg:tspan"); rtspan->setAttribute("sodipodi:role", "line"); // otherwise, why bother creating the tspan? rtext->addChild(rtspan, NULL); Inkscape::GC::release(rtspan); /* Create TEXT */ - Inkscape::XML::Node *rstring = sp_repr_new_text(""); + Inkscape::XML::Node *rstring = xml_doc->createTextNode(""); rtspan->addChild(rstring, NULL); Inkscape::GC::release(rstring); SPItem *text_item = SP_ITEM(ec->desktop->currentLayer()->appendChildRepr(rtext)); @@ -586,9 +578,9 @@ show_curr_uni_char(SPTextContext *const tc) } } tc->defaultMessageContext()->setF(Inkscape::NORMAL_MESSAGE, - _("Unicode: %s: %s"), tc->uni, utf8); + _("Unicode (Enter to finish): %s: %s"), tc->uni, utf8); } else { - tc->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Unicode: ")); + tc->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Unicode (Enter to finish): ")); } } @@ -639,11 +631,6 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) tc->over_text = 0; // update cursor and statusbar: we are not over a text object now ec->cursor_shape = cursor_text_xpm; - ec->cursor_pixbuf = gdk_pixbuf_new_from_inline( - -1, - cursor_text_pixbuf, - FALSE, - NULL); ec->hot_x = 7; ec->hot_y = 7; sp_event_context_update_cursor(ec); @@ -712,6 +699,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) if (fabs(p1[NR::Y] - tc->p0[NR::Y]) > cursor_height) { // otherwise even one line won't fit; most probably a slip of hand (even if bigger than tolerance) SPItem *ft = create_flowtext_with_internal_frame (desktop, tc->p0, p1); + /* Set style */ + sp_desktop_apply_style_tool(SP_EVENT_CONTEXT_DESKTOP(ec), SP_OBJECT_REPR(ft), "tools.text", true); sp_desktop_selection(desktop)->set(ft); ec->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created.")); sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, @@ -851,14 +840,14 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) break; case GDK_U: case GDK_u: - if (MOD__CTRL_ONLY) { + if (MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT)) { if (tc->unimode) { tc->unimode = false; ec->defaultMessageContext()->clear(); } else { tc->unimode = true; tc->unipos = 0; - ec->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Unicode: ")); + ec->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Unicode (Enter to finish): ")); } if (tc->imc) { gtk_im_context_reset(tc->imc); @@ -1474,7 +1463,10 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) SPItem *frame = SP_FLOWTEXT(tc->text)->get_frame (NULL); // first frame only if (frame) { sp_canvas_item_show(tc->frame); - SP_CTRLRECT(tc->frame)->setRectangle(sp_item_bbox_desktop(frame)); + NR::Maybe frame_bbox = sp_item_bbox_desktop(frame); + if (frame_bbox) { + SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox); + } } SP_EVENT_CONTEXT(tc)->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Type flowed text; Enter to start new paragraph.")); } else { @@ -1553,6 +1545,8 @@ sp_text_context_forget_text(SPTextContext *tc) // the XML editor if ( text_repr && sp_repr_parent(text_repr) ) { sp_repr_unparent(text_repr); + sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, + _("Remove empty text")); } } }