r1996: Cope slightly better with invalid filenames in various places (reported by
[rox-filer.git] / ROX-Filer / src / collection.h
blob9c9b8ee6dfb5cd29a38a6bc04436ec78f1ea4109
1 /*
2 * $Id$
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
7 * etc.
9 * Thomas Leonard, <tal197@users.sourceforge.net>
13 #ifndef __COLLECTION_H__
14 #define __COLLECTION_H__
16 #include <gdk/gdk.h>
17 #include <gtk/gtkwidget.h>
19 #ifdef __cplusplus
20 extern "C" {
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
30 * chance.
32 enum
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,
48 CollectionItem *item,
49 GdkRectangle *area,
50 gpointer user_data);
51 typedef gboolean (*CollectionTestFunc)( Collection *collection,
52 int point_x, int point_y,
53 CollectionItem *item,
54 int width, int height,
55 gpointer user_data);
56 typedef void (*CollectionFreeFunc)(Collection *collection,
57 CollectionItem *item);
59 struct _CollectionItem
61 gpointer data;
62 gpointer view_data;
63 gboolean selected;
66 struct _Collection
68 GtkWidget parent_widget;
70 /* With 2.0, the collection is in a Viewport, and this is used only to
71 * force scrolling, etc.
73 GtkAdjustment *vadj;
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 */
82 int drag_box_y[2];
83 GdkGC *xor_gc;
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 */
91 gint wink_timeout;
92 guint columns;
93 gint number_of_items; /* (often compared with -1) */
94 guint item_width, item_height;
96 guint number_selected;
98 guint array_size;
100 gint auto_scroll; /* Timer */
102 gint block_selection_changed;
105 struct _CollectionClass
107 GtkWidgetClass parent_class;
109 void (*gain_selection)(Collection *collection,
110 gint time);
111 void (*lose_selection)(Collection *collection,
112 gint time);
113 void (*selection_changed)(Collection *collection,
114 gint time);
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,
122 gpointer data,
123 gpointer view);
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,
132 gboolean blank);
133 void collection_set_item_size (Collection *collection,
134 int width, int height);
135 void collection_qsort (Collection *collection,
136 int (*compar)(const void *,
137 const void *));
138 int collection_find_item (Collection *collection,
139 gpointer data,
140 int (*compar)(const void *,
141 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,
147 gpointer data),
148 gpointer data);
149 void collection_move_cursor (Collection *collection,
150 int drow, int dcol);
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,
155 GdkFunction fn);
156 void collection_snap_size (Collection *collection,
157 int rows, int cols);
158 void collection_unblock_selection_changed(Collection *collection,
159 guint time,
160 gboolean emit);
162 #ifdef __cplusplus
164 #endif /* __cplusplus */
166 #endif /* __COLLECTION_H__ */