]> Pileus Git - ~andy/gtk/blob - gtk/gtkiconview.h
Add new convenience api for tooltips on icon views
[~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 #ifndef __GTK_ICON_VIEW_H__
20 #define __GTK_ICON_VIEW_H__
21
22 #include <gtk/gtkcontainer.h>
23 #include <gtk/gtktreemodel.h>
24 #include <gtk/gtkcellrenderer.h>
25 #include <gtk/gtkselection.h>
26 #include <gtk/gtktooltip.h>
27
28 G_BEGIN_DECLS
29
30 #define GTK_TYPE_ICON_VIEW              (gtk_icon_view_get_type ())
31 #define GTK_ICON_VIEW(obj)              (GTK_CHECK_CAST ((obj), GTK_TYPE_ICON_VIEW, GtkIconView))
32 #define GTK_ICON_VIEW_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
33 #define GTK_IS_ICON_VIEW(obj)           (GTK_CHECK_TYPE ((obj), GTK_TYPE_ICON_VIEW))
34 #define GTK_IS_ICON_VIEW_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_VIEW))
35 #define GTK_ICON_VIEW_GET_CLASS(obj)    (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_ICON_VIEW, GtkIconViewClass))
36
37 typedef struct _GtkIconView           GtkIconView;
38 typedef struct _GtkIconViewClass      GtkIconViewClass;
39 typedef struct _GtkIconViewPrivate    GtkIconViewPrivate;
40
41 typedef void (* GtkIconViewForeachFunc)     (GtkIconView      *icon_view,
42                                              GtkTreePath      *path,
43                                              gpointer          data);
44
45 typedef enum
46 {
47   GTK_ICON_VIEW_NO_DROP,
48   GTK_ICON_VIEW_DROP_INTO,
49   GTK_ICON_VIEW_DROP_LEFT,
50   GTK_ICON_VIEW_DROP_RIGHT,
51   GTK_ICON_VIEW_DROP_ABOVE,
52   GTK_ICON_VIEW_DROP_BELOW
53 } GtkIconViewDropPosition;
54
55 struct _GtkIconView
56 {
57   GtkContainer parent;
58
59   GtkIconViewPrivate *priv;
60 };
61
62 struct _GtkIconViewClass
63 {
64   GtkContainerClass parent_class;
65
66   void    (* set_scroll_adjustments) (GtkIconView      *icon_view,
67                                       GtkAdjustment    *hadjustment,
68                                       GtkAdjustment    *vadjustment);
69   
70   void    (* item_activated)         (GtkIconView      *icon_view,
71                                       GtkTreePath      *path);
72   void    (* selection_changed)      (GtkIconView      *icon_view);
73
74   /* Key binding signals */
75   void    (* select_all)             (GtkIconView      *icon_view);
76   void    (* unselect_all)           (GtkIconView      *icon_view);
77   void    (* select_cursor_item)     (GtkIconView      *icon_view);
78   void    (* toggle_cursor_item)     (GtkIconView      *icon_view);
79   gboolean (* move_cursor)           (GtkIconView      *icon_view,
80                                       GtkMovementStep   step,
81                                       gint              count);
82   gboolean (* activate_cursor_item)  (GtkIconView      *icon_view);
83 };
84
85 GType          gtk_icon_view_get_type          (void) G_GNUC_CONST;
86 GtkWidget *    gtk_icon_view_new               (void);
87 GtkWidget *    gtk_icon_view_new_with_model    (GtkTreeModel   *model);
88
89 void           gtk_icon_view_set_model         (GtkIconView    *icon_view,
90                                                 GtkTreeModel   *model);
91 GtkTreeModel * gtk_icon_view_get_model         (GtkIconView    *icon_view);
92 void           gtk_icon_view_set_text_column   (GtkIconView    *icon_view,
93                                                 gint            column);
94 gint           gtk_icon_view_get_text_column   (GtkIconView    *icon_view);
95 void           gtk_icon_view_set_markup_column (GtkIconView    *icon_view,
96                                                 gint            column);
97 gint           gtk_icon_view_get_markup_column (GtkIconView    *icon_view);
98 void           gtk_icon_view_set_pixbuf_column (GtkIconView    *icon_view,
99                                                 gint            column);
100 gint           gtk_icon_view_get_pixbuf_column (GtkIconView    *icon_view);
101
102 void           gtk_icon_view_set_orientation   (GtkIconView    *icon_view,
103                                                 GtkOrientation  orientation);
104 GtkOrientation gtk_icon_view_get_orientation   (GtkIconView    *icon_view);
105 void           gtk_icon_view_set_columns       (GtkIconView    *icon_view,
106                                                 gint            columns);
107 gint           gtk_icon_view_get_columns       (GtkIconView    *icon_view);
108 void           gtk_icon_view_set_item_width    (GtkIconView    *icon_view,
109                                                 gint            item_width);
110 gint           gtk_icon_view_get_item_width    (GtkIconView    *icon_view);
111 void           gtk_icon_view_set_spacing       (GtkIconView    *icon_view, 
112                                                 gint            spacing);
113 gint           gtk_icon_view_get_spacing       (GtkIconView    *icon_view);
114 void           gtk_icon_view_set_row_spacing   (GtkIconView    *icon_view, 
115                                                 gint            row_spacing);
116 gint           gtk_icon_view_get_row_spacing   (GtkIconView    *icon_view);
117 void           gtk_icon_view_set_column_spacing (GtkIconView    *icon_view, 
118                                                 gint            column_spacing);
119 gint           gtk_icon_view_get_column_spacing (GtkIconView    *icon_view);
120 void           gtk_icon_view_set_margin        (GtkIconView    *icon_view, 
121                                                 gint            margin);
122 gint           gtk_icon_view_get_margin        (GtkIconView    *icon_view);
123
124
125 GtkTreePath *  gtk_icon_view_get_path_at_pos   (GtkIconView     *icon_view,
126                                                 gint             x,
127                                                 gint             y);
128 gboolean       gtk_icon_view_get_item_at_pos   (GtkIconView     *icon_view,
129                                                 gint              x,
130                                                 gint              y,
131                                                 GtkTreePath     **path,
132                                                 GtkCellRenderer **cell);
133 gboolean       gtk_icon_view_get_visible_range (GtkIconView      *icon_view,
134                                                 GtkTreePath     **start_path,
135                                                 GtkTreePath     **end_path);
136
137 void           gtk_icon_view_selected_foreach   (GtkIconView            *icon_view,
138                                                  GtkIconViewForeachFunc  func,
139                                                  gpointer                data);
140 void           gtk_icon_view_set_selection_mode (GtkIconView            *icon_view,
141                                                  GtkSelectionMode        mode);
142 GtkSelectionMode gtk_icon_view_get_selection_mode (GtkIconView            *icon_view);
143 void             gtk_icon_view_select_path        (GtkIconView            *icon_view,
144                                                    GtkTreePath            *path);
145 void             gtk_icon_view_unselect_path      (GtkIconView            *icon_view,
146                                                    GtkTreePath            *path);
147 gboolean         gtk_icon_view_path_is_selected   (GtkIconView            *icon_view,
148                                                    GtkTreePath            *path);
149 GList           *gtk_icon_view_get_selected_items (GtkIconView            *icon_view);
150 void             gtk_icon_view_select_all         (GtkIconView            *icon_view);
151 void             gtk_icon_view_unselect_all       (GtkIconView            *icon_view);
152 void             gtk_icon_view_item_activated     (GtkIconView            *icon_view,
153                                                    GtkTreePath            *path);
154 void             gtk_icon_view_set_cursor         (GtkIconView            *icon_view,
155                                                    GtkTreePath            *path,
156                                                    GtkCellRenderer        *cell,
157                                                    gboolean                start_editing);
158 gboolean         gtk_icon_view_get_cursor         (GtkIconView            *icon_view,
159                                                    GtkTreePath           **path,
160                                                    GtkCellRenderer       **cell);
161 void             gtk_icon_view_scroll_to_path     (GtkIconView            *icon_view,
162                                                    GtkTreePath            *path,
163                                                    gboolean                use_align,
164                                                    gfloat                  row_align,
165                                                    gfloat                  col_align);
166
167 /* Drag-and-Drop support */
168 void                   gtk_icon_view_enable_model_drag_source (GtkIconView              *icon_view,
169                                                                GdkModifierType           start_button_mask,
170                                                                const GtkTargetEntry     *targets,
171                                                                gint                      n_targets,
172                                                                GdkDragAction             actions);
173 void                   gtk_icon_view_enable_model_drag_dest   (GtkIconView              *icon_view,
174                                                                const GtkTargetEntry     *targets,
175                                                                gint                      n_targets,
176                                                                GdkDragAction             actions);
177 void                   gtk_icon_view_unset_model_drag_source  (GtkIconView              *icon_view);
178 void                   gtk_icon_view_unset_model_drag_dest    (GtkIconView              *icon_view);
179 void                   gtk_icon_view_set_reorderable          (GtkIconView              *icon_view,
180                                                                gboolean                  reorderable);
181 gboolean               gtk_icon_view_get_reorderable          (GtkIconView              *icon_view);
182
183
184 /* These are useful to implement your own custom stuff. */
185 void                   gtk_icon_view_set_drag_dest_item       (GtkIconView              *icon_view,
186                                                                GtkTreePath              *path,
187                                                                GtkIconViewDropPosition   pos);
188 void                   gtk_icon_view_get_drag_dest_item       (GtkIconView              *icon_view,
189                                                                GtkTreePath             **path,
190                                                                GtkIconViewDropPosition  *pos);
191 gboolean               gtk_icon_view_get_dest_item_at_pos     (GtkIconView              *icon_view,
192                                                                gint                      drag_x,
193                                                                gint                      drag_y,
194                                                                GtkTreePath             **path,
195                                                                GtkIconViewDropPosition  *pos);
196 GdkPixmap             *gtk_icon_view_create_drag_icon         (GtkIconView              *icon_view,
197                                                                GtkTreePath              *path);
198
199 void    gtk_icon_view_convert_widget_to_bin_window_coords     (GtkIconView *icon_view,
200                                                                gint         wx,
201                                                                gint         wy,
202                                                                gint        *bx,
203                                                                gint        *by);
204
205
206 void    gtk_icon_view_set_tooltip_item                        (GtkIconView     *icon_view,
207                                                                GtkTooltip      *tooltip,
208                                                                GtkTreePath     *path);
209 void    gtk_icon_view_set_tooltip_cell                        (GtkIconView     *icon_view,
210                                                                GtkTooltip      *tooltip,
211                                                                GtkTreePath     *path,
212                                                                GtkCellRenderer *cell);
213 gboolean gtk_icon_view_get_tooltip_context                    (GtkIconView       *icon_view,
214                                                                gint              *x,
215                                                                gint              *y,
216                                                                gboolean           keyboard_tip,
217                                                                GtkTreeModel     **model,
218                                                                GtkTreePath      **path,
219                                                                GtkTreeIter       *iter);
220 void     gtk_icon_view_set_tooltip_column                     (GtkIconView       *icon_view,
221                                                                gint               column);
222 gint     gtk_icon_view_get_tooltip_column                     (GtkIconView       *icon_view);
223
224
225 G_END_DECLS
226
227 #endif /* __GTK_ICON_VIEW_H__ */