]> Pileus Git - ~andy/gtk/blob - gtk/gtkiconview.h
API: make gtk_icon_view_create_drag_icon() return a cairo_surface_t
[~andy/gtk] / gtk / gtkiconview.h
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
21 #error "Only <gtk/gtk.h> can be included directly."
22 #endif
23
24 #ifndef __GTK_ICON_VIEW_H__
25 #define __GTK_ICON_VIEW_H__
26
27 #include <gtk/gtkcontainer.h>
28 #include <gtk/gtktreemodel.h>
29 #include <gtk/gtkcellrenderer.h>
30 #include <gtk/gtkselection.h>
31 #include <gtk/gtktooltip.h>
32
33 G_BEGIN_DECLS
34
35 #define GTK_TYPE_ICON_VIEW            (gtk_icon_view_get_type ())
36 #define GTK_ICON_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_ICON_VIEW, GtkIconView))
37 #define GTK_ICON_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
38 #define GTK_IS_ICON_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_ICON_VIEW))
39 #define GTK_IS_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_VIEW))
40 #define GTK_ICON_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
41
42 typedef struct _GtkIconView           GtkIconView;
43 typedef struct _GtkIconViewClass      GtkIconViewClass;
44 typedef struct _GtkIconViewPrivate    GtkIconViewPrivate;
45
46 /**
47  * GtkIconViewForeachFunc:
48  * @icon_view: a #GtkIconView
49  * @path: The #GtkTreePath of a selected row
50  * @data: user data
51  *
52  * A function used by gtk_icon_view_selected_foreach() to map all
53  * selected rows.  It will be called on every selected row in the view.
54  */
55 typedef void (* GtkIconViewForeachFunc)     (GtkIconView      *icon_view,
56                                              GtkTreePath      *path,
57                                              gpointer          data);
58
59 /**
60  * GtkIconViewDropPosition:
61  * @GTK_ICON_VIEW_NO_DROP: no drop possible
62  * @GTK_ICON_VIEW_DROP_INTO: dropped item replaces the item
63  * @GTK_ICON_VIEW_DROP_LEFT: droppped item is inserted to the left
64  * @GTK_ICON_VIEW_DROP_RIGHT: dropped item is inserted to the right
65  * @GTK_ICON_VIEW_DROP_ABOVE: dropped item is inserted above
66  * @GTK_ICON_VIEW_DROP_BELOW: dropped item is inserted below
67  *
68  * An enum for determining where a dropped item goes.
69  */
70 typedef enum
71 {
72   GTK_ICON_VIEW_NO_DROP,
73   GTK_ICON_VIEW_DROP_INTO,
74   GTK_ICON_VIEW_DROP_LEFT,
75   GTK_ICON_VIEW_DROP_RIGHT,
76   GTK_ICON_VIEW_DROP_ABOVE,
77   GTK_ICON_VIEW_DROP_BELOW
78 } GtkIconViewDropPosition;
79
80 struct _GtkIconView
81 {
82   GtkContainer parent;
83
84   /* <private> */
85   GtkIconViewPrivate *priv;
86 };
87
88 struct _GtkIconViewClass
89 {
90   GtkContainerClass parent_class;
91
92   void    (* set_scroll_adjustments) (GtkIconView      *icon_view,
93                                       GtkAdjustment    *hadjustment,
94                                       GtkAdjustment    *vadjustment);
95   
96   void    (* item_activated)         (GtkIconView      *icon_view,
97                                       GtkTreePath      *path);
98   void    (* selection_changed)      (GtkIconView      *icon_view);
99
100   /* Key binding signals */
101   void    (* select_all)             (GtkIconView      *icon_view);
102   void    (* unselect_all)           (GtkIconView      *icon_view);
103   void    (* select_cursor_item)     (GtkIconView      *icon_view);
104   void    (* toggle_cursor_item)     (GtkIconView      *icon_view);
105   gboolean (* move_cursor)           (GtkIconView      *icon_view,
106                                       GtkMovementStep   step,
107                                       gint              count);
108   gboolean (* activate_cursor_item)  (GtkIconView      *icon_view);
109 };
110
111 GType          gtk_icon_view_get_type          (void) G_GNUC_CONST;
112 GtkWidget *    gtk_icon_view_new               (void);
113 GtkWidget *    gtk_icon_view_new_with_model    (GtkTreeModel   *model);
114
115 void           gtk_icon_view_set_model         (GtkIconView    *icon_view,
116                                                 GtkTreeModel   *model);
117 GtkTreeModel * gtk_icon_view_get_model         (GtkIconView    *icon_view);
118 void           gtk_icon_view_set_text_column   (GtkIconView    *icon_view,
119                                                 gint            column);
120 gint           gtk_icon_view_get_text_column   (GtkIconView    *icon_view);
121 void           gtk_icon_view_set_markup_column (GtkIconView    *icon_view,
122                                                 gint            column);
123 gint           gtk_icon_view_get_markup_column (GtkIconView    *icon_view);
124 void           gtk_icon_view_set_pixbuf_column (GtkIconView    *icon_view,
125                                                 gint            column);
126 gint           gtk_icon_view_get_pixbuf_column (GtkIconView    *icon_view);
127
128 void           gtk_icon_view_set_item_orientation (GtkIconView    *icon_view,
129                                                    GtkOrientation  orientation);
130 GtkOrientation gtk_icon_view_get_item_orientation (GtkIconView    *icon_view);
131 void           gtk_icon_view_set_columns       (GtkIconView    *icon_view,
132                                                 gint            columns);
133 gint           gtk_icon_view_get_columns       (GtkIconView    *icon_view);
134 void           gtk_icon_view_set_item_width    (GtkIconView    *icon_view,
135                                                 gint            item_width);
136 gint           gtk_icon_view_get_item_width    (GtkIconView    *icon_view);
137 void           gtk_icon_view_set_spacing       (GtkIconView    *icon_view, 
138                                                 gint            spacing);
139 gint           gtk_icon_view_get_spacing       (GtkIconView    *icon_view);
140 void           gtk_icon_view_set_row_spacing   (GtkIconView    *icon_view, 
141                                                 gint            row_spacing);
142 gint           gtk_icon_view_get_row_spacing   (GtkIconView    *icon_view);
143 void           gtk_icon_view_set_column_spacing (GtkIconView    *icon_view, 
144                                                 gint            column_spacing);
145 gint           gtk_icon_view_get_column_spacing (GtkIconView    *icon_view);
146 void           gtk_icon_view_set_margin        (GtkIconView    *icon_view, 
147                                                 gint            margin);
148 gint           gtk_icon_view_get_margin        (GtkIconView    *icon_view);
149 void           gtk_icon_view_set_item_padding  (GtkIconView    *icon_view, 
150                                                 gint            item_padding);
151 gint           gtk_icon_view_get_item_padding  (GtkIconView    *icon_view);
152
153
154 GtkTreePath *  gtk_icon_view_get_path_at_pos   (GtkIconView     *icon_view,
155                                                 gint             x,
156                                                 gint             y);
157 gboolean       gtk_icon_view_get_item_at_pos   (GtkIconView     *icon_view,
158                                                 gint              x,
159                                                 gint              y,
160                                                 GtkTreePath     **path,
161                                                 GtkCellRenderer **cell);
162 gboolean       gtk_icon_view_get_visible_range (GtkIconView      *icon_view,
163                                                 GtkTreePath     **start_path,
164                                                 GtkTreePath     **end_path);
165
166 void           gtk_icon_view_selected_foreach   (GtkIconView            *icon_view,
167                                                  GtkIconViewForeachFunc  func,
168                                                  gpointer                data);
169 void           gtk_icon_view_set_selection_mode (GtkIconView            *icon_view,
170                                                  GtkSelectionMode        mode);
171 GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView            *icon_view);
172 void             gtk_icon_view_select_path        (GtkIconView            *icon_view,
173                                                    GtkTreePath            *path);
174 void             gtk_icon_view_unselect_path      (GtkIconView            *icon_view,
175                                                    GtkTreePath            *path);
176 gboolean         gtk_icon_view_path_is_selected   (GtkIconView            *icon_view,
177                                                    GtkTreePath            *path);
178 gint             gtk_icon_view_get_item_row       (GtkIconView            *icon_view,
179                                                    GtkTreePath            *path);
180 gint             gtk_icon_view_get_item_column    (GtkIconView            *icon_view,
181                                                    GtkTreePath            *path);
182 GList           *gtk_icon_view_get_selected_items (GtkIconView            *icon_view);
183 void             gtk_icon_view_select_all         (GtkIconView            *icon_view);
184 void             gtk_icon_view_unselect_all       (GtkIconView            *icon_view);
185 void             gtk_icon_view_item_activated     (GtkIconView            *icon_view,
186                                                    GtkTreePath            *path);
187 void             gtk_icon_view_set_cursor         (GtkIconView            *icon_view,
188                                                    GtkTreePath            *path,
189                                                    GtkCellRenderer        *cell,
190                                                    gboolean                start_editing);
191 gboolean         gtk_icon_view_get_cursor         (GtkIconView            *icon_view,
192                                                    GtkTreePath           **path,
193                                                    GtkCellRenderer       **cell);
194 void             gtk_icon_view_scroll_to_path     (GtkIconView            *icon_view,
195                                                    GtkTreePath            *path,
196                                                    gboolean                use_align,
197                                                    gfloat                  row_align,
198                                                    gfloat                  col_align);
199
200 /* Drag-and-Drop support */
201 void                   gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
202                                                                GdkModifierType           start_button_mask,
203                                                                const GtkTargetEntry     *targets,
204                                                                gint                      n_targets,
205                                                                GdkDragAction             actions);
206 void                   gtk_icon_view_enable_model_drag_dest   (GtkIconView              *icon_view,
207                                                                const GtkTargetEntry     *targets,
208                                                                gint                      n_targets,
209                                                                GdkDragAction             actions);
210 void                   gtk_icon_view_unset_model_drag_source  (GtkIconView              *icon_view);
211 void                   gtk_icon_view_unset_model_drag_dest    (GtkIconView              *icon_view);
212 void                   gtk_icon_view_set_reorderable          (GtkIconView              *icon_view,
213                                                                gboolean                  reorderable);
214 gboolean               gtk_icon_view_get_reorderable          (GtkIconView              *icon_view);
215
216
217 /* These are useful to implement your own custom stuff. */
218 void                   gtk_icon_view_set_drag_dest_item       (GtkIconView              *icon_view,
219                                                                GtkTreePath              *path,
220                                                                GtkIconViewDropPosition   pos);
221 void                   gtk_icon_view_get_drag_dest_item       (GtkIconView              *icon_view,
222                                                                GtkTreePath             **path,
223                                                                GtkIconViewDropPosition  *pos);
224 gboolean               gtk_icon_view_get_dest_item_at_pos     (GtkIconView              *icon_view,
225                                                                gint                      drag_x,
226                                                                gint                      drag_y,
227                                                                GtkTreePath             **path,
228                                                                GtkIconViewDropPosition  *pos);
229 cairo_surface_t       *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
230                                                                GtkTreePath              *path);
231
232 void    gtk_icon_view_convert_widget_to_bin_window_coords     (GtkIconView *icon_view,
233                                                                gint         wx,
234                                                                gint         wy,
235                                                                gint        *bx,
236                                                                gint        *by);
237
238
239 void    gtk_icon_view_set_tooltip_item                        (GtkIconView     *icon_view,
240                                                                GtkTooltip      *tooltip,
241                                                                GtkTreePath     *path);
242 void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *icon_view,
243                                                                GtkTooltip      *tooltip,
244                                                                GtkTreePath     *path,
245                                                                GtkCellRenderer *cell);
246 gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
247                                                                gint              *x,
248                                                                gint              *y,
249                                                                gboolean           keyboard_tip,
250                                                                GtkTreeModel     **model,
251                                                                GtkTreePath      **path,
252                                                                GtkTreeIter       *iter);
253 void     gtk_icon_view_set_tooltip_column                     (GtkIconView       *icon_view,
254                                                                gint               column);
255 gint     gtk_icon_view_get_tooltip_column                     (GtkIconView       *icon_view);
256
257
258 G_END_DECLS
259
260 #endif /* __GTK_ICON_VIEW_H__ */