summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/svg-fonts-dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog/svg-fonts-dialog.cpp')
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp93
1 files changed, 41 insertions, 52 deletions
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index 9dd2342f8..6a87f3714 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -113,11 +113,11 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){
void SvgFontsDialog::AttrEntry::on_attr_changed(){
SPObject* o = NULL;
- for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: dialog->get_selected_spfont()->children) {
switch(this->attr){
case SP_PROP_FONT_FAMILY:
- if (SP_IS_FONTFACE(node)){
- o = node;
+ if (SP_IS_FONTFACE(&node)){
+ o = &node;
continue;
}
break;
@@ -168,9 +168,9 @@ void GlyphComboBox::update(SPFont* spfont){
this->append(""); //Gtk is refusing to clear the combobox when I comment out this line
this->remove_all();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
- this->append((static_cast<SPGlyph*>(node))->unicode);
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
+ this->append((static_cast<SPGlyph*>(&node))->unicode);
}
}
}
@@ -306,10 +306,9 @@ void SvgFontsDialog::update_global_settings_tab(){
SPFont* font = get_selected_spfont();
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
- _familyname_entry->set_text((SP_FONTFACE(obj))->font_family);
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
+ _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family);
}
}
}
@@ -412,12 +411,12 @@ SvgFontsDialog::populate_glyphs_box()
SPFont* spfont = this->get_selected_spfont();
_glyphs_observer.set(spfont);
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_GLYPH(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_GLYPH(&node)){
Gtk::TreeModel::Row row = *(_GlyphsListStore->append());
- row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(node);
- row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(node))->glyph_name;
- row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(node))->unicode;
+ row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(&node);
+ row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(&node))->glyph_name;
+ row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(&node))->unicode;
}
}
}
@@ -430,13 +429,13 @@ SvgFontsDialog::populate_kerning_pairs_box()
SPFont* spfont = this->get_selected_spfont();
- for(SPObject* node = spfont->children; node; node=node->next){
- if (SP_IS_HKERN(node)){
+ for (auto& node: spfont->children) {
+ if (SP_IS_HKERN(&node)){
Gtk::TreeModel::Row row = *(_KerningPairsListStore->append());
- row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str();
- row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str();
- row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(node))->k;
- row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(node);
+ row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(&node))->u1->attribute_string().c_str();
+ row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(&node))->u2->attribute_string().c_str();
+ row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(&node))->k;
+ row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(&node);
}
}
}
@@ -491,11 +490,10 @@ void SvgFontsDialog::add_glyph(){
Geom::PathVector
SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){
double units_per_em = 1000;
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- sp_repr_get_double(obj->getRepr(), "units-per-em", &units_per_em);
+ sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em);
}
}
@@ -522,7 +520,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -564,7 +562,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
return;
}
- Inkscape::XML::Node* node = sel->reprList().front();
+ Inkscape::XML::Node* node = sel->xmlNodes().front();
if (!node) return;//TODO: should this be an assert?
if (!node->matchAttributeName("d") || !node->attribute("d")){
char *msg = _("The selected object does not have a <b>path</b> description.");
@@ -574,13 +572,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){
Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d"));
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
gchar *str = sp_svg_write_path (flip_coordinate_system(pathv));
- obj->getRepr()->setAttribute("d", str);
+ obj.getRepr()->setAttribute("d", str);
g_free(str);
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves"));
}
@@ -597,11 +594,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){
}
SPDocument* doc = desktop->getDocument();
- SPObject* obj;
- for (obj = get_selected_spfont()->children; obj; obj=obj->next){
- if (SP_IS_MISSING_GLYPH(obj)){
+ for (auto& obj: get_selected_spfont()->children) {
+ if (SP_IS_MISSING_GLYPH(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
+ obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z");
DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph"));
}
}
@@ -736,12 +732,12 @@ void SvgFontsDialog::add_kerning_pair(){
//look for this kerning pair on the currently selected font
this->kerning_pair = NULL;
- for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){
+ for (auto& node: get_selected_spfont()->children) {
//TODO: It is not really correct to get only the first byte of each string.
//TODO: We should also support vertical kerning
- if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
- && (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
- this->kerning_pair = static_cast<SPGlyphKerning*>(node);
+ if (SP_IS_HKERN(&node) && (static_cast<SPGlyphKerning*>(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0])
+ && (static_cast<SPGlyphKerning*>(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){
+ this->kerning_pair = static_cast<SPGlyphKerning*>(&node);
continue;
}
}
@@ -850,11 +846,10 @@ SPFont *new_font(SPDocument *document)
void set_font_family(SPFont* font, char* str){
if (!font) return;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", str);
+ obj.getRepr()->setAttribute("font-family", str);
}
}
@@ -871,11 +866,10 @@ void SvgFontsDialog::add_font(){
font->setLabel(os.str().c_str());
os2 << "SVGFont " << count;
- SPObject* obj;
- for (obj=font->children; obj; obj=obj->next){
- if (SP_IS_FONTFACE(obj)){
+ for (auto& obj: font->children) {
+ if (SP_IS_FONTFACE(&obj)){
//XML Tree being directly used here while it shouldn't be.
- obj->getRepr()->setAttribute("font-family", os2.str().c_str());
+ obj.getRepr()->setAttribute("font-family", os2.str().c_str());
}
}
@@ -888,12 +882,7 @@ void SvgFontsDialog::add_font(){
SvgFontsDialog::SvgFontsDialog()
: UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS), _add(Gtk::Stock::NEW)
{
-#if WITH_GTKMM_3_0
kerning_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL));
-#else
- kerning_slider = Gtk::manage(new Gtk::HScale);
-#endif
-
_add.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_font));
Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());