Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtfile / FileMgr.h
1 /* $XConsortium: FileMgr.h /main/6 1996/10/07 13:45:03 mustafa $ */
2 /************************************<+>*************************************
3  ****************************************************************************
4  *
5  *   FILE:           FileMgr.h
6  *
7  *   COMPONENT_NAME: Desktop File Manager
8  *
9  *   DESCRIPTION:    Public include file for the main window of the
10  *                   File Manager.
11  *
12  *   (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
13  *   (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
14  *   (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
15  *   (c) Copyright 1993, 1994, 1995 Novell, Inc.
16  *
17  ****************************************************************************
18  ************************************<+>*************************************/
19
20 #ifndef _FileMgr_h
21 #define _FileMgr_h
22 #include <stdio.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25
26
27 /*  Resource names  */
28
29 #define SELECTION_LIST          "selectionList"
30 #define BRANCH_LIST             "branchList"
31
32 /*  Used in all the dialogs as its userData value for OK and Cancel buttons */
33
34 #define FLAG_SET   0x22
35 #define FLAG_RESET 0x33
36
37 /* Menu button sensitivity defines */
38
39 #define RENAME         (1 << 1)
40 #define MOVE           (1 << 2)
41 #define DUPLICATE      (1 << 3)
42 #define LINK           (1 << 4)
43 #define TRASH          (1 << 5)
44 #define MODIFY         (1 << 6)
45 #define CHANGEDIR      (1 << 7)
46 #define PREFERENCES    (1 << 8)
47 #define FILTER         (1 << 9)
48 #define FIND           (1 << 10)
49 #define CREATE_DIR     (1 << 11)
50 #define CREATE_FILE    (1 << 12)
51 #define SETTINGS       (1 << 13)
52 #define PUTBACK        (1 << 14)
53 #define PUT_ON_DESKTOP (1 << 15)
54 #define CLEAN_UP       (1 << 16)
55 #define MOVE_UP        (1 << 17)
56 #define HOME           (1 << 18)
57 #define CHANGE_DIR     (1 << 19)
58 #define TERMINAL       (1 << 20)
59 /* CLEAN_UP_OP is not really a menu state.
60    It's a flag to let GetFileData in FileMgr.c (call when the directory
61    is being reread) not to reload icon positions from the .!dt<userid> file.
62 */
63 #define CLEAN_UP_OP    (1 << 21)
64
65
66 #define NOT_DESKTOP         0
67 #define DESKTOP             1
68 #define NOT_DESKTOP_DIR     2
69 #define FM_POPUP            3
70 #define TRASH_DIRECTORY     4
71
72 /* the number of columns standard in the fast change to text widget */
73 #define FAST_CHANGE_COLUMNS  35
74
75 /* Forward structure pointer declaration */
76 typedef struct _ObjectPosition * ObjectPtr;
77
78 /*  Structure for containing the data for 1 file  */
79
80 typedef struct _FileData
81 {
82    struct _FileData * next;
83    char * file_name;             /* name of the file */
84    char * action_name;           /* if it is an Action, the LABEL name */
85    unsigned char physical_type;  /* file, directory, device, pipe, ... */
86    char *        logical_type;   /* data type from data typing db */
87    int errnum;                   /* error code */
88    struct stat stat;             /* file status */
89    char * link;                  /* value of symbolic link */
90    char * final_link;            /* last of a chain of symbolic links */
91    Boolean is_subdir;            /* directory other than "." or ".." */
92    Boolean is_broken;            /* broken link */
93 } FileData;
94
95 typedef struct _FileData2
96 {
97    struct _FileData2 * next;
98    short file_name;              /* name of the file */
99    short action_name;            /* if it is an Action, the LABEL name */
100    unsigned char physical_type;  /* file, directory, device, pipe, ... */
101    short logical_type;   /* data type from data typing db */
102    int errnum;                   /* error code */
103    struct stat stat;             /* file status */
104    short link;                   /* value of symbolic link */
105    short final_link;             /* last of a chain of symbolic links */
106    Boolean is_subdir;            /* directory other than "." or ".." */
107    Boolean is_broken;            /* broken link */
108    char text[BUFSIZ];
109 } FileData2;
110
111
112 /* position info read from the position info file */
113 typedef struct
114 {
115    char *name;
116    Position x;
117    Position y;
118    int stacking_order;
119 } PositionInfo;
120
121
122 /* tree branch expansion states */
123 typedef enum {
124   tsNotRead,     /* directory not yet read */
125   tsError,       /* error reading directory */
126   tsReading,     /* directory currently being read for the first time */
127   tsNone,        /* no contents shown */
128   tsDirs,        /* only sub directories shown */
129   tsAll          /* all contents shown */
130 } TreeShow;
131
132 typedef struct _FileViewData
133 {
134    XtPointer directory_set;
135    FileData * file_data;
136    struct _FileViewData *parent;    /* ptr to dir containing this entry */
137    struct _FileViewData *next;      /* ptr to next entry in the same dir */
138    struct _FileViewData *desc;      /* if this is a dir: list of entries */
139    Boolean filtered;             /* True if file is filtered */
140    Boolean selected;             /* True if file is selected */
141    Boolean displayed;            /* False if filtered or collapsed tree branch*/
142    TreeShow ts;                  /* how much to show in tree mode */
143    int ndir;                     /* no of sub directories */
144    int nfile;                    /* no of non-dir files */
145    int nnew;                     /* no of new files */
146    Widget widget;                /* icon gadget for this entry */
147    Widget treebtn;               /* button gadget for tree branch expand */
148    Boolean need_update;          /* False until widget created and up-to-date */
149    Boolean registered;           /* True if drop zone registered */
150    Position x, y;                /* bottom left corner of icon gadget */
151    char *label;                  /* icon label string */
152    long icon_mtime;              /* modified time of instance icon */
153    ObjectPtr position_info;
154 } FileViewData;
155
156
157 /*  Structure for containing a set of directories  */
158
159 typedef struct
160 {
161    char          * name;
162    FileViewData  * sub_root;           /* root of the sub-tree */
163    int             file_count;
164    FileViewData ** file_view_data;
165    FileViewData ** order_list;
166    int             filtered_file_count;
167    int             invisible_file_count;
168    XtPointer       file_mgr_data;
169 } DirectorySet;
170
171
172 /* Structure for containing desktop object position information */
173
174 typedef struct _ObjectPosition {
175    char * name;
176    Position x;
177    Position y;
178    Boolean in_use;
179    Boolean late_bind;
180    int stacking_order;
181    FileViewData * file_view_data;
182    ObjectPtr next;
183    ObjectPtr prev;
184 } ObjectPosition;
185
186 /*  External definitions for the file manager dialog class  */
187
188 extern DialogClass * fileMgrClass;
189
190 typedef enum
191 {
192   not_busy = 0,        /* not busy */
193   busy_readdir,        /* busy reading directory */
194   initiating_readdir   /* inside call to ReadDir */
195 } BusyStatus;
196
197 typedef struct
198 {
199    /* first 5 fields must be identical to DialogInstanceData struct */
200    Boolean   displayed;
201    Position  x;
202    Position  y;
203    Dimension width;
204    Dimension height;
205
206    Boolean   mapped;
207    short busy_status;
208    int busy_detail;
209
210    unsigned char show_type;     /* single directory or directory tree? */
211    unsigned char tree_files;    /* show only subdirs or files as well? */
212    short tree_preread_level;    /* how many levels to pre-read */
213    short tree_show_level;       /* how many levels to show initially */
214
215    int           restoreKind;
216
217    char * host;
218    char * current_directory;
219    char ** branch_list;
220
221    unsigned char view;              /* current view */
222    unsigned char view_single;       /* view for singlge directory */
223    unsigned char view_tree;         /* view for tree mode */
224    unsigned char order;             /* sort order */
225    unsigned char direction;         /* sort direction */
226    unsigned char positionEnabled;   /* random positioning vs sorted grid */
227
228    Boolean newSize;
229    char * restricted_directory;
230    char * title;
231    char * helpVol;
232    Boolean toolbox;
233    Boolean dropSite;
234    Boolean IsTrashCan;
235
236    int             directory_count;
237    DirectorySet ** directory_set;
238    FileViewData  * tree_root;           /* root of the tree */
239
240    FileViewData  * renaming;
241
242    FileViewData ** selection_list;
243    char ** selection_table;
244    int selected_file_count;
245
246    Boolean       show_iconic_path;
247    Boolean       show_current_dir;
248    Boolean       show_status_line;
249    Boolean       fast_cd_enabled;
250    Boolean       show_hid_enabled;
251
252    char *special_msg;
253    XtIntervalId msg_timer_id;
254
255    Boolean       cd_inited;
256    XFontStruct * cd_font;
257    XFontSet      cd_fontset;
258    XmFontType    cd_fonttype;
259    GC            cd_normal_gc;
260    GC            cd_select_gc;
261    char          *cd_select;
262
263    GC            tree_solid_thin_gc;
264    GC            tree_solid_thick_gc;
265    GC            tree_dash_thin_gc;
266    GC            tree_dash_thick_gc;
267
268    XtPointer file_mgr_rec;
269    FileViewData * popup_menu_icon;
270    FileViewData * drag_file_view_data;
271
272    DialogData * find;
273    DialogData * attribute;
274    DialogData * change_dir;
275    DialogData * preferences;
276    DialogData * filter_active;
277    DialogData * filter_edit;
278    DialogData ** attr_dialog_list;
279    int           attr_dialog_count;
280    DialogData ** secondaryHelpDialogList;
281    int           secondaryHelpDialogCount;
282    DialogData *  primaryHelpDialog;
283
284    ObjectPosition ** object_positions;
285    int              num_objects;
286    Dimension        grid_height;
287    Dimension        grid_width;
288
289    /* When user creates new file or directory, we want to store
290       away the new file info so we can scroll to it later.
291    */
292    char * scrollToThisFile;
293    char * scrollToThisDirectory;
294
295    XtPointer layout_data;
296    char * desktop_file;
297 } FileMgrData, * FileMgrDataPtr;
298
299
300 typedef struct
301 {
302    Widget shell;
303    Widget main;
304    Widget menu;
305    Widget header_frame;
306    Widget header_separator;
307    Widget iconic_path_da;
308    Widget current_directory_frame;
309    Widget current_directory_drop;
310    Widget current_directory_icon;
311    Widget current_directory;
312    Widget current_directory_text;
313    Widget status_line;
314    Widget scroll_window;
315    Widget horizontal_scroll_bar;
316    Widget vertical_scroll_bar;
317    Widget file_window;
318    Widget actions;
319    Widget action_pane;
320    Widget directoryBarBtn;
321    Dimension iconic_path_width;
322    char * action_pane_file_type;
323    unsigned int menuStates;
324    Widget focus_widget;
325    Widget create_directoryBtn_child;
326    Widget create_dataBtn_child;
327    Widget findBtn_child;
328    Widget change_directoryBtn_child;
329    Widget preferencesBtn_child;
330    Widget defaultEnvBtn_child;
331    Widget filterBtn_child;
332 } FileMgrRec;
333
334 typedef struct
335 {
336    char * action_pane_file_type;
337    Widget menu;
338    Widget title;
339    Widget wsPopup[6];
340    Widget objPopup[6];
341    Widget trash_objPopup[2];
342    Widget action_separator;
343 } FileMgrPopup;
344
345 typedef struct
346 {
347    Widget dialog_widget;
348    Widget menu_widget;
349    Widget dir_text_widget;
350    Widget file_text_widget;
351    Widget file_type_widget;
352    Widget Ok;
353    Widget Cancel;
354    Widget Apply;
355    Widget Help;
356    Widget Misc;
357    int    original_physical_type;
358    char * original_logical_type;
359    char * file_name;
360    char * directory_name;
361    char * host_name;
362    int mode;
363    FileMgrRec * file_mgr_rec;
364    char * previous_file_type;
365    FileMgrData * file_mgr_data;
366 } DialogCallbackStruct;
367
368 /*  Local structure used for passing callback data  */
369
370 typedef struct
371 {
372    Widget w;
373    DialogCallbackStruct *call_struct;
374    unsigned char type;
375    unsigned int btnMask;
376    char *new_name;
377 } MakeFileDoneData;
378
379
380 typedef struct
381 {
382    Widget w;
383    DialogCallbackStruct *call_struct;
384    int mode;
385    unsigned int btnMask;
386 } RenameDoneData;
387
388 /* data for doing icon update and layout */
389 typedef struct
390 {
391   /* ordered list of all files */
392   FileViewData ** order_list;
393   int order_count;
394
395   /* icon layout parameters */
396   Dimension width;
397   Dimension height;
398   Dimension pixmap_width;
399   Dimension pixmap_height;
400   Dimension char_width;
401   Dimension margin;
402   Dimension spacing;
403   Dimension highlight;
404   unsigned char alignment;
405   unsigned char pixmap_position;
406   Boolean icon_top;
407   int treebtn_size;
408
409   /* colors to use */
410   Pixel background;
411   Pixel foreground;
412   Pixel pixmap_back;
413   Pixel pixmap_fore;
414 #ifdef _SHOW_LINK
415   Pixel topshadow;
416 #endif
417
418   /* widgets to be re-used */
419   Widget *reuse_icons;
420   Widget *reuse_btns;
421   Widget *next_icon_to_use;
422   Widget *next_btn_to_use;
423   Widget dup_icon_widget;
424   Widget *manage;
425   int manage_count;
426
427   /* DisplayWorkProc */
428   XtWorkProcId work_id;
429   Widget drop_site_w;
430   int ex, ey;
431   Boolean focus_done;
432   Boolean visible_done;
433   Boolean all_done;
434   int i_do_next_vis;
435   int i_do_next_all;
436 } IconLayoutData;
437
438
439
440
441 #define FM_POPUP_CHILDREN    17
442 #define FM_POPUP_CHILDREN_NA 15
443
444 #define WS_BTNS              6
445 #define OBJ_BTNS             6
446 #define OBJ_BTNS_NA          4
447 #define TRASH_OBJ_BTNS       2
448
449 #define BTN_PROPERTIES       0
450
451 /* white space buttons */
452 #define BTN_FIND             1
453 #define BTN_CLEANUP          2
454 #define BTN_SELECTALL        3
455 #define BTN_UNSELECTALL      4
456 #define BTN_SHOWHIDDEN       5
457
458 /* object buttons */
459 #define BTN_PUTON            1
460 #define BTN_TRASH            2
461 #define BTN_HELP             3
462
463 /* trash object buttons */
464 #define BTN_RESTORE          0
465 #define BTN_REMOVE           1
466
467 #endif /* _FileMgr_h */
468 /* DON'T ADD ANYTHING AFTER THIS #endif */