gtkiconview.h 14.6 KB
Newer Older
1
/* gtkiconview.h
2
 * Copyright (C) 2002, 2004  Anders Carlsson <andersca@gnome.org>
Anders Carlsson's avatar
Anders Carlsson committed
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
Anders Carlsson's avatar
Anders Carlsson committed
16
 */
17

18 19 20
#ifndef __GTK_ICON_VIEW_H__
#define __GTK_ICON_VIEW_H__

21
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
22 23 24
#error "Only <gtk/gtk.h> can be included directly."
#endif

Anders Carlsson's avatar
Anders Carlsson committed
25
#include <gtk/gtkcontainer.h>
26
#include <gtk/gtktreemodel.h>
Matthias Clasen's avatar
Matthias Clasen committed
27
#include <gtk/gtkcellrenderer.h>
28
#include <gtk/gtkcellarea.h>
Matthias Clasen's avatar
Matthias Clasen committed
29
#include <gtk/gtkselection.h>
30
#include <gtk/gtktooltip.h>
Anders Carlsson's avatar
Anders Carlsson committed
31 32 33

G_BEGIN_DECLS

34 35 36 37 38 39
#define GTK_TYPE_ICON_VIEW            (gtk_icon_view_get_type ())
#define GTK_ICON_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW, GtkIconView))
#define GTK_ICON_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
#define GTK_IS_ICON_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW))
#define GTK_IS_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_VIEW))
#define GTK_ICON_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
Anders Carlsson's avatar
Anders Carlsson committed
40

41 42 43
typedef struct _GtkIconView           GtkIconView;
typedef struct _GtkIconViewClass      GtkIconViewClass;
typedef struct _GtkIconViewPrivate    GtkIconViewPrivate;
Anders Carlsson's avatar
Anders Carlsson committed
44

45 46 47 48
/**
 * GtkIconViewForeachFunc:
 * @icon_view: a #GtkIconView
 * @path: The #GtkTreePath of a selected row
49
 * @data: (closure): user data
50 51 52 53
 *
 * A function used by gtk_icon_view_selected_foreach() to map all
 * selected rows.  It will be called on every selected row in the view.
 */
54
typedef void (* GtkIconViewForeachFunc)     (GtkIconView      *icon_view,
55
					     GtkTreePath      *path,
Anders Carlsson's avatar
Anders Carlsson committed
56 57
					     gpointer          data);

58 59 60 61 62 63 64 65 66 67 68
/**
 * GtkIconViewDropPosition:
 * @GTK_ICON_VIEW_NO_DROP: no drop possible
 * @GTK_ICON_VIEW_DROP_INTO: dropped item replaces the item
 * @GTK_ICON_VIEW_DROP_LEFT: droppped item is inserted to the left
 * @GTK_ICON_VIEW_DROP_RIGHT: dropped item is inserted to the right
 * @GTK_ICON_VIEW_DROP_ABOVE: dropped item is inserted above
 * @GTK_ICON_VIEW_DROP_BELOW: dropped item is inserted below
 *
 * An enum for determining where a dropped item goes.
 */
Matthias Clasen's avatar
Matthias Clasen committed
69 70 71 72 73 74 75 76 77 78
typedef enum
{
  GTK_ICON_VIEW_NO_DROP,
  GTK_ICON_VIEW_DROP_INTO,
  GTK_ICON_VIEW_DROP_LEFT,
  GTK_ICON_VIEW_DROP_RIGHT,
  GTK_ICON_VIEW_DROP_ABOVE,
  GTK_ICON_VIEW_DROP_BELOW
} GtkIconViewDropPosition;

79
struct _GtkIconView
Anders Carlsson's avatar
Anders Carlsson committed
80 81 82
{
  GtkContainer parent;

83
  /*< private >*/
84
  GtkIconViewPrivate *priv;
Anders Carlsson's avatar
Anders Carlsson committed
85 86
};

87
struct _GtkIconViewClass
Anders Carlsson's avatar
Anders Carlsson committed
88 89 90
{
  GtkContainerClass parent_class;

91
  void    (* item_activated)         (GtkIconView      *icon_view,
92
				      GtkTreePath      *path);
93
  void    (* selection_changed)      (GtkIconView      *icon_view);
94

Anders Carlsson's avatar
Anders Carlsson committed
95
  /* Key binding signals */
96 97 98 99 100
  void    (* select_all)             (GtkIconView      *icon_view);
  void    (* unselect_all)           (GtkIconView      *icon_view);
  void    (* select_cursor_item)     (GtkIconView      *icon_view);
  void    (* toggle_cursor_item)     (GtkIconView      *icon_view);
  gboolean (* move_cursor)           (GtkIconView      *icon_view,
Matthias Clasen's avatar
Matthias Clasen committed
101 102
				      GtkMovementStep   step,
				      gint              count);
103
  gboolean (* activate_cursor_item)  (GtkIconView      *icon_view);
104 105 106 107 108 109

  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
Anders Carlsson's avatar
Anders Carlsson committed
110 111
};

112
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
113
GType          gtk_icon_view_get_type          (void) G_GNUC_CONST;
114
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
115
GtkWidget *    gtk_icon_view_new               (void);
116
GDK_AVAILABLE_IN_ALL
117
GtkWidget *    gtk_icon_view_new_with_area     (GtkCellArea    *area);
118
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
119 120
GtkWidget *    gtk_icon_view_new_with_model    (GtkTreeModel   *model);

121
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
122 123
void           gtk_icon_view_set_model         (GtkIconView    *icon_view,
 					        GtkTreeModel   *model);
124
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
125
GtkTreeModel * gtk_icon_view_get_model         (GtkIconView    *icon_view);
126
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
127 128
void           gtk_icon_view_set_text_column   (GtkIconView    *icon_view,
	 	 			        gint            column);
129
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
130
gint           gtk_icon_view_get_text_column   (GtkIconView    *icon_view);
131
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
132 133
void           gtk_icon_view_set_markup_column (GtkIconView    *icon_view,
					        gint            column);
134
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
135
gint           gtk_icon_view_get_markup_column (GtkIconView    *icon_view);
136
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
137 138
void           gtk_icon_view_set_pixbuf_column (GtkIconView    *icon_view,
					        gint            column);
139
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
140
gint           gtk_icon_view_get_pixbuf_column (GtkIconView    *icon_view);
141

142
GDK_AVAILABLE_IN_ALL
143 144
void           gtk_icon_view_set_item_orientation (GtkIconView    *icon_view,
                                                   GtkOrientation  orientation);
145
GDK_AVAILABLE_IN_ALL
146
GtkOrientation gtk_icon_view_get_item_orientation (GtkIconView    *icon_view);
147
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
148 149
void           gtk_icon_view_set_columns       (GtkIconView    *icon_view,
		 			        gint            columns);
150
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
151
gint           gtk_icon_view_get_columns       (GtkIconView    *icon_view);
152
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
153
void           gtk_icon_view_set_item_width    (GtkIconView    *icon_view,
Matthias Clasen's avatar
Matthias Clasen committed
154
					        gint            item_width);
155
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
156
gint           gtk_icon_view_get_item_width    (GtkIconView    *icon_view);
157
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
158 159
void           gtk_icon_view_set_spacing       (GtkIconView    *icon_view, 
		 			        gint            spacing);
160
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
161
gint           gtk_icon_view_get_spacing       (GtkIconView    *icon_view);
162
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
163
void           gtk_icon_view_set_row_spacing   (GtkIconView    *icon_view, 
Matthias Clasen's avatar
Matthias Clasen committed
164
					        gint            row_spacing);
165
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
166
gint           gtk_icon_view_get_row_spacing   (GtkIconView    *icon_view);
167
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
168
void           gtk_icon_view_set_column_spacing (GtkIconView    *icon_view, 
Matthias Clasen's avatar
Matthias Clasen committed
169
					        gint            column_spacing);
170
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
171
gint           gtk_icon_view_get_column_spacing (GtkIconView    *icon_view);
172
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
173
void           gtk_icon_view_set_margin        (GtkIconView    *icon_view, 
Matthias Clasen's avatar
Matthias Clasen committed
174
					        gint            margin);
175
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
176
gint           gtk_icon_view_get_margin        (GtkIconView    *icon_view);
177
GDK_AVAILABLE_IN_ALL
178 179
void           gtk_icon_view_set_item_padding  (GtkIconView    *icon_view, 
					        gint            item_padding);
180
GDK_AVAILABLE_IN_ALL
181
gint           gtk_icon_view_get_item_padding  (GtkIconView    *icon_view);
Matthias Clasen's avatar
Matthias Clasen committed
182

183
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
184 185 186
GtkTreePath *  gtk_icon_view_get_path_at_pos   (GtkIconView     *icon_view,
						gint             x,
						gint             y);
187
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
188 189 190 191 192
gboolean       gtk_icon_view_get_item_at_pos   (GtkIconView     *icon_view,
						gint              x,
						gint              y,
						GtkTreePath     **path,
						GtkCellRenderer **cell);
193
GDK_AVAILABLE_IN_ALL
194 195 196
gboolean       gtk_icon_view_get_visible_range (GtkIconView      *icon_view,
						GtkTreePath     **start_path,
						GtkTreePath     **end_path);
197 198 199 200 201
GDK_AVAILABLE_IN_3_8
void           gtk_icon_view_set_activate_on_single_click (GtkIconView  *icon_view,
                                                           gboolean      single);
GDK_AVAILABLE_IN_3_8
gboolean       gtk_icon_view_get_activate_on_single_click (GtkIconView  *icon_view);
Matthias Clasen's avatar
Matthias Clasen committed
202

203
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
204 205 206
void           gtk_icon_view_selected_foreach   (GtkIconView            *icon_view,
						 GtkIconViewForeachFunc  func,
						 gpointer                data);
207
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
208 209
void           gtk_icon_view_set_selection_mode (GtkIconView            *icon_view,
						 GtkSelectionMode        mode);
210
GDK_AVAILABLE_IN_ALL
211
GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView            *icon_view);
212
GDK_AVAILABLE_IN_ALL
213
void             gtk_icon_view_select_path        (GtkIconView            *icon_view,
214
						   GtkTreePath            *path);
215
GDK_AVAILABLE_IN_ALL
216
void             gtk_icon_view_unselect_path      (GtkIconView            *icon_view,
217
						   GtkTreePath            *path);
218
GDK_AVAILABLE_IN_ALL
219
gboolean         gtk_icon_view_path_is_selected   (GtkIconView            *icon_view,
220
						   GtkTreePath            *path);
221
GDK_AVAILABLE_IN_ALL
222 223
gint             gtk_icon_view_get_item_row       (GtkIconView            *icon_view,
                                                   GtkTreePath            *path);
224
GDK_AVAILABLE_IN_ALL
225 226
gint             gtk_icon_view_get_item_column    (GtkIconView            *icon_view,
                                                   GtkTreePath            *path);
227
GDK_AVAILABLE_IN_ALL
228
GList           *gtk_icon_view_get_selected_items (GtkIconView            *icon_view);
229
GDK_AVAILABLE_IN_ALL
230
void             gtk_icon_view_select_all         (GtkIconView            *icon_view);
231
GDK_AVAILABLE_IN_ALL
232
void             gtk_icon_view_unselect_all       (GtkIconView            *icon_view);
233
GDK_AVAILABLE_IN_ALL
234
void             gtk_icon_view_item_activated     (GtkIconView            *icon_view,
235
						   GtkTreePath            *path);
236
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
237 238 239 240
void             gtk_icon_view_set_cursor         (GtkIconView            *icon_view,
						   GtkTreePath            *path,
						   GtkCellRenderer        *cell,
						   gboolean                start_editing);
241
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
242 243 244
gboolean         gtk_icon_view_get_cursor         (GtkIconView            *icon_view,
						   GtkTreePath           **path,
						   GtkCellRenderer       **cell);
245
GDK_AVAILABLE_IN_ALL
246 247 248 249 250
void             gtk_icon_view_scroll_to_path     (GtkIconView            *icon_view,
                                                   GtkTreePath            *path,
						   gboolean                use_align,
						   gfloat                  row_align,
                                                   gfloat                  col_align);
Matthias Clasen's avatar
Matthias Clasen committed
251

Matthias Clasen's avatar
Matthias Clasen committed
252
/* Drag-and-Drop support */
253
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
254 255 256 257 258
void                   gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
							       GdkModifierType           start_button_mask,
							       const GtkTargetEntry     *targets,
							       gint                      n_targets,
							       GdkDragAction             actions);
259
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
260 261 262 263
void                   gtk_icon_view_enable_model_drag_dest   (GtkIconView              *icon_view,
							       const GtkTargetEntry     *targets,
							       gint                      n_targets,
							       GdkDragAction             actions);
264
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
265
void                   gtk_icon_view_unset_model_drag_source  (GtkIconView              *icon_view);
266
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
267
void                   gtk_icon_view_unset_model_drag_dest    (GtkIconView              *icon_view);
268
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
269 270
void                   gtk_icon_view_set_reorderable          (GtkIconView              *icon_view,
							       gboolean                  reorderable);
271
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
272 273 274 275
gboolean               gtk_icon_view_get_reorderable          (GtkIconView              *icon_view);


/* These are useful to implement your own custom stuff. */
276
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
277 278 279
void                   gtk_icon_view_set_drag_dest_item       (GtkIconView              *icon_view,
							       GtkTreePath              *path,
							       GtkIconViewDropPosition   pos);
280
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
281 282 283
void                   gtk_icon_view_get_drag_dest_item       (GtkIconView              *icon_view,
							       GtkTreePath             **path,
							       GtkIconViewDropPosition  *pos);
284
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
285 286 287 288 289
gboolean               gtk_icon_view_get_dest_item_at_pos     (GtkIconView              *icon_view,
							       gint                      drag_x,
							       gint                      drag_y,
							       GtkTreePath             **path,
							       GtkIconViewDropPosition  *pos);
290
GDK_AVAILABLE_IN_ALL
291
cairo_surface_t       *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
Matthias Clasen's avatar
Matthias Clasen committed
292 293
							       GtkTreePath              *path);

294
GDK_AVAILABLE_IN_ALL
295 296 297 298 299
void    gtk_icon_view_convert_widget_to_bin_window_coords     (GtkIconView *icon_view,
                                                               gint         wx,
                                                               gint         wy,
                                                               gint        *bx,
                                                               gint        *by);
300
GDK_AVAILABLE_IN_3_6
301
gboolean gtk_icon_view_get_cell_rect                          (GtkIconView     *icon_view,
302 303 304
							       GtkTreePath     *path,
							       GtkCellRenderer *cell,
							       GdkRectangle    *rect);
305

Matthias Clasen's avatar
Matthias Clasen committed
306

307
GDK_AVAILABLE_IN_ALL
308 309 310
void    gtk_icon_view_set_tooltip_item                        (GtkIconView     *icon_view,
                                                               GtkTooltip      *tooltip,
                                                               GtkTreePath     *path);
311
GDK_AVAILABLE_IN_ALL
312 313 314 315
void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *icon_view,
                                                               GtkTooltip      *tooltip,
                                                               GtkTreePath     *path,
                                                               GtkCellRenderer *cell);
316
GDK_AVAILABLE_IN_ALL
317 318 319 320 321 322 323
gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
                                                               gint              *x,
                                                               gint              *y,
                                                               gboolean           keyboard_tip,
                                                               GtkTreeModel     **model,
                                                               GtkTreePath      **path,
                                                               GtkTreeIter       *iter);
324
GDK_AVAILABLE_IN_ALL
325 326
void     gtk_icon_view_set_tooltip_column                     (GtkIconView       *icon_view,
                                                               gint               column);
327
GDK_AVAILABLE_IN_ALL
328
gint     gtk_icon_view_get_tooltip_column                     (GtkIconView       *icon_view);
329 330


Anders Carlsson's avatar
Anders Carlsson committed
331 332
G_END_DECLS

333
#endif /* __GTK_ICON_VIEW_H__ */