r232: Added 'prune' and 'system' find commands.
[rox-filer.git] / ROX-Filer / src / collection.h
blobff5d903c533d6f0afadfe723dd77889596a24e7b
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@ecs.soton.ac.uk>
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(klass) GTK_CHECK_CLASS_CAST((klass), \
25 collection_get_type(), CollectionClass)
26 #define IS_COLLECTION(obj) GTK_CHECK_TYPE((obj), collection_get_type())
28 /* If the display gets mucked up then remember to fix it next time we get the
29 * chance.
31 enum
33 PAINT_NORMAL, /* Just redraw what we need to */
34 PAINT_OVERWRITE, /* Draw everything */
35 PAINT_CLEAR, /* Blank everything, then redraw */
39 typedef struct _Collection Collection;
40 typedef struct _CollectionClass CollectionClass;
41 typedef struct _CollectionItem CollectionItem;
42 typedef void (*CollectionDrawFunc)(GtkWidget *widget,
43 CollectionItem *item,
44 GdkRectangle *area);
45 typedef gboolean (*CollectionTestFunc)( Collection *collection,
46 int point_x, int point_y,
47 CollectionItem *item,
48 int width, int height);
49 typedef void (*CollectionTargetFunc)(Collection *collection,
50 gint item,
51 gpointer user_data);
53 struct _CollectionItem
55 gpointer data;
56 gboolean selected;
59 struct _Collection
61 GtkWidget parent_widget;
62 gboolean panel;
64 GtkAdjustment *vadj;
65 guint last_scroll; /* Current/previous scroll value */
67 CollectionDrawFunc draw_item;
68 CollectionTestFunc test_point;
69 int paint_level; /* Complete redraw on next paint? */
71 gboolean lasso_box; /* Is the box drawn? */
72 int drag_box_x[2]; /* Index 0 is the fixed corner */
73 int drag_box_y[2];
74 GdkGC *xor_gc;
75 int buttons_pressed; /* Number of buttons down */
76 gboolean may_drag; /* Tried to drag since first press? */
78 CollectionItem *items;
79 gint cursor_item; /* -1 if not shown */
80 gint wink_item; /* -1 if not active */
81 gint wink_timeout;
82 guint columns;
83 gint number_of_items; /* (often compared with -1) */
84 guint item_width, item_height;
86 guint number_selected;
87 int item_clicked; /* For collection_single_click */
89 guint array_size;
91 CollectionTargetFunc target_cb;
92 gpointer target_data;
95 struct _CollectionClass
97 GtkWidgetClass parent_class;
99 void (*open_item)(Collection *collection,
100 CollectionItem *item,
101 guint item_number);
102 void (*drag_selection)(Collection *collection,
103 GdkEventMotion *motion_event,
104 guint items_selected);
105 void (*show_menu)(Collection *collection,
106 GdkEventButton *button_event,
107 guint items_selected);
108 void (*gain_selection)(Collection *collection,
109 guint time);
110 void (*lose_selection)(Collection *collection,
111 guint time);
114 guint collection_get_type (void);
115 GtkWidget *collection_new (GtkAdjustment *vadj);
116 void collection_clear (Collection *collection);
117 gint collection_insert (Collection *collection, gpointer data);
118 void collection_remove (Collection *collection, gint item);
119 void collection_unselect_item (Collection *collection, gint item);
120 void collection_select_item (Collection *collection, gint item);
121 void collection_toggle_item (Collection *collection, gint item);
122 void collection_select_all (Collection *collection);
123 void collection_clear_selection (Collection *collection);
124 void collection_draw_item (Collection *collection, gint item,
125 gboolean blank);
126 void collection_set_functions (Collection *collection,
127 CollectionDrawFunc draw_item,
128 CollectionTestFunc test_point);
129 void collection_set_item_size (Collection *collection,
130 int width, int height);
131 void collection_qsort (Collection *collection,
132 int (*compar)(const void *,
133 const void *));
134 int collection_find_item (Collection *collection,
135 gpointer data,
136 int (*compar)(const void *,
137 const void *));
138 void collection_set_panel (Collection *collection,
139 gboolean panel);
140 int collection_get_item (Collection *collection, int x, int y);
141 void collection_set_cursor_item (Collection *collection, gint item);
142 void collection_wink_item (Collection *collection, gint item);
143 void collection_delete_if (Collection *collection,
144 gboolean (*test)(gpointer item,
145 gpointer data),
146 gpointer data);
147 void collection_target (Collection *collection,
148 CollectionTargetFunc callback,
149 gpointer user_data);
150 void collection_move_cursor (Collection *collection,
151 int drow, int dcol);
153 #ifdef __cplusplus
155 #endif /* __cplusplus */
157 #endif /* __COLLECTION_H__ */