r4269: Bugfix: New detail crashes cleanice theme. Try another value... (reported
[rox-filer/translations.git] / ROX-Filer / src / collection.h
blobc2916d574d356595cd2a3c0868884b2996c66088
1 /*
2 * The collection widget provides an area for displaying a collection of
3 * objects (such as files). It allows the user to choose a selection of
4 * them and provides signals to allow popping up menus, detecting double-clicks
5 * etc.
7 * Thomas Leonard, <tal197@users.sourceforge.net>
8 */
11 #ifndef __COLLECTION_H__
12 #define __COLLECTION_H__
14 #include <gdk/gdk.h>
15 #include <gtk/gtkwidget.h>
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 #define COLLECTION(obj) GTK_CHECK_CAST((obj), collection_get_type(), Collection)
22 #define COLLECTION_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), \
23 collection_get_type(), CollectionClass)
24 #define IS_COLLECTION(obj) \
25 G_TYPE_CHECK_INSTANCE_TYPE((obj), collection_get_type())
27 /* If the display gets mucked up then remember to fix it next time we get the
28 * chance.
30 enum
32 PAINT_NORMAL, /* Just redraw what we need to */
33 PAINT_OVERWRITE, /* Draw everything */
34 PAINT_CLEAR, /* Blank everything, then redraw */
37 typedef struct _Collection Collection;
39 /* Each item in a Collection has one of these, which stores its selected
40 * state, data, and view_data.
42 typedef struct _CollectionItem CollectionItem;
44 typedef struct _CollectionClass CollectionClass;
45 typedef void (*CollectionDrawFunc)(GtkWidget *widget,
46 CollectionItem *item,
47 GdkRectangle *area,
48 gpointer user_data);
49 typedef gboolean (*CollectionTestFunc)( Collection *collection,
50 int point_x, int point_y,
51 CollectionItem *item,
52 int width, int height,
53 gpointer user_data);
54 typedef void (*CollectionFreeFunc)(Collection *collection,
55 CollectionItem *item);
57 struct _CollectionItem
59 gpointer data;
60 gpointer view_data;
61 gboolean selected;
64 struct _Collection
66 GtkWidget parent_widget;
68 /* With 2.0, the collection is in a Viewport, and this is used only to
69 * force scrolling, etc.
71 GtkAdjustment *vadj;
73 CollectionDrawFunc draw_item;
74 CollectionTestFunc test_point;
75 CollectionFreeFunc free_item;
76 gpointer cb_user_data; /* Passed to above functions */
78 gboolean lasso_box; /* Is the box drawn? */
79 int drag_box_x[2]; /* Index 0 is the fixed corner */
80 int drag_box_y[2];
81 GdkGC *xor_gc;
83 CollectionItem *items;
84 gint cursor_item; /* -1 if not shown */
85 gint cursor_item_old; /* May be -1 */
86 gint wink_item; /* -1 if not active */
87 gint wink_on_map; /* -1 if not waiting for map */
88 gint winks_left; /* Flashes in this wink op */
89 gint wink_timeout;
90 guint columns;
91 gboolean vertical_order; /* order elements vertically? */
92 gint number_of_items; /* (often compared with -1) */
93 guint item_width, item_height;
95 guint number_selected;
97 guint array_size;
99 gint block_selection_changed;
102 struct _CollectionClass
104 GtkWidgetClass parent_class;
106 void (*gain_selection)(Collection *collection,
107 gint time);
108 void (*lose_selection)(Collection *collection,
109 gint time);
110 void (*selection_changed)(Collection *collection,
111 gint time);
114 GType collection_get_type (void);
115 GtkWidget *collection_new (void);
116 void collection_clear (Collection *collection);
117 void collection_clear_except (Collection *collection, gint item);
118 gint collection_insert (Collection *collection,
119 gpointer data,
120 gpointer view);
121 void collection_remove (Collection *collection, gint item);
122 void collection_unselect_item (Collection *collection, gint item);
123 void collection_select_item (Collection *collection, gint item);
124 void collection_toggle_item (Collection *collection, gint item);
125 void collection_select_all (Collection *collection);
126 void collection_clear_selection (Collection *collection);
127 void collection_invert_selection (Collection *collection);
128 void collection_draw_item (Collection *collection, gint item,
129 gboolean blank);
130 void collection_set_item_size (Collection *collection,
131 int width, int height);
132 void collection_qsort (Collection *collection,
133 int (*compar)(const void *,
134 const void *),
135 GtkSortType order);
136 int collection_find_item (Collection *collection,
137 gpointer data,
138 int (*compar)(const void *,
139 const void *),
140 GtkSortType order);
141 int collection_get_item (Collection *collection, int x, int y);
142 void collection_set_cursor_item (Collection *collection, gint item,
143 gboolean may_scroll);
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_lasso_box (Collection *collection, int x, int y);
152 void collection_end_lasso (Collection *collection,
153 GdkFunction fn);
154 void collection_snap_size (Collection *collection,
155 int rows, int cols);
156 void collection_unblock_selection_changed(Collection *collection,
157 guint time,
158 gboolean emit);
159 void collection_item_to_rowcol (const Collection *collection,
160 int item, int *row, int *col);
161 int collection_rowcol_to_item (const Collection *collection,
162 int row, int col);
163 #ifdef __cplusplus
165 #endif /* __cplusplus */
167 #endif /* __COLLECTION_H__ */