1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Extra data associated with actions: Label, Section, Tooltip.
4  *
5  * Extra data is indexed by "detailed action names", that is an action
6  * with prefix and value (if statefull). For example:
7  *   "win.canvas-display-mode(1)"
8  *
9  * Copyright (C) 2020 Tavmjong Bah
10  *
11  * The contents of this file may be used under the GNU General Public License Version 2 or later.
12  *
13  */
14 
15 #ifndef INK_ACTIONS_EXTRA_DATA_H
16 #define INK_ACTIONS_EXTRA_DATA_H
17 
18 #include <glibmm/ustring.h>
19 #include <glibmm/varianttype.h>
20 #include <map>
21 #include <utility>
22 #include <vector>
23 
24 enum class ParamType
25 {
26     INTEGER,
27     DOUBLE,
28     STRING,
29 };
30 
31 class InkActionExtraDatum {
32 public:
InkActionExtraDatum(Glib::ustring & label,Glib::ustring & section,Glib::ustring & tooltip)33     InkActionExtraDatum(Glib::ustring& label, Glib::ustring& section, Glib::ustring& tooltip)
34         : action_label(label)
35         , action_section(section)
36         , action_tooltip(tooltip)
37     {
38     }
39 
get_label()40     Glib::ustring get_label()   { return action_label; }
get_section()41     Glib::ustring get_section() { return action_section; }
get_tooltip()42     Glib::ustring get_tooltip() { return action_tooltip; }
43 
44 private:
45     Glib::ustring action_label;
46     Glib::ustring action_section;
47     Glib::ustring action_tooltip;
48 };
49 
50 class InkActionExtraData
51 {
52 public:
53     InkActionExtraData() = default;
54 
55     std::vector<Glib::ustring> get_actions();
56 
57     void add_data(std::vector<std::vector<Glib::ustring>> &raw_data);
58 
59     Glib::ustring get_label_for_action(Glib::ustring const &action_name, bool translated = true);
60     Glib::ustring get_section_for_action(Glib::ustring const &action_name);
61     Glib::ustring get_tooltip_for_action(Glib::ustring const &action_name, bool translated = true);
62 
63 private:
64     std::map<Glib::ustring, InkActionExtraDatum> data;
65 };
66 
67 #endif // INK_ACTIONS_EXTRA_DATA_H
68 
69 /*
70   Local Variables:
71   mode:c++
72   c-file-style:"stroustrup"
73   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
74   indent-tabs-mode:nil
75   fill-column:99
76   End:
77 */
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
79