From: JucaBlues Date: Fri, 15 Aug 2008 01:38:12 +0000 (+0000) Subject: family name field on svgfonts dialog now properly saves attribute. Should do the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c7433e6c4fb590ebc52554acc8422988c478b653;p=inkscape.git family name field on svgfonts dialog now properly saves attribute. Should do the same for other fields on next commits. --- diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index ccbe45046..fa81e84ca 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -19,6 +19,7 @@ #include "svg-fonts-dialog.h" #include #include +#include "xml/node.h" SvgFontDrawingArea::SvgFontDrawingArea(){ this->text = ""; @@ -59,15 +60,60 @@ namespace Inkscape { namespace UI { namespace Dialog { -Gtk::HBox* SvgFontsDialog::AttrEntry(gchar* lbl){ +/* +Gtk::HBox* SvgFontsDialog::AttrEntry(gchar* lbl, const SPAttributeEnum attr){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); - hbox->add(* Gtk::manage(new Gtk::Entry()) ); + Gtk::Entry* entry = Gtk::manage(new Gtk::Entry()); + hbox->add(* entry ); hbox->show_all(); + + entry->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_attr_changed)); return hbox; } +*/ + +SvgFontsDialog::AttrEntry::AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr){ + this->dialog = d; + this->attr = attr; + this->add(* Gtk::manage(new Gtk::Label(lbl)) ); + this->add(entry); + this->show_all(); + + entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::AttrEntry::on_attr_changed)); +} + +void SvgFontsDialog::AttrEntry::on_attr_changed(){ + g_warning("attr entry changed: %s", this->entry.get_text().c_str()); + + SPObject* o = NULL; + for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){ + switch(this->attr){ + case SP_PROP_FONT_FAMILY: + if (SP_IS_FONTFACE(node)){ + o = node; + continue; + } + break; + default: + o = NULL; + } + } -Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl){ + const gchar* name = (const gchar*)sp_attribute_name(this->attr); + if(name && o) { + SP_OBJECT_REPR(o)->setAttribute((const gchar*) name, this->entry.get_text().c_str()); + o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + + Glib::ustring undokey = "svgfonts:"; + undokey += name; + sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, + _("Set SVG Font attribute")); + } + +} + +Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum attr){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); hbox->add(* Gtk::manage(new Gtk::ComboBox()) ); @@ -202,10 +248,13 @@ SPFont* SvgFontsDialog::get_selected_spfont() Gtk::VBox* SvgFontsDialog::global_settings_tab(){ Gtk::VBox* global_vbox = Gtk::manage(new Gtk::VBox()); - global_vbox->add(*AttrEntry((gchar*) "Family Name")); - global_vbox->add(*AttrCombo((gchar*) "Style")); - global_vbox->add(*AttrCombo((gchar*) "Variant")); - global_vbox->add(*AttrCombo((gchar*) "Weight")); + AttrEntry* familyname; + familyname = new AttrEntry(this, (gchar*) "Family Name", SP_PROP_FONT_FAMILY); + + global_vbox->add(*familyname); + global_vbox->add(*AttrCombo((gchar*) "Style", SP_PROP_FONT_STYLE)); + global_vbox->add(*AttrCombo((gchar*) "Variant", SP_PROP_FONT_VARIANT)); + global_vbox->add(*AttrCombo((gchar*) "Weight", SP_PROP_FONT_WEIGHT)); //Set Width (horiz_adv_x): Gtk::HBox* setwidth_hbox = Gtk::manage(new Gtk::HBox()); @@ -222,10 +271,10 @@ Gtk::VBox* SvgFontsDialog::global_settings_tab(){ Gtk::VBox* SvgFontsDialog::glyphs_tab(){ Gtk::VBox* glyphs_vbox = Gtk::manage(new Gtk::VBox()); - glyphs_vbox->add(*AttrEntry((gchar*) "Glyph Name")); - glyphs_vbox->add(*AttrEntry((gchar*) "Unicode")); - //glyphs_vbox->add(*AttrSpin((gchar*) "Horizontal Advance")); - //glyphs_vbox->add(*AttrCombo((gchar*) "Missing Glyph")); + glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Glyph Name", SP_ATTR_GLYPH_NAME)); + glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Unicode", SP_ATTR_UNICODE)); + //glyphs_vbox->add(*AttrSpin((gchar*) "Horizontal Advance"), SP_ATTR_HORIZ_ADV_X); + //glyphs_vbox->add(*AttrCombo((gchar*) "Missing Glyph"), SP_ATTR_); ? return glyphs_vbox; } diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index d478f8d8d..8502a3468 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -14,6 +14,7 @@ #include "ui/widget/panel.h" #include "sp-font.h" +#include "sp-font-face.h" #include "verbs.h" #include "document.h" #include "desktop.h" @@ -26,6 +27,8 @@ #include #include "display/nr-svgfonts.h" +#include "attributes.h" + class SvgFontDrawingArea : Gtk::DrawingArea{ public: @@ -70,10 +73,20 @@ public: void on_kerning_changed(); void on_setwidth_changed(); + class AttrEntry : public Gtk::HBox + { + public: + AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr); + private: + SvgFontsDialog* dialog; + void on_attr_changed(); + Gtk::Entry entry; + SPAttributeEnum attr; + }; + private: - Gtk::HBox* AttrEntry(gchar* lbl); - Gtk::HBox* AttrCombo(gchar* lbl); -// Gtk::HBox* AttrSpin(gchar* lbl); + Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr); +// Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr); Gtk::VBox* global_settings_tab(); Gtk::VBox* kerning_tab(); Gtk::VBox* glyphs_tab();