From e18bc7a8318131440a2941934ad0a78ae3805e2c Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 28 Mar 2025 10:44:28 -0400 Subject: [PATCH] Create a href editor for 1.4.x This doesn't apply to master as it's not broken there. Fixes: https://gitlab.com/inkscape/inkscape/-/issues/5556 --- src/ui/dialog/attrdialog.cpp | 10 ++++++++-- src/ui/dialog/attrdialog.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index e6683f3309..ec5a9f8949 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -92,11 +92,11 @@ constexpr int MAX_POPOVER_HEIGHT = 450; constexpr int MAX_POPOVER_WIDTH = 520; constexpr int TEXT_MARGIN = 3; -std::unique_ptr AttrDialog::init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map) +std::unique_ptr AttrDialog::init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map, bool wrap) { auto edit = Syntax::TextEditView::create(coloring); auto& textview = edit->getTextView(); - textview.set_wrap_mode(Gtk::WrapMode::WRAP_WORD); + textview.set_wrap_mode(wrap ? Gtk::WrapMode::WRAP_CHAR : Gtk::WrapMode::WRAP_WORD); // this actually sets padding rather than margin and extends textview's background color to the sides textview.set_top_margin(TEXT_MARGIN); @@ -144,6 +144,9 @@ AttrDialog::AttrDialog() _text_edit = init_text_view(this, SyntaxMode::PlainText, false); _style_edit = init_text_view(this, SyntaxMode::CssStyle, false); + // Href editing + _href_edit = init_text_view(this, SyntaxMode::PlainText, false, true); + set_size_request(20, 15); // For text and comment nodes: update XML on the fly, as users type @@ -402,6 +405,9 @@ void AttrDialog::startValueEdit(Gtk::CellEditable *cell, const Glib::ustring &pa } else if (attribute == "points") { enable_rouding = true; set_current_textedit(_points_edit.get()); + } else if (attribute == "href" || attribute == "xlink:href") { + set_current_textedit(_href_edit.get()); + edit_in_popup = true; } else { set_current_textedit(_attr_edit.get()); edit_in_popup = false; diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h index 434b5724d6..96ae281a5f 100644 --- a/src/ui/dialog/attrdialog.h +++ b/src/ui/dialog/attrdialog.h @@ -147,6 +147,7 @@ private: std::unique_ptr _css_edit; // in-line CSS style std::unique_ptr _svgd_edit; // SVG path data std::unique_ptr _points_edit; // points in a or + std::unique_ptr _href_edit; // long entries without spaces std::unique_ptr _attr_edit; // all other attributes (plain text) Syntax::TextEditView* _current_text_edit = nullptr; // current text edit for attribute value editing auto_connection _adjust_size; @@ -162,7 +163,7 @@ private: static Glib::ustring round_numbers(const Glib::ustring& text, int precision); Gtk::TextView &_activeTextView() const; void set_current_textedit(Syntax::TextEditView* edit); - static std::unique_ptr init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map); + static std::unique_ptr init_text_view(AttrDialog* owner, Syntax::SyntaxMode coloring, bool map, bool char_wrap = false); }; } // namespace UI::Dialog -- GitLab