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
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/>.
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."
30 #include <libgnomecanvas/libgnomecanvas.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 \
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))
68 typedef struct _ETable ETable
;
69 typedef struct _ETableClass ETableClass
;
71 typedef struct _ETableDragSourceSite ETableDragSourceSite
;
74 E_TABLE_CURSOR_LOC_NONE
= 0,
75 E_TABLE_CURSOR_LOC_ETCTA
= 1 << 0,
76 E_TABLE_CURSOR_LOC_TABLE
= 1 << 1
84 ETableHeader
*full_header
, *header
;
86 GnomeCanvasItem
*canvas_vbox
;
89 ETableSortInfo
*sort_info
;
92 ETableSelectionModel
*selection
;
93 ETableCursorLoc cursor_loc
;
94 ETableSpecification
*spec
;
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
;
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;
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
;
164 GnomeCanvasItem
*drop_highlight
;
168 GdkDragContext
*last_drop_context
;
172 ETableDragSourceSite
*site
;
178 gboolean state_changed
;
179 guint state_change_freeze
;
182 struct _ETableClass
{
183 GtkTableClass parent_class
;
185 void (*cursor_change
) (ETable
*et
,
187 void (*cursor_activated
) (ETable
*et
,
189 void (*selection_change
) (ETable
*et
);
190 void (*double_click
) (ETable
*et
,
194 gboolean (*right_click
) (ETable
*et
,
198 gboolean (*click
) (ETable
*et
,
202 gboolean (*key_press
) (ETable
*et
,
206 gboolean (*start_drag
) (ETable
*et
,
210 void (*state_change
) (ETable
*et
);
211 gboolean (*white_space_event
) (ETable
*et
,
214 /* Source side drag signals */
215 void (*table_drag_begin
) (ETable
*table
,
218 GdkDragContext
*context
);
219 void (*table_drag_end
) (ETable
*table
,
222 GdkDragContext
*context
);
223 void (*table_drag_data_get
) (ETable
*table
,
226 GdkDragContext
*context
,
227 GtkSelectionData
*selection_data
,
230 void (*table_drag_data_delete
)
234 GdkDragContext
*context
);
236 /* Target side drag signals */
237 void (*table_drag_leave
) (ETable
*table
,
240 GdkDragContext
*context
,
242 gboolean (*table_drag_motion
) (ETable
*table
,
245 GdkDragContext
*context
,
249 gboolean (*table_drag_drop
) (ETable
*table
,
252 GdkDragContext
*context
,
256 void (*table_drag_data_received
)
260 GdkDragContext
*context
,
263 GtkSelectionData
*selection_data
,
268 GType
e_table_get_type (void) G_GNUC_CONST
;
269 ETable
* e_table_construct (ETable
*e_table
,
272 ETableSpecification
*specification
);
273 GtkWidget
* e_table_new (ETableModel
*etm
,
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
,
285 void e_table_load_state (ETable
*e_table
,
286 const gchar
*filename
);
287 void e_table_set_cursor_row (ETable
*e_table
,
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
,
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
,
299 gint
e_table_get_prev_row (ETable
*e_table
,
301 gint
e_table_model_to_view_row (ETable
*e_table
,
303 gint
e_table_view_to_model_row (ETable
*e_table
,
305 void e_table_get_cell_at (ETable
*table
,
310 void e_table_get_mouse_over_cell (ETable
*table
,
313 void e_table_get_cell_geometry (ETable
*table
,
319 gint
*height_return
);
321 /* Useful accessor functions. */
322 ESelectionModel
*e_table_get_selection_model (ETable
*table
);
324 /* Drag & drop stuff. */
326 void e_table_drag_get_data (ETable
*table
,
329 GdkDragContext
*context
,
332 void e_table_drag_highlight (ETable
*table
,
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
,
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
349 void e_table_drag_dest_unset (GtkWidget
*widget
);
352 void e_table_drag_source_set (ETable
*table
,
353 GdkModifierType start_button_mask
,
354 const GtkTargetEntry
*targets
,
356 GdkDragAction actions
);
357 void e_table_drag_source_unset (ETable
*table
);
359 /* There probably should be functions for setting the targets
362 GdkDragContext
*e_table_drag_begin (ETable
*table
,
365 GtkTargetList
*targets
,
366 GdkDragAction actions
,
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
);
384 #endif /* _E_TABLE_H_ */