diff options
| author | Patrick Storz <eduard.braun2@gmx.de> | 2019-08-10 17:56:50 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2019-08-31 14:50:39 +0000 |
| commit | e610752037735e10980a62a7ca7f0c3b2bd99d7d (patch) | |
| tree | 4b7062448a2c8831491241a18c54683f03bf017d /src | |
| parent | Add new widgets "hbox" and "vbox" for layouting purposes (diff) | |
| download | inkscape-e610752037735e10980a62a7ca7f0c3b2bd99d7d.tar.gz inkscape-e610752037735e10980a62a7ca7f0c3b2bd99d7d.zip | |
Add new widget "separator" which draws a line between widgets
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/extension/prefdialog/widget-separator.cpp | 42 | ||||
| -rw-r--r-- | src/extension/prefdialog/widget-separator.h | 53 | ||||
| -rw-r--r-- | src/extension/prefdialog/widget.cpp | 5 |
4 files changed, 101 insertions, 1 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index ebe058761..a82ff3fbe 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -64,6 +64,7 @@ set(extension_SRC prefdialog/widget.cpp prefdialog/widget-box.cpp prefdialog/widget-label.cpp + prefdialog/widget-separator.cpp # ------ # Header @@ -140,6 +141,7 @@ set(extension_SRC prefdialog/widget.h prefdialog/widget-box.h prefdialog/widget-label.h + prefdialog/widget-separator.h ) if(WIN32) diff --git a/src/extension/prefdialog/widget-separator.cpp b/src/extension/prefdialog/widget-separator.cpp new file mode 100644 index 000000000..94778e027 --- /dev/null +++ b/src/extension/prefdialog/widget-separator.cpp @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Separator widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "widget-separator.h" + +#include <gtkmm/separator.h> + +#include "xml/node.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { + + +WidgetSeparator::WidgetSeparator(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) +{ +} + +/** \brief Create a label for the description */ +Gtk::Widget *WidgetSeparator::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::Separator *separator = Gtk::manage(new Gtk::Separator()); + separator->show(); + return dynamic_cast<Gtk::Widget *>(separator); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/widget-separator.h b/src/extension/prefdialog/widget-separator.h new file mode 100644 index 000000000..9533aba61 --- /dev/null +++ b/src/extension/prefdialog/widget-separator.h @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Separator widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_SEPARATOR_H +#define SEEN_INK_EXTENSION_WIDGET_SEPARATOR_H + +#include "widget.h" + +#include <glibmm/ustring.h> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A separator widget */ +class WidgetSeparator : public InxWidget { +public: + WidgetSeparator(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_SEPARATOR_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 : diff --git a/src/extension/prefdialog/widget.cpp b/src/extension/prefdialog/widget.cpp index 097406763..eb9d23e07 100644 --- a/src/extension/prefdialog/widget.cpp +++ b/src/extension/prefdialog/widget.cpp @@ -14,6 +14,7 @@ #include "widget.h" #include "widget-box.h" #include "widget-label.h" +#include "widget-separator.h" #include <algorithm> @@ -48,6 +49,8 @@ InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex widget = new WidgetBox(in_repr, in_ext); } else if (!strcmp(name, "label")) { widget = new WidgetLabel(in_repr, in_ext); + } else if (!strcmp(name, "separator")) { + widget = new WidgetSeparator(in_repr, in_ext); } else if (!strcmp(name, "param")) { widget = InxParameter::make(in_repr, in_ext); } else { @@ -61,7 +64,7 @@ InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex bool InxWidget::is_valid_widget_name(const char *name) { // keep in sync with names supported in InxWidget::make() above - static const std::vector<std::string> valid_names = {"hbox", "vbox", "label", "param"}; + static const std::vector<std::string> valid_names = {"hbox", "vbox", "label", "separator", "param"}; if (std::find(valid_names.begin(), valid_names.end(), name) != valid_names.end()) { return true; |
