1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis 3 * 4 * gimpviewable.h 5 * Copyright (C) 2001 Michael Natterer <mitch@gimp.org> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __GIMP_VIEWABLE_H__ 22 #define __GIMP_VIEWABLE_H__ 23 24 25 #include "gimpobject.h" 26 27 28 #define GIMP_VIEWABLE_MAX_PREVIEW_SIZE 2048 29 #define GIMP_VIEWABLE_MAX_POPUP_SIZE 256 30 #define GIMP_VIEWABLE_MAX_BUTTON_SIZE 64 31 #define GIMP_VIEWABLE_MAX_MENU_SIZE 48 32 33 34 #define GIMP_TYPE_VIEWABLE (gimp_viewable_get_type ()) 35 #define GIMP_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VIEWABLE, GimpViewable)) 36 #define GIMP_VIEWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VIEWABLE, GimpViewableClass)) 37 #define GIMP_IS_VIEWABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VIEWABLE)) 38 #define GIMP_IS_VIEWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VIEWABLE)) 39 #define GIMP_VIEWABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VIEWABLE, GimpViewableClass)) 40 41 42 typedef struct _GimpViewableClass GimpViewableClass; 43 44 struct _GimpViewable 45 { 46 GimpObject parent_instance; 47 }; 48 49 struct _GimpViewableClass 50 { 51 GimpObjectClass parent_class; 52 53 const gchar *default_icon_name; 54 const gchar *name_changed_signal; 55 gboolean name_editable; 56 57 /* signals */ 58 void (* invalidate_preview) (GimpViewable *viewable); 59 void (* size_changed) (GimpViewable *viewable); 60 void (* expanded_changed) (GimpViewable *viewable); 61 void (* ancestry_changed) (GimpViewable *viewable); 62 63 /* virtual functions */ 64 gboolean (* get_size) (GimpViewable *viewable, 65 gint *width, 66 gint *height); 67 void (* get_preview_size) (GimpViewable *viewable, 68 gint size, 69 gboolean is_popup, 70 gboolean dot_for_dot, 71 gint *width, 72 gint *height); 73 gboolean (* get_popup_size) (GimpViewable *viewable, 74 gint width, 75 gint height, 76 gboolean dot_for_dot, 77 gint *popup_width, 78 gint *popup_height); 79 GimpTempBuf * (* get_preview) (GimpViewable *viewable, 80 GimpContext *context, 81 gint width, 82 gint height); 83 GimpTempBuf * (* get_new_preview) (GimpViewable *viewable, 84 GimpContext *context, 85 gint width, 86 gint height); 87 GdkPixbuf * (* get_pixbuf) (GimpViewable *viewable, 88 GimpContext *context, 89 gint width, 90 gint height); 91 GdkPixbuf * (* get_new_pixbuf) (GimpViewable *viewable, 92 GimpContext *context, 93 gint width, 94 gint height); 95 gchar * (* get_description) (GimpViewable *viewable, 96 gchar **tooltip); 97 98 gboolean (* is_name_editable) (GimpViewable *viewable); 99 100 void (* preview_freeze) (GimpViewable *viewable); 101 void (* preview_thaw) (GimpViewable *viewable); 102 103 GimpContainer * (* get_children) (GimpViewable *viewable); 104 105 void (* set_expanded) (GimpViewable *viewable, 106 gboolean expand); 107 gboolean (* get_expanded) (GimpViewable *viewable); 108 }; 109 110 111 GType gimp_viewable_get_type (void) G_GNUC_CONST; 112 113 void gimp_viewable_invalidate_preview (GimpViewable *viewable); 114 void gimp_viewable_size_changed (GimpViewable *viewable); 115 void gimp_viewable_expanded_changed (GimpViewable *viewable); 116 117 void gimp_viewable_calc_preview_size (gint aspect_width, 118 gint aspect_height, 119 gint width, 120 gint height, 121 gboolean dot_for_dot, 122 gdouble xresolution, 123 gdouble yresolution, 124 gint *return_width, 125 gint *return_height, 126 gboolean *scaling_up); 127 128 gboolean gimp_viewable_get_size (GimpViewable *viewable, 129 gint *width, 130 gint *height); 131 void gimp_viewable_get_preview_size (GimpViewable *viewable, 132 gint size, 133 gboolean popup, 134 gboolean dot_for_dot, 135 gint *width, 136 gint *height); 137 gboolean gimp_viewable_get_popup_size (GimpViewable *viewable, 138 gint width, 139 gint height, 140 gboolean dot_for_dot, 141 gint *popup_width, 142 gint *popup_height); 143 144 GimpTempBuf * gimp_viewable_get_preview (GimpViewable *viewable, 145 GimpContext *context, 146 gint width, 147 gint height); 148 GimpTempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable, 149 GimpContext *context, 150 gint width, 151 gint height); 152 153 GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable, 154 gint width, 155 gint height, 156 const Babl *format); 157 158 GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable, 159 GimpContext *context, 160 gint width, 161 gint height); 162 GdkPixbuf * gimp_viewable_get_new_pixbuf (GimpViewable *viewable, 163 GimpContext *context, 164 gint width, 165 gint height); 166 167 GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable, 168 gint width, 169 gint height, 170 gboolean with_alpha); 171 172 gchar * gimp_viewable_get_description (GimpViewable *viewable, 173 gchar **tooltip); 174 175 gboolean gimp_viewable_is_name_editable (GimpViewable *viewable); 176 177 const gchar * gimp_viewable_get_icon_name (GimpViewable *viewable); 178 void gimp_viewable_set_icon_name (GimpViewable *viewable, 179 const gchar *icon_name); 180 181 void gimp_viewable_preview_freeze (GimpViewable *viewable); 182 void gimp_viewable_preview_thaw (GimpViewable *viewable); 183 gboolean gimp_viewable_preview_is_frozen (GimpViewable *viewable); 184 185 GimpViewable * gimp_viewable_get_parent (GimpViewable *viewable); 186 void gimp_viewable_set_parent (GimpViewable *viewable, 187 GimpViewable *parent); 188 189 gint gimp_viewable_get_depth (GimpViewable *viewable); 190 191 GimpContainer * gimp_viewable_get_children (GimpViewable *viewable); 192 193 gboolean gimp_viewable_get_expanded (GimpViewable *viewable); 194 void gimp_viewable_set_expanded (GimpViewable *viewable, 195 gboolean expanded); 196 197 gboolean gimp_viewable_is_ancestor (GimpViewable *ancestor, 198 GimpViewable *descendant); 199 200 201 #endif /* __GIMP_VIEWABLE_H__ */ 202