1/* gtkiconview.h
2 * Copyright (C) 2002, 2004 Anders Carlsson <andersca@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __GTK_ICON_VIEW_H__
19#define __GTK_ICON_VIEW_H__
20
21#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22#error "Only <gtk/gtk.h> can be included directly."
23#endif
24
25#include <gtk/gtkcontainer.h>
26#include <gtk/gtktreemodel.h>
27#include <gtk/gtkcellrenderer.h>
28#include <gtk/gtkcellarea.h>
29#include <gtk/gtkselection.h>
30#include <gtk/gtktooltip.h>
31
32G_BEGIN_DECLS
33
34#define GTK_TYPE_ICON_VIEW (gtk_icon_view_get_type ())
35#define GTK_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW, GtkIconView))
36#define GTK_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
37#define GTK_IS_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW))
38#define GTK_IS_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_VIEW))
39#define GTK_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
40
41typedef struct _GtkIconView GtkIconView;
42typedef struct _GtkIconViewClass GtkIconViewClass;
43typedef struct _GtkIconViewPrivate GtkIconViewPrivate;
44
45/**
46 * GtkIconViewForeachFunc:
47 * @icon_view: a #GtkIconView
48 * @path: The #GtkTreePath of a selected row
49 * @data: (closure): user data
50 *
51 * A function used by gtk_icon_view_selected_foreach() to map all
52 * selected rows. It will be called on every selected row in the view.
53 */
54typedef void (* GtkIconViewForeachFunc) (GtkIconView *icon_view,
55 GtkTreePath *path,
56 gpointer data);
57
58/**
59 * GtkIconViewDropPosition:
60 * @GTK_ICON_VIEW_NO_DROP: no drop possible
61 * @GTK_ICON_VIEW_DROP_INTO: dropped item replaces the item
62 * @GTK_ICON_VIEW_DROP_LEFT: droppped item is inserted to the left
63 * @GTK_ICON_VIEW_DROP_RIGHT: dropped item is inserted to the right
64 * @GTK_ICON_VIEW_DROP_ABOVE: dropped item is inserted above
65 * @GTK_ICON_VIEW_DROP_BELOW: dropped item is inserted below
66 *
67 * An enum for determining where a dropped item goes.
68 */
69typedef enum
70{
71 GTK_ICON_VIEW_NO_DROP,
72 GTK_ICON_VIEW_DROP_INTO,
73 GTK_ICON_VIEW_DROP_LEFT,
74 GTK_ICON_VIEW_DROP_RIGHT,
75 GTK_ICON_VIEW_DROP_ABOVE,
76 GTK_ICON_VIEW_DROP_BELOW
77} GtkIconViewDropPosition;
78
79struct _GtkIconView
80{
81 GtkContainer parent;
82
83 /*< private >*/
84 GtkIconViewPrivate *priv;
85};
86
87struct _GtkIconViewClass
88{
89 GtkContainerClass parent_class;
90
91 void (* item_activated) (GtkIconView *icon_view,
92 GtkTreePath *path);
93 void (* selection_changed) (GtkIconView *icon_view);
94
95 /* Key binding signals */
96 void (* select_all) (GtkIconView *icon_view);
97 void (* unselect_all) (GtkIconView *icon_view);
98 void (* select_cursor_item) (GtkIconView *icon_view);
99 void (* toggle_cursor_item) (GtkIconView *icon_view);
100 gboolean (* move_cursor) (GtkIconView *icon_view,
101 GtkMovementStep step,
102 gint count);
103 gboolean (* activate_cursor_item) (GtkIconView *icon_view);
104
105 /* Padding for future expansion */
106 void (*_gtk_reserved1) (void);
107 void (*_gtk_reserved2) (void);
108 void (*_gtk_reserved3) (void);
109 void (*_gtk_reserved4) (void);
110};
111
112GDK_AVAILABLE_IN_ALL
113GType gtk_icon_view_get_type (void) G_GNUC_CONST;
114GDK_AVAILABLE_IN_ALL
115GtkWidget * gtk_icon_view_new (void);
116GDK_AVAILABLE_IN_ALL
117GtkWidget * gtk_icon_view_new_with_area (GtkCellArea *area);
118GDK_AVAILABLE_IN_ALL
119GtkWidget * gtk_icon_view_new_with_model (GtkTreeModel *model);
120
121GDK_AVAILABLE_IN_ALL
122void gtk_icon_view_set_model (GtkIconView *icon_view,
123 GtkTreeModel *model);
124GDK_AVAILABLE_IN_ALL
125GtkTreeModel * gtk_icon_view_get_model (GtkIconView *icon_view);
126GDK_AVAILABLE_IN_ALL
127void gtk_icon_view_set_text_column (GtkIconView *icon_view,
128 gint column);
129GDK_AVAILABLE_IN_ALL
130gint gtk_icon_view_get_text_column (GtkIconView *icon_view);
131GDK_AVAILABLE_IN_ALL
132void gtk_icon_view_set_markup_column (GtkIconView *icon_view,
133 gint column);
134GDK_AVAILABLE_IN_ALL
135gint gtk_icon_view_get_markup_column (GtkIconView *icon_view);
136GDK_AVAILABLE_IN_ALL
137void gtk_icon_view_set_pixbuf_column (GtkIconView *icon_view,
138 gint column);
139GDK_AVAILABLE_IN_ALL
140gint gtk_icon_view_get_pixbuf_column (GtkIconView *icon_view);
141
142GDK_AVAILABLE_IN_ALL
143void gtk_icon_view_set_item_orientation (GtkIconView *icon_view,
144 GtkOrientation orientation);
145GDK_AVAILABLE_IN_ALL
146GtkOrientation gtk_icon_view_get_item_orientation (GtkIconView *icon_view);
147GDK_AVAILABLE_IN_ALL
148void gtk_icon_view_set_columns (GtkIconView *icon_view,
149 gint columns);
150GDK_AVAILABLE_IN_ALL
151gint gtk_icon_view_get_columns (GtkIconView *icon_view);
152GDK_AVAILABLE_IN_ALL
153void gtk_icon_view_set_item_width (GtkIconView *icon_view,
154 gint item_width);
155GDK_AVAILABLE_IN_ALL
156gint gtk_icon_view_get_item_width (GtkIconView *icon_view);
157GDK_AVAILABLE_IN_ALL
158void gtk_icon_view_set_spacing (GtkIconView *icon_view,
159 gint spacing);
160GDK_AVAILABLE_IN_ALL
161gint gtk_icon_view_get_spacing (GtkIconView *icon_view);
162GDK_AVAILABLE_IN_ALL
163void gtk_icon_view_set_row_spacing (GtkIconView *icon_view,
164 gint row_spacing);
165GDK_AVAILABLE_IN_ALL
166gint gtk_icon_view_get_row_spacing (GtkIconView *icon_view);
167GDK_AVAILABLE_IN_ALL
168void gtk_icon_view_set_column_spacing (GtkIconView *icon_view,
169 gint column_spacing);
170GDK_AVAILABLE_IN_ALL
171gint gtk_icon_view_get_column_spacing (GtkIconView *icon_view);
172GDK_AVAILABLE_IN_ALL
173void gtk_icon_view_set_margin (GtkIconView *icon_view,
174 gint margin);
175GDK_AVAILABLE_IN_ALL
176gint gtk_icon_view_get_margin (GtkIconView *icon_view);
177GDK_AVAILABLE_IN_ALL
178void gtk_icon_view_set_item_padding (GtkIconView *icon_view,
179 gint item_padding);
180GDK_AVAILABLE_IN_ALL
181gint gtk_icon_view_get_item_padding (GtkIconView *icon_view);
182
183GDK_AVAILABLE_IN_ALL
184GtkTreePath * gtk_icon_view_get_path_at_pos (GtkIconView *icon_view,
185 gint x,
186 gint y);
187GDK_AVAILABLE_IN_ALL
188gboolean gtk_icon_view_get_item_at_pos (GtkIconView *icon_view,
189 gint x,
190 gint y,
191 GtkTreePath **path,
192 GtkCellRenderer **cell);
193GDK_AVAILABLE_IN_ALL
194gboolean gtk_icon_view_get_visible_range (GtkIconView *icon_view,
195 GtkTreePath **start_path,
196 GtkTreePath **end_path);
197GDK_AVAILABLE_IN_3_8
198void gtk_icon_view_set_activate_on_single_click (GtkIconView *icon_view,
199 gboolean single);
200GDK_AVAILABLE_IN_3_8
201gboolean gtk_icon_view_get_activate_on_single_click (GtkIconView *icon_view);
202
203GDK_AVAILABLE_IN_ALL
204void gtk_icon_view_selected_foreach (GtkIconView *icon_view,
205 GtkIconViewForeachFunc func,
206 gpointer data);
207GDK_AVAILABLE_IN_ALL
208void gtk_icon_view_set_selection_mode (GtkIconView *icon_view,
209 GtkSelectionMode mode);
210GDK_AVAILABLE_IN_ALL
211GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView *icon_view);
212GDK_AVAILABLE_IN_ALL
213void gtk_icon_view_select_path (GtkIconView *icon_view,
214 GtkTreePath *path);
215GDK_AVAILABLE_IN_ALL
216void gtk_icon_view_unselect_path (GtkIconView *icon_view,
217 GtkTreePath *path);
218GDK_AVAILABLE_IN_ALL
219gboolean gtk_icon_view_path_is_selected (GtkIconView *icon_view,
220 GtkTreePath *path);
221GDK_AVAILABLE_IN_ALL
222gint gtk_icon_view_get_item_row (GtkIconView *icon_view,
223 GtkTreePath *path);
224GDK_AVAILABLE_IN_ALL
225gint gtk_icon_view_get_item_column (GtkIconView *icon_view,
226 GtkTreePath *path);
227GDK_AVAILABLE_IN_ALL
228GList *gtk_icon_view_get_selected_items (GtkIconView *icon_view);
229GDK_AVAILABLE_IN_ALL
230void gtk_icon_view_select_all (GtkIconView *icon_view);
231GDK_AVAILABLE_IN_ALL
232void gtk_icon_view_unselect_all (GtkIconView *icon_view);
233GDK_AVAILABLE_IN_ALL
234void gtk_icon_view_item_activated (GtkIconView *icon_view,
235 GtkTreePath *path);
236GDK_AVAILABLE_IN_ALL
237void gtk_icon_view_set_cursor (GtkIconView *icon_view,
238 GtkTreePath *path,
239 GtkCellRenderer *cell,
240 gboolean start_editing);
241GDK_AVAILABLE_IN_ALL
242gboolean gtk_icon_view_get_cursor (GtkIconView *icon_view,
243 GtkTreePath **path,
244 GtkCellRenderer **cell);
245GDK_AVAILABLE_IN_ALL
246void gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
247 GtkTreePath *path,
248 gboolean use_align,
249 gfloat row_align,
250 gfloat col_align);
251
252/* Drag-and-Drop support */
253GDK_AVAILABLE_IN_ALL
254void gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
255 GdkModifierType start_button_mask,
256 const GtkTargetEntry *targets,
257 gint n_targets,
258 GdkDragAction actions);
259GDK_AVAILABLE_IN_ALL
260void gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
261 const GtkTargetEntry *targets,
262 gint n_targets,
263 GdkDragAction actions);
264GDK_AVAILABLE_IN_ALL
265void gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view);
266GDK_AVAILABLE_IN_ALL
267void gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view);
268GDK_AVAILABLE_IN_ALL
269void gtk_icon_view_set_reorderable (GtkIconView *icon_view,
270 gboolean reorderable);
271GDK_AVAILABLE_IN_ALL
272gboolean gtk_icon_view_get_reorderable (GtkIconView *icon_view);
273
274
275/* These are useful to implement your own custom stuff. */
276GDK_AVAILABLE_IN_ALL
277void gtk_icon_view_set_drag_dest_item (GtkIconView *icon_view,
278 GtkTreePath *path,
279 GtkIconViewDropPosition pos);
280GDK_AVAILABLE_IN_ALL
281void gtk_icon_view_get_drag_dest_item (GtkIconView *icon_view,
282 GtkTreePath **path,
283 GtkIconViewDropPosition *pos);
284GDK_AVAILABLE_IN_ALL
285gboolean gtk_icon_view_get_dest_item_at_pos (GtkIconView *icon_view,
286 gint drag_x,
287 gint drag_y,
288 GtkTreePath **path,
289 GtkIconViewDropPosition *pos);
290GDK_AVAILABLE_IN_ALL
291cairo_surface_t *gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
292 GtkTreePath *path);
293
294GDK_AVAILABLE_IN_ALL
295void gtk_icon_view_convert_widget_to_bin_window_coords (GtkIconView *icon_view,
296 gint wx,
297 gint wy,
298 gint *bx,
299 gint *by);
300GDK_AVAILABLE_IN_3_6
301gboolean gtk_icon_view_get_cell_rect (GtkIconView *icon_view,
302 GtkTreePath *path,
303 GtkCellRenderer *cell,
304 GdkRectangle *rect);
305
306
307GDK_AVAILABLE_IN_ALL
308void gtk_icon_view_set_tooltip_item (GtkIconView *icon_view,
309 GtkTooltip *tooltip,
310 GtkTreePath *path);
311GDK_AVAILABLE_IN_ALL
312void gtk_icon_view_set_tooltip_cell (GtkIconView *icon_view,
313 GtkTooltip *tooltip,
314 GtkTreePath *path,
315 GtkCellRenderer *cell);
316GDK_AVAILABLE_IN_ALL
317gboolean gtk_icon_view_get_tooltip_context (GtkIconView *icon_view,
318 gint *x,
319 gint *y,
320 gboolean keyboard_tip,
321 GtkTreeModel **model,
322 GtkTreePath **path,
323 GtkTreeIter *iter);
324GDK_AVAILABLE_IN_ALL
325void gtk_icon_view_set_tooltip_column (GtkIconView *icon_view,
326 gint column);
327GDK_AVAILABLE_IN_ALL
328gint gtk_icon_view_get_tooltip_column (GtkIconView *icon_view);
329
330
331G_END_DECLS
332
333#endif /* __GTK_ICON_VIEW_H__ */
334