4 * The collection widget provides an area for displaying a collection of
5 * objects (such as files). It allows the user to choose a selection of
6 * them and provides signals to allow popping up menus, detecting double-clicks
9 * Thomas Leonard, <tal197@users.sourceforge.net>
13 #ifndef __COLLECTION_H__
14 #define __COLLECTION_H__
17 #include <gtk/gtkwidget.h>
21 #endif /* __cplusplus */
23 #define COLLECTION(obj) GTK_CHECK_CAST((obj), collection_get_type(), Collection)
24 #define COLLECTION_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
25 collection_get_type(), CollectionClass)
26 #define IS_COLLECTION(obj) \
27 G_TYPE_CHECK_INSTANCE_TYPE((obj), collection_get_type())
29 /* If the display gets mucked up then remember to fix it next time we get the
34 PAINT_NORMAL
, /* Just redraw what we need to */
35 PAINT_OVERWRITE
, /* Draw everything */
36 PAINT_CLEAR
, /* Blank everything, then redraw */
39 typedef struct _Collection Collection
;
41 /* Each item in a Collection has one of these, which stores its selected
42 * state, data, and view_data.
44 typedef struct _CollectionItem CollectionItem
;
46 typedef struct _CollectionClass CollectionClass
;
47 typedef void (*CollectionDrawFunc
)(GtkWidget
*widget
,
51 typedef gboolean (*CollectionTestFunc
)( Collection
*collection
,
52 int point_x
, int point_y
,
54 int width
, int height
,
56 typedef void (*CollectionFreeFunc
)(Collection
*collection
,
57 CollectionItem
*item
);
59 struct _CollectionItem
68 GtkWidget parent_widget
;
70 /* With 2.0, the collection is in a Viewport, and this is used only to
71 * force scrolling, etc.
75 CollectionDrawFunc draw_item
;
76 CollectionTestFunc test_point
;
77 CollectionFreeFunc free_item
;
78 gpointer cb_user_data
; /* Passed to above functions */
80 gboolean lasso_box
; /* Is the box drawn? */
81 int drag_box_x
[2]; /* Index 0 is the fixed corner */
85 CollectionItem
*items
;
86 gint cursor_item
; /* -1 if not shown */
87 gint cursor_item_old
; /* May be -1 */
88 gint wink_item
; /* -1 if not active */
89 gint wink_on_map
; /* -1 if not waiting for map */
90 gint winks_left
; /* Flashes in this wink op */
93 gint number_of_items
; /* (often compared with -1) */
94 guint item_width
, item_height
;
96 guint number_selected
;
100 gint auto_scroll
; /* Timer */
102 gint block_selection_changed
;
105 struct _CollectionClass
107 GtkWidgetClass parent_class
;
109 void (*gain_selection
)(Collection
*collection
,
111 void (*lose_selection
)(Collection
*collection
,
113 void (*selection_changed
)(Collection
*collection
,
117 GType
collection_get_type (void);
118 GtkWidget
*collection_new (void);
119 void collection_clear (Collection
*collection
);
120 void collection_clear_except (Collection
*collection
, gint item
);
121 gint
collection_insert (Collection
*collection
,
124 void collection_remove (Collection
*collection
, gint item
);
125 void collection_unselect_item (Collection
*collection
, gint item
);
126 void collection_select_item (Collection
*collection
, gint item
);
127 void collection_toggle_item (Collection
*collection
, gint item
);
128 void collection_select_all (Collection
*collection
);
129 void collection_clear_selection (Collection
*collection
);
130 void collection_invert_selection (Collection
*collection
);
131 void collection_draw_item (Collection
*collection
, gint item
,
133 void collection_set_item_size (Collection
*collection
,
134 int width
, int height
);
135 void collection_qsort (Collection
*collection
,
136 int (*compar
)(const void *,
138 int collection_find_item (Collection
*collection
,
140 int (*compar
)(const void *,
142 int collection_get_item (Collection
*collection
, int x
, int y
);
143 void collection_set_cursor_item (Collection
*collection
, gint item
);
144 void collection_wink_item (Collection
*collection
, gint item
);
145 void collection_delete_if (Collection
*collection
,
146 gboolean (*test
)(gpointer item
,
149 void collection_move_cursor (Collection
*collection
,
151 void collection_set_autoscroll (Collection
*collection
,
152 gboolean auto_scroll
);
153 void collection_lasso_box (Collection
*collection
, int x
, int y
);
154 void collection_end_lasso (Collection
*collection
,
156 void collection_snap_size (Collection
*collection
,
158 void collection_unblock_selection_changed(Collection
*collection
,
164 #endif /* __cplusplus */
166 #endif /* __COLLECTION_H__ */