r345: Fixed a bug that prevented i18n from working.
[rox-filer/dt.git] / ROX-Filer / src / collection.h
blobcd08e24c07e28b9649945b7eb400713e9483bc69
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(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 gpointer user_data);
46 typedef gboolean (*CollectionTestFunc)( Collection *collection,
47 int point_x, int point_y,
48 CollectionItem *item,
49 int width, int height,
50 gpointer user_data);
51 typedef void (*CollectionTargetFunc)(Collection *collection,
52 gint item,
53 gpointer user_data);
55 struct _CollectionItem
57 gpointer data;
58 gboolean selected;
61 struct _Collection
63 GtkWidget parent_widget;
64 gboolean panel;
66 GtkAdjustment *vadj;
67 guint last_scroll; /* Current/previous scroll value */
69 CollectionDrawFunc draw_item;
70 CollectionTestFunc test_point;
71 gpointer cb_user_data; /* Passed to above two functions */
72 int paint_level; /* Complete redraw on next paint? */
73 GdkGC *bg_gc; /* NULL unless pixmap background */
75 gboolean lasso_box; /* Is the box drawn? */
76 int drag_box_x[2]; /* Index 0 is the fixed corner */
77 int drag_box_y[2];
78 GdkGC *xor_gc;
79 int buttons_pressed; /* Number of buttons down */
80 gboolean may_drag; /* Tried to drag since first press? */
82 CollectionItem *items;
83 gint cursor_item; /* -1 if not shown */
84 gint cursor_item_old; /* May be -1 */
85 gint wink_item; /* -1 if not active */
86 gint wink_timeout;
87 guint columns;
88 gint number_of_items; /* (often compared with -1) */
89 guint item_width, item_height;
91 guint number_selected;
92 int item_clicked; /* For collection_single_click */
94 guint array_size;
96 CollectionTargetFunc target_cb;
97 gpointer target_data;
99 gint auto_scroll; /* Timer */
102 struct _CollectionClass
104 GtkWidgetClass parent_class;
106 void (*open_item)(Collection *collection,
107 CollectionItem *item,
108 guint item_number);
109 void (*drag_selection)(Collection *collection,
110 GdkEventMotion *motion_event,
111 guint items_selected);
112 void (*show_menu)(Collection *collection,
113 GdkEventButton *button_event,
114 guint items_selected);
115 void (*gain_selection)(Collection *collection,
116 guint time);
117 void (*lose_selection)(Collection *collection,
118 guint time);
121 guint collection_get_type (void);
122 GtkWidget *collection_new (GtkAdjustment *vadj);
123 void collection_clear (Collection *collection);
124 gint collection_insert (Collection *collection, gpointer data);
125 void collection_remove (Collection *collection, gint item);
126 void collection_unselect_item (Collection *collection, gint item);
127 void collection_select_item (Collection *collection, gint item);
128 void collection_toggle_item (Collection *collection, gint item);
129 void collection_select_all (Collection *collection);
130 void collection_clear_selection (Collection *collection);
131 void collection_draw_item (Collection *collection, gint item,
132 gboolean blank);
133 void collection_set_functions (Collection *collection,
134 CollectionDrawFunc draw_item,
135 CollectionTestFunc test_point,
136 gpointer user_data);
137 void collection_set_item_size (Collection *collection,
138 int width, int height);
139 void collection_qsort (Collection *collection,
140 int (*compar)(const void *,
141 const void *));
142 int collection_find_item (Collection *collection,
143 gpointer data,
144 int (*compar)(const void *,
145 const void *));
146 void collection_set_panel (Collection *collection,
147 gboolean panel);
148 int collection_get_item (Collection *collection, int x, int y);
149 void collection_set_cursor_item (Collection *collection, gint item);
150 void collection_wink_item (Collection *collection, gint item);
151 void collection_delete_if (Collection *collection,
152 gboolean (*test)(gpointer item,
153 gpointer data),
154 gpointer data);
155 void collection_target (Collection *collection,
156 CollectionTargetFunc callback,
157 gpointer user_data);
158 void collection_move_cursor (Collection *collection,
159 int drow, int dcol);
160 void collection_set_autoscroll (Collection *collection,
161 gboolean auto_scroll);
163 #ifdef __cplusplus
165 #endif /* __cplusplus */
167 #endif /* __COLLECTION_H__ */