1 /**************************************************************/
2 /////////////////////  5.2.10 ///////////////////////////////////
3 /**************************************************************/
4 
5 #ifndef __RFM_TYPES_H__
6 #define __RFM_TYPES_H__
7 #include <string.h>
8 #include <stdlib.h>
9 #include <gtk/gtk.h>
10 #include <time.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <unistd.h>
14 #include <X11/Xlib.h>
15 #include <X11/Xatom.h>
16 #include <semaphore.h>
17 #include <gmodule.h>
18 #include <glob.h>
19 
20 /* increment this MACRO whenever any change is done to structures
21  * (to avoid incorrect memory accesses by modules)
22  * Must be an integer.
23  * */
24 #define LIBRFM_SERIAL 538
25 #define  LIBRFM_MODULE \
26 void *module_sanity(void){ \
27     return (GINT_TO_POINTER(LIBRFM_SERIAL)); \
28 }
29 
30 #if GLIB_MAJOR_VERSION==2 && GLIB_MINOR_VERSION>=32
31 # define RfmRecMutex GRecMutex
32 # define RfmRWLock GRWLock
33 # define RFM_RW_LOCK_INIT(X) RfmRWLock X
34 #else
35 # define RfmRecMutex GStaticRecMutex
36 # define RfmRWLock GStaticRWLock
37 # define RFM_RW_LOCK_INIT(X) RfmRWLock X = G_STATIC_RW_LOCK_INIT
38 #endif
39 
40 /**************************************************************/
41 /////////////////////  record_entry_t //////////////////////////
42 /**************************************************************/
43 
44 typedef struct record_entry_t	/* was: record_entry_t */
45 {
46     gint type;
47     struct stat *st;
48     gchar *mimetype;
49     gchar *mimemagic;
50     gchar *filetype;
51     gchar *encoding;
52     gchar *tag;
53     gchar *path;
54     gchar *pseudo_path;
55     const gchar *module;	/* module name, or NULL for local files */
56     const gchar *parent_module;	/* module name, or NULL for local files */
57 }
58 record_entry_t;
59 
60 /**************************************************************/
61 /////////////////////  rfm_global_t /////////////////////////
62 /**************************************************************/
63 typedef struct rfm_global_t
64 {
65   gint 		argc; 		/* partial argument list */
66   gchar 	**argv; 	/* partial argument list */
67 
68   Display 	*Xdisplay;
69   Drawable 	root_Xwindow;
70   Visual 	*Xvisual;
71 
72   // GThread	*self;
73   // In the 3.6 threading paradigm, self is replaced by main_context
74   // We now use rfm_get_gtk_thread(), which is set by rfm_init()
75   // or later by rfm_set_gtk_thread().
76 
77   GtkWidget 	*window; 		// main  window
78 
79   // list of valid views (necessary for tabbed iconview)
80 
81   RfmRWLock    setup_lock;
82 
83   // A write lock must be obtained to destroy the window:
84   RfmRWLock	window_lock;
85   GCond		*janitor_signal;
86   GCond		*status_signal;
87   GMutex	*status_mutex;
88   gint		status;
89   gint		thread_count;
90   GThreadPool	*thread_queue;
91   gint          cores;
92 
93   void 		*settings_widgets_p;
94 #if GTK_MAJOR_VERSION==3
95   GdkDevice     *pointer;
96 #endif
97 }
98 rfm_global_t;
99 
100 
101 
102 
103 
104 
105 
106 /**************************************************************/
107 /////////////////////  xfdir_t /////////////////////////////////
108 /**************************************************************/
109 
110 typedef struct dir_t
111 {
112     gchar		*pathv;		/* matched pathname.  */
113     record_entry_t	 *en;
114 
115 }
116 dir_t;
117 
118 
119 typedef struct xfdir_t
120 {
121     size_t 		pathc;		/* Count of paths matched */
122     dir_t 		*gl;
123     void 		*data;
124     off_t 		tama;
125     guint		monitor_id;
126     guint		view_id;
127     //flags
128     gboolean		reload;
129     gboolean		invalidate_icons;
130     gint		preferences;
131     gint		sort_column;
132     struct view_t	*view_p;
133     GThread 		*thread;
134     void		*control_p;
135     record_entry_t	*en;
136 
137 }
138 xfdir_t;
139 
140 /**************************************************************/
141 /////////////////////   population_t ///////////////////////////
142 /**************************************************************/
143 
144 
145 typedef struct population_t {
146     record_entry_t 	*en;
147     gchar		*icon_id;
148     gchar		*label;
149     GdkPixbuf 		*pixbuf; // extra reference in pixbuf hash
150     GdkPixbuf		*thumbnail; // extra reference in pixbuf hash
151     GdkPixbuf 		*preview_pixbuf;  // referenced: for tooltip and properties preview
152     PangoLayout 	*layout;
153     PangoLayout 	*layout2;
154     PangoLayout 	*layout_full;
155 
156     PangoRectangle 	logical_rect;
157     PangoRectangle 	logical_rect2;
158     PangoRectangle 	logical_rect_full;
159 
160     struct view_t	*view_p;
161     gint 		population_serial;
162     const gchar 	*module;
163     gboolean		content_icon;
164 
165     gint 		icon_size; // current icon size
166     gint 		icon_size_id; // This allows id == 0 for details view
167     gint		flags;
168 // normal_tip: preview was tried but not accomplished
169 			// normal_tip	POPULATION_NORMAL_TIP
170 			// preview_done	POPULATION_PREVIEW_DONE
171  // preview_busy: for tooltip and properties preview
172 			// preview_busy	POPULATION_PREVIEW_BUSY
173 			// selected	POPULATION_SELECTED
174 			// saturated	POPULATION_SATURATED
175 			// thumbnailed	POPULATION_THUMBNAILED
176 			// cut		POPULATION_CUT
177 			// copied	POPULATION_COPIED
178 			// short_icon	POPULATION_SHORT_ICON
179 
180     gint 		row;
181     gint 		column;
182 
183     //PangoLayout 	*extension;
184     //PangoRectangle 	extension_rect;
185 } population_t;
186 
187 
188 /**************************************************************/
189 /////////////////////  widgets_t ///////////////////////////////
190 /**************************************************************/
191 
192 typedef struct widgets_t {
193     struct view_t	*view_p;		// view_t * parent
194     gchar		*workdir;		// current workdir
195 
196     void 		*data;			// Available to plugins
197 
198     GtkWidget 		*paper; 		// drawing area
199     GtkWidget 		*diagnostics;		// diagnostics text area
200     GtkWidget 		*diagnostics_window;	// window to place diagnostics
201     GtkWidget 		*status;		// status text area
202     GtkWidget 		*rename;		// rename entry box
203     GtkWidget 		*button_space;		// little button space
204     GtkWidget 		*clear_button;		// clear text area button
205 #if 0
206     // notebook is only for gridview
207     GtkScrolledWindow 	*scrolled_window;	// viewport for drawing area
208     GtkWidget 		*vpane;			// drawing/diagnostics pane
209     GtkWidget 		**notebook; 		// notebook
210     GtkWidget 		*page_child; 		// notebook page
211     GtkWidget 		*page_icon; 		// notebook tab icon
212     GtkWidget 		*page_label; 		// notebook tab label
213     GtkWidget 		*page_button; 		// notebook remove button
214     GtkWidget 		*page_menu_label_box; 	// notebook menu box
215     GtkWidget 		*size_scale;		//
216 #endif
217 } widgets_t;
218 
219 
220 
221 /**************************************************************/
222 /////////////////////   eyecandy_t  ////////////////////////////
223 /**************************************************************/
224 
225 typedef struct eyecandy_t {
226     cairo_surface_t	*bg_surface;
227     gchar		*desktop_bg_file;
228     gchar		*desktop_color;
229     gchar		*iconview_color;
230 }eyecandy_t;
231 
232 /**************************************************************/
233 /////////////////////   mouse_event_t  /////////////////////////
234 /**************************************************************/
235 
236 typedef struct mouse_event_t {
237     // mouse events
238     guint32 		eventtime;  	/* eventtime for module popup menu */
239     gboolean		rubberbanding;
240     gint 		single_click_mode_state;
241     GdkDragAction 	drag_action;
242     GdkEventDND 	drag_event;
243     GdkPixbuf 		*dnd_pixbuf;
244     GtkTargetList	*target_list;
245     gint 		current_mouseX;	//
246     gint 		current_mouseY;	//
247     gint 		old_X;		//
248     gint 		old_Y;		//
249     gint 		boxX;		//
250     gint 		boxY;		//
251     gdouble 		initial_x;
252     gdouble 		mouseX;
253     gdouble 		initial_y;
254     gdouble 		mouseY;
255     gdouble 		offset_x;
256     gdouble 		offset_y;
257     const population_t 	*selected_p;
258     const population_t 	*doing_drag_p;
259     const population_t 	*saturated_p;
260     const population_t 	*label_p;
261     gboolean 		dragstate;
262 } mouse_event_t;
263 
264 /**************************************************************/
265 /////////////////////   view_layout_t  ///////////////////////
266 /**************************************************************/
267 
268 typedef struct view_layout_t {
269     gint 		tripwire; // set if value is set
270 
271     gint 		max_elements;
272     gint 		cellwidth;
273     gint 		cellheight;
274     gint 		grid_rows;
275     gint 		grid_columns;
276     gint 		grid_area;
277     GtkAllocation 	vpane_allocation;	// only for gridview
278 
279     gint 		icon_size;
280     gint 		paperX;			// configuration parameter
281     gint 		paperY;			// configuration parameter
282     gint 		window_width;		// configuration parameter
283     gint 		window_height;		// configuration parameter
284     gint		margin_top;
285     gint		margin_bottom;
286     gint		margin_left;
287     gint		margin_right;
288 
289     gint 		text_height;	//
290     gint 		column_width;	//
291     gint 		root_w;
292     gint 		root_h;
293     gint 		root_d;
294     gint		name_width;
295     gint		details_width;
296 } view_layout_t;
297 
298 /**************************************************************/
299 /////////////////////   mutexes_t   ////////////////////////////
300 /**************************************************************/
301 
302 typedef struct mutexes_t {
303     GMutex		*reload_mutex;
304     GMutex		*status_mutex;
305 
306     GMutex		*population_serial;
307     GMutex		*monitor_control;
308     GMutex		*monitor_run_mutex;
309     GCond		*monitor_signal;
310     GCond		*monitor_run_signal;
311     RfmRWLock		population_rwlock;
312     RfmRWLock		view_lock;
313     RfmRWLock		monitor_lock;
314 
315 } mutexes_t;
316 
317 /**************************************************************/
318 /////////////////////   flags_t     ////////////////////////////
319 /**************************************************************/
320 
321 typedef struct flags_t {
322     gboolean		refresh;
323 
324     gboolean 		enable_buffer_surface;
325     // redraw deskview buffer pixbuf
326     gboolean 		monitor_enabled;
327     gboolean 		thumbnailer_active;
328     gboolean 		thumbnailer_exit;
329     gboolean		monitor_go;
330     gboolean		active_monitor;
331     gint 		preferences;	//
332     gint 		serial;
333     gint 		type;		// iconview type:
334     gint 		sortcolumn;	//
335     gint 		count; 		// to monitor load progress
336     gint 		status;
337     gint 		monitor_id;
338     gint		pasteboard_serial;
339     gint		bookmark_serial;
340     gint		population_serial;
341     gint		saturation_serial;
342     gint		thread_count;
343 
344 } flags_t;
345 
346 /**************************************************************/
347 /////////////////////   view_t /////////////////////////////////
348 /**************************************************************/
349 
350 typedef struct view_t {
351     record_entry_t 	*en;			// folder entry
352     gchar 		*desktop_dir;		// used by deskview
353     gchar 		*lp_command;
354     gchar 		*xbuffer;
355     gchar 		*deepest_dir;
356 
357     GSList 		*selection_list;
358     GSList 		*reselect_list;
359     GList 		*go_list;
360     GSList 		*f_list;
361     GList 		*sh_command;
362     GdkPixbuf		*bg_pixbuf;
363 
364     widgets_t 		widgets;
365 
366     view_layout_t	view_layout;
367     mouse_event_t	mouse_event;
368     eyecandy_t		eyecandy;
369     mutexes_t		mutexes;
370     flags_t		flags;
371 
372     gboolean            expose_hold;
373     gboolean            monitor_running;
374     gint 		sh_command_counter;
375 
376 
377 
378     gulong		signal_handlers[1];
379 
380     population_t 	**population_pp;
381     GHashTable          *population_hash;
382 
383     const gchar 	*module;
384     /* constructor functions: */
385     void	        *constructor;
386     void 		(*child_constructor)(struct widgets_t *widgets_p,
387 				    gchar *path);
388     void 		(*tab_constructor)(struct widgets_t *widgets_p,
389 				    const gchar *path);
390     void 		(*tab_destructor)(struct view_t *view_p);
391     void		*user_data;
392 
393 } view_t;
394 
395 
396 #endif
397