From: cilix42 Date: Wed, 30 Jul 2008 10:56:10 +0000 (+0000) Subject: Make text widget for TextParams work and re-enable it X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4ea30e1bba14987abced98e7bf194b69153e9e21;p=inkscape.git Make text widget for TextParams work and re-enable it --- diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 4b36edf78..bf11192dd 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -28,6 +28,7 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, const Glib::ustring default_value ) : Parameter(label, tip, key, wr, effect), + value(default_value), defvalue(default_value) { canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(inkscape_active_desktop()), Geom::Point(0,0), ""); @@ -69,32 +70,27 @@ TextParam::param_readSVGValue(const gchar * strvalue) gchar * TextParam::param_getSVGValue() const { - return (gchar *) defvalue.c_str(); + return (gchar *) value.c_str(); } Gtk::Widget * TextParam::param_newWidget(Gtk::Tooltips * /*tooltips*/) { - /** Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); - rsu->setText(""); + rsu->setText(value.c_str()); rsu->setProgrammatically = false; rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); return dynamic_cast (rsu); - **/ - - // widget is disabled until it works correctly - return NULL; } void TextParam::param_setValue(const Glib::ustring newvalue) { - defvalue = newvalue; + value = newvalue; sp_canvastext_set_text (canvas_text, newvalue.c_str()); } diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 432ceeed1..ee47f028f 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -51,6 +51,7 @@ private: double anchor_x; double anchor_y; + Glib::ustring value; Glib::ustring defvalue; SPCanvasText *canvas_text; diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index b91e5d998..2cc6e3c62 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -273,6 +273,8 @@ RegisteredText::on_activate() write_to_xml(os.str().c_str()); set_sensitive(true); + setText(os.str().c_str()); + _wr->setUpdating (false); } diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp index 974e85054..3284af54a 100644 --- a/src/ui/widget/text.cpp +++ b/src/ui/widget/text.cpp @@ -39,7 +39,6 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip, : Labelled(label, tooltip, new Gtk::Entry(), suffix, icon, mnemonic), setProgrammatically(false) { - //static_cast(_widget)->set_numeric(); } /** Get the text in the entry */ @@ -47,17 +46,15 @@ const char * Text::getText() const { g_assert(_widget != NULL); - //return g_strdup_printf("%f", static_cast(_widget)->get_value()); return static_cast(_widget)->get_text().c_str(); } /** Sets the text of the text entry */ void -Text::setText(char* text) +Text::setText(const char* text) { g_assert(_widget != NULL); setProgrammatically = true; // callback is supposed to reset back, if it cares - //static_cast(_widget)->set_value(42.43); // FIXME: set correctly static_cast(_widget)->set_text(text); // FIXME: set correctly } @@ -65,7 +62,6 @@ Text::setText(char* text) Glib::SignalProxy0 Text::signal_activate() { - //return static_cast(_widget)->signal_value_changed(); return static_cast(_widget)->signal_activate(); } diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h index a1ec03355..038e6e5dd 100644 --- a/src/ui/widget/text.h +++ b/src/ui/widget/text.h @@ -34,7 +34,7 @@ public: const char* getText() const; - void setText(char* text); + void setText(const char* text); void update();