From: JucaBlues Date: Wed, 25 Jun 2008 16:18:02 +0000 (+0000) Subject: adding list of available SVGFonts to the SVGFonts dialog X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6fd67bd386767141cc557108237de0a257300516;p=inkscape.git adding list of available SVGFonts to the SVGFonts dialog --- diff --git a/share/examples/svgfont.svg b/share/examples/svgfont.svg index 05c9159a2..1915bb642 100644 --- a/share/examples/svgfont.svg +++ b/share/examples/svgfont.svg @@ -2,7 +2,7 @@ - + @@ -14,7 +14,7 @@ - + diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 9ba4730be..8667af4cb 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -105,6 +105,8 @@ static void sp_font_build(SPObject *object, SPDocument *document, Inkscape::XML: sp_object_read_attr(object, "vert-adv-y"); SvgFont* svgfont = new SvgFont(SP_FONT(object)); + + sp_document_add_resource(document, "font", object); } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index f6d357a0e..284003c92 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -23,11 +23,43 @@ namespace Dialog { /*** SvgFontsDialog ***/ +/* Add all fonts in the document to the combobox. */ +void SvgFontsDialog::update_fonts() +{ +g_warning("update_fonts"); + SPDesktop* desktop = this->getDesktop(); + SPDocument* document = sp_desktop_document(desktop); + const GSList* fonts = sp_document_get_resource_list(document, "font"); + + _model->clear(); +g_warning("after _model->clear()"); + for(const GSList *l = fonts; l; l = l->next) { + Gtk::TreeModel::Row row = *_model->append(); + SPFont* f = (SPFont*)l->data; + row[_columns.font] = f; + const gchar* lbl = f->label(); +g_warning("label: %s", lbl); + const gchar* id = SP_OBJECT_ID(f); + row[_columns.label] = lbl ? lbl : (id ? id : "font"); + } + +// update_selection(desktop->selection); +// _dialog.update_filter_general_settings_view(); +} + SvgFontsDialog::SvgFontsDialog() : UI::Widget::Panel("", "dialogs.svgfonts", SP_VERB_DIALOG_SVG_FONTS) { - Gtk::Label* label = Gtk::manage(new Gtk::Label("Here we will have settings for the SVGFonts used in the document.")); - _getContents()->add(*label); + //Gtk::Label* label = Gtk::manage(new Gtk::Label("Here we will have settings for the SVGFonts used in the document.")); + _getContents()->add(_list); +g_warning("a"); + _model = Gtk::ListStore::create(_columns); +g_warning("b"); + _list.set_model(_model); + _list.append_column_editable("_Font", _columns.label); +g_warning("c"); + this->update_fonts(); +g_warning("d"); } SvgFontsDialog::~SvgFontsDialog(){} diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index c2cd7a803..d12e9481c 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -15,6 +15,12 @@ #include "ui/widget/panel.h" #include "sp-font.h" #include "verbs.h" +#include "document.h" +#include "desktop.h" +#include "desktop-handles.h" + +#include +#include using namespace Inkscape::UI::Widget; @@ -29,6 +35,27 @@ public: static SvgFontsDialog &getInstance() { return *new SvgFontsDialog(); } + + void update_fonts(); + +private: + class Columns : public Gtk::TreeModel::ColumnRecord + { + public: + Columns() + { + add(font); + add(label); + //add(sel); + } + + Gtk::TreeModelColumn font; + Gtk::TreeModelColumn label; + //Gtk::TreeModelColumn sel; + }; + Glib::RefPtr _model; + Columns _columns; + Gtk::TreeView _list; }; } // namespace Dialog