X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftext-context.cpp;h=e969ffbfc74529a5158948c6a3fbf3cf5e452e49;hb=9778e170b43ef3ab1416d84092061ff7d29325e3;hp=1185e08ef6053fcb593f15bf29d0d328bc2a0d31;hpb=4ec52515516e3a6bf2fbc3ed01a7e179bde16d20;p=inkscape.git diff --git a/src/text-context.cpp b/src/text-context.cpp index 1185e08ef..e969ffbfc 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; @@ -297,6 +290,10 @@ sp_text_context_finish(SPEventContext *ec) { SPTextContext *tc = SP_TEXT_CONTEXT(ec); + if (ec->desktop) { + sp_signal_disconnect_by_data(sp_desktop_canvas(ec->desktop), tc); + } + ec->enableGrDrag(false); tc->style_set_connection.disconnect(); @@ -337,10 +334,6 @@ sp_text_context_finish(SPEventContext *ec) gtk_object_destroy(*it); } tc->text_selection_quads.clear(); - - if (ec->desktop) { - sp_signal_disconnect_by_data(sp_desktop_canvas(ec->desktop), tc); - } } @@ -446,11 +439,6 @@ sp_text_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) SP_CTRLRECT(tc->indicator)->setRectangle(sp_item_bbox_desktop(item_ungrouped)); 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); @@ -512,7 +500,7 @@ sp_text_context_setup_text(SPTextContext *tc) text_item->transform = SP_ITEM(ec->desktop->currentRoot())->getRelativeTransform(ec->desktop->currentLayer()); text_item->updateRepr(); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:515"); + _("Create text")); } /** @@ -551,7 +539,7 @@ insert_uni_char(SPTextContext *const tc) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, - /* TODO: annotate */ "text-context.cpp:554"); + _("Insert Unicode character")); } } @@ -586,9 +574,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 +627,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); @@ -715,7 +698,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) 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, - /* TODO: annotate */ "text-context.cpp:718"); + _("Create flowed text")); } else { ec->desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is too small for the current font size. Flowed text not created.")); } @@ -845,20 +828,20 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_text_selection(tc); ec->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No-break space")); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:848"); + _("Insert no-break space")); return TRUE; } 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); @@ -882,7 +865,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); sp_repr_css_attr_unref(css); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:885"); + _("Make bold")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@ -900,7 +883,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); sp_repr_css_attr_unref(css); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:903"); + _("Make italic")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@ -932,7 +915,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:935"); + _("New line")); return TRUE; case GDK_BackSpace: if (tc->text) { // if nascent_object, do nothing, but return TRUE; same for all other delete and move keys @@ -942,7 +925,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:945"); + _("Backspace")); } return TRUE; case GDK_Delete: @@ -954,7 +937,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:957"); + _("Delete")); } return TRUE; case GDK_Left: @@ -969,7 +952,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:left", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:972"); + _("Kern to the left")); } else { cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorLeftWithControl : &Inkscape::Text::Layout::iterator::cursorLeft; @@ -989,7 +972,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:right", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:992"); + _("Kern to the right")); } else { cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorRightWithControl : &Inkscape::Text::Layout::iterator::cursorRight; @@ -1009,7 +992,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:up", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1012"); + _("Kern up")); } else { cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorUpWithControl @@ -1030,7 +1013,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:down", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1033"); + _("Kern down")); } else { cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorDownWithControl @@ -1086,7 +1069,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -90); } sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1089"); + _("Rotate counterclockwise")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@ -1107,7 +1090,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 90); } sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1110"); + _("Rotate clockwise")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); return TRUE; @@ -1124,7 +1107,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -1); sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1127"); + _("Contract line spacing")); } else { if (MOD__SHIFT) @@ -1132,7 +1115,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -1); sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1135"); + _("Contract letter spacing")); } sp_text_context_update_cursor(tc); @@ -1151,7 +1134,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) else sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 1); sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1154"); + _("Expand line spacing")); } else { if (MOD__SHIFT) @@ -1159,7 +1142,7 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event) else sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 1); sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1162"); + _("Expand letter spacing")); } sp_text_context_update_cursor(tc); @@ -1263,7 +1246,7 @@ sp_text_paste_inline(SPEventContext *ec) begin = end + 1; } sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1266"); + _("Paste text")); return true; } @@ -1377,7 +1360,7 @@ sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc) sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css); sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1380"); + _("Set text style")); sp_text_context_update_cursor(tc); sp_text_context_update_text_selection(tc); @@ -1441,6 +1424,10 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) { GdkRectangle im_cursor = { 0, 0, 1, 1 }; + // due to interruptible display, tc may already be destroyed during a display update before + // the cursor update (can't do both atomically, alas) + if (!tc->desktop) return; + if (tc->text) { NR::Point p0, p1; sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1); @@ -1494,6 +1481,10 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) static void sp_text_context_update_text_selection(SPTextContext *tc) { + // due to interruptible display, tc may already be destroyed during a display update before + // the selection update (can't do both atomically, alas) + if (!tc->desktop) return; + for (std::vector::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; it++) { sp_canvas_item_hide(*it); gtk_object_destroy(*it); @@ -1576,7 +1567,7 @@ sptc_commit(GtkIMContext *imc, gchar *string, SPTextContext *tc) sp_text_context_update_text_selection(tc); sp_document_done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, - /* TODO: annotate */ "text-context.cpp:1579"); + _("Type text")); }