r2216: Cursor and selection work on view details.
[rox-filer.git] / ROX-Filer / src / view_iface.h
blob72f11c34a9a086ce2cb719a5c3223881e099770c
1 /*
2 * $Id$
5 * ROX-Filer, filer for the ROX desktop project
6 * By Thomas Leonard, <tal197@users.sourceforge.net>.
7 */
9 #ifndef __VIEW_IFACE_H__
10 #define __VIEW_IFACE_H__
12 #include <glib-object.h>
14 typedef enum {
15 /* iter->next moves to selected items only */
16 VIEW_ITER_SELECTED = 1 << 0,
18 /* iteration starts from cursor (first call to next() returns
19 * iter AFTER cursor). If there is no cursor, flag is ignored
20 * (will iterate over everything).
22 VIEW_ITER_FROM_CURSOR = 1 << 1,
24 /* next() moves backwards */
25 VIEW_ITER_BACKWARDS = 1 << 2,
27 /* next() always returns NULL and has no effect */
28 VIEW_ITER_ONE_ONLY = 1 << 3,
30 /* Like FROM_CURSOR, but using the base position. The base is set
31 * from the cursor position when the path minibuffer is opened.
33 VIEW_ITER_FROM_BASE = 1 << 4,
34 } IterFlags;
36 typedef struct _ViewIfaceClass ViewIfaceClass;
38 /* A viewport containing a Collection which also handles redraw.
39 * This is the Collection-based implementation of the View interface.
41 typedef struct _ViewCollection ViewCollection;
43 struct _ViewIter {
44 /* Returns the value last returned by next() */
45 DirItem *(*peek)(ViewIter *iter);
47 DirItem *(*next)(ViewIter *iter);
49 /* private fields */
50 ViewCollection *view_collection; /* XXX (use ->view instead) */
51 ViewIface *view;
52 int i, n_remaining;
53 int flags;
56 struct _ViewIfaceClass {
57 GTypeInterface base_iface;
59 void (*sort)(ViewIface *obj);
60 void (*style_changed)(ViewIface *obj, int flags);
61 gboolean (*autoselect)(ViewIface *obj, const gchar *leaf);
62 void (*add_items)(ViewIface *obj, GPtrArray *items);
63 void (*update_items)(ViewIface *obj, GPtrArray *items);
64 void (*delete_if)(ViewIface *obj,
65 gboolean (*test)(gpointer item, gpointer data),
66 gpointer data);
67 void (*clear)(ViewIface *obj);
68 void (*select_all)(ViewIface *obj);
69 void (*clear_selection)(ViewIface *obj);
70 int (*count_items)(ViewIface *obj);
71 int (*count_selected)(ViewIface *obj);
72 void (*show_cursor)(ViewIface *obj);
74 void (*get_iter)(ViewIface *obj, ViewIter *iter, IterFlags flags);
75 void (*cursor_to_iter)(ViewIface *obj, ViewIter *iter);
77 void (*set_selected)(ViewIface *obj, ViewIter *iter, gboolean selected);
78 gboolean (*get_selected)(ViewIface *obj, ViewIter *iter);
79 void (*set_frozen)(ViewIface *obj, gboolean frozen);
80 void (*select_only)(ViewIface *obj, ViewIter *iter);
81 void (*wink_item)(ViewIface *obj, ViewIter *iter);
82 void (*autosize)(ViewIface *obj);
83 gboolean (*cursor_visible)(ViewIface *obj);
84 void (*set_base)(ViewIface *obj, ViewIter *iter);
87 #define VIEW_TYPE_IFACE (view_iface_get_type())
89 #define VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
90 VIEW_TYPE_IFACE, ViewIface))
92 #define VIEW_IS_IFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
93 VIEW_TYPE_IFACE))
95 #define VIEW_IFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), \
96 VIEW_TYPE_IFACE, ViewIfaceClass))
98 /* Flags for view_style_changed() */
99 enum {
100 VIEW_UPDATE_VIEWDATA = 1 << 0,
101 VIEW_UPDATE_NAME = 1 << 1,
104 GType view_iface_get_type(void);
105 void view_sort(ViewIface *obj);
106 void view_style_changed(ViewIface *obj, int flags);
107 gboolean view_autoselect(ViewIface *obj, const gchar *leaf);
108 void view_add_items(ViewIface *obj, GPtrArray *items);
109 void view_update_items(ViewIface *obj, GPtrArray *items);
110 void view_delete_if(ViewIface *obj,
111 gboolean (*test)(gpointer item, gpointer data),
112 gpointer data);
113 void view_clear(ViewIface *obj);
114 void view_select_all(ViewIface *obj);
115 void view_clear_selection(ViewIface *obj);
116 int view_count_items(ViewIface *obj);
117 int view_count_selected(ViewIface *obj);
118 void view_show_cursor(ViewIface *obj);
120 void view_get_iter(ViewIface *obj, ViewIter *iter, IterFlags flags);
121 void view_get_cursor(ViewIface *obj, ViewIter *iter);
122 void view_cursor_to_iter(ViewIface *obj, ViewIter *iter);
124 void view_set_selected(ViewIface *obj, ViewIter *iter, gboolean selected);
125 gboolean view_get_selected(ViewIface *obj, ViewIter *iter);
126 void view_select_only(ViewIface *obj, ViewIter *iter);
127 void view_freeze(ViewIface *obj);
128 void view_thaw(ViewIface *obj);
129 void view_select_if(ViewIface *obj,
130 gboolean (*test)(ViewIter *iter, gpointer data),
131 gpointer data);
133 void view_wink_item(ViewIface *obj, ViewIter *iter);
134 void view_autosize(ViewIface *obj);
135 gboolean view_cursor_visible(ViewIface *obj);
136 void view_set_base(ViewIface *obj, ViewIter *iter);
138 #endif /* __VIEW_IFACE_H__ */