1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef SEEN_GRADIENT_VECTOR_H
3 #define SEEN_GRADIENT_VECTOR_H
4 
5 /*
6  * Gradient vector selection widget
7  *
8  * Author:
9  *   Lauris Kaplinski <lauris@kaplinski.com>
10  *   Jon A. Cruz <jon@joncruz.org>
11  *
12  * Copyright (C) 2010 Jon A. Cruz
13  * Copyright (C) 2001-2002 Lauris Kaplinski
14  * Copyright (C) 2001 Ximian, Inc.
15  *
16  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17  */
18 
19 #include "ui/widget/gradient-selector.h"
20 
21 #include <gtkmm/liststore.h>
22 #include <sigc++/connection.h>
23 
24 class SPDocument;
25 class SPObject;
26 class SPGradient;
27 class SPStop;
28 
29 namespace Inkscape {
30 namespace UI {
31 namespace Widget {
32 
33 class GradientVectorSelector : public Gtk::Box {
34   private:
35     bool _swatched = false;
36 
37     SPDocument *_doc = nullptr;
38     SPGradient *_gr  = nullptr;
39 
40     /* Gradient vectors store */
41     Glib::RefPtr<Gtk::ListStore> _store;
42     Inkscape::UI::Widget::GradientSelector::ModelColumns *_columns;
43 
44     sigc::connection _gradient_release_connection;
45     sigc::connection _defs_release_connection;
46     sigc::connection _defs_modified_connection;
47     sigc::connection _tree_select_connection;
48 
49     sigc::signal<void, SPGradient *> _signal_vector_set;
50 
51     void gradient_release(SPObject *obj);
52     void defs_release(SPObject *defs);
53     void defs_modified(SPObject *defs, guint flags);
54     void rebuild_gui_full();
55 
56   public:
57     GradientVectorSelector(SPDocument *doc, SPGradient *gradient);
58     ~GradientVectorSelector() override;
59 
60     void setSwatched();
61     void set_gradient(SPDocument *doc, SPGradient *gr);
62 
get_columns()63     inline decltype(_columns) get_columns()  const { return _columns; }
get_document()64     inline decltype(_doc)     get_document() const { return _doc; }
get_gradient()65     inline decltype(_gr)      get_gradient() const { return _gr; }
get_store()66     inline decltype(_store)   get_store()    const { return _store; }
67 
signal_vector_set()68     inline decltype(_signal_vector_set) signal_vector_set() const { return _signal_vector_set; }
69 
set_tree_select_connection(sigc::connection & connection)70     inline void set_tree_select_connection(sigc::connection &connection) { _tree_select_connection = connection; }
71 };
72 
73 } // namespace Widget
74 } // namespace UI
75 } // namespace Inkscape
76 
77 Glib::ustring gr_prepare_label (SPObject *obj);
78 Glib::ustring gr_ellipsize_text(Glib::ustring const &src, size_t maxlen);
79 
80 #endif // SEEN_GRADIENT_VECTOR_H
81 
82 /*
83   Local Variables:
84   mode:c++
85   c-file-style:"stroustrup"
86   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
87   indent-tabs-mode:nil
88   fill-column:99
89   End:
90 */
91 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
92