Updated Spanish translation
[evolution.git] / e-util / e-table.h
blobaefc3b3525eb763259a1cb6faf952da2cc4e0231
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU Lesser General Public License as published by
4 * the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful, but
7 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 * Authors:
16 * Chris Lahey <clahey@ximian.com>
17 * Miguel de Icaza <miguel@ximian.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
24 #error "Only <e-util/e-util.h> should be included directly."
25 #endif
27 #ifndef _E_TABLE_H_
28 #define _E_TABLE_H_
30 #include <libgnomecanvas/libgnomecanvas.h>
31 #include <gtk/gtk.h>
32 #include <libxml/tree.h>
34 #include <e-util/e-printable.h>
35 #include <e-util/e-table-extras.h>
36 #include <e-util/e-table-group.h>
37 #include <e-util/e-table-header.h>
38 #include <e-util/e-table-item.h>
39 #include <e-util/e-table-model.h>
40 #include <e-util/e-table-search.h>
41 #include <e-util/e-table-selection-model.h>
42 #include <e-util/e-table-sort-info.h>
43 #include <e-util/e-table-sorter.h>
44 #include <e-util/e-table-specification.h>
45 #include <e-util/e-table-state.h>
47 /* Standard GObject macros */
48 #define E_TYPE_TABLE \
49 (e_table_get_type ())
50 #define E_TABLE(obj) \
51 (G_TYPE_CHECK_INSTANCE_CAST \
52 ((obj), E_TYPE_TABLE, ETable))
53 #define E_TABLE_CLASS(cls) \
54 (G_TYPE_CHECK_CLASS_CAST \
55 ((cls), E_TYPE_TABLE, ETableClass))
56 #define E_IS_TABLE(obj) \
57 (G_TYPE_CHECK_INSTANCE_TYPE \
58 ((obj), E_TYPE_TABLE))
59 #define E_IS_TABLE_CLASS(cls) \
60 (G_TYPE_CHECK_CLASS_TYPE \
61 ((cls), E_TYPE_TABLE))
62 #define E_TABLE_GET_CLASS(obj) \
63 (G_TYPE_INSTANCE_GET_CLASS \
64 ((obj), E_TYPE_TABLE, ETableClass))
66 G_BEGIN_DECLS
68 typedef struct _ETable ETable;
69 typedef struct _ETableClass ETableClass;
71 typedef struct _ETableDragSourceSite ETableDragSourceSite;
73 typedef enum {
74 E_TABLE_CURSOR_LOC_NONE = 0,
75 E_TABLE_CURSOR_LOC_ETCTA = 1 << 0,
76 E_TABLE_CURSOR_LOC_TABLE = 1 << 1
77 } ETableCursorLoc;
79 struct _ETable {
80 GtkTable parent;
82 ETableModel *model;
84 ETableHeader *full_header, *header;
86 GnomeCanvasItem *canvas_vbox;
87 ETableGroup *group;
89 ETableSortInfo *sort_info;
90 ETableSorter *sorter;
92 ETableSelectionModel *selection;
93 ETableCursorLoc cursor_loc;
94 ETableSpecification *spec;
96 ETableSearch *search;
98 ETableCol *current_search_col;
100 guint search_search_id;
101 guint search_accept_id;
103 gint table_model_change_id;
104 gint table_row_change_id;
105 gint table_cell_change_id;
106 gint table_rows_inserted_id;
107 gint table_rows_deleted_id;
109 gint group_info_change_id;
110 gint sort_info_change_id;
112 gint structure_change_id;
113 gint expansion_change_id;
114 gint dimension_change_id;
116 gint reflow_idle_id;
117 gint scroll_idle_id;
119 GnomeCanvas *header_canvas, *table_canvas;
121 GnomeCanvasItem *header_item, *root;
123 GnomeCanvasItem *white_item;
125 gint length_threshold;
127 gint rebuild_idle_id;
128 guint need_rebuild : 1;
129 guint size_allocated : 1;
132 * Configuration settings
134 guint alternating_row_colors : 1;
135 guint horizontal_draw_grid : 1;
136 guint vertical_draw_grid : 1;
137 guint draw_focus : 1;
138 guint row_selection_active : 1;
140 guint horizontal_scrolling : 1;
141 guint horizontal_resize : 1;
143 guint is_grouped : 1;
145 guint scroll_direction : 4;
147 guint do_drag : 1;
149 guint uniform_row_height : 1;
150 guint allow_grouping : 1;
152 guint always_search : 1;
153 guint search_col_set : 1;
155 gchar *click_to_add_message;
156 GnomeCanvasItem *click_to_add;
157 gboolean use_click_to_add;
158 gboolean use_click_to_add_end;
160 ECursorMode cursor_mode;
162 gint drop_row;
163 gint drop_col;
164 GnomeCanvasItem *drop_highlight;
165 gint last_drop_x;
166 gint last_drop_y;
167 gint last_drop_time;
168 GdkDragContext *last_drop_context;
170 gint drag_row;
171 gint drag_col;
172 ETableDragSourceSite *site;
174 gint header_width;
176 gchar *domain;
178 gboolean state_changed;
179 guint state_change_freeze;
182 struct _ETableClass {
183 GtkTableClass parent_class;
185 void (*cursor_change) (ETable *et,
186 gint row);
187 void (*cursor_activated) (ETable *et,
188 gint row);
189 void (*selection_change) (ETable *et);
190 void (*double_click) (ETable *et,
191 gint row,
192 gint col,
193 GdkEvent *event);
194 gboolean (*right_click) (ETable *et,
195 gint row,
196 gint col,
197 GdkEvent *event);
198 gboolean (*click) (ETable *et,
199 gint row,
200 gint col,
201 GdkEvent *event);
202 gboolean (*key_press) (ETable *et,
203 gint row,
204 gint col,
205 GdkEvent *event);
206 gboolean (*start_drag) (ETable *et,
207 gint row,
208 gint col,
209 GdkEvent *event);
210 void (*state_change) (ETable *et);
211 gboolean (*white_space_event) (ETable *et,
212 GdkEvent *event);
214 /* Source side drag signals */
215 void (*table_drag_begin) (ETable *table,
216 gint row,
217 gint col,
218 GdkDragContext *context);
219 void (*table_drag_end) (ETable *table,
220 gint row,
221 gint col,
222 GdkDragContext *context);
223 void (*table_drag_data_get) (ETable *table,
224 gint row,
225 gint col,
226 GdkDragContext *context,
227 GtkSelectionData *selection_data,
228 guint info,
229 guint time);
230 void (*table_drag_data_delete)
231 (ETable *table,
232 gint row,
233 gint col,
234 GdkDragContext *context);
236 /* Target side drag signals */
237 void (*table_drag_leave) (ETable *table,
238 gint row,
239 gint col,
240 GdkDragContext *context,
241 guint time);
242 gboolean (*table_drag_motion) (ETable *table,
243 gint row,
244 gint col,
245 GdkDragContext *context,
246 gint x,
247 gint y,
248 guint time);
249 gboolean (*table_drag_drop) (ETable *table,
250 gint row,
251 gint col,
252 GdkDragContext *context,
253 gint x,
254 gint y,
255 guint time);
256 void (*table_drag_data_received)
257 (ETable *table,
258 gint row,
259 gint col,
260 GdkDragContext *context,
261 gint x,
262 gint y,
263 GtkSelectionData *selection_data,
264 guint info,
265 guint time);
268 GType e_table_get_type (void) G_GNUC_CONST;
269 ETable * e_table_construct (ETable *e_table,
270 ETableModel *etm,
271 ETableExtras *ete,
272 ETableSpecification *specification);
273 GtkWidget * e_table_new (ETableModel *etm,
274 ETableExtras *ete,
275 ETableSpecification *specification);
277 /* To save the state */
278 void e_table_save_state (ETable *e_table,
279 const gchar *filename);
280 ETableState * e_table_get_state_object (ETable *e_table);
282 /* note that it is more efficient to provide the state at creation time */
283 void e_table_set_state_object (ETable *e_table,
284 ETableState *state);
285 void e_table_load_state (ETable *e_table,
286 const gchar *filename);
287 void e_table_set_cursor_row (ETable *e_table,
288 gint row);
290 /* -1 means we don't have the cursor. This is in model rows. */
291 gint e_table_get_cursor_row (ETable *e_table);
292 void e_table_selected_row_foreach (ETable *e_table,
293 EForeachFunc callback,
294 gpointer closure);
295 gint e_table_selected_count (ETable *e_table);
296 EPrintable * e_table_get_printable (ETable *e_table);
297 gint e_table_get_next_row (ETable *e_table,
298 gint model_row);
299 gint e_table_get_prev_row (ETable *e_table,
300 gint model_row);
301 gint e_table_model_to_view_row (ETable *e_table,
302 gint model_row);
303 gint e_table_view_to_model_row (ETable *e_table,
304 gint view_row);
305 void e_table_get_cell_at (ETable *table,
306 gint x,
307 gint y,
308 gint *row_return,
309 gint *col_return);
310 void e_table_get_mouse_over_cell (ETable *table,
311 gint *row,
312 gint *col);
313 void e_table_get_cell_geometry (ETable *table,
314 gint row,
315 gint col,
316 gint *x_return,
317 gint *y_return,
318 gint *width_return,
319 gint *height_return);
321 /* Useful accessor functions. */
322 ESelectionModel *e_table_get_selection_model (ETable *table);
324 /* Drag & drop stuff. */
325 /* Target */
326 void e_table_drag_get_data (ETable *table,
327 gint row,
328 gint col,
329 GdkDragContext *context,
330 GdkAtom target,
331 guint32 time);
332 void e_table_drag_highlight (ETable *table,
333 gint row,
334 gint col); /* col == -1 to highlight entire row. */
335 void e_table_drag_unhighlight (ETable *table);
336 void e_table_drag_dest_set (ETable *table,
337 GtkDestDefaults flags,
338 const GtkTargetEntry *targets,
339 gint n_targets,
340 GdkDragAction actions);
341 void e_table_drag_dest_set_proxy (ETable *table,
342 GdkWindow *proxy_window,
343 GdkDragProtocol protocol,
344 gboolean use_coordinates);
346 /* There probably should be functions for setting the targets
347 * as a GtkTargetList
349 void e_table_drag_dest_unset (GtkWidget *widget);
351 /* Source side */
352 void e_table_drag_source_set (ETable *table,
353 GdkModifierType start_button_mask,
354 const GtkTargetEntry *targets,
355 gint n_targets,
356 GdkDragAction actions);
357 void e_table_drag_source_unset (ETable *table);
359 /* There probably should be functions for setting the targets
360 * as a GtkTargetList
362 GdkDragContext *e_table_drag_begin (ETable *table,
363 gint row,
364 gint col,
365 GtkTargetList *targets,
366 GdkDragAction actions,
367 gint button,
368 GdkEvent *event);
370 /* selection stuff */
371 void e_table_select_all (ETable *table);
373 /* This function is only needed in single_selection_mode. */
374 void e_table_right_click_up (ETable *table);
376 void e_table_commit_click_to_add (ETable *table);
378 void e_table_freeze_state_change (ETable *table);
379 void e_table_thaw_state_change (ETable *table);
380 gboolean e_table_is_editing (ETable *table);
382 G_END_DECLS
384 #endif /* _E_TABLE_H_ */