]> Pileus Git - ~andy/gtk/blob - gtk/gtkiconview.h
stylecontext: Do invalidation on first resize container
[~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, 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
32 G_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
41 typedef struct _GtkIconView           GtkIconView;
42 typedef struct _GtkIconViewClass      GtkIconViewClass;
43 typedef struct _GtkIconViewPrivate    GtkIconViewPrivate;
44
45 /**
46  * GtkIconViewForeachFunc:
47  * @icon_view: a #GtkIconView
48  * @path: The #GtkTreePath of a selected row
49  * @data: 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  */
54 typedef 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  */
69 typedef 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
79 struct _GtkIconView
80 {
81   GtkContainer parent;
82
83   /*< private >*/
84   GtkIconViewPrivate *priv;
85 };
86
87 struct _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
112 GType          gtk_icon_view_get_type          (void) G_GNUC_CONST;
113 GtkWidget *    gtk_icon_view_new               (void);
114 GtkWidget *    gtk_icon_view_new_with_area     (GtkCellArea    *area);
115 GtkWidget *    gtk_icon_view_new_with_model    (GtkTreeModel   *model);
116
117 void           gtk_icon_view_set_model         (GtkIconView    *icon_view,
118                                                 GtkTreeModel   *model);
119 GtkTreeModel * gtk_icon_view_get_model         (GtkIconView    *icon_view);
120 void           gtk_icon_view_set_text_column   (GtkIconView    *icon_view,
121                                                 gint            column);
122 gint           gtk_icon_view_get_text_column   (GtkIconView    *icon_view);
123 void           gtk_icon_view_set_markup_column (GtkIconView    *icon_view,
124                                                 gint            column);
125 gint           gtk_icon_view_get_markup_column (GtkIconView    *icon_view);
126 void           gtk_icon_view_set_pixbuf_column (GtkIconView    *icon_view,
127                                                 gint            column);
128 gint           gtk_icon_view_get_pixbuf_column (GtkIconView    *icon_view);
129
130 void           gtk_icon_view_set_item_orientation (GtkIconView    *icon_view,
131                                                    GtkOrientation  orientation);
132 GtkOrientation gtk_icon_view_get_item_orientation (GtkIconView    *icon_view);
133 void           gtk_icon_view_set_columns       (GtkIconView    *icon_view,
134                                                 gint            columns);
135 gint           gtk_icon_view_get_columns       (GtkIconView    *icon_view);
136 void           gtk_icon_view_set_item_width    (GtkIconView    *icon_view,
137                                                 gint            item_width);
138 gint           gtk_icon_view_get_item_width    (GtkIconView    *icon_view);
139 void           gtk_icon_view_set_spacing       (GtkIconView    *icon_view, 
140                                                 gint            spacing);
141 gint           gtk_icon_view_get_spacing       (GtkIconView    *icon_view);
142 void           gtk_icon_view_set_row_spacing   (GtkIconView    *icon_view, 
143                                                 gint            row_spacing);
144 gint           gtk_icon_view_get_row_spacing   (GtkIconView    *icon_view);
145 void           gtk_icon_view_set_column_spacing (GtkIconView    *icon_view, 
146                                                 gint            column_spacing);
147 gint           gtk_icon_view_get_column_spacing (GtkIconView    *icon_view);
148 void           gtk_icon_view_set_margin        (GtkIconView    *icon_view, 
149                                                 gint            margin);
150 gint           gtk_icon_view_get_margin        (GtkIconView    *icon_view);
151 void           gtk_icon_view_set_item_padding  (GtkIconView    *icon_view, 
152                                                 gint            item_padding);
153 gint           gtk_icon_view_get_item_padding  (GtkIconView    *icon_view);
154
155 GtkTreePath *  gtk_icon_view_get_path_at_pos   (GtkIconView     *icon_view,
156                                                 gint             x,
157                                                 gint             y);
158 gboolean       gtk_icon_view_get_item_at_pos   (GtkIconView     *icon_view,
159                                                 gint              x,
160                                                 gint              y,
161                                                 GtkTreePath     **path,
162                                                 GtkCellRenderer **cell);
163 gboolean       gtk_icon_view_get_visible_range (GtkIconView      *icon_view,
164                                                 GtkTreePath     **start_path,
165                                                 GtkTreePath     **end_path);
166 GDK_AVAILABLE_IN_3_8
167 void           gtk_icon_view_set_activate_on_single_click (GtkIconView  *icon_view,
168                                                            gboolean      single);
169 GDK_AVAILABLE_IN_3_8
170 gboolean       gtk_icon_view_get_activate_on_single_click (GtkIconView  *icon_view);
171
172 void           gtk_icon_view_selected_foreach   (GtkIconView            *icon_view,
173                                                  GtkIconViewForeachFunc  func,
174                                                  gpointer                data);
175 void           gtk_icon_view_set_selection_mode (GtkIconView            *icon_view,
176                                                  GtkSelectionMode        mode);
177 GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView            *icon_view);
178 void             gtk_icon_view_select_path        (GtkIconView            *icon_view,
179                                                    GtkTreePath            *path);
180 void             gtk_icon_view_unselect_path      (GtkIconView            *icon_view,
181                                                    GtkTreePath            *path);
182 gboolean         gtk_icon_view_path_is_selected   (GtkIconView            *icon_view,
183                                                    GtkTreePath            *path);
184 gint             gtk_icon_view_get_item_row       (GtkIconView            *icon_view,
185                                                    GtkTreePath            *path);
186 gint             gtk_icon_view_get_item_column    (GtkIconView            *icon_view,
187                                                    GtkTreePath            *path);
188 GList           *gtk_icon_view_get_selected_items (GtkIconView            *icon_view);
189 void             gtk_icon_view_select_all         (GtkIconView            *icon_view);
190 void             gtk_icon_view_unselect_all       (GtkIconView            *icon_view);
191 void             gtk_icon_view_item_activated     (GtkIconView            *icon_view,
192                                                    GtkTreePath            *path);
193 void             gtk_icon_view_set_cursor         (GtkIconView            *icon_view,
194                                                    GtkTreePath            *path,
195                                                    GtkCellRenderer        *cell,
196                                                    gboolean                start_editing);
197 gboolean         gtk_icon_view_get_cursor         (GtkIconView            *icon_view,
198                                                    GtkTreePath           **path,
199                                                    GtkCellRenderer       **cell);
200 void             gtk_icon_view_scroll_to_path     (GtkIconView            *icon_view,
201                                                    GtkTreePath            *path,
202                                                    gboolean                use_align,
203                                                    gfloat                  row_align,
204                                                    gfloat                  col_align);
205
206 /* Drag-and-Drop support */
207 void                   gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
208                                                                GdkModifierType           start_button_mask,
209                                                                const GtkTargetEntry     *targets,
210                                                                gint                      n_targets,
211                                                                GdkDragAction             actions);
212 void                   gtk_icon_view_enable_model_drag_dest   (GtkIconView              *icon_view,
213                                                                const GtkTargetEntry     *targets,
214                                                                gint                      n_targets,
215                                                                GdkDragAction             actions);
216 void                   gtk_icon_view_unset_model_drag_source  (GtkIconView              *icon_view);
217 void                   gtk_icon_view_unset_model_drag_dest    (GtkIconView              *icon_view);
218 void                   gtk_icon_view_set_reorderable          (GtkIconView              *icon_view,
219                                                                gboolean                  reorderable);
220 gboolean               gtk_icon_view_get_reorderable          (GtkIconView              *icon_view);
221
222
223 /* These are useful to implement your own custom stuff. */
224 void                   gtk_icon_view_set_drag_dest_item       (GtkIconView              *icon_view,
225                                                                GtkTreePath              *path,
226                                                                GtkIconViewDropPosition   pos);
227 void                   gtk_icon_view_get_drag_dest_item       (GtkIconView              *icon_view,
228                                                                GtkTreePath             **path,
229                                                                GtkIconViewDropPosition  *pos);
230 gboolean               gtk_icon_view_get_dest_item_at_pos     (GtkIconView              *icon_view,
231                                                                gint                      drag_x,
232                                                                gint                      drag_y,
233                                                                GtkTreePath             **path,
234                                                                GtkIconViewDropPosition  *pos);
235 cairo_surface_t       *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
236                                                                GtkTreePath              *path);
237
238 void    gtk_icon_view_convert_widget_to_bin_window_coords     (GtkIconView *icon_view,
239                                                                gint         wx,
240                                                                gint         wy,
241                                                                gint        *bx,
242                                                                gint        *by);
243 GDK_AVAILABLE_IN_3_6
244 gboolean gtk_icon_view_get_cell_rect                          (GtkIconView     *icon_view,
245                                                                GtkTreePath     *path,
246                                                                GtkCellRenderer *cell,
247                                                                GdkRectangle    *rect);
248
249
250 void    gtk_icon_view_set_tooltip_item                        (GtkIconView     *icon_view,
251                                                                GtkTooltip      *tooltip,
252                                                                GtkTreePath     *path);
253 void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *icon_view,
254                                                                GtkTooltip      *tooltip,
255                                                                GtkTreePath     *path,
256                                                                GtkCellRenderer *cell);
257 gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
258                                                                gint              *x,
259                                                                gint              *y,
260                                                                gboolean           keyboard_tip,
261                                                                GtkTreeModel     **model,
262                                                                GtkTreePath      **path,
263                                                                GtkTreeIter       *iter);
264 void     gtk_icon_view_set_tooltip_column                     (GtkIconView       *icon_view,
265                                                                gint               column);
266 gint     gtk_icon_view_get_tooltip_column                     (GtkIconView       *icon_view);
267
268
269 G_END_DECLS
270
271 #endif /* __GTK_ICON_VIEW_H__ */