| 1 |
/* Copyright (C) 2003 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <vector> |
| 18 |
|
| 19 |
#include <gtkmm/stylecontext.h> |
| 20 |
#include <gdkmm/rectangle.h> |
| 21 |
#include <gdkmm/pixbuf.h> |
| 22 |
#include <gdkmm/rgba.h> |
| 23 |
#include <gdkmm/types.h> |
| 24 |
#include <giomm/asyncresult.h> |
| 25 |
#include <giomm/cancellable.h> |
| 26 |
|
| 27 |
_DEFS(gtkmm,gtk) |
| 28 |
|
| 29 |
namespace Gtk |
| 30 |
{ |
| 31 |
|
| 32 |
class GTKMM_API IconTheme; |
| 33 |
|
| 34 |
class GTKMM_API IconInfo |
| 35 |
{ |
| 36 |
_CLASS_BOXEDTYPE(IconInfo, GtkIconInfo, NONE, gtk_icon_info_ref, g_object_unref, GTKMM_API) |
| 37 |
_IGNORE(gtk_icon_info_get_attach_points, gtk_icon_info_copy, gtk_icon_info_free) |
| 38 |
public: |
| 39 |
|
| 40 |
IconInfo(const Glib::RefPtr<IconTheme>& icon_theme, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf); |
| 41 |
_IGNORE(gtk_icon_info_new_for_pixbuf) |
| 42 |
|
| 43 |
_DEPRECATE_IFDEF_START |
| 44 |
/** This typedef is just to make it more obvious that |
| 45 |
* our operator const void* should be used like operator bool(). |
| 46 |
* |
| 47 |
* @deprecated Use the explicit operator bool() instead. |
| 48 |
*/ |
| 49 |
typedef const void* BoolExpr; |
| 50 |
|
| 51 |
/** Tests whether the IconInfo is valid. |
| 52 |
* For instance, |
| 53 |
* @code |
| 54 |
* if(iconinfo) |
| 55 |
* do_something() |
| 56 |
* @endcode |
| 57 |
* |
| 58 |
* @deprecated Use the explicit operator bool() instead. |
| 59 |
*/ |
| 60 |
operator BoolExpr() const; |
| 61 |
_DEPRECATE_IFDEF_END |
| 62 |
|
| 63 |
/** Tests whether the IconInfo is valid. |
| 64 |
* |
| 65 |
* @newin{3,22} |
| 66 |
*/ |
| 67 |
explicit operator bool() const; |
| 68 |
|
| 69 |
_WRAP_METHOD(int get_base_size() const, gtk_icon_info_get_base_size) |
| 70 |
_WRAP_METHOD(int get_base_scale() const, gtk_icon_info_get_base_scale) |
| 71 |
|
| 72 |
_WRAP_METHOD(Glib::ustring get_filename() const, gtk_icon_info_get_filename) |
| 73 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_builtin_pixbuf(), gtk_icon_info_get_builtin_pixbuf, refreturn, |
| 74 |
deprecated "Use Gtk::IconTheme::add_resource_path() instead of builtin icons.") |
| 75 |
_WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_builtin_pixbuf() const, gtk_icon_info_get_builtin_pixbuf, refreturn, constversion, |
| 76 |
deprecated "Use Gtk::IconTheme::add_resource_path() instead of builtin icons.") |
| 77 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon() const, gtk_icon_info_load_icon, errthrow) |
| 78 |
|
| 79 |
#m4 _CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::Surface>',`::Cairo::RefPtr< ::Cairo::Surface>(new Cairo::Surface($3, true /* do not take reference */))') |
| 80 |
_WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> load_surface(const Glib::RefPtr<Gdk::Window>& for_window), gtk_icon_info_load_surface, errthrow) |
| 81 |
|
| 82 |
//TODO: Documentation |
| 83 |
Glib::RefPtr<Gdk::Pixbuf> load_symbolic(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& warning_color, const Gdk::RGBA& error_color, bool& was_symbolic) const; |
| 84 |
_IGNORE(gtk_icon_info_load_symbolic) |
| 85 |
|
| 86 |
_IGNORE(gtk_icon_info_load_symbolic_for_style) //deprecated |
| 87 |
|
| 88 |
/** Asynchronously load, render and scale an icon previously looked up from the icon theme using Gtk::IconTheme::lookup_icon(). |
| 89 |
* |
| 90 |
* @param slot A callback slot to call when the request is satisfied. |
| 91 |
* @param cancellable A Cancellable object which can be used to cancel the operation. |
| 92 |
* |
| 93 |
* @newin{3,8} |
| 94 |
*/ |
| 95 |
void load_icon_async(const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::Cancellable>& cancellable); |
| 96 |
|
| 97 |
/** Asynchronously load, render and scale an icon previously looked up from the icon theme using Gtk::IconTheme::lookup_icon(). |
| 98 |
* |
| 99 |
* @param slot A callback slot to call when the request is satisfied. |
| 100 |
* |
| 101 |
* @newin{3,8} |
| 102 |
*/ |
| 103 |
void load_icon_async(const Gio::SlotAsyncReady& slot); |
| 104 |
_IGNORE(gtk_icon_info_load_icon_async) |
| 105 |
|
| 106 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_icon_finish(const Glib::RefPtr<Gio::AsyncResult>& result), gtk_icon_info_load_icon_finish, errthrow) |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
/** Loads an icon, modifying it to match the system colors for the foreground, success, warning and error colors provided. |
| 111 |
* If the icon is not a symbolic one, this method will return the result from load_icon(). |
| 112 |
* This method uses the regular foreground color and the symbolic colors with the names "success_color", |
| 113 |
* "warning_color" and "error_color" from the context. |
| 114 |
* |
| 115 |
* This allows loading symbolic icons that will match the system theme. |
| 116 |
* |
| 117 |
* @param style A StyleContext. |
| 118 |
* @param was_symbolic Whether the loaded icon was a symbolic one and whether the fg color was applied to it. |
| 119 |
*/ |
| 120 |
Glib::RefPtr<Gdk::Pixbuf> load_symbolic(const Glib::RefPtr<StyleContext>& style, bool& was_symbolic); |
| 121 |
_IGNORE(gtk_icon_info_load_symbolic_for_context) |
| 122 |
|
| 123 |
//TODO: When we can break ABI: Rename these to load_symbolic_async(), or rename load_symbolic(context) to load_symbolic_for_context() for consistency. |
| 124 |
/** Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using Gtk::IconTheme::lookup_icon(). |
| 125 |
* For more details, see load_symbolic() which is the synchronous version of this call. |
| 126 |
* |
| 127 |
* @param context A StyleContext. |
| 128 |
* @param slot A callback slot to call when the request is satisfied. |
| 129 |
* @param cancellable A Cancellable object which can be used to cancel the operation. |
| 130 |
* |
| 131 |
* @newin{3,8} |
| 132 |
*/ |
| 133 |
void load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::Cancellable>& cancellable); |
| 134 |
|
| 135 |
/** Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using Gtk::IconTheme::lookup_icon(). |
| 136 |
* For more details, see load_symbolic() which is the synchronous version of this call. |
| 137 |
* |
| 138 |
* @param context A StyleContext. |
| 139 |
* @param slot A callback slot to call when the request is satisfied. |
| 140 |
* |
| 141 |
* @newin{3,8} |
| 142 |
*/ |
| 143 |
void load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context, const Gio::SlotAsyncReady& slot); |
| 144 |
_IGNORE(gtk_icon_info_load_symbolic_for_context_async) |
| 145 |
|
| 146 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_symbolic_for_context_finish(const Glib::RefPtr<Gio::AsyncResult>& result, bool& was_symbolic), gtk_icon_info_load_symbolic_for_context_finish, errthrow) |
| 147 |
|
| 148 |
|
| 149 |
//TODO: In gtk_icon_info_load_symbolic_async(), each GdkRGBA* can be NULL, but we do not want that many method overloads. |
| 150 |
//TODO: Documentation. |
| 151 |
void load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot, const Glib::RefPtr<Gio::Cancellable>& cancellable); |
| 152 |
void load_symbolic_async(const Gdk::RGBA& fg, const Gdk::RGBA& success_color, const Gdk::RGBA& warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot); |
| 153 |
_IGNORE(gtk_icon_info_load_symbolic_async) |
| 154 |
|
| 155 |
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> load_symbolic_finish(const Glib::RefPtr<Gio::AsyncResult>& result, bool& was_symbolic), gtk_icon_info_load_symbolic_finish, errthrow) |
| 156 |
|
| 157 |
|
| 158 |
_WRAP_METHOD(void set_raw_coordinates(bool raw_coordinates = true), gtk_icon_info_set_raw_coordinates, deprecated "Embedded rectangles and attachment points are deprecated.") |
| 159 |
_WRAP_METHOD(bool get_embedded_rect(Gdk::Rectangle& rectangle) const, gtk_icon_info_get_embedded_rect, deprecated "Embedded rectangles are deprecated.") |
| 160 |
|
| 161 |
_DEPRECATE_IFDEF_START |
| 162 |
/** |
| 163 |
* @deprecated Attachment points are deprecated. |
| 164 |
*/ |
| 165 |
std::vector<Gdk::Point> get_attach_points() const; |
| 166 |
_DEPRECATE_IFDEF_END |
| 167 |
|
| 168 |
_WRAP_METHOD(Glib::ustring get_display_name() const, gtk_icon_info_get_display_name, deprecated "Display names are deprecated.") |
| 169 |
|
| 170 |
_WRAP_METHOD(bool is_symbolic() const, gtk_icon_info_is_symbolic) |
| 171 |
}; |
| 172 |
|
| 173 |
} // namespace Gtk |