diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-07-29 23:44:17 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-07-29 23:44:17 +0000 |
| commit | d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8 (patch) | |
| tree | b64c872c22dc7a81f335b93dd06c7dd8aacf18ac /src/ui | |
| parent | Add orientation and alow unsort combobox enum widget (diff) | |
| download | inkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.tar.gz inkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.zip | |
Remove font-Dialog and useGtk::FontSelector instead
(bzr r15017.1.13)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/ui/widget/Makefile_insert | 4 | ||||
| -rw-r--r-- | src/ui/widget/font-button.cpp | 58 | ||||
| -rw-r--r-- | src/ui/widget/font-button.h (renamed from src/ui/widget/font-selector.h) | 45 | ||||
| -rw-r--r-- | src/ui/widget/font-selector.cpp | 115 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 24 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.h | 12 |
7 files changed, 92 insertions, 170 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 62f341962..af375f1f9 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -128,7 +128,7 @@ set(ui_SRC widget/entity-entry.cpp widget/entry.cpp widget/filter-effect-chooser.cpp - widget/font-selector.cpp + widget/font-button.cpp widget/font-variants.cpp widget/frame.cpp widget/gimpcolorwheel.c @@ -313,7 +313,7 @@ set(ui_SRC widget/entity-entry.h widget/entry.h widget/filter-effect-chooser.h - widget/font-selector.h + widget/font-button.h widget/font-variants.h widget/frame.h widget/gimpspinscale.h diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index bb833e5ec..b5d8a74f6 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -33,8 +33,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ - ui/widget/font-selector.h \ - ui/widget/font-selector.cpp \ + ui/widget/font-button.h \ + ui/widget/font-button.cpp \ ui/widget/font-variants.h \ ui/widget/font-variants.cpp \ ui/widget/gimpspinscale.c \ diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp new file mode 100644 index 000000000..2c79347b2 --- /dev/null +++ b/src/ui/widget/font-button.cpp @@ -0,0 +1,58 @@ +/* + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "font-button.h" +#include <glibmm/i18n.h> + +namespace Inkscape { +namespace UI { +namespace Widget { + +FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip, + Glib::ustring const &suffix, + Glib::ustring const &icon, + bool mnemonic) + : Labelled(label, tooltip, new Gtk::FontButton("sans"), suffix, icon, mnemonic) +{ +} + +Glib::ustring FontButton::getValue() const +{ + g_assert(_widget != NULL); + return static_cast<Gtk::FontButton*>(_widget)->get_font_name(); +} + + +void FontButton::setValue (Glib::ustring fontspec) +{ + g_assert(_widget != NULL); + static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec); +} + +Glib::SignalProxy0<void> FontButton::signal_font_value_changed() +{ + g_assert(_widget != NULL); + return static_cast<Gtk::FontButton*>(_widget)->signal_font_set(); +} + + +} // 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 : diff --git a/src/ui/widget/font-selector.h b/src/ui/widget/font-button.h index 8146bc370..1f1ad2d01 100644 --- a/src/ui/widget/font-selector.h +++ b/src/ui/widget/font-button.h @@ -5,30 +5,24 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ -#ifndef INKSCAPE_UI_WIDGET_FONT_SELECTOR_H -#define INKSCAPE_UI_WIDGET_FONT_SELECTOR_H +#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H +#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H #include <gtkmm.h> -#include "widgets/font-selector.h" +#include "labelled.h" -struct SPFontSelector; namespace Inkscape { namespace UI { namespace Widget { /** - * A labelled text box, with spin buttons and optional - * icon or suffix, for entering arbitrary number values. It adds an extra - * number called "startseed", that is not UI edittable, but should be put in SVG. - * This does NOT generate a random number, but provides merely the saving of - * the startseed value. + * A labelled font button for entering font values */ -class FontSelector : public Gtk::HBox +class FontButton : public Labelled { public: - /** - * Construct a FontSelector Widget. + * Construct a FontButton Widget. * * @param label Label. * @param suffix Suffix, placed after the widget (defaults to ""). @@ -37,31 +31,18 @@ public: * indicates the next character should be used for the * mnemonic accelerator key (defaults to false). */ - FontSelector( Glib::ustring const &label, + FontButton( Glib::ustring const &label, Glib::ustring const &tooltip, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", bool mnemonic = true); - Glib::ustring getFontSpec() const; - void onExpanderChanged(); - void setFontSpec(Glib::ustring fontspec); - double getFontSize() const; - void setFontSize(double fontsize); - void setValue (Glib::ustring fontspec, double fontsize); - sigc::signal <void> signal_fontselupd; - -protected: - Gtk::Widget *_widget; - bool expanded; - Glib::ustring _label; - Gtk::Expander * expander; - SPFontSelector *fsel; - Glib::ustring _fontspec; - double _fontsize; - -private: - void onFontSelectorSave(); + Glib::ustring getValue() const; + void setValue (Glib::ustring fontspec); + /** + * Signal raised when the font button's value changes. + */ + Glib::SignalProxy0<void> signal_font_value_changed(); }; } // namespace Widget diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp deleted file mode 100644 index 0fcb307eb..000000000 --- a/src/ui/widget/font-selector.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * 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(false), _label(label) -{ - 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(label)); - 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(_label)); - } else { - expander->set_label (Glib::ustring(_label + _(" <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 : diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index c58e599ee..38bb7f7cc 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -25,7 +25,7 @@ #include "ui/widget/scalar-unit.h" #include "ui/widget/point.h" #include "ui/widget/random.h" -#include "ui/widget/font-selector.h" +#include "ui/widget/font-button.h" #include "widgets/spinbutton-events.h" #include "xml/repr.h" @@ -805,33 +805,31 @@ RegisteredRandom::on_value_changed() } /*######################################### - * Registered FONT-SELECTOR + * Registered FONT-BUTTON */ -RegisteredFontSelector::~RegisteredFontSelector() +RegisteredFontButton::~RegisteredFontButton() { - _value_changed_connection.disconnect(); + _signal_font_set.disconnect(); } -RegisteredFontSelector::RegisteredFontSelector ( const Glib::ustring& label, const Glib::ustring& tip, +RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument* doc_in ) - : RegisteredWidget<FontSelector> (label, tip) + : RegisteredWidget<FontButton>(label, tip) { init_parent(key, wr, repr_in, doc_in); - _value_changed_connection = signal_fontselupd.connect (sigc::mem_fun (*this, &RegisteredFontSelector::on_value_changed)); + _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed)); } void -RegisteredFontSelector::setValue (Glib::ustring fontspec, double fontsize) +RegisteredFontButton::setValue (Glib::ustring fontspec) { - if (fontsize != 0) { //have value in the effect - FontSelector::setValue (fontspec, fontsize); - } + FontButton::setValue(fontspec); } void -RegisteredFontSelector::on_value_changed() +RegisteredFontButton::on_value_changed() { if (_wr->isUpdating()) @@ -840,7 +838,7 @@ RegisteredFontSelector::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << getFontSpec() << " @ " << getFontSize(); + os << getValue(); write_to_xml(os.str().c_str()); diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 2b4d98b88..d410dbfe6 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -22,7 +22,7 @@ #include "ui/widget/text.h" #include "ui/widget/random.h" #include "ui/widget/unit-menu.h" -#include "ui/widget/font-selector.h" +#include "ui/widget/font-button.h" #include "ui/widget/color-picker.h" #include "inkscape.h" @@ -421,20 +421,20 @@ protected: void on_value_changed(); }; -class RegisteredFontSelector : public RegisteredWidget<FontSelector> { +class RegisteredFontButton : public RegisteredWidget<FontButton> { public: - virtual ~RegisteredFontSelector(); - RegisteredFontSelector ( const Glib::ustring& label, + virtual ~RegisteredFontButton(); + RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in = NULL, SPDocument *doc_in = NULL); - void setValue (Glib::ustring fontspec, double fontsize); + void setValue (Glib::ustring fontspec); protected: - sigc::connection _value_changed_connection; + sigc::connection _signal_font_set; void on_value_changed(); }; |
