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