diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2008-06-25 16:18:02 +0000 |
|---|---|---|
| committer | JucaBlues <JucaBlues@users.sourceforge.net> | 2008-06-25 16:18:02 +0000 |
| commit | d7221942795e4bf740efb6851af320cf50bf0f96 (patch) | |
| tree | 5b86940e8f05cc5462d1e9aff47bf3e3f3b8d4c3 | |
| parent | warning cleanup (diff) | |
| download | inkscape-d7221942795e4bf740efb6851af320cf50bf0f96.tar.gz inkscape-d7221942795e4bf740efb6851af320cf50bf0f96.zip | |
adding list of available SVGFonts to the SVGFonts dialog
(bzr r6059)
| -rw-r--r-- | share/examples/svgfont.svg | 4 | ||||
| -rw-r--r-- | src/sp-font.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/svg-fonts-dialog.cpp | 36 | ||||
| -rw-r--r-- | src/ui/dialog/svg-fonts-dialog.h | 27 |
4 files changed, 65 insertions, 4 deletions
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 @@ <svg width="400px" height="300px" version="1.1" xmlns = 'http://www.w3.org/2000/svg'> - <font id="Font1" horiz-adv-x="1000"> + <font id="FirstExample" horiz-adv-x="1000"> <font-face font-family="Super Sans" font-style="oblique" font-stretch="ultra-expanded" /> <glyph unicode="!" d="M0,0h500v500h-500z"> <circle r='500' cx='500' cy='500' style="fill:none;stroke:green;"/> @@ -14,7 +14,7 @@ <hkern u1="!" u2="@" k="500" /> </font> - <font id="Font2" horiz-adv-x="1100"> + <font id="AnotherSVGFont" horiz-adv-x="1100"> <font-face font-family="Super Sans2" font-style="oblique" font-stretch="ultra-expanded" /> <glyph unicode="!" d="M0,0h500v500h-500v-300h100v200h300v-300h-400z" /> <glyph unicode="@!" d="M0,0h200L1000,800v200h-200L0,200z" /> 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 <gtkmm/liststore.h> +#include <gtkmm/treeview.h> 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<SPFont*> font; + Gtk::TreeModelColumn<Glib::ustring> label; + //Gtk::TreeModelColumn<int> sel; + }; + Glib::RefPtr<Gtk::ListStore> _model; + Columns _columns; + Gtk::TreeView _list; }; } // namespace Dialog |
