Debian Codegraph @

gtk/gtkmm/stockid.h

raw symbols SCIP
1 #ifndef _GTKMM_STOCKID_H
2 #define _GTKMM_STOCKID_H
3
4 #include <gtkmmconfig.h>
5 #ifndef GTKMM_DISABLE_DEPRECATED // This whole file is deprecated.
6
7 /* stockid.h
8 *
9 * Copyright (C) 2002 The gtkmm Development Team
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
23 */
24
25 #include <gtkmmconfig.h>
26
27 #include <glibmm/ustring.h>
28 #include <glibmm/containerhandle_shared.h>
29
30 namespace Gtk
31 {
32
33 struct BuiltinStockID;
34
35 /** See also Gtk::BuiltinStockID.
36 * @deprecated Use icon names instead of StockItem, StockID and BuiltinStockID.
37 */
38 class GTKMM_API StockID
39 {
40 public:
41 /** Create an empty StockID
42 */
43 StockID(); //TODO: This was added for Action::Action, but there might be a better way to do this.
44
45 /** Create a StockID from one of the build-in stock ids.
46 *
47 * See also Gtk::BuildinStockID.
48 */
49 StockID(const BuiltinStockID& id);
50
51 /** Create a StockID from its string representation.
52 * @param id string representation of the stock id. Usually something like "gtk-about".
53 */
54 explicit StockID(const Glib::ustring& id);
55
56 /** Create a StockID from its string representation.
57 * @param id string representation of the stock id. Usually something like "gtk-about".
58 *
59 * If id is 0 an empty StockID will be created.
60 */
61 explicit StockID(const char* id);
62 ~StockID() noexcept;
63
64 /** Create a StockID as copy from another.
65 * @param other: StockID to copy.
66 */
67 StockID(const StockID& other);
68
69 /** Check if the StockIDs are equal.
70 * @param other Another StockID.
71 */
72 StockID& operator=(const StockID& other);
73
74 /** This typedef is just to make it more obvious that
75 * our operator const void* should be used like operator bool().
76 */
77 typedef const void* BoolExpr;
78
79 /** Tests whether the StockID is not empty.
80 * For instance,
81 * @code
82 * if(stockid)
83 * do_something()
84 * @endcode
85 */
86 operator BoolExpr() const;
87
88 /** Check if two StockIDs are equal.
89 * @param rhs Another StockID.
90 *
91 * @return <tt>true</tt> if both ids equal - <tt>false</tt> otherwise.
92 */
93 bool equal(const StockID& rhs) const;
94
95 /** Get the string representation of the StockID.
96 *
97 * @return something like "gtk-about".
98 */
99 Glib::ustring get_string() const;
100
101 /** Get the string representation as a const gchar*.
102 *
103 * @return string representation as const gchar*.
104 */
105 const char* get_c_str() const;
106
107 protected:
108 Glib::ustring id_;
109 };
110
111 /** @deprecated Use icon names instead of StockItem, StockID and BuiltinStockID.
112 * @relates Gtk::StockID */
113 inline bool operator==(const StockID& lhs, const StockID& rhs)
114 { return lhs.equal(rhs); }
115
116 /** @deprecated Use icon names instead of StockItem, StockID and BuiltinStockID.
117 * @relates Gtk::StockID */
118 inline bool operator!=(const StockID& lhs, const StockID& rhs)
119 { return !lhs.equal(rhs); }
120
121
122 #ifndef DOXYGEN_SHOULD_SKIP_THIS
123 struct StockIDTraits : public Glib::Container_Helpers::TypeTraits<Glib::ustring>
124 {
125 typedef Gtk::StockID CppType;
126
127 static const char* to_c_type(const StockID& id) { return id.get_c_str(); }
128 static StockID to_cpp_type(const char* str) { return StockID(str); }
129 };
130 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
131
132 } // namespace Gtk
133
134
135 #ifndef DOXYGEN_SHOULD_SKIP_THIS
136 namespace Glib
137 {
138
139 template <>
140 class GTKMM_API Value<Gtk::StockID> : public Glib::ValueBase_String
141 {
142 public:
143 typedef Gtk::StockID CppType;
144
145 void set(const Gtk::StockID& data) { set_cstring(data.get_c_str()); }
146 Gtk::StockID get() const { return Gtk::StockID(get_cstring()); }
147 };
148
149 } // namespace Glib
150 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
151
152 #endif // GTKMM_DISABLE_DEPRECATED
153
154 #endif /* _GTKMM_STOCKID_H */