diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-07-24 16:49:11 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-07-24 16:49:11 +0000 |
| commit | a5d6c9a27683820be3d84eea73c2d6f161ce0e8e (patch) | |
| tree | b9ba6c20747c4d6d7b4479d229b9daf8eea5c5bd /src/ui/widget/font-selector.cpp | |
| parent | This for you CR ยท Measure line, show the distance on rect lines CAD like wit... (diff) | |
| download | inkscape-a5d6c9a27683820be3d84eea73c2d6f161ce0e8e.tar.gz inkscape-a5d6c9a27683820be3d84eea73c2d6f161ce0e8e.zip | |
Add Text tag and update widgets code
(bzr r15017.1.2)
Diffstat (limited to 'src/ui/widget/font-selector.cpp')
| -rw-r--r-- | src/ui/widget/font-selector.cpp | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp new file mode 100644 index 000000000..77bf83fe1 --- /dev/null +++ b/src/ui/widget/font-selector.cpp @@ -0,0 +1,115 @@ +/* + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "font-selector.h" +#include "widgets/icon.h" +#include <glibmm/i18n.h> + +namespace Inkscape { +namespace UI { +namespace Widget { + +FontSelector::FontSelector(Glib::ustring const &label, Glib::ustring const &tooltip, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + :_widget(new Gtk::HBox()), expanded(true) +{ + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); + GtkWidget *fontsel = sp_font_selector_new(); + gtk_widget_set_size_request (fontsel, 290, 150); + fsel = SP_FONT_SELECTOR(fontsel); + Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "on", Inkscape::ICON_SIZE_BUTTON) ); + Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &FontSelector::onFontSelectorSave)); + pButton->set_tooltip_text(_("Save the changes to font selector")); + vbox_expander->pack_start(*Gtk::manage(Glib::wrap(fontsel)), true, true); + vbox_expander->pack_start(*pButton, true, true); + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Font Selector:")))); + expander->add(*vbox_expander); + expander->set_expanded(expanded); + expander->set_spacing(5); + expander->set_use_markup(true); + onExpanderChanged(); + _widget->set_tooltip_text(tooltip); + expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &FontSelector::onExpanderChanged) ); + pack_start(*expander, true, true); + pack_start(*Gtk::manage(_widget), true, true); +} + +void +FontSelector::onExpanderChanged() +{ + expanded = expander->get_expanded(); + if(expanded) { + expander->set_label (Glib::ustring(_("Font Selector:"))); + } else { + expander->set_label (Glib::ustring(_("Font Selector: <b>hided</b>"))); + } +} + +Glib::ustring FontSelector::getFontSpec() const +{ + return _fontspec; +} + +void FontSelector::setFontSpec(Glib::ustring fontspec) +{ + _fontspec = fontspec; +} + +double FontSelector::getFontSize() const +{ + return _fontsize; +} + +void FontSelector::setFontSize(double fontsize) +{ + _fontsize = fontsize; +} + +void FontSelector::setValue (Glib::ustring fontspec, double fontsize) +{ + if (_fontsize != fontsize || _fontspec != fontspec) { + setFontSize(fontsize); + setFontSpec(fontspec); + sp_font_selector_set_fontspec(fsel, fontspec, fontsize); + } +} + +void +FontSelector::onFontSelectorSave() +{ + if (_fontspec != sp_font_selector_get_fontspec(fsel) || _fontsize != sp_font_selector_get_size(fsel)) { + setFontSpec(sp_font_selector_get_fontspec(fsel)); + setFontSize(sp_font_selector_get_size(fsel)); + signal_fontselupd.emit(); + onExpanderChanged(); + } +} + + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |
