1 /*
2  * ROX-Filer, filer for the ROX desktop project
3  * By Thomas Leonard, <tal197@users.sourceforge.net>.
4  */
5 
6 #ifndef _FILER_H
7 #define _FILER_H
8 
9 #include <gtk/gtk.h>
10 
11 enum {
12 	RESIZE_STYLE = 0,
13 	RESIZE_ALWAYS = 1,
14 	RESIZE_NEVER = 2,
15 };
16 
17 typedef enum
18 {
19 	OPEN_SHIFT		= 0x01,	/* Do ShiftOpen */
20 	OPEN_SAME_WINDOW	= 0x02, /* Directories open in same window */
21 	OPEN_CLOSE_WINDOW	= 0x04, /* Opening files closes the window */
22 	OPEN_FROM_MINI		= 0x08,	/* Non-dir => close minibuffer */
23 } OpenFlags;
24 
25 typedef enum
26 {
27 	FILER_NEEDS_RESCAN	= 0x01, /* Call may_rescan after scanning */
28 	FILER_UPDATING		= 0x02, /* (scanning) items may already exist */
29 	FILER_CREATE_THUMBS	= 0x04, /* Create thumbs when scan ends */
30 } FilerFlags;
31 
32 /* Numbers used in options */
33 typedef enum
34 {
35 	VIEW_TYPE_COLLECTION = 0,	/* Icons view */
36 	VIEW_TYPE_DETAILS = 1		/* TreeView details list */
37 } ViewType;
38 
39 /* Filter types */
40 typedef enum
41 {
42 	FILER_SHOW_ALL,           /* Show all files, modified by show_hidden */
43 	FILER_SHOW_GLOB,          /* Show files that match a glob pattern */
44 } FilterType;
45 
46 /* What to do when all a mount point's windows are closed */
47 typedef enum {
48 	UNMOUNT_PROMPT_ASK = GPOINTER_TO_INT(NULL),
49 	UNMOUNT_PROMPT_NO_CHANGE,
50 	UNMOUNT_PROMPT_UNMOUNT,
51 	UNMOUNT_PROMPT_EJECT
52 } UnmountPrompt;
53 
54 /* iter's next method has just returned the clicked item... */
55 typedef void (*TargetFunc)(FilerWindow *filer_window,
56 			   ViewIter *iter,
57 			   gpointer data);
58 
59 struct _FilerWindow
60 {
61 	GtkWidget	*window;
62 	GtkBox		*toplevel_vbox, *view_hbox;
63 	gboolean	scanning;	/* State of the 'scanning' indicator */
64 	gchar		*sym_path;		/* Path the user sees */
65 	gchar		*real_path;		/* realpath(sym_path) */
66 	ViewIface	*view;
67 	ViewType	view_type;
68 	gboolean	temp_item_selected;
69 	gboolean	show_hidden;
70 	gboolean	filter_directories;
71 	FilerFlags	flags;
72 	SortType	sort_type;
73 	GtkSortType	sort_order;
74 
75 	DetailsType	details_type;
76 	DisplayStyle	display_style;
77 	DisplayStyle	display_style_wanted;
78 
79 	Directory	*directory;
80 
81 	gboolean	had_cursor;	/* (before changing directory) */
82 	char		*auto_select;	/* If it we find while scanning */
83 
84 	GtkWidget	*message;	/* The 'Running as ...' message */
85 
86 	GtkWidget	*minibuffer_area;	/* The hbox to show/hide */
87 	GtkWidget	*minibuffer_label;	/* The operation name */
88 	GtkWidget	*minibuffer;		/* The text entry */
89 	int		mini_cursor_base;	/* XXX */
90 	MiniType	mini_type;
91 
92 	FilterType      filter;
93 	gchar           *filter_string;  /* Glob or regexp pattern */
94 	gchar           *regexp;         /* Compiled regexp pattern */
95 	/* TRUE if hidden files are shown because the minibuffer leafname
96 	 * starts with a dot.
97 	 */
98 	gboolean 	temp_show_hidden;
99 
100 	TargetFunc	target_cb;
101 	gpointer	target_data;
102 
103 	GtkWidget	*toolbar;
104 	GtkWidget	*toolbar_text;
105 	GtkWidget	*scrollbar;
106 
107 	gint		open_timeout;	/* Will resize and show window... */
108 
109 	GtkStateType	selection_state;	/* for drawing selection */
110 
111 	gboolean	show_thumbs;
112 	GList		*thumb_queue;		/* paths to thumbnail */
113 	GtkWidget	*thumb_bar, *thumb_progress;
114 	int		max_thumbs;		/* total for this batch */
115 
116 	gint		auto_scroll;		/* Timer */
117 
118 	char		*window_id;		/* For remote control */
119 };
120 
121 extern FilerWindow 	*window_with_focus;
122 extern GList		*all_filer_windows;
123 extern GHashTable	*child_to_filer;
124 extern Option		o_filer_auto_resize, o_unique_filer_windows;
125 extern Option		o_filer_size_limit;
126 
127 /* Prototypes */
128 void filer_init(void);
129 FilerWindow *filer_opendir(const char *path, FilerWindow *src_win, const gchar *wm_class);
130 gboolean filer_update_dir(FilerWindow *filer_window, gboolean warning);
131 void filer_update_all(void);
132 DirItem *filer_selected_item(FilerWindow *filer_window);
133 void change_to_parent(FilerWindow *filer_window);
134 void full_refresh(void);
135 void filer_openitem(FilerWindow *filer_window, ViewIter *iter, OpenFlags flags);
136 void filer_check_mounted(const char *real_path);
137 void filer_close_recursive(const char *path);
138 void filer_change_to(FilerWindow *filer_window,
139 			const char *path, const char *from);
140 gboolean filer_exists(FilerWindow *filer_window);
141 FilerWindow *filer_get_by_id(const char *id);
142 void filer_set_id(FilerWindow *, const char *id);
143 void filer_open_parent(FilerWindow *filer_window);
144 void filer_detach_rescan(FilerWindow *filer_window);
145 void filer_target_mode(FilerWindow	*filer_window,
146 			TargetFunc	fn,
147 			gpointer	data,
148 			const char	*reason);
149 GList *filer_selected_items(FilerWindow *filer_window);
150 void filer_create_thumb(FilerWindow *filer_window, const gchar *pathname);
151 void filer_cancel_thumbnails(FilerWindow *filer_window);
152 void filer_set_title(FilerWindow *filer_window);
153 void filer_create_thumbs(FilerWindow *filer_window);
154 void filer_add_tip_details(FilerWindow *filer_window,
155 			   GString *tip, DirItem *item);
156 void filer_selection_changed(FilerWindow *filer_window, gint time);
157 void filer_lost_selection(FilerWindow *filer_window, guint time);
158 void filer_window_set_size(FilerWindow *filer_window, int w, int h);
159 gboolean filer_window_delete(GtkWidget *window,
160 			     GdkEvent *unused,
161 			     FilerWindow *filer_window);
162 void filer_set_view_type(FilerWindow *filer_window, ViewType type);
163 void filer_window_toggle_cursor_item_selected(FilerWindow *filer_window);
164 void filer_perform_action(FilerWindow *filer_window, GdkEventButton *event);
165 gint filer_motion_notify(FilerWindow *filer_window, GdkEventMotion *event);
166 gint filer_key_press_event(GtkWidget *widget, GdkEventKey *event,
167 			   FilerWindow *filer_window);
168 void filer_set_autoscroll(FilerWindow *filer_window, gboolean auto_scroll);
169 void filer_refresh(FilerWindow *filer_window);
170 
171 gboolean filer_match_filter(FilerWindow *filer_window, DirItem *item);
172 gboolean filer_set_filter(FilerWindow *filer_window,
173 			  FilterType type, const gchar *filter_string);
174 void filer_set_filter_directories(FilerWindow *fwin, gboolean filter_directories);
175 void filer_set_hidden(FilerWindow *fwin, gboolean hidden);
176 void filer_next_selected(FilerWindow *filer_window, int dir);
177 void filer_save_settings(FilerWindow *fwin);
178 
179 UnmountPrompt filer_get_unmount_action(const char *path);
180 void filer_set_unmount_action(const char *path, UnmountPrompt action);
181 
182 #endif /* _FILER_H */
183