summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2016-10-08 15:39:06 +0000
committerShlomi Fish <shlomif@shlomifish.org>2016-10-08 15:39:06 +0000
commit2a5534a166dff8bfe6b56c8a3b496e989280fbd1 (patch)
treedbd8330a6b3dcfb201ee751dbf283a17a41a2dfa /src/ui/widget
parentMerged. (diff)
parent[Bug #770681] KEY MAPPING: Comma and period hijacked by scaling. (diff)
downloadinkscape-2a5534a166dff8bfe6b56c8a3b496e989280fbd1.tar.gz
inkscape-2a5534a166dff8bfe6b56c8a3b496e989280fbd1.zip
Merged.
(bzr r15100.1.31)
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/combo-enums.h9
-rw-r--r--src/ui/widget/font-button.cpp58
-rw-r--r--src/ui/widget/font-button.h63
-rw-r--r--src/ui/widget/registered-enums.h6
-rw-r--r--src/ui/widget/registered-widget.cpp54
-rw-r--r--src/ui/widget/registered-widget.h20
-rw-r--r--src/ui/widget/scalar.cpp6
-rw-r--r--src/ui/widget/scalar.h2
-rw-r--r--src/ui/widget/text.cpp6
-rw-r--r--src/ui/widget/text.h4
10 files changed, 203 insertions, 25 deletions
diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h
index 4678ab83b..e7524ac71 100644
--- a/src/ui/widget/combo-enums.h
+++ b/src/ui/widget/combo-enums.h
@@ -16,7 +16,6 @@
#include <gtkmm/liststore.h>
#include "attr-widget.h"
#include "util/enums.h"
-
#include <glibmm/i18n.h>
namespace Inkscape {
@@ -190,9 +189,11 @@ public:
const Util::EnumDataConverter<E>& c,
Glib::ustring const &suffix = "",
Glib::ustring const &icon = "",
- bool mnemonic = true)
- : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
- { }
+ bool mnemonic = true,
+ bool sorted = true)
+ : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
+ {
+ }
ComboBoxEnum<E>* getCombobox() {
return static_cast< ComboBoxEnum<E>* > (_widget);
diff --git a/src/ui/widget/font-button.cpp b/src/ui/widget/font-button.cpp
new file mode 100644
index 000000000..a472ac6a4
--- /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 10"), 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-button.h b/src/ui/widget/font-button.h
new file mode 100644
index 000000000..1f1ad2d01
--- /dev/null
+++ b/src/ui/widget/font-button.h
@@ -0,0 +1,63 @@
+/*
+ *
+ * Copyright (C) 2007 Author
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H
+
+#include <gtkmm.h>
+#include "labelled.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * A labelled font button for entering font values
+ */
+class FontButton : public Labelled
+{
+public:
+ /**
+ * Construct a FontButton Widget.
+ *
+ * @param label Label.
+ * @param suffix Suffix, placed after the widget (defaults to "").
+ * @param icon Icon filename, placed before the label (defaults to "").
+ * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
+ * indicates the next character should be used for the
+ * mnemonic accelerator key (defaults to false).
+ */
+ FontButton( Glib::ustring const &label,
+ Glib::ustring const &tooltip,
+ Glib::ustring const &suffix = "",
+ Glib::ustring const &icon = "",
+ bool mnemonic = true);
+
+ 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
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_RANDOM_H
+
+/*
+ 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-enums.h b/src/ui/widget/registered-enums.h
index 9e1682c7d..1d5074836 100644
--- a/src/ui/widget/registered-enums.h
+++ b/src/ui/widget/registered-enums.h
@@ -33,11 +33,11 @@ public:
const Util::EnumDataConverter<E>& c,
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
- SPDocument *doc_in = NULL )
- : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
+ SPDocument *doc_in = NULL,
+ bool sorted = true )
+ : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
{
RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
-
_changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
}
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 7dc5abc75..be677a434 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -285,7 +285,6 @@ RegisteredScalar::on_value_changed()
setProgrammatically = false;
return;
}
-
if (_wr->isUpdating()) {
return;
}
@@ -319,8 +318,6 @@ RegisteredText::RegisteredText ( const Glib::ustring& label, const Glib::ustring
init_parent(key, wr, repr_in, doc_in);
setProgrammatically = false;
-
- setText("");
_activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate));
}
@@ -336,16 +333,12 @@ RegisteredText::on_activate()
return;
}
_wr->setUpdating (true);
-
- Inkscape::SVGOStringStream os;
- os << getText();
-
+ Glib::ustring str(getText());
set_sensitive(false);
+ Inkscape::SVGOStringStream os;
+ os << str;
write_to_xml(os.str().c_str());
set_sensitive(true);
-
- setText(os.str().c_str());
-
_wr->setUpdating (false);
}
@@ -791,6 +784,47 @@ RegisteredRandom::on_value_changed()
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered FONT-BUTTON
+ */
+
+RegisteredFontButton::~RegisteredFontButton()
+{
+ _signal_font_set.disconnect();
+}
+
+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<FontButton>(label, tip)
+{
+ init_parent(key, wr, repr_in, doc_in);
+ _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
+}
+
+void
+RegisteredFontButton::setValue (Glib::ustring fontspec)
+{
+ FontButton::setValue(fontspec);
+}
+
+void
+RegisteredFontButton::on_value_changed()
+{
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Inkscape::SVGOStringStream os;
+ os << getValue();
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index ab2e4c8e4..d410dbfe6 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -22,6 +22,7 @@
#include "ui/widget/text.h"
#include "ui/widget/random.h"
#include "ui/widget/unit-menu.h"
+#include "ui/widget/font-button.h"
#include "ui/widget/color-picker.h"
#include "inkscape.h"
@@ -77,6 +78,8 @@ protected:
RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
template< typename A, typename B, typename C, typename D, typename E , typename F>
RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
+ template< typename A, typename B, typename C, typename D, typename E , typename F, typename G>
+ RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); }
virtual ~RegisteredWidget() {};
@@ -418,6 +421,23 @@ protected:
void on_value_changed();
};
+class RegisteredFontButton : public RegisteredWidget<FontButton> {
+public:
+ 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);
+
+protected:
+ sigc::connection _signal_font_set;
+ void on_value_changed();
+};
+
} // namespace Widget
} // namespace UI
} // namespace Inkscape
diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp
index 434c2c0bb..f8543a371 100644
--- a/src/ui/widget/scalar.cpp
+++ b/src/ui/widget/scalar.cpp
@@ -122,10 +122,12 @@ void Scalar::setRange(double min, double max)
static_cast<SpinButton*>(_widget)->set_range(min, max);
}
-void Scalar::setValue(double value)
+void Scalar::setValue(double value, bool setProg)
{
g_assert(_widget != NULL);
- setProgrammatically = true; // callback is supposed to reset back, if it cares
+ if (setProg) {
+ setProgrammatically = true; // callback is supposed to reset back, if it cares
+ }
static_cast<SpinButton*>(_widget)->set_value(value);
}
diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h
index 847790b96..f186f46ac 100644
--- a/src/ui/widget/scalar.h
+++ b/src/ui/widget/scalar.h
@@ -135,7 +135,7 @@ public:
/**
* Sets the value of the spin button.
*/
- void setValue(double value);
+ void setValue(double value, bool setProg = true);
/**
* Manually forces an update of the spin button.
diff --git a/src/ui/widget/text.cpp b/src/ui/widget/text.cpp
index ec58d5bb4..e6795b138 100644
--- a/src/ui/widget/text.cpp
+++ b/src/ui/widget/text.cpp
@@ -28,13 +28,13 @@ Text::Text(Glib::ustring const &label, Glib::ustring const &tooltip,
{
}
-const char *Text::getText() const
+Glib::ustring const Text::getText() const
{
g_assert(_widget != NULL);
- return static_cast<Gtk::Entry*>(_widget)->get_text().c_str();
+ return static_cast<Gtk::Entry*>(_widget)->get_text();
}
-void Text::setText(const char* text)
+void Text::setText(Glib::ustring const text)
{
g_assert(_widget != NULL);
setProgrammatically = true; // callback is supposed to reset back, if it cares
diff --git a/src/ui/widget/text.h b/src/ui/widget/text.h
index b90788940..593875b23 100644
--- a/src/ui/widget/text.h
+++ b/src/ui/widget/text.h
@@ -44,12 +44,12 @@ public:
/**
* Get the text in the entry.
*/
- const char* getText() const;
+ Glib::ustring const getText() const;
/**
* Sets the text of the text entry.
*/
- void setText(const char* text);
+ void setText(Glib::ustring const text);
void update();