1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_ICON_H 3 #define _GIOMM_ICON_H 4 5 #include <giommconfig.h> 6 7 8 #include <glibmm/ustring.h> 9 #include <sigc++/sigc++.h> 10 11 /* Copyright (C) 2007 The giomm Development Team 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or (at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 28 #include <glibmm/interface.h> 29 #include <glibmm/variant.h> 30 31 32 #ifndef DOXYGEN_SHOULD_SKIP_THIS 33 typedef struct _GIconIface GIconIface; 34 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 35 36 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 using GIcon = struct _GIcon; 38 using GIconClass = struct _GIconClass; 39 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 40 41 42 #ifndef DOXYGEN_SHOULD_SKIP_THIS 43 namespace Gio 44 { class GIOMM_API Icon_Class; } // namespace Gio 45 #endif // DOXYGEN_SHOULD_SKIP_THIS 46 47 namespace Gio 48 { 49 50 /** This is a very minimal interface for icons. 51 * It provides functions for checking the equality of two icons, 52 * hashing of icons and serializing an icon to and from strings and Variants. 53 * 54 * Gio::Icon does not provide the actual pixmap for the icon as this is out 55 * of GIO's scope. However implementations of Icon may contain the name of an 56 * icon (see ThemedIcon), or the path to an icon (see LoadableIcon). 57 * 58 * To obtain a hash of an Icon instance, see hash(). 59 * 60 * To check if two Icon instances are equal, see equal(). 61 * 62 * For serializing an Icon, use serialize() and deserialize(). 63 * 64 * @newin{2,16} 65 */ 66 67 class GIOMM_API Icon : public Glib::Interface 68 { 69 70 #ifndef DOXYGEN_SHOULD_SKIP_THIS 71 72 public: 73 using CppObjectType = Icon; 74 using CppClassType = Icon_Class; 75 using BaseObjectType = GIcon; 76 using BaseClassType = GIconIface; 77 78 // noncopyable 79 Icon(const Icon&) = delete; 80 Icon& operator=(const Icon&) = delete; 81 82 private: 83 friend class Icon_Class; 84 static CppClassType icon_class_; 85 86 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 87 protected: 88 /** 89 * You should derive from this class to use it. 90 */ 91 Icon(); 92 93 #ifndef DOXYGEN_SHOULD_SKIP_THIS 94 /** Called by constructors of derived classes. Provide the result of 95 * the Class init() function to ensure that it is properly 96 * initialized. 97 * 98 * @param interface_class The Class object for the derived type. 99 */ 100 explicit Icon(const Glib::Interface_Class& interface_class); 101 102 public: 103 // This is public so that C++ wrapper instances can be 104 // created for C instances of unwrapped types. 105 // For instance, if an unexpected C type implements the C interface. 106 explicit Icon(GIcon* castitem); 107 108 protected: 109 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 110 111 public: 112 113 Icon(Icon&& src) noexcept; 114 Icon& operator=(Icon&& src) noexcept; 115 116 ~Icon() noexcept override; 117 118 static void add_interface(GType gtype_implementer); 119 120 /** Get the GType for this class, for use with the underlying GObject type system. 121 */ 122 static GType get_type() G_GNUC_CONST; 123 124 #ifndef DOXYGEN_SHOULD_SKIP_THIS 125 static GType get_base_type() G_GNUC_CONST; 126 #endif 127 128 ///Provides access to the underlying C GObject. gobj()129 GIcon* gobj() { return reinterpret_cast<GIcon*>(gobject_); } 130 131 ///Provides access to the underlying C GObject. gobj()132 const GIcon* gobj() const { return reinterpret_cast<GIcon*>(gobject_); } 133 134 private: 135 136 137 public: 138 // We can't just use a _WRAP_CREATE macro here since this is an abstract 139 // interface class, so implement it by hand 140 /** Generate an Icon instance from @a str. 141 * 142 * This function can fail if @a str is not valid. See to_string() for discussion. 143 * 144 * If your application or library provides one or more Icon 145 * implementations, you need to ensure that each GType is registered 146 * with the type system prior to calling create(). 147 * 148 * @newin{2,20} 149 * 150 * @param str A string obtained via to_string(). 151 * @return An object implementing the Icon interface, or throws an exception. 152 * @throw Gio::Error 153 */ 154 static Glib::RefPtr<Icon> create(const std::string& str); 155 156 157 /** Gets a hash for an icon. 158 * 159 * Virtual: hash 160 * 161 * @return A <tt>unsigned int</tt> containing a hash for the @a icon, suitable for 162 * use in a HashTable or similar data structure. 163 */ 164 guint hash() const; 165 166 /** Generates a textual representation of @a icon that can be used for 167 * serialization such as when passing @a icon to a different process or 168 * saving it to persistent storage. Use g_icon_new_for_string() to 169 * get @a icon back from the returned string. 170 * 171 * The encoding of the returned string is proprietary to Icon except 172 * in the following two cases 173 * 174 * - If @a icon is a FileIcon, the returned string is a native path 175 * (such as `/path/to/my icon.png`) without escaping 176 * if the File for @a icon is a native file. If the file is not 177 * native, the returned string is the result of g_file_get_uri() 178 * (such as `sftp://path/to/my%20icon.png`). 179 * 180 * - If @a icon is a ThemedIcon with exactly one name and no fallbacks, 181 * the encoding is simply the name (such as `network-server`). 182 * 183 * Virtual: to_tokens 184 * @newin{2,20} 185 * 186 * @return An allocated NUL-terminated UTF8 string or 187 * <tt>nullptr</tt> if @a icon can't be serialized. 188 */ 189 std::string to_string() const; 190 191 192 // TODO: should this, and File's equal(), be virtual, in order to 193 // be available to derived classes? 194 bool equal(const Glib::RefPtr<Icon>& other) const; 195 196 197 /** Serializes a Icon into a Variant. An equivalent Icon can be retrieved 198 * back by calling g_icon_deserialize() on the returned value. 199 * As serialization will avoid using raw icon data when possible, it only 200 * makes sense to transfer the Variant between processes on the same machine, 201 * (as opposed to over the network), and within the same file system namespace. 202 * 203 * @newin{2,48} 204 * 205 * @return A Variant, or <tt>nullptr</tt> when serialization fails. 206 */ 207 Glib::VariantBase serialize() const; 208 209 /** Deserializes a Icon previously serialized using g_icon_serialize(). 210 * 211 * @newin{2,48} 212 * 213 * @param value A Variant created with g_icon_serialize(). 214 * @return A Icon, or <tt>nullptr</tt> when deserialization fails. 215 */ 216 static Glib::RefPtr<Icon> deserialize(const Glib::VariantBase& value); 217 218 //_WRAP_VFUNC(guint hash() const, "hash") 219 220 // TODO: also kind of related to equal() being virtual or not, 221 // do we need to have equal_vfunc()? Or rather, why would we want 222 // to have it generally... 223 224 225 public: 226 227 public: 228 //C++ methods used to invoke GTK+ virtual functions: 229 230 protected: 231 //GTK+ Virtual Functions (override these to change behaviour): 232 233 //Default Signal Handlers:: 234 235 236 }; 237 238 } // namespace Gio 239 240 241 namespace Glib 242 { 243 /** A Glib::wrap() method for this object. 244 * 245 * @param object The C instance. 246 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 247 * @result A C++ instance that wraps this C instance. 248 * 249 * @relates Gio::Icon 250 */ 251 GIOMM_API 252 Glib::RefPtr<Gio::Icon> wrap(GIcon* object, bool take_copy = false); 253 254 } // namespace Glib 255 256 257 #endif /* _GIOMM_ICON_H */ 258 259