2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: Main.c /main/29 1999/09/17 13:35:04 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 * COMPONENT_NAME: Desktop File Manager (dtfile)
31 * Description: This file contains the main program for dtfile.
32 * It also contains functions for session management and
33 * directory view control.
35 * FUNCTIONS: BlackPixelOfScreen
36 * BuildAndShowIconName
37 * CheckForOpenDirectory
44 * DtfileCvtStringToDTIcon
45 * DtfileCvtStringToDirection
46 * DtfileCvtStringToGrid
47 * DtfileCvtStringToObjPlace
48 * DtfileCvtStringToOpenDir
49 * DtfileCvtStringToOrder
50 * DtfileCvtStringToTree
51 * DtfileCvtStringToTreeFiles
52 * DtfileCvtStringToView
53 * DtfileStringToDirection
57 * DtfileStringToTreeFiles
66 * GetRestrictedDirectory
85 * SetupSendRequestArgs
90 * ViewDirectoryHandler
92 * ViewHomeDirectoryHandler
94 * ViewToolsDirectoryHandler
95 * WaitForResponseAndExit
99 * _DtWsmAddMarqueeSelectionCallback
105 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
106 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
107 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
108 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
110 ****************************************************************************
111 ************************************<+>*************************************/
113 #include <sys/types.h>
116 #include <sys/stat.h>
119 #if defined(CSRG_BASED)
120 #include <sys/wait.h>
121 #endif /* CSRG_BASED */
128 #ifndef sun /* don't need the nl_types.h file */
129 #include <nl_types.h>
135 #include <Xm/DrawingA.h>
136 #include <Xm/DrawingAP.h>
137 #include <Xm/MessageB.h>
138 #include <Xm/RowColumn.h>
139 #include <Xm/MwmUtil.h>
141 #include <Xm/IconFileP.h>
143 #include <Dt/IconP.h>
144 #include <Dt/IconFile.h>
146 #include <Dt/HelpDialog.h>
149 #include <X11/extensions/shape.h>
152 #include <X11/Shell.h>
153 #include <X11/Xatom.h>
154 #include <Xm/Protocols.h>
156 #include <X11/Xmu/Editres.h>
158 #include <Dt/Session.h>
161 #include <Dt/Connect.h>
162 #include <Dt/FileM.h>
163 #include <Dt/Indicator.h>
165 #include <Dt/UserMsg.h>
168 #include <Dt/DtNlUtils.h>
169 #include <Dt/CommandM.h>
170 #include <Dt/EnvControlP.h>
172 #include <Dt/SharedProcs.h>
175 #include "SharedProcs.h"
183 #include "ChangeDir.h"
191 extern void MoveCopyLinkHandler(Tt_message ttMsg, int opType);
194 extern void PutOnWorkspaceHandler(Tt_message ttMsg);
197 extern void UpdateFilterAfterDBReread (DialogData * dialog_data);
199 /* From ToolTalk.c */
200 extern int InitializeToolTalkSession( Widget topLevel, int ttFd );
201 extern Tt_status InitializeToolTalkProcid( int *ttFd, Widget topLevel, Boolean sendStarted );
202 extern void FinalizeToolTalkSession();
204 void CloseTrash(Widget w, XtPointer client_data, XtPointer call_data) ;
208 /* When openDir resource is set to NEW
209 File Manager will use this prefix to find for a different icon
212 #define ICON_OPEN_PREFIX "OPEN_"
214 /* THESE ARE ONLY STRINGS WHICH DO NOT NEED TO BE LOCALIZED */
215 /* Don't use '#define' since you end up with multiple copies */
216 char DTFILE_CLASS_NAME[] = "Dtfile";
217 char DTFILE_HELP_NAME[] = "Filemgr";
218 char DESKTOP_DIR[] = ".dt/Desktop";
220 static char WS_RES_HEADER[] = ".Workspace.";
221 static char SEC_HELP_RES_HEADER[] = ".secondaryHelpDialogCount: ";
222 static char WS_LOAD_RES_HEADER[] = "Workspace";
223 static char SEC_LOAD_HELP_RES_HEADER[] = "secondaryHelpDialogCount";
224 static char RESTRICTED_HEADER[] = "-restricted";
225 static char VIEW_HEADER[] = "-view";
228 /* Structure, resource definitions, for View's optional parameters. */
241 int instanceIconWidth;
242 int instanceIconHeight;
243 XmFontList user_font;
244 Dimension tool_width;
245 Dimension tool_height;
247 Dimension dir_height;
256 int maxDirectoryProcesses;
257 int maxRereadProcesses;
258 int maxRereadProcsPerTick;
261 Boolean showFilesystem;
262 Boolean showDropZone;
263 Boolean showEmptySet;
264 Boolean showEmptyMsg;
266 Boolean restrictMode;
267 int desktopPlacement;
268 Boolean freezeOnConfig;
269 #if defined(__hpux) || defined(sun)
270 Boolean follow_links;
275 int retryLoadDesktop;
280 Boolean emptyTrashOnExit;
281 } ApplicationArgs, *ApplicationArgsPtr;
283 static ApplicationArgs application_args;
285 /******** Static Function Declarations ********/
287 static void ErrorHandler(
289 XErrorEvent *event) ;
290 static void ToolkitErrorHandler(
294 static void RestrictModeUsage(
296 static void Stop( void ) ;
297 static void RestoreSettingsFile( void ) ;
298 static void MoveDefaultSettings(
300 static void SaveDefaultCancelCB(
302 XtPointer client_data,
303 XtPointer call_data) ;
304 static void SaveDefaultOkCB(
306 XtPointer client_data,
307 XtPointer call_data) ;
308 static void SaveSession(
310 static int RestoreSession(
315 char current_directory[]) ;
316 static void OpenDirectories(
319 static Tt_callback_action ObserveTtNotice(
322 static void ViewSessionHandler(
324 static void ViewDirectoryHandler(
326 static void ViewHomeDirectoryHandler(
328 static void ViewToolsDirectoryHandler(
330 static void ExitHandler(
332 XtPointer clientData,
333 String * messageFields,
335 static void ReloadDatabases( void );
336 static void ViewAccept(
339 static void LoadViews (
343 char *directory_name,
346 static void RemoveTextFields (
347 XtPointer client_data,
348 DialogData * old_dialog_data,
349 DialogData * new_dialog_data) ;
350 static void DtfileCvtStringToObjPlace (
355 static unsigned char *_DtNextToken (
356 unsigned char *pchIn,
358 unsigned char **ppchNext) ;
359 static void DtfileCvtStringToOpenDir (
364 static void DtfileCvtStringToDTIcon (
369 static void DtfileCvtStringToTree (
374 static void DtfileCvtStringToTreeFiles (
379 static void DtfileCvtStringToView (
384 static void DtfileCvtStringToOrder (
389 static void DtfileCvtStringToDirection (
394 static void DtfileCvtStringToGrid (
399 static void DtfileStringToTree(
402 static void DtfileStringToTreeFiles(
405 static void DtfileStringToView(
408 static void DtfileStringToOrder(
411 static void DtfileStringToDirection(
414 static void DtfileStringToGrid(
417 static void SetupSendRequestArgs(
418 ApplicationArgs application_args,
420 static void BuildAndShowIconName(
421 char *file_type_name,
423 unsigned char show_type,
425 static void MarqueeSelect (
432 XtPointer client_data);
433 static void WaitForResponseAndExit( void ) ;
435 XtPointer clientData,
438 static Widget post_dialog(
443 static void DtErrExitCB(
445 XtPointer client_data,
446 XtPointer call_data);
448 /******** End Static Function Declarations ********/
455 /* performance flag */
456 #ifdef DT_PERFORMANCE
460 /* The id's of the dialogs registered by main */
463 int change_dir_dialog;
464 int preferences_dialog;
470 /* The shared menu button and pane Id's */
472 Widget * create_dataBtn;
475 Widget * duplicateBtn;
478 Widget * create_directoryBtn;
479 Widget * change_directoryBtn;
480 Widget * showHiddenMenu;
481 Widget * preferencesBtn;
483 Widget * defaultEnvBtn;
490 Widget * terminalBtn;
491 Widget * usingHelp = NULL;
492 Widget * fileManagerHelp = NULL;
493 Widget * applicationManagerHelp = NULL;
494 Widget * usingHelpTrash = NULL;
497 /* Bitmask used to indicate the current sensitivity state of shared menu btns */
499 unsigned int currentMenuStates = ( RENAME | MOVE | DUPLICATE | LINK | TRASH |
500 MODIFY | CHANGEDIR | PREFERENCES | FILTER |
501 FIND | CREATE_DIR | CREATE_FILE |
502 PUT_ON_DESKTOP | PUTBACK |
504 HOME | CHANGE_DIR | TERMINAL);
506 /* Drag manager globals */
508 Boolean dragActive = False;
510 /* Desktop Globals */
514 /* Globally referenced application name. Set to argv[0] in main */
516 char * application_name = NULL;
519 /* uid for root user; used when we are checking access permissions */
526 char home_host_name[MAX_PATH];
527 char users_home_dir[MAX_PATH];
530 /* Toolbox directory */
532 char * desktop_dir = NULL;
533 char * trash_dir = NULL;
534 char * remote_sys_dir = NULL;
538 int restoreType = NORMAL_RESTORE;
541 /* Black and White pixels */
547 /* File manager view set before a new view is created and */
548 /* used to propagate visual attributes from the initiating */
549 /* view to the new view. */
551 XtPointer initiating_view = NULL;
552 Boolean special_view = False;
553 Boolean TrashView = False;
556 /* system wide user font */
558 XmFontList user_font;
561 /* Global localizable strings */
567 /* Global dialog button labels, as XmStrings */
570 XmString cancelXmString;
571 XmString helpXmString;
572 XmString applyXmString;
573 XmString closeXmString;
576 /* Global top level widget */
580 /* Global Application resources */
581 Boolean showFilesystem;
582 Boolean showDropZone;
583 Boolean showEmptySet;
584 Boolean showEmptyMsg;
585 Boolean restrictMode;
589 char *fileMgrHelpVol;
594 int desktopPlacement;
595 Boolean freezeOnConfig;
596 #if defined(__hpux) || defined(sun)
597 Boolean follow_links;
607 unsigned char keybdFocusPolicy;
608 int special_treeType;
609 int special_treeFiles;
610 int special_viewType;
611 int special_orderType;
612 int special_directionType;
613 int special_randomType;
614 char *special_restricted;
616 char *special_helpVol;
620 int retryLoadDesktopInfo;
627 Boolean emptyTrashOnExit;
630 Boolean shapeExtension;
633 /* Drag state variables */
634 Boolean B1DragPossible = False;
635 Boolean B2DragPossible = False;
636 Boolean ProcessBtnUp = False;
637 Boolean ProcessBtnUpCD = True;
641 int xErrorDetected = False;
643 /* BMenu button binding */
646 View ** view_set = NULL;
648 int view_set_size = 0;
650 /* Globals used within this file. */
652 static Display * display;
653 char * dt_path = NULL;
654 static Boolean message_display_enabled = True;
657 static Atom save_yourself_atom;
658 static Atom command_atom;
659 static Atom wm_state_atom;
660 static Atom save_mode;
662 /* Structure used on a save session to see if a dt is iconic */
671 /* Application resource list definition */
673 static XrmOptionDescRec option_list[] =
675 { "-noview", "noView", XrmoptionIsArg, NULL },
676 { "-session", "session", XrmoptionSepArg, NULL },
677 { "-dir", "folder", XrmoptionSepArg, NULL },
678 { "-folder", "folder", XrmoptionSepArg, NULL },
679 { "-tree", "treeView", XrmoptionSepArg, NULL },
680 { "-tree_files", "treeFiles", XrmoptionSepArg, NULL },
681 { VIEW_HEADER, "view", XrmoptionSepArg, NULL },
682 { "-order", "order", XrmoptionSepArg, NULL },
683 { "-direction", "direction", XrmoptionSepArg, NULL },
684 { "-grid", "grid", XrmoptionSepArg, NULL },
685 { RESTRICTED_HEADER, "restricted", XrmoptionIsArg, NULL },
686 { "-title", "title", XrmoptionSepArg, NULL },
687 { "-help_volume", "help_volume", XrmoptionSepArg, NULL },
688 { "-noprompt", "promptUser", XrmoptionNoArg, "False" },
689 { "-small_icon_width", "smallIconWidth", XrmoptionSepArg, NULL },
690 { "-small_icon_height", "smallIconHeight", XrmoptionSepArg, NULL },
691 { "-large_icon_width", "largeIconWidth", XrmoptionSepArg, NULL },
692 { "-large_icon_height", "largeIconHeight", XrmoptionSepArg, NULL },
696 static XtResource resources[] =
699 "noView", "NoView", XmRString, sizeof (char *),
700 XtOffset (ApplicationArgsPtr, no_view), XmRImmediate, (XtPointer) NULL,
704 "session", "Session", XmRString, sizeof (char *),
705 XtOffset (ApplicationArgsPtr, session), XmRImmediate, (XtPointer) NULL,
709 "folder", "Folder", XmRString, sizeof (char *),
710 XtOffset (ApplicationArgsPtr, directories), XmRImmediate, (XtPointer) NULL,
714 "treeView", "TreeView", "Tree", sizeof (int),
715 XtOffset (ApplicationArgsPtr, tree_view), XmRImmediate,
716 (XtPointer) UNSET_VALUE,
720 "treeFiles", "TreeFiles", "TreeFiles", sizeof (int),
721 XtOffset (ApplicationArgsPtr, tree_files), XmRImmediate,
722 (XtPointer) UNSET_VALUE,
726 "view", "View", "View", sizeof (int),
727 XtOffset (ApplicationArgsPtr, view), XmRImmediate, (XtPointer) UNSET_VALUE,
731 "order", "Order", "Order", sizeof (int),
732 XtOffset (ApplicationArgsPtr, order), XmRImmediate, (XtPointer) UNSET_VALUE,
736 "direction", "Direction", "Direction", sizeof (int),
737 XtOffset (ApplicationArgsPtr, direction), XmRImmediate,
738 (XtPointer) UNSET_VALUE,
742 "grid", "Grid", "Grid", sizeof (int),
743 XtOffset (ApplicationArgsPtr, grid), XmRImmediate, (XtPointer) UNSET_VALUE,
747 "instanceIconWidth", "InstanceIconWidth", XmRInt, sizeof (int),
748 XtOffset (ApplicationArgsPtr, instanceIconWidth), XmRImmediate,
753 "instanceIconHeight", "InstanceIconHeight", XmRInt, sizeof (int),
754 XtOffset (ApplicationArgsPtr, instanceIconHeight), XmRImmediate,
759 "restricted", "Restricted", XmRString, sizeof (char *),
760 XtOffset (ApplicationArgsPtr, restricted), XmRImmediate, (XtPointer) NULL,
764 "title", "Title", XmRString, sizeof (char *),
765 XtOffset (ApplicationArgsPtr, title), XmRImmediate, (XtPointer)NULL,
769 "help_volume", "Help_volume", XmRString, sizeof (char *),
770 XtOffset (ApplicationArgsPtr, help_volume), XmRImmediate, (XtPointer)NULL,
774 "userFont", "XmCFontList", XmRFontList, sizeof (XmFontList),
775 XtOffset (ApplicationArgsPtr, user_font), XmRString, (XtPointer) "Fixed",
779 "toolWidth", "ToolWidth", XmRHorizontalDimension, sizeof (Dimension),
780 XtOffset (ApplicationArgsPtr, tool_width), XmRImmediate, (XtPointer) 700,
784 "toolHeight", "ToolHeight", XmRVerticalDimension, sizeof (Dimension),
785 XtOffset (ApplicationArgsPtr, tool_height), XmRImmediate, (XtPointer) 250,
789 "dirWidth", "DirWidth", XmRHorizontalDimension, sizeof (Dimension),
790 XtOffset (ApplicationArgsPtr, dir_width), XmRImmediate, (XtPointer) 555,
794 "dirHeight", "DirHeight", XmRVerticalDimension, sizeof (Dimension),
795 XtOffset (ApplicationArgsPtr, dir_height), XmRImmediate, (XtPointer) 400,
799 "promptUser", "PromptUser", XmRBoolean, sizeof (Boolean),
800 XtOffset (ApplicationArgsPtr, prompt_user), XmRImmediate, (XtPointer) True,
804 "rootTitle", "RootTitle", XmRString, sizeof (char *),
805 XtOffset (ApplicationArgsPtr, root_title), XmRImmediate, (XtPointer)"ROOT",
809 "moveThreshold", "MoveThreshold", XmRInt, sizeof (int),
810 XtOffset (ApplicationArgsPtr, dragThreshold), XmRImmediate, (XtPointer) 4,
814 "rereadTime", "RereadTime", XmRInt, sizeof (int),
815 XtOffset (ApplicationArgsPtr, rereadTime), XmRImmediate, (XtPointer) 3,
819 "checkBrokenLink", "CheckBrokenLink", XmRInt, sizeof (int),
820 XtOffset (ApplicationArgsPtr, checkBrokenLink), XmRImmediate,
825 "maxDirectoryProcesses", "MaxDirectoryProcesses", XmRInt, sizeof (int),
826 XtOffset (ApplicationArgsPtr, maxDirectoryProcesses), XmRImmediate,
831 "maxRereadProcesses", "MaxRereadProcesses", XmRInt, sizeof (int),
832 XtOffset (ApplicationArgsPtr, maxRereadProcesses), XmRImmediate,
837 "maxRereadProcsPerTick", "MaxRereadProcsPerTick", XmRInt, sizeof (int),
838 XtOffset (ApplicationArgsPtr, maxRereadProcsPerTick), XmRImmediate,
843 "trashWait", "TrashWait", XmRInt, sizeof (int),
844 XtOffset (ApplicationArgsPtr, trashWait), XmRImmediate, (XtPointer) 1,
848 "desktopIcon", "DesktopIcon", "DesktopIcon", sizeof (int),
849 XtOffset (ApplicationArgsPtr, desktopIconType), XmRImmediate,
854 "showFilesystem", "ShowFilesystem", XmRBoolean, sizeof (Boolean),
855 XtOffset (ApplicationArgsPtr, showFilesystem), XmRImmediate,
860 "showDropZone", "ShowDropZone", XmRBoolean, sizeof (Boolean),
861 XtOffset (ApplicationArgsPtr, showDropZone), XmRImmediate,
866 "showEmptySet", "ShowEmptySet", XmRBoolean, sizeof (Boolean),
867 XtOffset (ApplicationArgsPtr, showEmptySet), XmRImmediate,
872 "showEmptyMsg", "ShowEmptyMsg", XmRBoolean, sizeof (Boolean),
873 XtOffset (ApplicationArgsPtr, showEmptyMsg), XmRImmediate,
878 "openFolder", "OpenFolder", "OpenFolder", sizeof (int),
879 XtOffset (ApplicationArgsPtr, openDirType), XmRImmediate,
884 "restrictMode", "RestrictMode", XmRBoolean, sizeof (Boolean),
885 XtOffset (ApplicationArgsPtr, restrictMode), XmRImmediate,
890 "objectPlacement", "ObjectPlacement", "ObjectPlacement", sizeof (int),
891 XtOffset (ApplicationArgsPtr, desktopPlacement), XmRImmediate,
892 (XtPointer)(OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_RIGHT_SECONDARY),
896 "freezeOnConfig", "FreezeOnConfig", XmRBoolean, sizeof (Boolean),
897 XtOffset (ApplicationArgsPtr, freezeOnConfig), XmRImmediate,
902 "fileManagerIcon", "FileManagerIcon", XmRString, sizeof (char *),
903 XtOffset (ApplicationArgsPtr, fileMgrIcon), XmRImmediate,
904 (XtPointer) HOME_ICON_NAME,
908 "appManagerIcon", "AppManagerIcon", XmRString, sizeof (char *),
909 XtOffset (ApplicationArgsPtr, appMgrIcon), XmRImmediate,
910 (XtPointer) TOOL_ICON_NAME,
914 "trashIcon", "TrashIcon", XmRString, sizeof (char *),
915 XtOffset (ApplicationArgsPtr, trashIcon), XmRImmediate,
916 (XtPointer) TRASH_ICON_NAME,
920 "retryLoadDesktop", "RetryLoadDesktop", XmRInt, sizeof (int),
921 XtOffset (ApplicationArgsPtr, retryLoadDesktop), XmRImmediate,
926 "smallIconWidth", "SmallIconWidth", XmRInt, sizeof (int),
927 XtOffset (ApplicationArgsPtr, smallIconWidth), XmRImmediate,
932 "smallIconHeight", "SmallIconHeight", XmRInt, sizeof (int),
933 XtOffset (ApplicationArgsPtr, smallIconHeight), XmRImmediate,
938 "largeIconWidth", "LargeIconWidth", XmRInt, sizeof (int),
939 XtOffset (ApplicationArgsPtr, largeIconWidth), XmRImmediate,
944 "largeIconHeight", "LargeIconHeight", XmRInt, sizeof (int),
945 XtOffset (ApplicationArgsPtr, largeIconHeight), XmRImmediate,
950 "emptyTrashOnExit", "EmptyTrashOnExit", XmRBoolean, sizeof (Boolean),
951 XtOffset (ApplicationArgsPtr, emptyTrashOnExit), XmRImmediate,
955 #if defined(__hpux) || defined(sun)
956 { "followLinks", "FollowLinks", XmRBoolean, sizeof(Boolean),
957 XtOffset(ApplicationArgsPtr, follow_links), XmRImmediate,
964 XtActionsRec actionTable[] = {
965 {"Space", (XtActionProc)VFTextChangeSpace},
966 {"EscapeFM", (XtActionProc)CancelOut},
969 /************************************************************************
972 * The main program for the file manager.
974 ************************************************************************/
976 extern XtInputId ProcessToolTalkInputId;
978 #if defined(CSRG_BASED)
979 extern void sigchld_handler(int);
980 #endif /* CSRG_BASED */
987 #ifdef DT_PERFORMANCE
988 struct timeval update_time_s;
989 struct timeval update_time_f;
990 struct timeval update_time_ss;
991 struct timeval update_time_fs;
994 char current_directory[MAX_PATH] = {0};
995 struct passwd * pwInfo;
999 Boolean eventDebugging;
1006 XSetWindowAttributes sAttributes;
1011 XrmValue resource_value;
1016 int ttFd; /* ToolTalk file descriptor */
1018 Tt_pattern events2Watch;
1019 Tt_pattern requests2Handle;
1022 #if defined(CSRG_BASED)
1023 struct sigaction sa, osa;
1024 #endif /* CSRG_BASED */
1025 int session_flag = 0;
1027 #ifdef DT_PERFORMANCE
1029 gettimeofday(&update_time_ss, NULL);
1031 (void) signal (SIGINT, (void (*)())Stop);
1033 /* We don't want any zombie children, do we? */
1034 #if defined(CSRG_BASED)
1035 sa.sa_handler = sigchld_handler;
1036 sigemptyset(&sa.sa_mask);
1039 if (sigaction(SIGCHLD, &sa, &osa) < 0)
1040 /* error handling follows, none for now */
1043 (void) signal (SIGCHLD, SIG_IGN);
1044 #endif /* CSRG_BASED */
1045 XtSetLanguageProc( NULL, NULL, NULL );
1047 #ifdef DT_PERFORMANCE
1048 { /* Initialize the checkpoint protocol - Aloke Gupta */
1050 display = XOpenDisplay("");
1051 _DtPerfChkpntInit(display, RootWindow(display, DefaultScreen(display)),
1057 _DtEnvControl(DT_ENV_SET);
1059 #ifdef DT_PERFORMANCE
1060 printf(" XtInitalize\n");
1061 gettimeofday(&update_time_s, NULL);
1063 /* Added by Aloke Gupta */
1064 _DtPerfChkpntMsgSend("Begin XtInitialize");
1067 /* Initialize the toolkit and open the display */
1068 toplevel = XtInitialize (argv[0], DTFILE_CLASS_NAME,
1069 option_list, XtNumber(option_list),
1070 (int *)&argc, argv);
1072 #ifdef DT_PERFORMANCE
1073 gettimeofday(&update_time_f, NULL);
1074 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1075 update_time_f.tv_usec += 1000000;
1076 update_time_f.tv_sec--;
1078 printf(" done XtInitialize, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1080 /* Added by Aloke Gupta */
1081 _DtPerfChkpntMsgSend("Done XtInitialize");
1084 /* Initialize the function ptr for alphabetic sorting */
1085 FMStrcoll = GetStrcollProc();
1087 /* Open the message catalog - DO NOT PERFORM until after XtInitialize! */
1089 char * foo = ((char *)GETMESSAGE(18, 1, ""));
1092 /* set application name for later */
1093 str = strrchr(argv[0], '/');
1095 application_name = XtNewString (str + 1);
1097 application_name = XtNewString (argv[0]);
1100 XtSetArg(args[n], XmNallowShellResize, True); n++;
1101 XtSetArg(args[n], XmNmappedWhenManaged, False); n++;
1102 XtSetArg(args[n], XmNheight, 1); n++;
1103 XtSetArg(args[n], XmNwidth, 1); n++;
1104 XtSetValues(toplevel, args, n);
1105 XtRealizeWidget(toplevel);
1106 display = XtDisplay (toplevel);
1108 XtAddEventHandler(toplevel, 0, True,
1109 (XtEventHandler) _XEditResCheckMessages,
1113 /* Initialize BMenu button binding */
1115 int numMouseButtons = XGetPointerMapping(display,
1116 (unsigned char *)NULL, 0);
1117 bMenuButton = (numMouseButtons < 3) ? Button2 : Button3;
1120 /* initialize debugging flag */
1122 if ((tmpStr = getenv("DTFILE_DEBUG")) != NULL)
1124 debug = atoi(tmpStr);
1128 if (getenv("DTFILE_XSYNC") != NULL)
1130 XSynchronize(display, True);
1134 /* initialize performance flag */
1135 #ifdef DT_PERFORMANCE
1136 if ((tmpStr = getenv("DTFILE_PERFORM")) != NULL)
1138 perform = atoi(tmpStr);
1142 if (getenv("DTFILE_XSYNC") != NULL)
1144 XSynchronize(display, True);
1148 /* Create the atom set used by save and restore session */
1149 save_yourself_atom = XmInternAtom (display, "WM_SAVE_YOURSELF", False);
1150 wm_state_atom = XmInternAtom (display, "WM_STATE", False);
1151 command_atom = XA_WM_COMMAND;
1152 save_mode = XmInternAtom (display, _XA_DT_RESTORE_MODE, False);
1154 root = RootWindowOfScreen(XtScreen(toplevel));
1156 /* Set session property on the top level window */
1157 XmAddWMProtocols(toplevel, &save_yourself_atom, 1);
1158 XmAddWMProtocolCallback(toplevel, save_yourself_atom, SaveSessionCallback,
1161 XSetErrorHandler ((int (*)())ErrorHandler);
1162 XtAppSetErrorHandler (XtWidgetToApplicationContext(toplevel),
1163 ToolkitErrorHandler);
1165 /* get the keyboard focus policy so we know how we want to set up the */
1167 XtSetArg(args[0], XmNkeyboardFocusPolicy, &keybdFocusPolicy);
1168 XtGetValues(toplevel, args, 1);
1170 /* If all of the command line parameters were not processed */
1171 /* out, print out a usage message set and exit. */
1173 if (argc != 1) Usage (argv);
1175 displayWidth = DisplayWidth(display, DefaultScreen(display));
1176 displayHeight = DisplayHeight(display, DefaultScreen(display));
1178 /* Get Dt initialized */
1180 if (DtInitialize (display, toplevel, argv[0], FILE_MANAGER_TOOL_CLASS) == False)
1182 /* Fatal Error: could not connect to the messaging system. */
1183 /* DtInitialize() has already logged an appropriate error msg */
1187 #ifdef DT_PERFORMANCE
1188 printf(" Setup Converters and get resources\n");
1189 gettimeofday(&update_time_s, NULL);
1191 /* Added by Aloke Gupta */
1192 _DtPerfChkpntMsgSend("Begin Setup Converters");
1196 /* First lets add the resource converters needed */
1197 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1198 XtRString, "ObjectPlacement",
1199 (XtConverter)DtfileCvtStringToObjPlace, NULL, 0);
1200 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1201 XtRString, "OpenFolder",
1202 (XtConverter)DtfileCvtStringToOpenDir, NULL, 0);
1203 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1204 XtRString, "DesktopIcon",
1205 (XtConverter)DtfileCvtStringToDTIcon, NULL, 0);
1206 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1208 (XtConverter)DtfileCvtStringToTree, NULL, 0);
1209 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1210 XtRString, "TreeFiles",
1211 (XtConverter)DtfileCvtStringToTreeFiles, NULL, 0);
1212 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1214 (XtConverter)DtfileCvtStringToView, NULL, 0);
1215 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1217 (XtConverter)DtfileCvtStringToOrder, NULL, 0);
1218 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1219 XtRString, "Direction",
1220 (XtConverter)DtfileCvtStringToDirection, NULL, 0);
1221 XtAppAddConverter (XtWidgetToApplicationContext (toplevel),
1223 (XtConverter)DtfileCvtStringToGrid, NULL, 0);
1225 /* Get the application defined resources of session and */
1226 /* directory, and get the processes host. */
1228 XtGetApplicationResources(toplevel, &application_args,
1229 resources, XtNumber(resources), NULL,0);
1231 #ifdef DT_PERFORMANCE
1232 gettimeofday(&update_time_f, NULL);
1233 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1234 update_time_f.tv_usec += 1000000;
1235 update_time_f.tv_sec--;
1237 printf(" done Setting up Converters and got resources, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1239 /* Added by Aloke Gupta */
1240 _DtPerfChkpntMsgSend("Done Setup Converters");
1243 #ifdef DT_PERFORMANCE
1244 printf(" DtDbLoad\n");
1245 gettimeofday(&update_time_s, NULL);
1246 /* Added by Aloke Gupta */
1247 _DtPerfChkpntMsgSend("Begin DtDbLoad");
1251 /* Set up the messaging and file types */
1254 #ifdef DT_PERFORMANCE
1255 gettimeofday(&update_time_f, NULL);
1256 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1257 update_time_f.tv_usec += 1000000;
1258 update_time_f.tv_sec--;
1260 printf(" done DtDbLoad, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1262 /* Added by Aloke Gupta */
1263 _DtPerfChkpntMsgSend("Done DtDbLoad");
1268 /* Create some global strings */
1269 db = XtDatabase(display);
1270 if (XrmGetResource (db, "dttypes.defaultActions",
1271 "Dttypes.DefaultActions", &rep_type,
1274 string = XtNewString(resource_value.addr);
1275 for(str = DtStrtok(string, ",") ,i = 0; str != NULL && i < 2 ;
1276 str = DtStrtok(NULL, ","), i++) {
1278 openInPlace = XtNewString(str);
1280 openNewView = XtNewString(str);
1284 if(openInPlace == NULL || strlen(openInPlace) == 0)
1285 openInPlace = XtNewString("OpenInPlace");
1286 if(openNewView == NULL || strlen(openNewView) == 0)
1287 openNewView = XtNewString("OpenNewView");
1289 DtGetShortHostname (home_host_name, MAX_PATH);
1291 /* Get the lock established to ensure only one dtfile process */
1293 if (_DtGetLock (display, DTFILE_CLASS_NAME) == 0)
1295 status = InitializeToolTalkProcid( &ttFd, toplevel, False );
1296 if (TT_OK != status)
1298 char *errfmt, *errmsg, *title, *statmsg;
1299 title = GETMESSAGE(21,38,"File Manager Error");
1300 errfmt = GETMESSAGE(18, 40,
1301 "Could not connect to ToolTalk:\n%s\nExiting ...");
1302 statmsg = tt_status_message(status);
1304 errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2);
1305 fprintf(stderr, errfmt, statmsg);
1306 sprintf(errmsg, errfmt, statmsg);
1308 /* put up error dialog and loop,
1309 * application will exit in dialog callback
1311 post_dialog(toplevel, title, errmsg, DtErrExitCB);
1314 if (application_args.session != NULL)
1316 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1317 "DtFileSession_Run",
1318 (Tt_message_callback)ExitApp );
1319 tt_message_file_set( msg, application_args.session );
1320 tt_message_send( msg );
1322 else if (application_args.directories != NULL)
1324 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1326 (Tt_message_callback)ExitApp );
1327 tt_message_file_set( msg, application_args.directories );
1328 SetupSendRequestArgs( application_args, msg );
1329 tt_message_send( msg );
1333 /* Default action: Open up pwd or home dir */
1334 GetPWD(current_directory);
1336 if (current_directory[0] != '\0')
1338 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1340 (Tt_message_callback)ExitApp );
1341 tt_message_file_set( msg, current_directory );
1345 msg = tttk_message_create( 0, TT_REQUEST, TT_SESSION, 0,
1347 (Tt_message_callback)ExitApp );
1349 SetupSendRequestArgs( application_args, msg );
1350 tt_message_send( msg );
1352 WaitForResponseAndExit();
1355 /* Initialize the encapsulation mechanism and install the dialogs */
1356 /* used by the file manager. */
1358 _DtInitializeEncapsulation (display, argv[0], DTFILE_CLASS_NAME);
1359 topPositionOffset = -8;
1361 status = InitializeToolTalkProcid( &ttFd, toplevel, True );
1362 if (TT_OK != status)
1364 char *errfmt, *errmsg, *title, *statmsg;
1365 title = GETMESSAGE(21,38,"File Manager Error");
1366 errfmt = GETMESSAGE(18, 40,
1367 "Could not connect to ToolTalk:\n%s\nExiting ...");
1368 statmsg = tt_status_message(status);
1370 errmsg = XtMalloc(strlen(errfmt) + strlen(statmsg) + 2);
1371 fprintf(stderr, errfmt, statmsg);
1372 sprintf(errmsg, errfmt, statmsg);
1374 /* put up error dialog and loop,
1375 * application will exit in dialog callback
1377 post_dialog(toplevel, title, errmsg, DtErrExitCB);
1381 #ifdef DT_PERFORMANCE
1382 printf(" Setup Callbacks (messaging)\n");
1383 gettimeofday(&update_time_s, NULL);
1385 /* Added by Aloke Gupta */
1386 _DtPerfChkpntMsgSend("Begin Setup Callbacks");
1389 events2Watch = tt_pattern_create();
1390 tt_pattern_category_set( events2Watch, TT_OBSERVE );
1391 tt_pattern_class_add( events2Watch, TT_NOTICE );
1392 tt_pattern_scope_add( events2Watch, TT_SESSION );
1393 sessId = tt_default_session();
1394 tt_pattern_session_add( events2Watch, sessId );
1396 tt_pattern_op_add( events2Watch, "DtTypes_Reloaded" );
1397 tt_pattern_op_add( events2Watch, "XSession_Ending" );
1398 tt_pattern_callback_add( events2Watch, ObserveTtNotice );
1399 tt_pattern_register( events2Watch );
1401 requests2Handle = tt_pattern_create();
1402 tt_pattern_category_set( requests2Handle, TT_HANDLE );
1403 tt_pattern_class_add( requests2Handle, TT_REQUEST );
1404 tt_pattern_scope_add( requests2Handle, TT_SESSION );
1405 sessId = tt_default_session();
1406 tt_pattern_session_add( requests2Handle, sessId );
1408 tt_pattern_op_add( requests2Handle, "DtFileSession_Run" );
1409 tt_pattern_op_add( requests2Handle, "DtFolder_Show" );
1410 tt_pattern_op_add( requests2Handle, "DtHome_Show" );
1411 tt_pattern_op_add( requests2Handle, "DtTools_Show" );
1412 tt_pattern_op_add( requests2Handle, "DtTrash_Show" );
1413 tt_pattern_op_add( requests2Handle, "DtTrash_Remove" );
1414 tt_pattern_op_add( requests2Handle, "DtTrash_Empty" );
1415 tt_pattern_op_add( requests2Handle, "DtTrash_File" );
1416 tt_pattern_op_add( requests2Handle, "DtTrash_Restore" );
1417 tt_pattern_op_add( requests2Handle, "DtFile_PutOnWorkspace" );
1418 tt_pattern_op_add( requests2Handle, "DtFile_Move" );
1419 tt_pattern_op_add( requests2Handle, "DtFile_Copy" );
1420 tt_pattern_op_add( requests2Handle, "DtFile_Link" );
1421 tt_pattern_callback_add( requests2Handle, HandleTtRequest );
1422 tt_pattern_register( requests2Handle );
1424 /* Setup the settings file if any to setup */
1426 _DtWsmAddMarqueeSelectionCallback(toplevel,
1427 (DtWsmMarqueeSelectionProc) MarqueeSelect,
1430 #ifdef DT_PERFORMANCE
1431 gettimeofday(&update_time_f, NULL);
1432 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1433 update_time_f.tv_usec += 1000000;
1434 update_time_f.tv_sec--;
1436 printf(" done Setting Callbacks (messaging), time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1438 /* Added by Aloke Gupta */
1439 _DtPerfChkpntMsgSend("Done Setup Callbacks");
1443 smallIconWidth = application_args.smallIconWidth;
1444 smallIconHeight = application_args.smallIconHeight;
1445 largeIconWidth = application_args.largeIconWidth;
1446 largeIconHeight = application_args.largeIconHeight;
1447 user_font = application_args.user_font;
1448 dragThreshold = application_args.dragThreshold;
1449 rereadTime = application_args.rereadTime;
1450 checkBrokenLink = application_args.checkBrokenLink;
1451 maxDirectoryProcesses = application_args.maxDirectoryProcesses;
1452 maxRereadProcesses = application_args.maxRereadProcesses;
1453 maxRereadProcsPerTick = application_args.maxRereadProcsPerTick;
1454 trashWait = application_args.trashWait;
1455 showFilesystem = application_args.showFilesystem;
1456 showDropZone = application_args.showDropZone;
1457 showEmptySet = application_args.showEmptySet;
1458 showEmptyMsg = application_args.showEmptyMsg;
1459 restrictMode = application_args.restrictMode;
1460 openDirType = application_args.openDirType;
1461 desktopIconType = application_args.desktopIconType;
1462 desktopPlacement = application_args.desktopPlacement;
1463 freezeOnConfig = application_args.freezeOnConfig;
1464 emptyTrashOnExit = application_args.emptyTrashOnExit;
1465 #if defined(__hpux) || defined(sun)
1466 follow_links = application_args.follow_links;
1468 instanceWidth = application_args.instanceIconWidth;
1469 instanceHeight = application_args.instanceIconHeight;
1470 fileMgrIcon = application_args.fileMgrIcon;
1471 appMgrIcon = application_args.appMgrIcon;
1472 trashIcon = application_args.trashIcon;
1473 retryLoadDesktopInfo = application_args.retryLoadDesktop;
1474 if( application_args.directories != NULL
1475 || (strcmp (application_args.restricted, RESTRICTED_HEADER) == 0)
1478 special_view = True;
1479 if(strcmp (application_args.restricted, RESTRICTED_HEADER) == 0)
1481 if(application_args.directories != NULL)
1482 special_restricted = XtNewString(application_args.directories);
1485 /* Get users pwd so we can set the restricted dir to it */
1486 GetPWD(current_directory);
1488 if (current_directory[0] != '\0')
1489 special_restricted = XtNewString(current_directory);
1491 special_restricted = XtNewString("~");
1494 else if( restrictMode )
1495 special_restricted = XtNewString("~");
1497 special_restricted = NULL;
1498 special_treeType = treeType = application_args.tree_view;
1499 special_treeFiles = treeFiles = application_args.tree_files;
1500 special_viewType = viewType = application_args.view;
1501 special_orderType = orderType = application_args.order;
1502 special_directionType = directionType = application_args.direction;
1503 special_randomType = randomType = application_args.grid;
1504 special_title = XtNewString(application_args.title);
1505 if(application_args.help_volume == NULL)
1507 special_helpVol = XtNewString(DTFILE_HELP_NAME);
1508 fileMgrHelpVol = XtNewString(DTFILE_HELP_NAME);
1512 special_helpVol = XtNewString(application_args.help_volume);
1513 fileMgrHelpVol = XtNewString(application_args.help_volume);
1515 fileMgrTitle = application_args.title;
1519 special_view = False;
1520 treeType = application_args.tree_view;
1521 treeFiles = application_args.tree_files;
1522 viewType = application_args.view;
1523 orderType = application_args.order;
1524 directionType = application_args.direction;
1525 randomType = application_args.grid;
1526 fileMgrTitle = application_args.title;
1527 if(application_args.help_volume == NULL)
1528 fileMgrHelpVol = XtNewString(DTFILE_HELP_NAME);
1530 fileMgrHelpVol = XtNewString(application_args.help_volume);
1534 if(desktopIconType == LARGE)
1536 numRows = displayHeight / PIXELS_PER_ROW_LARGE;
1537 numColumns = displayWidth / PIXELS_PER_COLUMN_LARGE;
1541 numRows = displayHeight / PIXELS_PER_ROW_SMALL;
1542 numColumns = displayWidth / PIXELS_PER_COLUMN_SMALL;
1546 /* determine whether the Server has the shape extension */
1547 if(XShapeQueryExtension(display, &base1, &base2) == True)
1548 shapeExtension = True;
1550 shapeExtension = False;
1553 /* get the name for the root directory */
1554 root_title = (char *)XtMalloc(strlen(application_args.root_title) + 1);
1555 strcpy(root_title, application_args.root_title);
1557 if ((homeDir = getenv("HOME")) == NULL || strlen (homeDir) == 0)
1559 pwInfo = getpwuid (getuid());
1560 homeDir = pwInfo->pw_dir;
1562 strncpy(users_home_dir, homeDir, MAX_PATH - 1);
1565 if(application_args.directories != NULL &&
1566 strncmp(application_args.directories, "~", 1) != 0 )
1568 if(strncmp(application_args.directories, users_home_dir,
1569 strlen(users_home_dir)) != 0)
1570 RestrictModeUsage (argv);
1572 else if (application_args.directories == NULL)
1573 application_args.directories = XtNewString("~");
1575 if (strcmp(users_home_dir, "/") != 0)
1576 strcat(users_home_dir, "/");
1578 XtAppAddActions(XtWidgetToApplicationContext (toplevel), actionTable, 2);
1580 /* Create some global Xm strings for our dialog buttons */
1582 okXmString = XmStringCreateLocalized((char*)_DtOkString);
1583 cancelXmString = XmStringCreateLocalized((char*)_DtCancelString);
1584 helpXmString = XmStringCreateLocalized((char*)_DtHelpString);
1585 applyXmString = XmStringCreateLocalized((char*)_DtApplyString);
1586 closeXmString = XmStringCreateLocalized((char*)_DtCloseString);
1588 /* Get the dt path created and initialized */
1590 dt_path = _DtCreateDtDirs (display);
1592 if (dt_path == NULL)
1596 title = XtNewString((GETMESSAGE(21,38,"File Manager Error")));
1597 tmpStr = GETMESSAGE(18, 2, "Could not create the ~/.dt folder or sub folders.");
1598 msg = XtNewString(tmpStr);
1600 /* put up error dialog and loop, application will exit in
1603 dialog = post_dialog(toplevel, title, msg, DtErrExitCB);
1609 XtAppProcessEvent(XtWidgetToApplicationContext(dialog), XtIMAll );
1613 /* Set the black and white pixel globals. */
1615 black_pixel = BlackPixelOfScreen (XtScreen (toplevel));
1616 white_pixel = WhitePixelOfScreen (XtScreen (toplevel));
1619 * Take over the drawing area's redisplay functions, so that we can get
1620 * the dtfile views to redraw according to stacking order, using our own
1623 xmDrawingAreaWidgetClass->core_class.expose = DrawingAreaRedisplay;
1626 /* Get the root user id */
1628 if ((pw = getpwnam("root")) == NULL)
1629 root_user = 0; /* Assume root is uid 0 */
1631 root_user = pw->pw_uid;
1634 file_mgr_dialog = _DtInstallDialog (fileMgrClass, True, True);
1635 change_dir_dialog = _DtInstallDialog (changeDirClass, True, True);
1636 preferences_dialog = _DtInstallDialog (preferencesClass, True, True);
1637 filter_dialog = _DtInstallDialog (filterClass, True, True);
1638 find_dialog = _DtInstallDialog (findClass, True, True);
1639 mod_attr_dialog = _DtInstallDialog (modAttrClass, True, True);
1640 help_dialog = _DtInstallDialog (helpClass, False, False);
1642 if(special_view == True && special_restricted != NULL) {
1643 if(strncmp(special_restricted, "~", 1) == 0)
1647 special_restricted = _DtChangeTildeToHome(special_restricted);
1648 ptr = strrchr(special_restricted, '/');
1655 /* Setup the settings file if any to setup */
1656 RestoreSettingsFile();
1658 #ifdef DT_PERFORMANCE
1659 printf(" TrashCreateDialog\n");
1660 gettimeofday(&update_time_s, NULL);
1662 /* Added by Aloke Gupta */
1663 _DtPerfChkpntMsgSend("Begin TrashCreateDialog");
1666 if( InitializeTrash( application_args.prompt_user ) )
1668 #ifdef DEFER_TRASH_CREATION
1671 TrashCreateDialog (display);
1674 #ifdef DT_PERFORMANCE
1675 gettimeofday(&update_time_f, NULL);
1676 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1677 update_time_f.tv_usec += 1000000;
1678 update_time_f.tv_sec--;
1680 printf(" done TrashCreateDialog, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1682 /* Added by Aloke Gupta */
1683 _DtPerfChkpntMsgSend("Done TrashCreateDialog");
1686 /* lets go empty the trash if there is any */
1691 #ifdef DT_PERFORMANCE
1692 printf(" Setup Desktop\n");
1693 gettimeofday(&update_time_s, NULL);
1694 /* Added by Aloke Gupta */
1695 _DtPerfChkpntMsgSend("Begin Setup Desktop");
1698 /* go build 10 desktop windows */
1699 desktop_data = NULL;
1700 InitializeDesktopWindows(10, display);
1701 InitializeDesktopGrid(displayWidth, displayHeight);
1703 LoadDesktopInfo(application_args.session);
1705 /* Install WorkSpaceRemoved handler.
1706 This handler will be called when a workspace is being removed
1707 so File Manager can go through its desktop icons and clean up.
1709 DtWsmAddWorkspaceModifiedCallback( toplevel, WorkSpaceRemoved, NULL );
1711 #ifdef DT_PERFORMANCE
1712 gettimeofday(&update_time_f, NULL);
1713 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1714 update_time_f.tv_usec += 1000000;
1715 update_time_f.tv_sec--;
1717 printf(" done Setting up Desktop, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1719 /* Added by Aloke Gupta */
1720 _DtPerfChkpntMsgSend("Done Setup Desktop");
1724 /* Process the application resources to restore a session, dt */
1725 /* a directory set or display the users home directory. */
1727 #ifdef DT_PERFORMANCE
1728 printf(" Bring up View\n");
1729 gettimeofday(&update_time_s, NULL);
1731 /* Added by Aloke Gupta */
1732 _DtPerfChkpntMsgSend("Begin Bring up View");
1736 if (strcmp (application_args.no_view, "-noview") != 0)
1738 if (application_args.session != NULL)
1740 RestoreSession (application_args.session, NORMAL_RESTORE, NULL);
1741 else if (application_args.directories != NULL)
1743 restoreType = CURRENT_DIR_RESTORE;
1744 OpenDirectories (application_args.directories, NULL);
1748 #ifdef DT_PERFORMANCE
1749 gettimeofday(&update_time_f, NULL);
1750 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1751 update_time_f.tv_usec += 1000000;
1752 update_time_f.tv_sec--;
1754 printf(" done Bringing up view, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec); fflush(stdout);
1756 /* Added by Aloke Gupta */
1757 _DtPerfChkpntMsgSend("Done Bring up View");
1761 /* If no views were opened upon invocation, display the */
1762 /* current directory. */
1764 if ( (strcmp (application_args.no_view, "-noview") != 0) &&
1765 ((application_args.session == NULL) ||
1766 (session_flag != 0)) )
1768 if (view_count == 0)
1770 /* Get users pwd so we can create a fileviewer window of it */
1771 GetPWD(current_directory);
1773 if (current_directory[0] != '\0')
1775 if (!GetNewView (home_host_name, current_directory, NULL, NULL, 0))
1776 ViewHomeDirectoryHandler (0);
1780 ViewHomeDirectoryHandler (0);
1786 /* Set up the timer based directory reading. */
1787 InitializeDirectoryRead (toplevel);
1789 /* Process and dispatch incoming events */
1790 eventDebugging = getenv("EVENT_DEBUGGING") != NULL;
1792 #ifdef DT_PERFORMANCE
1793 printf(" InitializeToolTalkSession\n");
1794 gettimeofday(&update_time_s, NULL);
1796 (void) InitializeToolTalkSession( toplevel, ttFd );
1797 #ifdef DT_PERFORMANCE
1798 gettimeofday(&update_time_f, NULL);
1799 if (update_time_s.tv_usec > update_time_f.tv_usec) {
1800 update_time_f.tv_usec += 1000000;
1801 update_time_f.tv_sec--;
1803 printf(" done InitializeToolTalkSession, time: %ld.%ld\n\n", update_time_f.tv_sec - update_time_s.tv_sec, update_time_f.tv_usec - update_time_s .tv_usec);
1806 #ifdef DT_PERFORMANCE
1807 gettimeofday(&update_time_fs, NULL);
1808 if (update_time_ss.tv_usec > update_time_fs.tv_usec) {
1809 update_time_fs.tv_usec += 1000000;
1810 update_time_fs.tv_sec--;
1812 printf(" Finish, time: %ld.%ld\n\n", update_time_fs.tv_sec - update_time_ss.tv_sec, update_time_fs.tv_usec - update_time_ss .tv_usec);
1817 XtNextEvent(&event);
1819 if (event.type != 0)
1820 XtDispatchEvent(&event);
1823 return EXIT_SUCCESS;
1828 /************************************************************************
1832 ************************************************************************/
1837 XErrorEvent *event )
1839 #define _DTFILE_BUFSIZE 1024
1840 char errmsg[_DTFILE_BUFSIZE];
1842 _DtPrintDefaultErrorSafe (disp, event, errmsg, _DTFILE_BUFSIZE);
1843 _DtSimpleError(application_name, DtWarning, NULL, errmsg, NULL);
1844 xErrorDetected = True;
1846 /* We do not want to exit here lets try to continue... */
1851 ToolkitErrorHandler(
1857 tmpStr = GETMESSAGE(18, 6, "An X Toolkit error occurred... Exiting.\n");
1858 msg = (char *)malloc(strlen(tmpStr) + strlen(message) + 3);
1859 strcpy(msg, message);
1861 strcat(msg, tmpStr);
1862 _DtSimpleError (application_name, DtError, NULL, msg);
1865 FinalizeToolTalkSession( );
1872 /************************************************************************
1875 * When incorrect parameters have been specified on the command
1876 * line, print out a set of messages detailing the correct use
1879 ************************************************************************/
1886 char * message_string1 = "\nUsage: %s...\n\n"
1888 "Dtfile runs in server mode.\n\n"
1889 " -session SessionFile\n\n\t"
1890 "Dtfile runs with the session file specified in the SessionFile\n\t"
1892 " -folder Folder[,Folder,Folder]\n"
1893 " -dir Folder[,Folder,Folder]\n\n\t"
1894 "Dtfile displays a window for each folder specified in the\n\t"
1895 "Folder parameter. The Folder parameter may contain many\n\t"
1896 "folders separated by commas. Folders may be in the form\n\t"
1898 " -title Title\n\n\t"
1899 "Dtfile uses the string specified in the Title parameter as the\n\t"
1900 "title for its windows.\n\n"
1901 " -help_volume HelpVolume\n\n\t"
1902 "Dtfile uses the help volume specified in the HelpVolume parameter.\n\n"
1903 " -restricted\n\n\t"
1904 "Dtfile will not display folders above the restricted folder.\n\t"
1905 "If the -dir option is used, the folder specified in that option\n\t"
1906 "is the restricted folder. If the -dir option is not used, the\n\t"
1907 "user's current folder is the restricted folder.\n\n"
1908 " -grid on/off\n\n\t"
1909 "on = Files are displayed in a grid pattern.\n\t"
1910 "off = Files are displayed as placed.\n\n"
1911 " -tree on/off\n\n\t"
1912 "on = Files are displayed in single folder mode.\n";
1914 char * message_string2 = "\toff = Files are displayed in folder tree mode.\n\n"
1915 " -tree_files never/always/choose\n\n\t"
1916 "never = Tree mode has two states: partially expanded or collapsed.\n\t"
1917 "always = Tree mode has two states: fully expanded or collapsed.\n\t"
1918 "choose = Tree mode has three states: partially expanded, fully\n\t"
1919 " expanded, or collapsed.\n\n"
1920 " -order alphabetical/file_type/date/size\n\n\t"
1921 "Files are displayed in the specified order: alphabetical, by file\n\t"
1922 "type, by date, or by size.\n\n"
1923 " -view no_icon/large_icon/small_icon/attributes\n\n\t"
1924 "Files are displayed in the specified format: text only, text and\n\t"
1925 "large icons, text and small icons, with attributes.\n\n"
1926 " -direction ascending/descending\n\n\t"
1927 "Files are displayed in the specified direction: ascending or\n\t"
1929 " -large_icon_width <size>\n\n"
1930 " -large_icon_height <size>\n\n"
1931 " -small_icon_width <size>\n\n"
1932 " -small_icon_height <size>\n\n"
1933 " The display area size for the icon images in File Manager\n"
1934 " Icon images larger than this size will be clipped to this size\n"
1935 " The default display area size for large is 38 and small is 24\n\n"
1939 template = (GETMESSAGE(18,23, message_string1));
1940 fprintf (stderr, template, argv[0]);
1941 template = (GETMESSAGE(18,24, message_string2));
1942 fprintf (stderr, "%s", template);
1952 char * message_string = "\nRestricted Mode Usage: %s...\n\n"
1953 " -folder Folder[,Folder,Folder]\n"
1954 " -dir Folder[,Folder,Folder]\n\n\t"
1955 "Where Folder is a Folder below and/or including\n\t"
1956 "the user's Home Folder.\n\n";
1958 template = (GETMESSAGE(18,26, message_string));
1960 fprintf (stderr, template, argv[0]);
1962 FinalizeToolTalkSession( );
1969 /************************************************************************
1972 * Catches Ctrl C's and exits.
1974 ************************************************************************/
1979 FinalizeToolTalkSession( );
1989 /***********************************************************************
1991 * RestoreSettingsFile
1992 * Used to restore the save settings files from
1993 * either $HOME/.dt/$DISPLAY/current or $HOME/.dt/$DISPLAY/home.
1995 ***********************************************************************/
1997 RestoreSettingsFile( void )
2001 char *homeSavePath=NULL;
2002 char *homeHomePath=NULL;
2003 char *toolSavePath=NULL;
2004 char *toolHomePath=NULL;
2008 unsigned long nitems;
2009 unsigned long leftover;
2010 unsigned char *data = NULL;
2013 /* go get the dt path */
2014 /* _DtCreateDtDirs returs a path of MaxPath Length */
2015 dtPath = (char *)_DtCreateDtDirs(display);
2017 /* Determin which type of session we are running HOME or CURRENT */
2019 /* get the root window property of SaveMode */
2020 XGetWindowProperty(display, RootWindow(display,0),
2021 save_mode, 0L, (long)BUFSIZ,False,
2022 XA_STRING, &actualType,
2023 &actualFormat,&nitems,&leftover,
2026 if(strcmp((char *)data, "home") == 0)
2027 dirName = XtNewString("home");
2028 else if(strcmp((char *)data, "current") == 0)
2029 dirName = XtNewString("current");
2033 return; /* we are coming up in a system mode (e.g. default) */
2037 /* Build the paths to read the files from */
2039 toolSavePath = (char *)XtMalloc(strlen(dtPath) +
2040 strlen(TOOL_SETTINGS_FILENAME) +
2041 strlen(dirName) + 4);
2043 homeSavePath = (char *)XtMalloc(strlen(dtPath) +
2044 strlen(HOME_SETTINGS_FILENAME) +
2045 strlen(dirName) + 4);
2047 sprintf( homeSavePath, "%s/%s/%s", dtPath, dirName, HOME_SETTINGS_FILENAME );
2048 sprintf( toolSavePath, "%s/%s/%s", dtPath, dirName, TOOL_SETTINGS_FILENAME );
2050 /* open the home settings file to see if its there */
2051 if((fd = open(homeSavePath, O_RDONLY)) != -1)
2054 /* create where the saved file is going to go */
2056 homeHomePath = (char *)XtMalloc(strlen(dtPath) +
2057 strlen(HOME_SETTINGS_FILENAME) + 2);
2059 sprintf( homeHomePath, "%s/%s", dtPath, HOME_SETTINGS_FILENAME );
2061 /* remove any existing dtfile.home (e.g. HOME_SETTINGS_FILENAME) */
2062 unlink(homeHomePath);
2064 /* copy the saved one into $HOME/.dt/$DISPLAY ... this is the one that
2065 * will be used by the dtfile
2067 status = link(homeSavePath, homeHomePath);
2072 tmpStr = GETMESSAGE(18,27, "Unable to recover the saved default home settings file, will use default.\n");
2073 msg = XtNewString(tmpStr);
2074 _DtSimpleErrnoError(application_name, DtWarning, NULL, msg, NULL);
2080 /* open the tool settings file to see if its there */
2081 if((fd = open(toolSavePath, O_RDONLY)) != -1)
2084 /* create where the saved file is going to go */
2085 toolHomePath = (char *)XtMalloc(strlen(dtPath) +
2086 strlen(TOOL_SETTINGS_FILENAME) + 2);
2088 sprintf( toolHomePath, "%s/%s", dtPath, TOOL_SETTINGS_FILENAME );
2090 /* remove any existing dtfile.tool (e.g. TOOL_SETTINGS_FILENAME) */
2091 unlink(toolHomePath);
2093 /* copy the saved one into $HOME/.dt/$DISPLAY ... this is the one that
2094 * will be used by the dtfile
2096 status = link(toolSavePath, toolHomePath);
2101 tmpStr = GETMESSAGE(18,28, "Unable to recover the saved default tool settings file, will use default.\n");
2102 msg = XtNewString(tmpStr);
2103 _DtSimpleErrnoError(application_name, DtWarning, NULL, msg, NULL);
2113 XtFree(homeSavePath);
2114 XtFree(toolSavePath);
2115 XtFree(toolHomePath);
2116 XtFree(homeHomePath);
2125 /***********************************************************************
2127 * MoveDefaultSettings
2128 * Used to save the dtfile.tool and dtfile.home settings files to
2129 * either $HOME/.dt/$DISPLAY/current or $HOME/.dt/$DISPLAY/home.
2130 * The parameter mode determines whether it is home or
2133 ***********************************************************************/
2135 MoveDefaultSettings(
2139 char *toolSavePath=NULL;
2140 char *homeSavePath=NULL;
2142 char *toolMovePath=NULL;
2143 char *homeMovePath=NULL;
2146 /* determine whether home or current */
2147 if(mode == HOME_DIR_RESTORE)
2148 dirName = XtNewString("home");
2150 dirName = XtNewString("current");
2152 /* go get the dt path */
2153 /* _DtCreateDtDirs returs a path of MaxPath Length */
2154 dtPath = (char *)_DtCreateDtDirs(display);
2157 /* Build the paths to save the files to */
2159 toolSavePath = (char *)XtMalloc(strlen(dtPath) +
2160 strlen(TOOL_SETTINGS_FILENAME) +
2161 strlen(dirName) + 4);
2163 homeSavePath = (char *)XtMalloc(strlen(dtPath) +
2164 strlen(HOME_SETTINGS_FILENAME) +
2165 strlen(dirName) + 4);
2168 /* create the directory and filename of where its going to be saved */
2169 sprintf( homeSavePath, "%s/%s/%s", dtPath, dirName, HOME_SETTINGS_FILENAME );
2170 sprintf( toolSavePath, "%s/%s/%s", dtPath, dirName, TOOL_SETTINGS_FILENAME );
2172 /* Setup the paths used to GET the old files */
2174 toolMovePath= (char *)XtMalloc(strlen(dtPath) +
2175 strlen(TOOL_SETTINGS_FILENAME) + 3);
2177 homeMovePath= (char *)XtMalloc(strlen(dtPath) +
2178 strlen(HOME_SETTINGS_FILENAME) + 3);
2180 /* create the filename of where its going to be saved from */
2182 /* Tool File location */
2183 sprintf( toolMovePath, "%s/%s", dtPath, TOOL_SETTINGS_FILENAME );
2185 /* Home File location */
2186 sprintf( homeMovePath, "%s/%s", dtPath, HOME_SETTINGS_FILENAME );
2189 /* get rid of the tool settings file that is already in home or current */
2190 status = unlink(toolSavePath);
2192 /* get rid of the home settings file that is already in home or current */
2193 status = unlink(homeSavePath);
2196 /* now save tool settings file in home or current determined by savePath */
2197 status = link(toolMovePath, toolSavePath);
2199 /* now save home settings file in home or current determined by savePath */
2200 status = link(homeMovePath, homeSavePath);
2203 XtFree(homeMovePath);
2204 XtFree(toolMovePath);
2205 XtFree(homeSavePath);
2206 XtFree(toolSavePath);
2212 /************************************************************************
2215 * Callback for the Save Settings menupick.
2217 ************************************************************************/
2221 XtPointer client_data,
2222 XtPointer call_data )
2229 FileMgrRec * file_mgr_rec;
2230 DialogData * dialog_data;
2231 FileMgrData * file_mgr_data;
2234 /* Strip the file_mgr_rec from the current widget
2235 * and attach it to the ok callback button
2239 /* Get the file_mgr_rec hanging off the menubar */
2240 mbar = XmGetPostedFromWidget(XtParent(w));
2241 XmUpdateDisplay (w);
2242 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2243 XtGetValues(mbar, args, 1);
2246 /* Ignore accelerators when we're insensitive */
2247 if ((file_mgr_rec->menuStates & SETTINGS) == 0)
2249 XSetInputFocus(XtDisplay(w),
2250 XtWindow(file_mgr_rec->defaultEnvBtn_child),
2251 RevertToParent, CurrentTime);
2255 /* Desensatize the save settings menu pick here */
2256 file_mgr_rec->menuStates &= ~SETTINGS;
2259 /* Get the file_mgr_rec dialog data info */
2260 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
2262 file_mgr_data = (FileMgrData *) dialog_data->data;
2265 /* Based on the path we must determine if we are saving a Tools or
2266 * HomeDir dtfile view.
2268 if (file_mgr_data->restricted_directory != NULL && file_mgr_data->toolbox)
2269 file_mgr_data->restoreKind = TOOL_RESTORE;
2271 file_mgr_data->restoreKind = HOME_RESTORE;
2274 /* Setup and call the _DtMessageDialog procedure to post the dialog */
2276 if (file_mgr_data->restoreKind == HOME_RESTORE)
2278 tmpStr = (GETMESSAGE(18,29, "Save the current File Manager View window size,\npreferences, and filter settings?\n\nThey will be used for any new File Manager View windows\nstarted from the Front Panel."));
2282 tmpStr = (GETMESSAGE(18,35, "Save the current Application Manager\nView window size, preferences, and filter settings?\n\nThey will be used for any new Application Manager\nwindows started from the Front Panel."));
2284 message = XtNewString(tmpStr);
2286 if(file_mgr_data->title != NULL &&
2287 strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0)
2289 tmpStr = GETMESSAGE(18, 16, "Save As Default Options");
2290 title = (char *)XtMalloc(strlen(tmpStr) +
2291 strlen(file_mgr_data->title) + 5);
2292 sprintf(title, "%s - %s", file_mgr_data->title, tmpStr);
2296 tmpStr = GETMESSAGE(18, 32, "File Manager - Save As Default Options");
2297 title = XtNewString(tmpStr);
2299 dlog = (Widget)_DtMessageDialog(mbar, title, message, NULL, TRUE,
2300 SaveDefaultCancelCB, SaveDefaultOkCB, NULL,
2301 HelpRequestCB, False, QUESTION_DIALOG);
2302 file_mgr_rec->defaultEnvBtn_child=dlog;
2307 /* Add array as userdata on the dialog. */
2309 XtSetArg(args[0], XmNuserData, file_mgr_rec);
2310 XtSetValues(dlog, args, 1);
2314 /************************************************************************
2316 * SaveDefaultCancelCB
2317 * Cleanup and unmanage the save settings dialog.
2319 ************************************************************************/
2321 SaveDefaultCancelCB(
2323 XtPointer client_data,
2324 XtPointer call_data )
2326 FileMgrRec * file_mgr_rec;
2329 /* Update the display, and un-post the dialog */
2330 XtUnmanageChild((Widget)client_data);
2331 XmUpdateDisplay((Widget)client_data);
2332 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2333 XtGetValues((Widget)client_data, args, 1);
2336 /* Re-sensatize the save settings menu pick */
2337 file_mgr_rec->menuStates |= SETTINGS;
2340 XtDestroyWidget((Widget)client_data);
2345 /************************************************************************
2348 * Save the current dtfile view as the default environment for
2349 * new dtfiles created.
2351 ************************************************************************/
2355 XtPointer client_data,
2356 XtPointer call_data )
2359 FileMgrRec * file_mgr_rec;
2360 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
2361 char view_number[5];
2365 DialogData * dialog_data;
2366 FileMgrData * file_mgr_data;
2369 char full_path[MAX_PATH + 1];
2372 char * save_directory;
2373 char ** save_branch_list;
2374 FileViewData ** save_selection_list;
2375 int save_selected_file_count;
2378 /* Get the file_mgr_rec hanging off the dialog */
2379 XtUnmanageChild((Widget)client_data);
2380 XmUpdateDisplay ((Widget)client_data);
2381 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2382 XtGetValues((Widget)client_data, args, 1);
2385 /* Re-sensatize the save settings menu pick */
2386 file_mgr_rec->menuStates |= SETTINGS;
2389 /* Get the file_mgr_rec dialog data info */
2391 dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
2392 file_mgr_data = (FileMgrData *) dialog_data->data;
2395 /* Build the path for our env file */
2397 tmp_path = _DtCreateDtDirs(display);
2398 if (tmp_path == NULL)
2400 XtDestroyWidget(client_data);
2405 /* Look and see what type of restore we are doing */
2406 if (file_mgr_data->restoreKind == TOOL_RESTORE)
2408 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
2409 application_args.tool_width = file_mgr_data->width;
2410 application_args.tool_height = file_mgr_data->height;
2414 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
2415 application_args.dir_width = file_mgr_data->width;
2416 application_args.dir_height = file_mgr_data->height;
2422 /* Create the Environment session file */
2424 if ((fd = creat(full_path, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP)) == -1)
2427 tmpStr = GETMESSAGE(18, 17, "Unable to create a file to store the default options.");
2428 title = XtNewString((GETMESSAGE(21,38,"Object Create Error")));
2429 msg = XtNewString(tmpStr);
2430 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
2437 /* Write out the general information */
2439 (void) write (fd, "*", strlen ("*"));
2440 (void) write (fd, DTFILE_CLASS_NAME,strlen (DTFILE_CLASS_NAME));
2441 (void) write (fd, "*view_count: ", strlen ("*view_count: "));
2443 (void) sprintf (view_number, "%d", 1);
2444 (void) write (fd, view_number, strlen (view_number));
2445 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2447 name_list[1] = view_number;
2449 /* Temporarily remove data that we don't need or want saved */
2451 save_host = file_mgr_data->host;
2452 save_directory = file_mgr_data->current_directory;
2453 save_branch_list = file_mgr_data->branch_list;
2454 save_selection_list = file_mgr_data->selection_list;
2455 save_selected_file_count = file_mgr_data->selected_file_count;
2456 file_mgr_data->host = NULL;
2457 file_mgr_data->current_directory = NULL;
2458 file_mgr_data->branch_list = NULL;
2459 file_mgr_data->selection_list = NULL;
2460 file_mgr_data->selected_file_count = 0;
2462 /* Call the encapsulation mechanism to write each dialog */
2464 (void) sprintf (view_number, "%d", 0);
2465 _DtWriteDialogData (dialog_data, fd, name_list);
2466 (void) write (fd, "#\n", strlen ("#\n"));
2468 /* Restore the data that was temporarily removed */
2470 file_mgr_data->host = save_host;
2471 file_mgr_data->current_directory = save_directory;
2472 file_mgr_data->branch_list = save_branch_list;
2473 file_mgr_data->selection_list = save_selection_list;
2474 file_mgr_data->selected_file_count = save_selected_file_count;
2478 XtDestroyWidget(client_data);
2484 /************************************************************************
2486 * SaveSessionCallback
2487 * Get the session name and call the function to save the session.
2489 ************************************************************************/
2492 SaveSessionCallback(
2494 XtPointer client_data,
2495 XtPointer call_data )
2497 char * full_path=NULL;
2498 char * file_name=NULL;
2500 int restore=NORMAL_RESTORE;
2501 Boolean status=FALSE;
2502 char * sessionFileName;
2505 if(view_count == 0 && desktop_data->numIconsUsed == 0)
2507 XChangeProperty (display, XtWindow (toplevel), command_atom,
2508 XA_STRING, 8, PropModeReplace, (unsigned char *)NULL, 0);
2509 XSync(display, False);
2510 FinalizeToolTalkSession( );
2514 status = DtSessionSavePath(w, &full_path, &file_name);
2517 sessionFileName = file_name;
2520 XtFree( (char *)full_path);
2521 full_path = (char *) XtMalloc (sizeof (char) * MAX_PATH);
2522 sprintf( full_path, "%s/%s", dt_path, DTFILE_CLASS_NAME );
2523 sessionFileName = full_path;
2525 SaveSession( full_path );
2527 /* skip to the /.dt/ portion of the sessionFileName */
2528 strPtr = strstr(full_path, "/.dt/");
2529 (void)strcpy(full_path, strPtr);
2531 /* Save off the settings files for both tool and home views */
2533 strPtr = DtStrrchr(full_path, '/');
2536 if ((strncmp(strPtr, "/home", 5) == 0))
2537 restore = HOME_DIR_RESTORE;
2538 else if ((strncmp(strPtr, "/current", 8) == 0))
2539 restore = CURRENT_DIR_RESTORE;
2543 } while ((strPtr != NULL) && (restore == NORMAL_RESTORE));
2545 SaveDesktopInfo(restore);
2547 /* Cop the settings files to the proper dir */
2548 MoveDefaultSettings(restore);
2550 /* Generate the reinvoking command and add it as the property value */
2551 argv = (char **) XtMalloc(3 * sizeof(char *));
2552 argv[0] = XtNewString(application_name);
2553 argv[1] = XtNewString("-session");
2554 argv[2] = XtNewString(sessionFileName);
2555 XSetCommand(XtDisplay(toplevel), XtWindow(toplevel), argv, 3);
2557 XtFree ((char *) argv[0]);
2558 XtFree ((char *) argv[1]);
2559 XtFree ((char *) argv[2]);
2560 XtFree ((char *) argv);
2562 XtFree ((char *) full_path);
2563 XtFree ((char *) file_name);
2566 /************************************************************************
2569 * Save the current File Manager session as a set of resources
2570 * within the file denoted by path.
2572 ************************************************************************/
2579 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
2581 char view_number[11];
2583 char workspaceNumber[11];
2585 Atom * ws_presence = NULL;
2586 char * workspace_name=NULL;
2587 unsigned long num_workspaces = 0;
2591 unsigned long nitems;
2592 unsigned long leftover;
2593 WM_STATE * wm_state;
2595 DialogData * dialog_data;
2596 FileMgrData * file_mgr_data;
2597 FileMgrRec * file_mgr_rec;
2602 WorkspaceRec * workspaceInfo;
2605 char *actualSavedTitle;
2607 /* This needs to be done because name_list is static and the values
2608 can be changed during the routine. This means that they need to be
2609 NULL'd out each pass */
2610 name_list[1] = NULL;
2611 name_list[2] = NULL;
2612 name_list[3] = NULL;
2613 name_list[4] = NULL;
2614 name_list[5] = NULL;
2616 /* Disable any message box display during save session */
2618 message_display_enabled = False;
2621 /* Create the session file */
2623 if ((fd = creat (path, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP)) == -1)
2625 tmpStr = GETMESSAGE(18, 18, "Could not open the session file.");
2626 msg = XtNewString(tmpStr);
2627 _DtSimpleError (application_name, DtError, NULL, msg);
2629 message_display_enabled = True;
2635 /* Write out the general information */
2637 /* Number of dtfile views */
2638 (void) write (fd, "*", strlen ("*"));
2639 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2640 (void) write (fd, "*view_count: ", strlen ("*view_count: "));
2642 if (trashFileMgrData)
2644 if (trashFileMgrData->file_mgr_rec)
2645 (void) sprintf (view_number, "%d", view_count + 1);
2647 (void) sprintf (view_number, "%d", view_count);
2651 (void) sprintf (view_number, "%d", view_count);
2653 (void) write (fd, view_number, strlen (view_number));
2654 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2656 (void) write (fd, "*", strlen ("*"));
2657 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2658 (void) write (fd, "*showFilesystem: ", strlen ("*showFilesystem: "));
2661 (void) write (fd, "True", strlen ("True"));
2663 (void) write (fd, "False", strlen ("False"));
2664 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2666 (void) write (fd, "*", strlen ("*"));
2667 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2668 (void) write (fd, "*restrictMode: ", strlen ("*restrictMode: "));
2671 (void) write (fd, "True", strlen ("True"));
2673 (void) write (fd, "False", strlen ("False"));
2674 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2676 (void) write (fd, "*", strlen ("*"));
2677 (void) write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2678 (void) write (fd, "*openFolder: ", strlen ("*openFolder: "));
2680 if(openDirType == NEW)
2681 (void) write (fd, "NEW", strlen ("NEW"));
2683 (void) write (fd, "CURRENT", strlen ("CURRENT"));
2684 (void) write (fd, "\n#\n", strlen ("\n#\n"));
2687 name_list[1] = view_number;
2691 /* Write out each of the view's resources */
2692 /* start with -1 so we can include the trash dialog */
2693 for (i = -1; i < view_count; i++)
2698 dialog_data = (DialogData *) trashDialogData;
2704 dialog_data = (DialogData *) view_set[i]->dialog_data;
2707 file_mgr_data = (FileMgrData *) dialog_data->data;
2708 if(i == -1 && trashDialogData)
2709 file_mgr_data->IsTrashCan = True;
2710 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
2711 if(file_mgr_rec == NULL)
2714 /* This is a bug fix ... We don't want to save the title if the
2715 View is the Trash Can of if it is an Application Manager. This
2716 is because if the user saves a session in one Locale, then logs
2717 in in another, the Title will be in the locale that the session was
2718 saved in rather then the new local. So let's save the Title,
2719 Null it out, Save the session info, and finally restore the Title.
2721 if(i == -1 || file_mgr_data->toolbox)
2723 /* the Trash Can or toolbox (i.e. Application Manager) */
2724 actualSavedTitle = file_mgr_data->title;
2725 file_mgr_data->title = NULL;
2729 /* Getting the WM_STATE property to see if iconified or not */
2730 XGetWindowProperty (display, XtWindow (file_mgr_rec->shell),
2731 wm_state_atom, 0L, (long) BUFSIZ, False,
2732 wm_state_atom, &actual_type, &actual_format,
2733 &nitems, &leftover, (unsigned char **) &wm_state);
2735 /* Write out if iconified our not */
2737 write (fd, "*", strlen ("*"));
2738 write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2739 sprintf (view_number, "%d", view_index);
2740 write (fd, ".", strlen ("."));
2741 write (fd, view_number, strlen (view_number));
2743 (void) write (fd, ".iconify: ", strlen (".iconify: "));
2745 if (wm_state->state == IconicState)
2746 write (fd, "True\n", strlen ("True\n"));
2748 write (fd, "False\n", strlen ("False\n"));
2751 /* Get the workspaces for this dt by accessing the property. */
2753 if (DtWsmGetWorkspacesOccupied (display, XtWindow (file_mgr_rec->shell),
2754 &ws_presence, &num_workspaces) == Success)
2756 write (fd, "*", strlen ("*"));
2757 write (fd, DTFILE_CLASS_NAME, strlen (DTFILE_CLASS_NAME));
2758 (void) write (fd, ".", strlen ("."));
2759 (void) write (fd, view_number, strlen (view_number));
2760 (void) write (fd, ".workspace: ", strlen (".workspace: "));
2763 for (j = 0; j < num_workspaces; j++)
2765 if (j != 0) (void) write (fd, "*", strlen ("*"));
2766 workspace_name = XGetAtomName (display, ws_presence[j]);
2767 (void) write (fd, workspace_name, strlen (workspace_name));
2768 XtFree ((char *) workspace_name);
2772 (void) write (fd, "\n", strlen ("\n"));
2773 XFree((char *)ws_presence);
2777 /* Call the encapsulation mechanism to write each dialog */
2780 _DtWriteDialogData (trashDialogData, fd, name_list);
2782 _DtWriteDialogData ((DialogData *)view_set[i]->dialog_data,
2784 (void) write (fd, "#\n", strlen ("#\n"));
2789 file_mgr_data->title = actualSavedTitle;
2795 * Save off help dialog information for each workspace.
2796 * These are the help dialogs used for the desktop objects.
2798 name_list[1] = WS_LOAD_RES_HEADER;
2799 name_list[2] = workspaceNumber;
2800 name_list[3] = number;
2802 for (i = 0; i < desktop_data->numWorkspaces; i++)
2804 workspaceInfo = desktop_data->workspaceData[i];
2807 * Save number of secondary help dialogs in format:
2808 * *Dtfile.Workspace.<WS#>.secondaryHelpDialogCount: <#>
2810 write(fd, "*", strlen("*"));
2811 write(fd, DTFILE_CLASS_NAME, strlen(DTFILE_CLASS_NAME));
2812 write(fd, WS_RES_HEADER, strlen(WS_RES_HEADER));
2813 sprintf(workspaceNumber, "%d", i);
2814 write(fd, workspaceNumber, strlen(workspaceNumber));
2815 write(fd, SEC_HELP_RES_HEADER, strlen(SEC_HELP_RES_HEADER));
2816 sprintf(view_number, "%d", workspaceInfo->secondaryHelpDialogCount);
2817 write(fd, view_number, strlen(view_number));
2818 write (fd, "\n#\n", strlen ("\n#\n"));
2820 /* Save each of the secondary help dialogs */
2821 for (j = 0; j < workspaceInfo->secondaryHelpDialogCount; j++)
2823 sprintf(number, "%d", j + 1);
2824 _DtWriteDialogData(workspaceInfo->secondaryHelpDialogList[j],
2828 /* Save the primary help dialog window */
2829 if (workspaceInfo->primaryHelpDialog)
2831 sprintf(number, "%d", 0);
2832 _DtWriteDialogData(workspaceInfo->primaryHelpDialog,
2835 write (fd, "#\n", strlen ("#\n"));
2839 /* Re-able message box display flag after save session */
2840 message_display_enabled = True;
2848 * Given a directory name, this function will see if a view of the parent
2849 * directory is open; if so, then it will update the icon representing
2850 * this icon, in the parent view, so that it is drawn as 'open'. This
2851 * function must only be called if openDirType == NEW.
2857 char * directory_name)
2859 FileViewData * file_view_data = NULL;
2860 DesktopRec *desktopWindow;
2868 char *icon_name, *new_file_type_name, *file_type_name;
2871 /* if directory_name is passed in a NULL, we want to go through all
2872 existing open directories and check to see if there are any open
2873 directories in each of them. This is used at the end of OpenNewView
2874 and the end of ShowNewDirectory */
2875 if (directory_name == NULL)
2877 for (i = 0; i < view_count; i++)
2879 dd = (DialogData *) view_set[i]->dialog_data;
2880 fmd = (FileMgrData *) dd->data;
2882 for(j = 0; j < fmd->directory_count; j++)
2884 ForceMyIconOpen(view_set[i]->host_name,
2885 fmd->directory_set[j]->name);
2891 parent = _DtPName(directory_name);
2892 fname = DName(directory_name);
2894 /* first lets check to see if the directory is open in one of the
2895 open file manager views */
2896 for (i = 0; i < view_count; i++)
2898 dd = (DialogData *) view_set[i]->dialog_data;
2899 fmd = (FileMgrData *) dd->data;
2901 /* loop through until we find the file_view_data structure for the
2902 directory to force open */
2903 if (strcmp(host_name, view_set[i]->host_name) == 0)
2905 for(j = 0; j < fmd->directory_count; j++)
2907 if (strcmp(parent, fmd->directory_set[j]->name) == 0)
2909 for (k = 0; k < fmd->directory_set[j]->file_count; k++)
2911 file_view_data = fmd->directory_set[j]->file_view_data[k];
2912 if (strcmp(file_view_data->file_data->file_name, fname) == 0)
2914 file_view_data = NULL;
2923 fmd = (FileMgrData *)(((DirectorySet *)file_view_data->directory_set)->
2926 file_type_name = file_view_data->file_data->logical_type;
2928 if(fmd->view != BY_NAME)
2929 BuildAndShowIconName(file_type_name, fmd->view,
2930 fmd->show_type, file_view_data->widget);
2934 /* now we need to check to see if the directory being opened has a
2935 representation on the Desktop */
2936 for(i = 0; i < desktop_data->numIconsUsed; i++)
2940 desktopWindow = desktop_data->desktopWindows[i];
2941 file_view_data = desktopWindow->file_view_data;
2943 sprintf(buf, "%s/%s", desktopWindow->dir_linked_to,
2944 desktopWindow->file_name);
2945 DtEliminateDots (buf);
2947 if (strcmp(buf, directory_name) == 0 &&
2948 strcmp(desktopWindow->host, host_name) == 0)
2950 file_type_name = file_view_data->file_data->logical_type;
2951 if(desktopIconType == LARGE)
2952 BuildAndShowIconName(file_type_name, BY_NAME_AND_ICON,
2953 SINGLE_DIRECTORY, desktopWindow->iconGadget);
2955 BuildAndShowIconName(file_type_name, BY_NAME_AND_SMALL_ICON,
2956 SINGLE_DIRECTORY, desktopWindow->iconGadget);
2964 /************************************************************************
2967 * Open the file as a resource data base, and use the data to
2968 * create a set of File Manager views.
2970 ************************************************************************/
2975 int type_of_restore,
2978 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
2981 XrmName xrm_name[10];
2982 XrmRepresentation rep_type;
2985 char * full_path = NULL;
2986 Boolean status=False;
2990 int num_sec_help_dialogs;
2993 DialogData * dialogData;
2994 struct stat stat_buf;
2997 /* Build the session path if we need to.
2998 * (e.g. When using the -session option)
3000 if (type_of_restore == NORMAL_RESTORE)
3002 status = DtSessionRestorePath(toplevel, &full_path, path);
3007 if (stat(full_path, &stat_buf) != 0)
3009 char *tmpStr, *msg, *title;
3011 tmpStr = GETMESSAGE(18, 18, "Could not open the session file.");
3012 msg = XtNewString(tmpStr);
3013 title = XtNewString((GETMESSAGE(21,39,"File Open Error")));
3014 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
3022 path = XtNewString(full_path);
3025 /* This prevents the encapsulator from placing the dialogs */
3026 disableDialogAutoPlacement = True;
3028 /* Open the file as a resource database and query it to */
3029 /* get the previously saved view count. */
3031 db = XrmGetFileDatabase (path);
3033 if (type_of_restore == NORMAL_RESTORE)
3035 /* first find out if it should show the file system */
3036 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3037 xrm_name [1] = XrmStringToQuark ("showFilesystem");
3039 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3041 if ((temp = (char *) value.addr) != NULL &&
3042 strcmp (temp, "True") == 0)
3044 showFilesystem = True;
3047 showFilesystem = False;
3050 showFilesystem = True;
3052 /* find out if it should be in restricted mode */
3053 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3054 xrm_name [1] = XrmStringToQuark ("restrictMode");
3056 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3058 if ((temp = (char *) value.addr) != NULL &&
3059 strcmp (temp, "True") == 0)
3061 restrictMode = True;
3064 restrictMode = False;
3067 restrictMode = False;
3069 /* find out openFolder mode */
3070 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3071 xrm_name [1] = XrmStringToQuark ("openFolder");
3073 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3075 if ((temp = (char *) value.addr) != NULL &&
3076 strcmp (temp, "NEW") == 0)
3081 openDirType = CURRENT;
3084 openDirType = CURRENT;
3087 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3088 xrm_name [1] = XrmStringToQuark ("view_count");
3091 /* Load standard dtfile views */
3092 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3094 num_views = atoi (value.addr);
3096 LoadViews(num_views, db, NULL, directory, special_restricted, 0);
3099 /* Restore any desktop help dialogs */
3100 if (type_of_restore == NORMAL_RESTORE)
3102 for (i = 0; i < desktop_data->numWorkspaces; i++)
3104 sprintf(wsNum, "%d", i);
3105 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3106 xrm_name [1] = XrmStringToQuark (WS_LOAD_RES_HEADER);
3107 xrm_name [2] = XrmStringToQuark (wsNum);
3108 xrm_name [3] = XrmStringToQuark (SEC_LOAD_HELP_RES_HEADER);
3111 /* Load standard dtfile views */
3112 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3114 num_sec_help_dialogs = atoi (value.addr);
3115 if (num_sec_help_dialogs > 0)
3117 desktop_data->workspaceData[i]->secondaryHelpDialogCount =
3118 num_sec_help_dialogs;
3119 desktop_data->workspaceData[i]->secondaryHelpDialogList =
3120 (DialogData **) XtMalloc(sizeof(DialogData *) *
3121 num_sec_help_dialogs);
3123 for (j = 0; j < num_sec_help_dialogs; j++)
3125 name_list[0] = DTFILE_CLASS_NAME;
3126 name_list[1] = WS_LOAD_RES_HEADER;
3127 name_list[2] = wsNum;
3128 name_list[3] = dialogNum;
3129 name_list[4] = NULL;
3130 sprintf(dialogNum, "%d", j + 1);
3132 _DtGetResourceDialogData(help_dialog, db, name_list);
3133 desktop_data->workspaceData[i]->secondaryHelpDialogList[j]=
3135 ShowDTHelpDialog(NULL, i, HYPER_HELP_DIALOG,
3136 dialogData, NULL, NULL, NULL, NULL,
3142 /* Load the primary help dialog */
3143 name_list[0] = DTFILE_CLASS_NAME;
3144 name_list[1] = WS_LOAD_RES_HEADER;
3145 name_list[2] = wsNum;
3146 name_list[3] = dialogNum;
3147 name_list[4] = NULL;
3148 sprintf(dialogNum, "%d", 0);
3149 dialogData = _DtGetResourceDialogData(help_dialog, db, name_list);
3151 /* Keep only if currently posted */
3152 if (!(((HelpData *)dialogData->data)->displayed))
3154 /* Not currently displayed */
3155 _DtFreeDialogData(dialogData);
3158 desktop_data->workspaceData[i]->primaryHelpDialog = dialogData;
3161 ShowDTHelpDialog(NULL, i, MAIN_HELP_DIALOG,
3162 dialogData, NULL, DTFILE_HELP_NAME,
3171 /* Free the Xrm Database */
3172 XrmDestroyDatabase(db);
3173 disableDialogAutoPlacement = False;
3184 extern Tt_message FileCallback();
3185 extern Tt_message SessionCallback();
3187 if ((msg == 0) || tt_is_err( tt_ptr_error( msg ))) {
3192 * Register for notifications on the directory viewed.
3193 * This is done so that requesting apps can notify the
3194 * view if the directory name is changed.
3196 view->pats = ttdt_file_join( view->directory_name, TT_SESSION, 0,
3197 FileCallback, view );
3198 if (tt_is_err( tt_ptr_error( view->pats ))) {
3202 /* Returned patterns automatically get destroyed when msg is destroyed */
3203 ttdt_message_accept( msg, SessionCallback,
3204 _DtGetDialogShell( (DialogData *)view->dialog_data ),
3214 char *directory_name,
3219 XrmName xrm_name[5];
3220 XrmRepresentation rep_type;
3222 static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL };
3223 char view_number[11];
3224 DialogData * dialog_data;
3225 FileMgrData * file_mgr_data;
3227 XClassHint classHints;
3228 char * iconify = NULL;
3229 Boolean iconify_window;
3231 char *title, *tmpTitle;
3233 name_list[1] = view_number;
3234 xrm_name [0] = XrmStringToQuark (DTFILE_CLASS_NAME);
3237 /* Get and display view_count views. */
3239 for (i = 0; i < num_views; i++)
3241 struct stat stat_buf;
3243 (void) sprintf (view_number, "%d", i);
3244 xrm_name [1] = XrmStringToQuark (view_number);
3246 /* Get the main dialog data and set up the view */
3248 dialog_data = _DtGetResourceDialogData (file_mgr_dialog, db, name_list);
3249 file_mgr_data = (FileMgrData *) dialog_data->data;
3251 if(file_mgr_data->toolbox && file_mgr_data->title == NULL)
3252 file_mgr_data->title = DtActionLabel("Dtappmgr");
3254 if (stat(file_mgr_data->current_directory, &stat_buf) != 0)
3256 _DtFreeDialogData(dialog_data);
3260 if (trashFileMgrData
3261 && (file_mgr_data->IsTrashCan == True)
3262 && strcmp(file_mgr_data->current_directory, trash_dir) == 0)
3264 trashFileMgrData->view = file_mgr_data->view;
3265 trashFileMgrData->order = file_mgr_data->order;
3266 trashFileMgrData->direction = file_mgr_data->direction;
3267 trashFileMgrData->positionEnabled = file_mgr_data->positionEnabled;
3268 trashFileMgrData->preferences = file_mgr_data->preferences;
3269 file_mgr_data->preferences = NULL;
3270 _DtFreeDialogData(dialog_data);
3274 /* Increment the view list size if necessary and add directory to list */
3276 if (view_count == view_set_size)
3278 view_set_size += 10;
3280 (View **) XtRealloc ((char *)view_set,
3281 sizeof (View **) * view_set_size);
3283 view_set[view_count] = (View *) XtMalloc (sizeof (View));
3284 view_set[view_count]->dialog_data = (XtPointer) dialog_data;
3285 view_set[view_count]->msg = 0;
3286 view_set[view_count]->pats = 0;
3288 if(restoreType == TOOL_RESTORE)
3289 file_mgr_data->toolbox = True;
3291 if(directory_name == NULL)
3293 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3294 view_set[view_count]->directory_name =
3295 XtNewString (file_mgr_data->current_directory);
3299 XtFree(file_mgr_data->current_directory);
3300 file_mgr_data->current_directory = NULL;
3301 XtFree(file_mgr_data->restricted_directory);
3302 file_mgr_data->restricted_directory = NULL;
3304 view_set[view_count]->directory_name = XtNewString(directory_name);
3305 XtFree((char *)file_mgr_data->selection_list);
3306 file_mgr_data->selection_list = NULL;
3307 if(host_name == NULL)
3309 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3310 file_mgr_data->current_directory = XtNewString(directory_name);
3312 file_mgr_data->restricted_directory =
3313 XtNewString(directory_name);
3315 file_mgr_data->restricted_directory =
3320 view_set[view_count]->host_name = XtNewString (host_name);
3321 XtFree(file_mgr_data->host);
3322 file_mgr_data->host = XtNewString(host_name);
3323 file_mgr_data->current_directory = XtNewString(directory_name);
3324 if(special_view && special_restricted != NULL)
3325 file_mgr_data->restricted_directory =
3326 XtNewString(special_restricted);
3328 file_mgr_data->restricted_directory = NULL;
3330 FileMgrBuildDirectories (file_mgr_data,
3331 view_set[view_count]->host_name, directory_name);
3334 /* Get the workspace set the view is contained in */
3335 /* and set the property for the view just created */
3337 xrm_name [2] = XrmStringToQuark ("workspace");
3340 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3342 /* Make sure we have some valid workspaces names to work with */
3344 /* value.addr should = NULL if no workspace names */
3345 workspaces = (char *) value.addr;
3348 /* we have no workspace resource so use default */
3351 /* Get and set whether the view is iconic */
3353 xrm_name [2] = XrmStringToQuark ("iconify");
3356 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value))
3358 /* If there is an iconify resource and its value is True, */
3359 /* then mark the window as iconified. */
3361 if ((iconify = (char *) value.addr) != NULL &&
3362 strcmp (iconify, "True") == 0)
3364 iconify_window = True;
3368 iconify_window = False;
3371 iconify_window = False;
3373 if(file_mgr_data->positionEnabled == RANDOM_ON &&
3374 (file_mgr_data->object_positions == NULL))
3375 LoadPositionInfo(file_mgr_data);
3377 /* Call _DtShowDialog to create and manage the new window */
3379 tmpTitle = file_mgr_data->title;
3380 title = file_mgr_data->title = _DtBuildFMTitle(file_mgr_data);
3382 XtFree(special_title);
3383 special_title = XtNewString(title);
3385 classHints.res_name = title;
3386 classHints.res_class = DTFILE_CLASS_NAME;
3388 _DtShowDialog (NULL, NULL, NULL, dialog_data, NULL, NULL,
3389 RemoveTextFields, NULL, workspaces, iconify_window,
3390 special_view, title, &classHints);
3393 file_mgr_data->title = tmpTitle;
3396 ViewAccept( view_set[view_count], msg );
3403 if (openDirType == NEW)
3404 ForceMyIconOpen(file_mgr_data->host, NULL);
3408 /************************************************************************
3412 ************************************************************************/
3415 char current_directory[] )
3417 FILE * pwd_file = NULL;
3420 /* Open a pwd process and read the current working directory */
3421 /* from it. If the open fails or a read fails, then display */
3422 /* the users home directory. */
3424 pwd_file = popen ("pwd", "r");
3431 if (fread (¤t_directory[i], sizeof(char), 1, pwd_file) != 1)
3439 if (current_directory[i] == '\n')
3449 current_directory[i] = '\0';
3452 /************************************************************************
3455 * Given a string that contains a single or set of host:path
3456 * specifications, parse out each host:path, validate it as
3457 * a accessible directory, and call a function to create a
3458 * file manager view of the directory.
3460 ************************************************************************/
3464 char *directory_set,
3471 /* Loop the the directory set string until all of */
3472 /* the path specifications have be parsed. */
3476 separator = DtStrchr (directory_set, ',');
3477 if (separator != NULL)
3480 _DtPathFromInput(directory_set, NULL, &host, &path);
3484 GetNewView (host, path, type, NULL, 0);
3488 char *tmpStr, *errTitle, *errMsg, *dmsg;
3490 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3491 errTitle = XtNewString(tmpStr);
3492 tmpStr = GETMESSAGE(18, 38, "Invalid folder specification, %s");
3493 errMsg = XtNewString(tmpStr);
3494 dmsg = XtMalloc(strlen(errMsg)+strlen(directory_set)+1);
3495 sprintf(dmsg, errMsg, directory_set);
3496 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
3503 /* Free up the unique host and directory names */
3504 /* that were allocated. */
3506 XtFree ((char *) host);
3507 XtFree ((char *) path);
3509 /* Set the starting position of the next host:path */
3511 if (separator != NULL)
3512 directory_set = separator + 1;
3521 /************************************************************************
3524 * Given a directory name, generate a new view for the directory.
3526 ************************************************************************/
3530 char *directory_name,
3532 WindowPosition *position,
3535 DialogData * dialog_data;
3536 DialogInstanceData * instance_data;
3537 FileMgrData * file_mgr_data;
3539 FileMgrRec * file_mgr_rec;
3540 char * real_directory_name;
3542 XClassHint classHints;
3543 char *title, *tmpTitle;
3544 struct stat stat_buf;
3546 char *errMsg = NULL;
3548 DtEliminateDots( directory_name );
3550 if (stat(directory_name, &stat_buf) == 0)
3552 if ((stat_buf.st_mode & S_IFMT) != S_IFDIR)
3554 tmpStr = GETMESSAGE(18, 19,
3555 "The folder specification,\n%s\nis not a folder.");
3556 errMsg = XtNewString(tmpStr);
3561 tmpStr = GETMESSAGE(18, 20,
3562 "The folder specification,\n%s\ndoes not exist.");
3563 errMsg = XtNewString(tmpStr);
3570 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
3571 title = XtNewString(tmpStr);
3572 dmsg = XtMalloc(strlen(errMsg) +
3573 strlen(directory_name) + 1);
3574 sprintf(dmsg, errMsg, directory_name);
3575 _DtMessage(toplevel, title, dmsg, NULL, HelpRequestCB);
3584 * Special case: When opening any of the special desktop directory
3585 * icons (Home, Remote Systems, etc), we want to display the correct
3586 * path (i.e. $HOME instead of $HOME/.dt/Desktop/Home). So ... we'll
3587 * do the remap here.
3589 real_directory_name = directory_name;
3591 if(openDirType == NEW || (strcmp(real_directory_name, desktop_dir) == 0))
3593 for(i = 0; i < view_count; i++)
3595 if((strcmp(real_directory_name, view_set[i]->directory_name) == 0 &&
3596 (strcmp(host_name, view_set[i]->host_name) == 0))
3601 Screen *currentScreen;
3604 dialog_data = (DialogData *) view_set[i]->dialog_data;
3605 file_mgr_data = (FileMgrData *) dialog_data->data;
3606 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
3608 screen = XDefaultScreen(display);
3609 currentScreen = XScreenOfDisplay(display, screen);
3610 rootWindow = RootWindowOfScreen(currentScreen);
3612 /* Get the current Workspace */
3613 if (DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
3616 Atom * ws_presence = NULL;
3617 unsigned long num_workspaces = 0;
3620 if (DtWsmGetWorkspacesOccupied(display,
3621 XtWindow(file_mgr_rec->shell), &ws_presence,
3622 &num_workspaces) == Success)
3624 /* Already in this workspace? */
3625 for (k = 0; k < num_workspaces; k++)
3627 if (ws_presence[k] == pCurrent)
3631 if (k >= num_workspaces)
3633 /* Add to the workspace */
3634 ws_presence = (Atom *) XtRealloc((char *)ws_presence,
3635 sizeof (Atom) * (num_workspaces + 1));
3637 ws_presence[num_workspaces] = pCurrent;
3638 DtWsmSetWorkspacesOccupied(display,
3639 XtWindow(file_mgr_rec->shell),
3640 ws_presence, num_workspaces + 1);
3642 XFree((char *)ws_presence);
3646 /* Change the hints to reflect the current workspace */
3647 DtWsmSetWorkspacesOccupied(display,
3648 XtWindow(file_mgr_rec->shell),
3653 /* must map the window to catch iconified windows */
3654 /* a XtPopup will not catch it */
3655 XtMapWidget(file_mgr_rec->shell);
3656 XRaiseWindow(display, XtWindow(file_mgr_rec->shell));
3658 /* announce activity */
3661 msg = tt_pnotice_create(TT_SESSION, "DtActivity_Began");
3662 tt_message_send(msg);
3663 tttk_message_destroy(msg);
3671 /* If in novice mode, force the icon for this dir to the 'Open' state */
3672 if (openDirType == NEW)
3673 ForceMyIconOpen(host_name, directory_name);
3675 /* Increment the list size if necessary. */
3677 if (view_count == view_set_size)
3679 view_set_size += 10;
3681 (View **) XtRealloc ((char *)view_set,
3682 sizeof (View **) * view_set_size);
3685 view_set[view_count] = (View *) XtMalloc (sizeof (View));
3686 view_set[view_count]->msg = 0;
3687 view_set[view_count]->pats = 0;
3689 if (initiating_view != NULL)
3690 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3694 char full_path[MAX_PATH + 1];
3697 tmp_path = _DtCreateDtDirs(display);
3699 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
3701 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
3703 db = XrmGetFileDatabase (full_path);
3708 restoreType = TOOL_RESTORE;
3709 LoadViews(1, db, NULL, directory_name, type, msg);
3713 restoreType = HOME_RESTORE;
3714 LoadViews(1, db, host_name, directory_name, NULL, msg);
3718 * Free the Xrm Database
3720 XrmDestroyDatabase(db);
3721 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
3722 file_mgr_data = (FileMgrData *) dialog_data->data;
3725 application_args.tool_width = file_mgr_data->width;
3726 application_args.tool_height = file_mgr_data->height;
3730 application_args.dir_width = file_mgr_data->width;
3731 application_args.dir_height = file_mgr_data->height;
3733 if(file_mgr_data->find != NULL &&
3734 file_mgr_data->current_directory != NULL)
3736 DialogData * dialog_data;
3737 FindData * find_data;
3739 dialog_data = (DialogData *)file_mgr_data->find;
3740 find_data = (FindData *)dialog_data->data;
3742 XtFree(find_data->directories);
3743 if(file_mgr_data->restricted_directory == NULL)
3746 find_data->directories = XtNewString(users_home_dir);
3748 find_data->directories =
3749 XtNewString(file_mgr_data->current_directory);
3753 if(strcmp(file_mgr_data->current_directory,
3754 file_mgr_data->restricted_directory) == 0)
3755 find_data->directories = XtNewString("/");
3757 find_data->directories =
3758 XtNewString(file_mgr_data->current_directory +
3759 strlen(file_mgr_data->restricted_directory));
3763 /* If in novice mode, force the icon for all the dir's to the
3765 if (openDirType == NEW)
3766 ForceMyIconOpen(host_name, NULL);
3768 return((DialogData *)view_set[view_count - 1]->dialog_data);
3771 dialog_data = _DtGetDefaultDialogData (file_mgr_dialog);
3773 view_set[view_count]->dialog_data = (XtPointer) dialog_data;
3774 file_mgr_data = (FileMgrData *) dialog_data->data;
3776 /* Adjust the view settings if this new view was created */
3777 /* because of an action on a previous view. */
3779 if (initiating_view != NULL)
3781 FileMgrPropagateSettings ((FileMgrData *)initiating_view, file_mgr_data);
3782 /* force new window to come up in flat mode */
3783 file_mgr_data->show_type =
3784 ((PreferencesData *)file_mgr_data->preferences->data)->show_type =
3786 file_mgr_data->view = file_mgr_data->view_single;
3789 /* Call the FileMgr dialog to build up its directory set for */
3790 /* the directory name. */
3791 FileMgrBuildDirectories (file_mgr_data, host_name, real_directory_name);
3795 PreferencesData *preferences_data;
3797 file_mgr_data->toolbox = True;
3798 file_mgr_data->width = application_args.tool_width;
3799 file_mgr_data->height = application_args.tool_height;
3801 /* we want to default for the toolboxes (i.e. Application Manager) to
3802 * look different from a normal File Manager view. Let's turn off
3803 * the iconic_path, current_directory, and status_line.
3805 file_mgr_data->show_iconic_path = False;
3806 file_mgr_data->show_current_dir = False;
3808 file_mgr_data->show_status_line = True;
3811 preferences_data = (PreferencesData *)file_mgr_data->preferences->data;
3812 preferences_data->show_iconic_path = file_mgr_data->show_iconic_path;
3813 preferences_data->show_current_dir = file_mgr_data->show_current_dir;
3814 preferences_data->show_status_line = file_mgr_data->show_status_line;
3818 file_mgr_data->toolbox = False;
3819 file_mgr_data->width = application_args.dir_width;
3820 file_mgr_data->height = application_args.dir_height;
3824 if(file_mgr_data->find != NULL && file_mgr_data->current_directory != NULL)
3826 DialogData * dialog_data;
3827 FindData * find_data;
3829 dialog_data = (DialogData *)file_mgr_data->find;
3830 find_data = (FindData *)dialog_data->data;
3832 XtFree(find_data->directories);
3833 if(file_mgr_data->restricted_directory == NULL)
3836 find_data->directories = XtNewString(users_home_dir);
3838 find_data->directories =
3839 XtNewString(file_mgr_data->current_directory);
3843 if(strcmp(file_mgr_data->current_directory,
3844 file_mgr_data->restricted_directory) == 0)
3845 find_data->directories = XtNewString("/");
3847 find_data->directories =
3848 XtNewString(file_mgr_data->current_directory +
3849 strlen(file_mgr_data->restricted_directory));
3853 view_set[view_count]->host_name = XtNewString (file_mgr_data->host);
3854 view_set[view_count]->directory_name =
3855 XtNewString (file_mgr_data->current_directory);
3857 /* Load default position info, or inherit, if appropriate */
3858 if ((fmd = (FileMgrData *)initiating_view) &&
3859 (strcmp(fmd->host, host_name) == 0) &&
3860 (strcmp(fmd->current_directory, real_directory_name) == 0))
3862 InheritPositionInfo(fmd, file_mgr_data);
3865 LoadPositionInfo(file_mgr_data);
3868 /* Get the dialog displayed. */
3871 instance_data = (DialogInstanceData *) dialog_data->data;
3872 instance_data->x = position->x;
3873 instance_data->y = position->y;
3874 instance_data->displayed = True; /* @@@ Hack! without this,
3875 _DtShowDialog will ignore
3876 our position info */
3879 tmpTitle = file_mgr_data->title;
3880 title = file_mgr_data->title = _DtBuildFMTitle(file_mgr_data);
3882 XtFree(special_title);
3883 special_title = XtNewString(title);
3885 classHints.res_name = title;
3886 classHints.res_class = DTFILE_CLASS_NAME;
3887 initiating_view = NULL;
3889 _DtShowDialog (NULL, NULL, NULL, dialog_data, NULL, NULL, RemoveTextFields,
3890 NULL, NULL, False, special_view, title, &classHints);
3893 file_mgr_data->title = tmpTitle;
3896 ViewAccept( view_set[view_count], msg );
3902 /* If in novice mode, force the icon for all the dir's to the 'Open' state */
3903 if (openDirType == NEW)
3904 ForceMyIconOpen(host_name, NULL);
3906 return(dialog_data);
3912 /************************************************************************
3915 * Update the view set array when a view is closed.
3917 ************************************************************************/
3921 DialogData *dialog_data )
3925 FileMgrData * file_mgr_data;
3926 DialogData * tmpDialog_data;
3927 FileMgrRec * file_mgr_rec;
3928 XmManagerWidget file_window;
3929 char *directory_name = NULL;
3930 char *host_name = NULL;
3932 if(dialog_data == trashDialogData)
3934 CloseTrash(NULL, NULL, NULL);
3938 for (i = 0; i < view_count; i++)
3940 if (dialog_data == (DialogData *) (view_set[i]->dialog_data))
3942 tmpDialog_data = (DialogData *) (view_set[i]->dialog_data);
3943 file_mgr_data = (FileMgrData *)tmpDialog_data->data;
3945 directory_name = (char *)XtMalloc( strlen(view_set[i]->directory_name) + 1);
3946 strcpy(directory_name, view_set[i]->directory_name);
3947 host_name = (char *)XtMalloc( strlen(view_set[i]->host_name) + 1);
3948 strcpy(host_name, view_set[i]->host_name);
3950 if (view_set[i]->msg != 0) {
3951 if (view_set[i]->pats != 0) {
3952 ttdt_file_quit( view_set[i]->pats, 0 );
3953 view_set[i]->pats = 0;
3955 tt_message_reply( view_set[i]->msg );
3956 tttk_message_destroy( view_set[i]->msg );
3957 view_set[i]->msg = 0;
3960 XtFree ((char *) view_set[i]->directory_name);
3961 XtFree ((char *) view_set[i]->host_name);
3962 XtFree ((char *) view_set[i]);
3965 for (j = i; j < view_count - 1; j++)
3966 view_set[j] = view_set[j + 1];
3970 _DtHideDialog (dialog_data, True);
3972 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
3973 file_window = (XmManagerWidget)file_mgr_rec->file_window;
3974 /* For next time, unmanage all the icons */
3975 XtUnmanageChildren(file_window->composite.children,
3976 file_window->composite.num_children);
3978 if(PositionFlagSet(file_mgr_data))
3979 SavePositionInfo(file_mgr_data);
3981 /* If it is an Application Manager view, then no point in
3982 caching this dialog, so free it */
3984 if(file_mgr_data->toolbox)
3985 _DtFreeDialog(dialog_data);
3987 _DtFreeDialogData (dialog_data);
3994 /* Update the directory cache list to remove unneeded directories. */
3996 UpdateCachedDirectories (view_set, view_count);
3998 if (openDirType == NEW)
3999 ForceMyIconClosed(host_name, directory_name);
4001 XtFree(directory_name);
4008 /************************************************************************
4011 * This function is called when a view may be changing its
4012 * current directory. It updates the view_set list to the
4013 * new host and directory.
4015 ************************************************************************/
4019 XtPointer file_mgr_data,
4020 char *old_host_name,
4021 char *new_host_name,
4022 char *old_directory_name,
4023 char *new_directory_name )
4028 /* See if the directory is one being viewed */
4030 for (i = 0; i < view_count; i++)
4032 if (((DialogData *) (view_set[i]->dialog_data))->data == file_mgr_data)
4034 if (strcmp (old_host_name, view_set[i]->host_name) == 0 &&
4035 strcmp (old_directory_name, view_set[i]->directory_name) == 0)
4037 XtFree ((char *) view_set[i]->host_name);
4038 view_set[i]->host_name = XtNewString (new_host_name);
4040 XtFree ((char *) view_set[i]->directory_name);
4041 view_set[i]->directory_name = XtNewString (new_directory_name);
4047 /* Update the directory cache list to remove unneeded directories. */
4049 UpdateCachedDirectories (view_set, view_count);
4054 /************************************************************************
4057 * Dispatch ToolTalk events to internal handlers.
4059 ************************************************************************/
4061 static Tt_callback_action
4070 op = tt_message_op( msg );
4071 status = tt_ptr_error( op );
4072 if ((status != TT_OK) || (op == 0)) {
4073 /* Let tttk_Xt_input_handler() Do The Right Thing */
4074 return TT_CALLBACK_CONTINUE;
4076 if (strcmp( op, "DtTypes_Reloaded" ) == 0) {
4078 } else if (strcmp( op, "XSession_Ending" ) == 0) {
4079 if( emptyTrashOnExit )
4083 return TT_CALLBACK_CONTINUE;
4086 tttk_message_destroy( msg );
4087 return TT_CALLBACK_PROCESSED;
4090 /************************************************************************
4093 * Dispatch ToolTalk requests to internal handlers.
4095 ************************************************************************/
4106 op = tt_message_op( msg );
4107 status = tt_ptr_error( op );
4108 if ((status != TT_OK) || (op == 0)) {
4109 /* Let tttk_Xt_input_handler() Do The Right Thing */
4110 return TT_CALLBACK_CONTINUE;
4112 if (strcmp( op, "DtFileSession_Run" ) == 0) {
4113 ViewSessionHandler( msg );
4114 } else if (strcmp( op, "DtFolder_Show" ) == 0) {
4115 ViewDirectoryHandler( msg );
4116 } else if (strcmp( op, "DtHome_Show" ) == 0) {
4117 ViewHomeDirectoryHandler( msg );
4118 } else if (strcmp( op, "DtTools_Show" ) == 0) {
4119 ViewToolsDirectoryHandler( msg );
4120 } else if (strcmp( op, "DtTrash_Show" ) == 0) {
4121 TrashDisplayHandler( msg );
4122 } else if (strcmp( op, "DtTrash_Remove" ) == 0) {
4123 TrashRemoveHandler( msg );
4124 } else if (strcmp( op, "DtTrash_Empty" ) == 0) {
4125 TrashEmptyHandler( msg );
4126 } else if (strcmp( op, "DtTrash_File" ) == 0) {
4127 TrashRemoveNoConfirmHandler( msg );
4128 } else if (strcmp( op, "DtTrash_Restore" ) == 0) {
4129 TrashRestoreHandler( msg );
4130 } else if (strcmp( op, "DtFile_PutOnWorkspace" ) == 0) {
4131 PutOnWorkspaceHandler( msg );
4132 } else if (strcmp( op, "DtFile_Move" ) == 0) {
4133 MoveCopyLinkHandler( msg, MOVE_FILE );
4134 } else if (strcmp( op, "DtFile_Copy" ) == 0) {
4135 MoveCopyLinkHandler( msg, COPY_FILE );
4136 } else if (strcmp( op, "DtFile_Link" ) == 0) {
4137 MoveCopyLinkHandler( msg, LINK_FILE );
4140 return TT_CALLBACK_CONTINUE;
4143 return TT_CALLBACK_PROCESSED;
4149 /************************************************************************
4151 * ViewSessionHandler
4152 * This function is called upon the dt session message
4153 * being received. The name of the session file is extracted
4154 * out of the message and a function is called to create
4155 * a view or set of views described by the file.
4157 ************************************************************************/
4163 char *file = tt_message_file( msg );
4164 tt_message_reply( msg );
4165 tttk_message_destroy( msg );
4167 if (! tt_is_err( tt_ptr_error( file )))
4169 if (view_count == 0 && desktop_data->numIconsUsed == 0)
4171 int session_flag = 0;
4174 session_name = strrchr(file, '/');
4176 LoadDesktopInfo(session_name);
4177 session_flag = RestoreSession (session_name, NORMAL_RESTORE, NULL);
4178 if ((session_flag != 0) && (view_count == 0))
4180 char current_directory[MAX_PATH];
4182 GetPWD(current_directory);
4183 if (current_directory[0] != '\0')
4186 (home_host_name, current_directory, NULL, NULL, 0))
4187 ViewHomeDirectoryHandler (0);
4191 ViewHomeDirectoryHandler (0);
4197 char *tmpStr, *msg, *title;
4199 tmpStr = GETMESSAGE(18, 39, "Cannot start a second File Manager session because a File Manager\nsession is already open on the desktop. If you want to start a new File\nManager session, you must first close all current File Manager windows\nand remove all File Manager objects from the workspaces.");
4200 msg = XtNewString(tmpStr);
4201 title = XtNewString((GETMESSAGE(18,40,"Session Error")));
4202 _DtMessage (toplevel, title, msg, NULL, HelpRequestCB);
4213 /************************************************************************
4215 * ViewDirectoryHandler
4216 * This function is called upon the dt directory message
4217 * being received. The name of the directory is extracted
4218 * out of the message and a function is called to create
4219 * a view of the directory.
4221 ************************************************************************/
4224 ViewDirectoryHandler(
4231 initiating_view = NULL;
4232 msgFile = tt_message_file( msg );
4233 if (tt_is_err( tt_ptr_error( msgFile ))) msgFile = 0;
4237 if(msgFile && strncmp(msgFile, "~", 1) != 0 )
4239 if((strcmp(users_home_dir, "/") != 0) &&
4240 (strncmp(msgFile, users_home_dir, strlen(users_home_dir)-1) != 0))
4242 char *tmpStr, *errTitle, *errMsg, *dmsg;
4244 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4245 errTitle = XtNewString(tmpStr);
4246 tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view this folder\nbecause it is a restricted folder.");
4247 errMsg = XtNewString(tmpStr);
4248 dmsg = XtMalloc(strlen(errMsg)+strlen(msgFile)+1);
4249 sprintf(dmsg, errMsg, msgFile);
4250 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4257 tt_message_reply( msg );
4258 tttk_message_destroy( msg );
4264 numArgs = tt_message_args_count( msg );
4265 if (tt_is_err( tt_int_error( numArgs ))) numArgs = 0;
4268 special_view = True;
4269 special_treeType = UNSET_VALUE;
4270 special_treeFiles = UNSET_VALUE;
4271 special_viewType = UNSET_VALUE;
4272 special_orderType = UNSET_VALUE;
4273 special_directionType = UNSET_VALUE;
4274 special_randomType = UNSET_VALUE;
4275 special_restricted = NULL;
4276 special_title = NULL;
4277 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4278 for(i = 0; i < numArgs; i++)
4282 vtype = tt_message_arg_type( msg, i );
4283 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4286 val = tt_message_arg_val( msg, i );
4287 if(strcmp(vtype, "-title") == 0)
4289 special_title = XtNewString(val);
4291 else if(strcmp(vtype, "-help_volume") == 0)
4293 special_helpVol = XtNewString(val);
4295 if(strcmp(vtype, "-tree") == 0)
4297 DtfileStringToTree(val, &special_treeType);
4299 else if(strcmp(vtype, "-tree_files") == 0)
4301 DtfileStringToTreeFiles(val, &special_treeFiles);
4303 else if(strcmp(vtype, VIEW_HEADER) == 0)
4305 DtfileStringToView(val, &special_viewType);
4307 else if(strcmp(vtype, "-order") == 0)
4309 DtfileStringToOrder(val, &special_orderType);
4311 else if(strcmp(vtype, "-direction") == 0)
4313 DtfileStringToDirection(val, &special_directionType);
4315 else if(strcmp(vtype, "-grid") == 0)
4317 DtfileStringToGrid(val, &special_randomType);
4319 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4321 special_restricted = XtNewString(msgFile);
4326 if ((restrictMode) && (!special_restricted))
4330 ptr = strrchr(users_home_dir, '/');
4332 special_restricted = XtNewString(users_home_dir);
4337 else if (restrictMode)
4341 special_view = True;
4342 special_treeType = treeType;
4343 special_treeFiles = treeFiles;
4344 special_viewType = viewType;
4345 special_orderType = orderType;
4346 special_directionType = directionType;
4347 special_randomType = randomType;
4349 ptr = strrchr(users_home_dir, '/');
4351 special_restricted = XtNewString(users_home_dir);
4354 special_title = NULL;
4355 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4359 special_view = False;
4361 OpenDirectories (msgFile, NULL);
4364 tt_message_reply( msg );
4365 tttk_message_destroy( msg );
4371 /************************************************************************
4374 * This function is called upon the dt directory message
4375 * being received. The name of the directory is extracted
4376 * out of the message and a function is called to create
4377 * a view of the directory. This function is passed directly
4378 * to DtActionInvoke to be used as a callback.
4380 ************************************************************************/
4389 DialogData *return_data;
4393 if(root_dir && strncmp(root_dir, "~", 1) != 0 )
4395 if((strcmp(users_home_dir, "/") != 0) &&
4396 (strncmp(root_dir, users_home_dir, strlen(users_home_dir)-1) != 0))
4398 char *tmpStr, *errTitle, *errMsg, *dmsg;
4400 tmpStr = GETMESSAGE(32, 2, "File Manager Open Directory Error");
4401 errTitle = XtNewString(tmpStr);
4402 tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view this folder\nbecause it is a restricted folder.");
4403 errMsg = XtNewString(tmpStr);
4404 dmsg = XtMalloc(strlen(errMsg)+strlen(root_dir)+1);
4405 sprintf(dmsg, errMsg, root_dir);
4406 _DtMessage(toplevel, errTitle, dmsg, NULL, HelpRequestCB);
4416 initiating_view = NULL;
4417 special_view = True;
4418 special_treeType = treeType;
4419 special_treeFiles = treeFiles;
4420 special_viewType = viewType;
4421 special_orderType = orderType;
4422 special_directionType = directionType;
4423 special_randomType = randomType;
4426 special_restricted = XtNewString(root_dir);
4429 special_restricted = NULL;
4432 if ((restrictMode) && (!special_restricted))
4436 ptr = strrchr(users_home_dir, '/');
4438 special_restricted = XtNewString(users_home_dir);
4442 special_title = NULL;
4443 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4445 return_data = GetNewView (home_host_name, root_dir, NULL, NULL, msg);
4447 if ((!return_data) && msg)
4449 tt_message_reply(msg);
4450 tttk_message_destroy( msg );
4453 return(return_data);
4458 /************************************************************************
4460 * ViewHomeDirectoryHandler
4461 * This function is called upon the dt home directory message
4462 * being received. The home directory is extracted from the
4463 * users uid and used to open the directory.
4465 ************************************************************************/
4469 ViewHomeDirectoryHandler(
4472 register int i, j, k;
4473 struct passwd * pwInfo;
4476 char full_path[MAX_PATH + 1];
4477 struct stat stat_buf;
4480 /* We have a new view so set initiating_view to null */
4481 initiating_view = NULL;
4483 if ((homeDir = getenv("HOME")) == NULL || strlen (homeDir) == 0)
4485 pwInfo = getpwuid (getuid());
4486 homeDir = pwInfo->pw_dir;
4489 /* Look and see if we have a default environment file present */
4490 tmp_path = _DtCreateDtDirs(display);
4493 if (msg) numArgs = tt_message_args_count(msg);
4494 if (tt_is_err(tt_int_error(numArgs))) numArgs = 0;
4497 special_view = True;
4498 special_treeType = UNSET_VALUE;
4499 special_treeFiles = UNSET_VALUE;
4500 special_viewType = UNSET_VALUE;
4501 special_orderType = UNSET_VALUE;
4502 special_directionType = UNSET_VALUE;
4503 special_randomType = UNSET_VALUE;
4504 special_restricted = NULL;
4505 special_title = NULL;
4506 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4507 for(i = 0; i < numArgs; i++)
4511 vtype = tt_message_arg_type( msg, i );
4512 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4515 val = tt_message_arg_val(msg, i);
4516 if(strcmp(vtype, "-title") == 0)
4518 special_title = XtNewString(val);
4520 else if(strcmp(vtype, "-help_volume") == 0)
4522 special_helpVol = XtNewString(val);
4524 if(strcmp(vtype, "-tree") == 0)
4526 DtfileStringToTree(val, &special_treeType);
4528 else if(strcmp(vtype, "-tree_files") == 0)
4530 DtfileStringToTreeFiles(val, &special_treeFiles);
4532 else if(strcmp(vtype, VIEW_HEADER) == 0)
4534 DtfileStringToView(val, &special_viewType);
4536 else if(strcmp(vtype, "-order") == 0)
4538 DtfileStringToOrder(val, &special_orderType);
4540 else if(strcmp(vtype, "-direction") == 0)
4542 DtfileStringToDirection(val, &special_directionType);
4544 else if(strcmp(vtype, "-grid") == 0)
4546 DtfileStringToGrid(val, &special_randomType);
4548 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4550 special_restricted = XtNewString(val);
4556 else if (restrictMode)
4560 special_view = True;
4561 special_treeType = treeType;
4562 special_treeFiles = treeFiles;
4563 special_viewType = viewType;
4564 special_orderType = orderType;
4565 special_directionType = directionType;
4566 special_randomType = randomType;
4568 ptr = strrchr(users_home_dir, '/');
4570 special_restricted = XtNewString(users_home_dir);
4573 special_title = NULL;
4574 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4577 special_view = False;
4579 if (tmp_path == NULL)
4580 OpenDirectories (homeDir, NULL);
4583 sprintf(full_path, "%s/%s", tmp_path, HOME_SETTINGS_FILENAME);
4586 /* Stat the file and make sure its there */
4589 if (stat (full_path, &stat_buf) == 0 && numArgs < 1)
4591 restoreType = HOME_RESTORE;
4592 RestoreSession(full_path, HOME_RESTORE, NULL);
4593 restoreType = NORMAL_RESTORE;
4599 ptr = strrchr(users_home_dir, '/');
4601 strcpy(full_path, users_home_dir);
4603 OpenDirectories (full_path, NULL);
4606 else if (numArgs < 1 && stat (full_path, &stat_buf) == 0)
4608 restoreType = HOME_RESTORE;
4609 RestoreSession(full_path, HOME_RESTORE, NULL);
4610 restoreType = NORMAL_RESTORE;
4616 ptr = strrchr(users_home_dir, '/');
4618 if( ptr != users_home_dir )
4621 strcpy(full_path, users_home_dir);
4624 OpenDirectories (full_path, NULL);
4630 tt_message_reply(msg);
4631 tttk_message_destroy(msg);
4635 /************************************************************************
4637 * ViewToolsDirectroyHandler
4638 * This function is called upon the dt tools message
4639 * being received. The names of the tools directories are
4640 * retrieved from libXue, a view is created and the change
4641 * directory dialog for the view is displayed with the
4642 * set of directories contained in the list.
4644 ************************************************************************/
4647 ViewToolsDirectoryHandler(
4651 char * tmp_path = NULL;
4652 char * tool_dir = NULL;
4653 char * msgFile = NULL;
4656 /* We have a new view so set initiating_view to null */
4657 initiating_view = NULL;
4659 /* Look and see if we have a default environment file present */
4660 tmp_path = _DtCreateDtDirs(display);
4662 if (msg) msgFile = tt_message_file(msg);
4663 if (tt_is_err(tt_ptr_error(msgFile))) msgFile = 0;
4665 if (msg) numArgs = tt_message_args_count(msg);
4666 if (tt_is_err(tt_int_error( numArgs ))) numArgs = 0;
4672 char *link_point = NULL;
4673 char *root_toolbox = NULL;
4674 char *user_install_point = NULL;
4676 special_view = True;
4677 special_treeType = treeType;
4678 special_treeFiles = treeFiles;
4679 special_viewType = viewType;
4680 special_orderType = orderType;
4681 special_directionType = directionType;
4682 special_randomType = randomType;
4683 special_restricted = XtNewString(msgFile);
4684 special_title = NULL;
4685 special_helpVol = XtNewString(DTFILE_HELP_NAME);
4686 for(i = 0; i < numArgs; i++)
4690 vtype = tt_message_arg_type( msg, i );
4691 if ((vtype == 0) || (tt_is_err( tt_ptr_error( vtype )))) {
4694 val = tt_message_arg_val( msg, i );
4695 if(strcmp(vtype, "-title") == 0)
4697 special_title = XtNewString(val);
4699 else if(strcmp(vtype, "-help_volume") == 0)
4701 special_helpVol = XtNewString(val);
4703 else if(strcmp(vtype, "-root") == 0)
4705 root_toolbox = XtNewString(val);
4707 else if(strcmp(vtype, "-common_link_point") == 0)
4709 link_point = XtNewString(val);
4711 else if(strcmp(vtype, "-user_install_point") == 0)
4713 user_install_point = XtNewString(val);
4715 if(strcmp(vtype, "-tree") == 0)
4717 DtfileStringToTree(val, &special_treeType);
4719 else if(strcmp(vtype, "-tree_files") == 0)
4721 DtfileStringToTreeFiles(val, &special_treeFiles);
4723 else if(strcmp(vtype, VIEW_HEADER) == 0)
4725 DtfileStringToView(val, &special_viewType);
4727 else if(strcmp(vtype, "-order") == 0)
4729 DtfileStringToOrder(val, &special_orderType);
4731 else if(strcmp(vtype, "-direction") == 0)
4733 DtfileStringToDirection(val, &special_directionType);
4735 else if(strcmp(vtype, "-grid") == 0)
4737 DtfileStringToGrid(val, &special_randomType);
4739 else if(strcmp(vtype, RESTRICTED_HEADER) == 0)
4746 /* Due to the use of tooltalk messaging, app manager objects
4747 that are dragged either to the desktop or to the front
4748 panel are identified by their fully resolved names (ie.
4749 /usr/dt/appconfig/appmanager/$LANG/.... as opposed to
4750 /var/dt/appconfig/appmanager/$DTUSERSESSION/....). In order
4751 for the File Manager to treat these objects as links existing
4752 in the /var/.... directory, we use the following ugly code:
4754 1. Search the incoming path for $LANG (if you can't find
4755 $LANG, try C since this is the default).
4756 2. Concatenate the path following $LANG to the path for the
4757 root toolbox (this comes in with the tooltalk message
4758 so that we don't have to hardcode it).
4759 3. Call OpenDirectories with the new path that you have
4760 created and with the root toolbox path as the restricted
4763 This problem is further complicated by:
4764 1. Users traversing into APPGROUPs.
4765 2. Users opening the parent folders for workspace APPGROUPs.
4767 For situation 1, File Manager kicks the user into the App Manager
4768 if he/she traverses into an APPGROUP. BUT we don't want to
4769 make modifications to the path as we do above.
4770 So, if there is nothing following $LANG or if we can't find
4772 (ie. /var/dt/appconfig/appmanager/$DTUSERSESSION), call
4773 OpenDirectories with no parameter changes.
4775 For situation 2, File Manager is unable to distinguish between
4776 workspace objects dragged from /usr/.... or /var/...., so
4777 the parent folder for all workspace APPGROUPS is considered to
4778 be in the /var path. In addition to the OpenAppGroup action,
4779 there is an OpenParentAppGroup action which also triggers
4780 ViewToolsDirectoryHandler but sends in an additional
4781 parameter (user_install_point).
4782 If we know that this msg was generated by the OpenParentAppGroup
4784 AND nothing follows $LANG.
4785 Modify the parameters as above.
4786 OR we can't find $LANG but we can find the user_install_point
4787 (user's personal appgroup path).
4788 Concatenate the path following .dt/appmanager to the path for the
4789 root toolbox. Call OpenDirectories with the new path and the
4790 root toolbox as the restricted directory.
4798 if ((user_install_point) &&
4799 (ptr = strstr(msgFile, user_install_point)))
4801 ptr += strlen(user_install_point);
4802 tool_dir = XtMalloc(strlen(root_toolbox) + strlen(ptr) + 1);
4803 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4804 XtFree(special_restricted);
4805 special_restricted = XtNewString(root_toolbox);
4809 ptr = strstr(msgFile, link_point);
4814 link_point = XtNewString("C");
4815 ptr = strstr(msgFile, link_point);
4820 ptr += strlen(link_point);
4821 if (strcmp(ptr, "") != 0)
4823 tool_dir = XtMalloc(strlen(root_toolbox) +
4825 sprintf(tool_dir, "%s%s", root_toolbox, ptr);
4826 XtFree(special_restricted);
4827 special_restricted = XtNewString(root_toolbox);
4829 else if (user_install_point)
4831 tool_dir = XtNewString(root_toolbox);
4832 XtFree(special_restricted);
4833 special_restricted = XtNewString(root_toolbox);
4840 XtFree(root_toolbox);
4841 XtFree(user_install_point);
4843 else if (restrictMode)
4847 special_view = True;
4848 ptr = strrchr(users_home_dir, '/');
4850 special_restricted = XtNewString(users_home_dir);
4854 special_view = False;
4857 if (tmp_path == NULL)
4860 OpenDirectories (tool_dir, special_restricted);
4861 else if (msgFile != NULL)
4862 OpenDirectories (msgFile, special_restricted);
4866 char full_path[MAX_PATH + 1];
4867 struct stat stat_buf;
4869 sprintf(full_path, "%s/%s", tmp_path, TOOL_SETTINGS_FILENAME);
4872 /* Stat the file and make sure its there */
4873 if (stat (full_path, &stat_buf) == 0 && numArgs > 0)
4875 DialogData * dialog_data;
4876 FileMgrData * file_mgr_data;
4878 restoreType = TOOL_RESTORE;
4880 RestoreSession(full_path, TOOL_RESTORE, tool_dir);
4882 RestoreSession(full_path, TOOL_RESTORE, msgFile);
4883 dialog_data = (DialogData *)view_set[view_count - 1]->dialog_data;
4884 file_mgr_data = (FileMgrData *) dialog_data->data;
4885 application_args.tool_width = file_mgr_data->width;
4886 application_args.tool_height = file_mgr_data->height;
4887 restoreType = NORMAL_RESTORE;
4892 OpenDirectories (tool_dir, special_restricted);
4893 else if (msgFile != NULL)
4894 OpenDirectories (msgFile, special_restricted);
4903 tt_message_reply( msg );
4904 tttk_message_destroy( msg );
4912 /************************************************************************
4915 * This function is called upon the DtSTOP message.
4917 ************************************************************************/
4922 XtPointer clientData,
4923 String * messageFields,
4926 tt_message_reply( msg );
4927 tttk_message_destroy( msg );
4928 FinalizeToolTalkSession( );
4934 * This is the message handling function responsible for reloading
4935 * the filetype and action databases, and then updating our collection
4936 * of action menu items, and updating all open views.
4940 ReloadDatabases(void)
4943 DialogData * dialog_data;
4944 FileMgrData * file_mgr_data;
4945 FileMgrRec * file_mgr_rec;
4946 FileViewData *file_view_data;
4947 DesktopRec *desktopWindow;
4951 XmeFlushIconFileCache ( NULL );
4953 /* Update each directory_set view, both mapped and not */
4954 UpdateDirectorySet();
4956 /* Force action menus to update the next time they're posted */
4957 XtFree(fileMgrPopup.action_pane_file_type);
4958 fileMgrPopup.action_pane_file_type = NULL;
4959 XtFree(desktop_data->popupMenu->action_pane_file_type);
4960 desktop_data->popupMenu->action_pane_file_type = NULL;
4962 /* Update each view */
4963 for (i = 0; i < view_count; i++)
4965 dialog_data = (DialogData *)view_set[i]->dialog_data;
4966 file_mgr_data = (FileMgrData *) dialog_data->data;
4967 file_mgr_rec = (FileMgrRec *) file_mgr_data->file_mgr_rec;
4968 XtFree(file_mgr_rec->action_pane_file_type);
4969 file_mgr_rec->action_pane_file_type = NULL;
4970 UpdateFilterAfterDBReread(file_mgr_data->filter_active);
4971 UpdateFilterAfterDBReread(file_mgr_data->filter_edit);
4972 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
4975 /* go through the desktop objects to make sure the icons change
4976 * Do this by setting the logical_type to -l, CheckDesktop will
4977 * then update the logical type and the icon
4979 for(i = 0; i < desktop_data->numIconsUsed; i++)
4981 desktopWindow = desktop_data->desktopWindows[i];
4982 file_view_data = desktopWindow->file_view_data;
4984 file_view_data->file_data->logical_type = NULL;
4991 * Whenever a directory view or drawer view is closed, we need to remove
4992 * any of its text field children, so that they will not magically reappear
4993 * should this view be reused from the cache to view the same directory later.
4998 XtPointer client_data,
4999 DialogData * old_dialog_data,
5000 DialogData * new_dialog_data)
5002 FileMgrRec * file_mgr_rec;
5003 XmManagerWidget file_window;
5007 file_mgr_rec = (FileMgrRec *) _DtGetDialogInstance(old_dialog_data);
5008 file_window = (XmManagerWidget) file_mgr_rec->file_window;
5009 num_children = file_window->composite.num_children;
5011 for (i = 0; i < num_children; i++)
5013 if (XmIsTextField(file_window->composite.children[i]))
5014 XtDestroyWidget(file_window->composite.children[i]);
5017 _DtFreeDialogData (new_dialog_data);
5022 * This function searches the view list, and returns the file_mgr_data
5023 * associated with the passed-in widget.
5031 DialogData * dialog_data;
5032 FileMgrData * file_mgr_data;
5034 for (i = 0; i < view_count; i++)
5036 dialog_data = (DialogData *) view_set[i]->dialog_data;
5037 file_mgr_data = (FileMgrData *) dialog_data->data;
5039 if (w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->file_window ||
5040 w == ((FileMgrRec *)file_mgr_data->file_mgr_rec)->shell)
5041 return(file_mgr_data);
5049 CheckForOpenDirectory(
5050 FileViewData *order_list,
5051 DirectorySet *directory_set,
5052 FileMgrData *file_mgr_data,
5053 char * logical_type)
5057 char *file_type_name, *new_file_type_name;
5058 char directory_name[MAX_PATH];
5059 char * real_dir_name;
5060 FileMgrRec *file_mgr_rec;
5062 PixmapData *pixmapData = NULL;
5064 if (file_mgr_data->view == BY_NAME_AND_ICON)
5069 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5071 if (strcmp (directory_set->name, "/") != 0)
5072 sprintf( directory_name, "%s/%s", directory_set->name, order_list->file_data->file_name);
5074 sprintf( directory_name, "%s%s", directory_set->name, order_list->file_data->file_name );
5076 (void) DtEliminateDots (directory_name);
5078 real_dir_name = XtNewString(directory_name);
5080 for(i = 0; i < view_count; i++)
5082 if(strcmp(real_dir_name, view_set[i]->directory_name) == 0)
5084 file_type_name = order_list->file_data->logical_type;
5085 new_file_type_name = (char *)XtMalloc(strlen(file_type_name)
5086 + strlen(ICON_OPEN_PREFIX) + 1);
5087 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5088 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5091 file_mgr_rec->file_window,
5093 XtFree(new_file_type_name);
5097 XtFree(real_dir_name);
5099 if(pixmapData == NULL || pixmapData->iconFileName == NULL)
5101 if( pixmapData != NULL )
5103 DtDtsFreeAttributeValue(pixmapData->hostPrefix);
5104 DtDtsFreeAttributeValue(pixmapData->instanceIconName);
5105 DtDtsFreeAttributeValue(pixmapData->iconName);
5106 XtFree((char *)pixmapData);
5109 pixmapData = _DtRetrievePixmapData(logical_type,
5112 file_mgr_rec->file_window,
5121 * The is the menu callback function for cleaning up a view.
5127 XtPointer client_data,
5128 XtPointer call_data)
5132 FileMgrRec * file_mgr_rec;
5133 DialogData * dialog_data;
5134 FileMgrData * file_mgr_data;
5136 XmManagerWidget file_window;
5138 FileViewData * file_view_data;
5139 XRectangle textExtent;
5142 if ((int)(XtArgVal) client_data == FM_POPUP)
5145 mbar = XmGetPostedFromWidget(XtParent(w));
5148 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
5149 XtGetValues(mbar, args, 1);
5151 /* Ignore accelerators when we're insensitive */
5152 if ((file_mgr_rec->menuStates & CLEAN_UP) == 0)
5155 /* Ignore accelerators received after we're unposted */
5156 if ((dialog_data = _DtGetInstanceData((XtPointer)file_mgr_rec)) == NULL)
5159 file_mgr_data = (FileMgrData *)dialog_data->data;
5161 /* Reset the grid size, so it will be recalculated later. */
5162 file_mgr_data->grid_height = 0;
5163 file_mgr_data->grid_width = 0;
5165 if(file_mgr_data->object_positions)
5166 FreePositionInfo(file_mgr_data);
5168 /* CLEAN_UP_OP is not really a menu state.
5169 It's a flag to let GetFileData in FileMgr.c (call when the directory
5170 is being reread) not to reload icon positions from the .!dt<userid> file.
5172 file_mgr_rec->menuStates |= CLEAN_UP_OP;
5174 /* Re-layout the view */
5175 FileMgrRedisplayFiles(file_mgr_rec, file_mgr_data, False);
5177 if ((file_mgr_data->show_type == SINGLE_DIRECTORY) &&
5178 (file_mgr_data->view != BY_ATTRIBUTES) &&
5179 (file_mgr_data->positionEnabled == RANDOM_ON))
5181 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5186 /* Update the preferences dialog */
5187 ((PreferencesData *)(file_mgr_data->preferences->data))->positionEnabled =
5191 /* Move any text widget, to keep them in sync with their icons */
5192 file_window = (XmManagerWidget)file_mgr_rec->file_window;
5194 for (j = 0; j < file_window->composite.num_children; j++)
5196 if (XmIsTextField(file_window->composite.children[j]) &&
5197 !file_window->composite.children[j]->core.being_destroyed)
5199 XtSetArg(args[0], XmNuserData, &name);
5200 XtGetValues(file_window->composite.children[j], args, 1);
5202 /* Find the associated icon data */
5203 /* @@@ this won't work for tree mode! */
5204 for (i = 0; i < file_mgr_data->directory_set[0]->file_count; i++)
5206 file_view_data = file_mgr_data->directory_set[0]->file_view_data[i];
5207 if (strcmp(name, file_view_data->file_data->file_name) == 0)
5209 _DtIconGetTextExtent_r(file_view_data->widget, &textExtent);
5212 (Dimension)(file_window->composite.children[j]->core.height -
5213 textExtent.height)/(Dimension)2;
5214 XtSetArg (args[0], XmNx, x);
5215 XtSetArg (args[1], XmNy, y);
5216 XtSetValues (file_window->composite.children[j], args, 2);
5223 if ((file_mgr_rec->menuStates & CLEAN_UP_OP))
5224 file_mgr_rec->menuStates &= ~CLEAN_UP_OP;
5227 /*************************************<->*************************************
5229 * DtfileCvtStringToObjPlace (args, numArgs, fromVal, toVal)
5234 * This function converts a string to an desktop placement scheme description.
5239 * args = NULL (don't care)
5241 * numArgs = 0 (don't care)
5243 * fromVal = resource value to convert
5248 * toVal = descriptor to use to return converted value
5250 *************************************<->***********************************/
5253 DtfileCvtStringToObjPlace (
5259 unsigned char *pch = (unsigned char *) (fromVal->addr);
5260 unsigned char *pchNext;
5264 Boolean fPrimarySet = False;
5265 Boolean fSecondarySet = False;
5268 * Icon placement layout values:
5271 #define OBJ_PLACE_BOTTOM_STR (unsigned char *)"bottom"
5272 #define OBJ_PLACE_LEFT_STR (unsigned char *)"left"
5273 #define OBJ_PLACE_RIGHT_STR (unsigned char *)"right"
5274 #define OBJ_PLACE_TOP_STR (unsigned char *)"top"
5278 * Convert the icon placement resource value:
5283 while (*pch && _DtNextToken (pch, &len, &pchNext))
5291 if (_DtStringsAreEquivalent((char *)pch, (char *)OBJ_PLACE_BOTTOM_STR))
5295 cval |= OBJ_PLACE_BOTTOM_PRIMARY;
5298 else if (!fSecondarySet)
5301 (OBJ_PLACE_BOTTOM_PRIMARY | OBJ_PLACE_TOP_PRIMARY)))
5303 cval |= OBJ_PLACE_BOTTOM_SECONDARY;
5304 fSecondarySet = True;
5313 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_LEFT_STR))
5317 cval |= OBJ_PLACE_LEFT_PRIMARY;
5320 else if (!fSecondarySet)
5323 (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY)))
5325 cval |= OBJ_PLACE_LEFT_SECONDARY;
5326 fSecondarySet = True;
5334 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_RIGHT_STR))
5338 cval |= OBJ_PLACE_RIGHT_PRIMARY;
5341 else if (!fSecondarySet)
5344 (OBJ_PLACE_RIGHT_PRIMARY | OBJ_PLACE_LEFT_PRIMARY)))
5346 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5347 fSecondarySet = True;
5355 if (_DtStringsAreEquivalent ((char *)pch, (char *)OBJ_PLACE_TOP_STR))
5359 cval |= OBJ_PLACE_TOP_PRIMARY;
5362 else if (!fSecondarySet)
5365 (OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_BOTTOM_PRIMARY)))
5367 cval |= OBJ_PLACE_TOP_SECONDARY;
5368 fSecondarySet = True;
5381 cval = OBJ_PLACE_TOP_PRIMARY;
5385 if (cval & (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_RIGHT_PRIMARY))
5387 cval |= OBJ_PLACE_TOP_SECONDARY;
5390 cval |= OBJ_PLACE_RIGHT_SECONDARY;
5395 (*toVal).size = sizeof (long);
5396 (*toVal).addr = (XtPointer) &cval;
5398 } /* END OF FUNCTION DtfileCvtStringToObjPlace */
5400 /*************************************<->*************************************
5402 * _DtNextToken (pchIn, pLen, ppchNext)
5412 * pchIn = pointer to start of next token
5417 * pLen = pointer to integer containing number of characters in next token
5418 * ppchNext = address of pointer to following token
5420 * Return = next token or NULL
5427 *************************************<->***********************************/
5429 static unsigned char
5431 unsigned char *pchIn,
5433 unsigned char **ppchNext)
5435 unsigned char *pchR = pchIn;
5439 for (i = 0; ((chlen = mblen ((char *)pchIn, MB_CUR_MAX)) > 0); i++)
5440 /* find end of word: requires singlebyte whitespace terminator */
5442 if ((chlen == 1) && isspace (*pchIn))
5449 /* skip to next word */
5450 while (pchIn && (mblen ((char *)pchIn, MB_CUR_MAX) == 1) && isspace (*pchIn))
5466 } /* END OF FUNCTION _DtNextToken */
5468 /*************************************<->*************************************
5470 * DtfileCvtStringToOpenDir (args, numArgs, fromVal, toVal)
5475 * This function converts a string to an desktop placement scheme description.
5480 * args = NULL (don't care)
5482 * numArgs = 0 (don't care)
5484 * fromVal = resource value to convert
5489 * toVal = descriptor to use to return converted value
5491 *************************************<->***********************************/
5494 DtfileCvtStringToOpenDir (
5500 char * in_str = (char *) (fromVal->addr);
5503 toVal->size = sizeof (int);
5504 toVal->addr = (XtPointer) &i;
5506 if (_DtStringsAreEquivalent (in_str, "current"))
5508 else if (_DtStringsAreEquivalent (in_str, "new"))
5517 XtStringConversionWarning ((char *)fromVal->addr, "OpenDir");
5522 /*************************************<->*************************************
5524 * DtfileCvtStringToDTIcon (args, numArgs, fromVal, toVal)
5529 * This function converts a string to an desktop placement scheme description.
5534 * args = NULL (don't care)
5536 * numArgs = 0 (don't care)
5538 * fromVal = resource value to convert
5543 * toVal = descriptor to use to return converted value
5545 *************************************<->***********************************/
5548 DtfileCvtStringToDTIcon (
5554 char * in_str = (char *) (fromVal->addr);
5557 toVal->size = sizeof (int);
5558 toVal->addr = (XtPointer) &i;
5560 if (_DtStringsAreEquivalent (in_str, "large"))
5562 else if (_DtStringsAreEquivalent (in_str, "small"))
5564 else if (_DtStringsAreEquivalent (in_str, "default"))
5565 i = LARGE; /* for now, eventually want to look at screen width/height*/
5573 XtStringConversionWarning ((char *)fromVal->addr, "DesktopIcon");
5579 DtfileCvtStringToTree (
5585 char * in_str = (char *) (fromVal->addr);
5588 toVal->size = sizeof (int);
5589 toVal->addr = (XtPointer) &i;
5591 DtfileStringToTree(in_str, &i);
5595 DtfileCvtStringToTreeFiles (
5601 char * in_str = (char *) (fromVal->addr);
5604 toVal->size = sizeof (int);
5605 toVal->addr = (XtPointer) &i;
5607 DtfileStringToTreeFiles(in_str, &i);
5611 DtfileCvtStringToView (
5617 char * in_str = (char *) (fromVal->addr);
5620 toVal->size = sizeof (int);
5621 toVal->addr = (XtPointer) &i;
5623 DtfileStringToView(in_str, &i);
5627 DtfileCvtStringToOrder (
5633 char * in_str = (char *) (fromVal->addr);
5636 toVal->size = sizeof (int);
5637 toVal->addr = (XtPointer) &i;
5639 DtfileStringToOrder(in_str, &i);
5643 DtfileCvtStringToDirection (
5649 char * in_str = (char *) (fromVal->addr);
5652 toVal->size = sizeof (int);
5653 toVal->addr = (XtPointer) &i;
5655 DtfileStringToDirection(in_str, &i);
5659 DtfileCvtStringToGrid (
5665 char * in_str = (char *) (fromVal->addr);
5668 toVal->size = sizeof (int);
5669 toVal->addr = (XtPointer) &i;
5671 DtfileStringToGrid(in_str, &i);
5680 FileMgrData *file_mgr_data;
5681 DialogData *dialog_data;
5683 for(i = 0; i < view_count; i++)
5685 if(strcmp(directory, view_set[i]->directory_name) == 0 &&
5686 strcmp(host, view_set[i]->host_name) == 0)
5688 dialog_data = (DialogData *) view_set[i]->dialog_data;
5689 file_mgr_data = (FileMgrData *) dialog_data->data;
5690 return(file_mgr_data);
5697 GetRestrictedDirectory (
5701 FileMgrData *file_mgr_data;
5702 FileMgrRec *file_mgr_rec;
5703 DialogData *dialog_data;
5705 for(i = 0; i < view_count; i++)
5707 dialog_data = (DialogData *) view_set[i]->dialog_data;
5708 file_mgr_data = (FileMgrData *) dialog_data->data;
5709 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
5710 if(file_mgr_rec->current_directory_text == widget &&
5711 file_mgr_data->fast_cd_enabled)
5713 return(file_mgr_data->restricted_directory);
5716 return((char *)NULL);
5724 if (_DtStringsAreEquivalent (str, "on"))
5725 *type = MULTIPLE_DIRECTORY;
5726 else if (_DtStringsAreEquivalent (str, "off"))
5727 *type = SINGLE_DIRECTORY;
5729 *type = UNSET_VALUE;
5733 DtfileStringToTreeFiles(
5737 if (_DtStringsAreEquivalent (str, "never"))
5738 *type = TREE_FILES_NEVER;
5739 else if (_DtStringsAreEquivalent (str, "choose"))
5740 *type = TREE_FILES_CHOOSE;
5741 else if (_DtStringsAreEquivalent (str, "always"))
5742 *type = TREE_FILES_ALWAYS;
5744 *type = UNSET_VALUE;
5752 if (_DtStringsAreEquivalent (str, "no_icon") ||
5753 _DtStringsAreEquivalent (str, "no_icons"))
5755 else if (_DtStringsAreEquivalent (str, "large_icon") ||
5756 _DtStringsAreEquivalent (str, "large_icons"))
5757 *type = BY_NAME_AND_ICON;
5758 else if (_DtStringsAreEquivalent (str, "small_icon") ||
5759 _DtStringsAreEquivalent (str, "small_icons"))
5760 *type = BY_NAME_AND_SMALL_ICON;
5761 else if (_DtStringsAreEquivalent (str, "attributes"))
5762 *type = BY_ATTRIBUTES;
5764 *type = UNSET_VALUE;
5768 DtfileStringToOrder(
5772 if (_DtStringsAreEquivalent (str, "file_type"))
5773 *type = ORDER_BY_FILE_TYPE;
5774 else if (_DtStringsAreEquivalent (str, "alphabetical"))
5775 *type = ORDER_BY_ALPHABETICAL;
5776 else if (_DtStringsAreEquivalent (str, "date"))
5777 *type = ORDER_BY_DATE;
5778 else if (_DtStringsAreEquivalent (str, "size"))
5779 *type = ORDER_BY_SIZE;
5781 *type = UNSET_VALUE;
5786 DtfileStringToDirection(
5790 if (_DtStringsAreEquivalent (str, "ascending"))
5791 *type = DIRECTION_ASCENDING;
5792 else if (_DtStringsAreEquivalent (str, "descending"))
5793 *type = DIRECTION_DESCENDING;
5795 *type = UNSET_VALUE;
5803 if (_DtStringsAreEquivalent (str, "on"))
5805 else if (_DtStringsAreEquivalent (str, "off"))
5808 *type = UNSET_VALUE;
5812 SetupSendRequestArgs(
5813 ApplicationArgs application_args,
5817 if(application_args.title != NULL)
5819 tt_message_arg_add( msg, TT_IN, "-title", application_args.title );
5821 if(application_args.restricted != NULL)
5823 tt_message_arg_add( msg, TT_IN, RESTRICTED_HEADER, 0 );
5825 vtype = VIEW_HEADER;
5826 switch( application_args.view )
5829 tt_message_arg_add( msg, TT_IN, vtype, "no_icon" );
5831 case BY_NAME_AND_ICON:
5832 tt_message_arg_add( msg, TT_IN, vtype, "large_icon" );
5834 case BY_NAME_AND_SMALL_ICON:
5835 tt_message_arg_add( msg, TT_IN, vtype, "small_icon" );
5838 tt_message_arg_add( msg, TT_IN, vtype, "attributes" );
5841 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5846 switch( application_args.order )
5848 case ORDER_BY_FILE_TYPE:
5849 tt_message_arg_add( msg, TT_IN, vtype, "file_type" );
5851 case ORDER_BY_ALPHABETICAL:
5852 tt_message_arg_add( msg, TT_IN, vtype, "alphabetical" );
5855 tt_message_arg_add( msg, TT_IN, vtype, "date" );
5858 tt_message_arg_add( msg, TT_IN, vtype, "size" );
5861 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5865 vtype = "-direction";
5866 switch( application_args.direction )
5868 case DIRECTION_ASCENDING:
5869 tt_message_arg_add( msg, TT_IN, vtype, "ascending" );
5871 case DIRECTION_DESCENDING:
5872 tt_message_arg_add( msg, TT_IN, vtype, "descending" );
5875 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5880 switch( application_args.grid )
5883 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5886 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5889 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5893 switch( application_args.tree_view )
5895 case MULTIPLE_DIRECTORY:
5896 tt_message_arg_add( msg, TT_IN, vtype, "on" );
5898 case SINGLE_DIRECTORY:
5899 tt_message_arg_add( msg, TT_IN, vtype, "off" );
5902 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5906 vtype = "-tree_files";
5907 switch( application_args.tree_files )
5909 case TREE_FILES_NEVER:
5910 tt_message_arg_add( msg, TT_IN, vtype, "never" );
5912 case TREE_FILES_CHOOSE:
5913 tt_message_arg_add( msg, TT_IN, vtype, "choose" );
5915 case TREE_FILES_ALWAYS:
5916 tt_message_arg_add( msg, TT_IN, vtype, "always" );
5919 tt_message_arg_add( msg, TT_IN, vtype, "none" );
5923 if(application_args.help_volume != NULL)
5925 tt_message_arg_add( msg, TT_IN, "-help_volume",
5926 application_args.help_volume );
5931 * This routine is used by ForceMyIconOpen to get the "Open" filetype and
5932 * find out what the new icon is. It then places that icon in the
5933 * correct icon gadget.
5936 BuildAndShowIconName(
5937 char *file_type_name,
5939 unsigned char show_type,
5942 char *new_file_type_name;
5945 PixmapData *pixmapData;
5947 new_file_type_name = (char *)XtMalloc(strlen(file_type_name) +
5948 strlen(ICON_OPEN_PREFIX) + 1);
5949 sprintf(new_file_type_name, "%s%s", ICON_OPEN_PREFIX, file_type_name);
5951 if (view == BY_NAME_AND_ICON && show_type != MULTIPLE_DIRECTORY)
5952 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5958 pixmapData = _DtRetrievePixmapData(new_file_type_name,
5964 if(pixmapData && pixmapData->iconFileName)
5966 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
5967 XtSetValues(widget, args, 1);
5972 XtSetArg (args[0], XmNimageName, NULL);
5973 XtSetValues(widget, args, 1);
5977 _DtCheckAndFreePixmapData(new_file_type_name,
5979 (DtIconGadget) widget,
5982 XtFree(new_file_type_name);
5987 * Given a directory name, this function will see if a view of the parent
5988 * directory is open; if so, then it will update the icon representing
5989 * this icon, in the parent view, so that it is drawn as 'closed'. This
5990 * function must only be called if openDirType == NEW.
5996 char * directory_name)
6002 FileViewData * file_view_data = NULL;
6003 DialogData *dialog_data;
6004 FileMgrData *file_mgr_data;
6005 DesktopRec *desktopWindow;
6008 PixmapData *pixmapData;
6010 /* find the parent directory of the one just removed */
6011 parent = _DtPName(directory_name);
6012 fname = DName(directory_name);
6014 /* first check to see if any File Manager views have this directory */
6015 for (i = 0; i < view_count; i++)
6017 dialog_data = (DialogData *) view_set[i]->dialog_data;
6018 file_mgr_data = (FileMgrData *) dialog_data->data;
6020 /* loop through until we find the file_view_data structure for
6021 * the directory to force open */
6023 for(j = 0; j < file_mgr_data->directory_count; j++)
6025 if (strcmp(parent, file_mgr_data->directory_set[j]->name) == 0)
6027 for (k = 0; k < file_mgr_data->directory_set[j]->file_count; k++)
6030 file_mgr_data->directory_set[j]->file_view_data[k];
6031 if (strcmp(file_view_data->file_data->file_name, fname) == 0)
6041 if( (file_view_data) && (file_mgr_data->view != BY_NAME) )
6043 if (file_mgr_data->view == BY_NAME_AND_ICON &&
6044 file_mgr_data->show_type != MULTIPLE_DIRECTORY)
6045 pixmapData = _DtRetrievePixmapData(
6046 file_view_data->file_data->logical_type,
6049 file_view_data->widget,
6052 pixmapData = _DtRetrievePixmapData(
6053 file_view_data->file_data->logical_type,
6056 file_view_data->widget,
6060 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6062 XtSetArg (args[0], XmNimageName, NULL);
6063 XtSetValues (file_view_data->widget, args, 1);
6065 _DtCheckAndFreePixmapData(file_view_data->file_data->logical_type,
6066 file_view_data->widget,
6067 (DtIconGadget) file_view_data->widget,
6071 /* now check to see if any desktop objects are this directory */
6072 for(j = 0; j < desktop_data->numIconsUsed; j++)
6076 desktopWindow = desktop_data->desktopWindows[j];
6077 file_view_data = desktopWindow->file_view_data;
6079 sprintf(buf, "%s/%s", desktopWindow->dir_linked_to,
6080 desktopWindow->file_name);
6081 DtEliminateDots (buf);
6083 if( (strcmp(buf, directory_name) == 0) &&
6084 (strcmp(desktopWindow->host, host_name) == 0) )
6086 pixmapData = _DtRetrievePixmapData(
6087 file_view_data->file_data->logical_type,
6090 desktopWindow->shell,
6094 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
6096 XtSetArg (args[0], XmNimageName, NULL);
6097 XtSetValues (desktopWindow->iconGadget, args, 1);
6099 _DtCheckAndFreePixmapData(
6100 desktopWindow->file_view_data->file_data->logical_type,
6101 desktopWindow->shell,
6102 (DtIconGadget) desktopWindow->iconGadget,
6109 /*************************************************************************
6111 * MarqueeSelect - this is the callback which gets called when there is
6112 * a marquee event happening on the root window.
6114 ************************************************************************/
6123 XtPointer client_data)
6128 Screen *currentScreen;
6130 char *workspace_name=NULL;
6136 case DT_WSM_MARQUEE_SELECTION_TYPE_BEGIN:
6137 display = XtDisplay(desktop_data->desktopWindows[0]->shell);
6138 screen = XDefaultScreen(display);
6139 currentScreen = XScreenOfDisplay(display, screen);
6140 rootWindow = RootWindowOfScreen(currentScreen);
6142 if(DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent)
6145 workspace_name = XGetAtomName (display, pCurrent);
6146 CleanUpWSName(workspace_name);
6150 XtNewString(desktop_data->workspaceData[0]->name);
6152 for(i = 0; i < desktop_data->numWorkspaces; i++)
6154 if(strcmp(workspace_name,
6155 desktop_data->workspaceData[i]->name) == 0)
6157 DeselectAllDTFiles(desktop_data->workspaceData[i]);
6161 XtFree(workspace_name);
6164 case DT_WSM_MARQUEE_SELECTION_TYPE_END:
6165 CheckDesktopMarquee(x, y, width, height);
6168 case DT_WSM_MARQUEE_SELECTION_TYPE_CANCEL:
6171 case DT_WSM_MARQUEE_SELECTION_TYPE_CONTINUE:
6172 CheckDesktopMarquee(x, y, width, height);
6182 * We must wait for the message response, before exiting
6186 WaitForResponseAndExit( void )
6194 XtPointer clientData,
6199 FinalizeToolTalkSession( );
6205 * Puts up an Error dialog with Cancel and Help unmapped in the
6206 * center of the screen. The last argument is the OK callback
6210 post_dialog(Widget parent, char *title, char *msg, void (*DtErrExitCB)())
6212 Widget dialog, dialogShell;
6213 XmString message_text, ok;
6215 Dimension dialogWd, dialogHt;
6218 ok = XmStringCreateLocalized ((char*)_DtOkString);
6219 message_text = XmStringCreateLocalized (msg);
6221 XtSetArg(args[n], XmNautoUnmanage, False); n++;
6222 XtSetArg(args[n], XmNokLabelString, ok); n++;
6223 XtSetArg(args[n], XmNtitle, title); n++;
6224 XtSetArg(args[n], XmNmessageString, message_text); n++;
6225 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
6226 XtSetArg (args[n], XmNdefaultPosition, False); n++;
6227 XtSetArg(args[n], XmNuseAsyncGeometry, True); n++;
6229 dialog = XmCreateErrorDialog (parent, title, args, n);
6230 XtAddCallback (dialog, XmNokCallback, DtErrExitCB, NULL);
6231 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON));
6232 XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
6234 /* Disable the frame menu from dialog since we don't want the user
6235 to be able to close dialogs with the frame menu */
6237 dialogShell = XtParent(dialog);
6238 XtSetArg(args[0], XmNmappedWhenManaged, False);
6239 XtSetArg(args[1], XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_MENU);
6240 XtSetValues(dialogShell, args, 2);
6241 XtManageChild (dialog);
6242 XtRealizeWidget (dialogShell);
6244 /* Center the dialog */
6246 XtSetArg(args[0], XmNwidth, &dialogWd);
6247 XtSetArg(args[1], XmNheight, &dialogHt);
6248 XtGetValues(dialog, args, 2);
6249 XtSetArg (args[0], XmNx,
6250 (WidthOfScreen(XtScreen(dialog)) - dialogWd) / 2);
6251 XtSetArg (args[1], XmNy,
6252 (HeightOfScreen(XtScreen(dialog)) - dialogHt) / 2);
6253 XtSetArg (args[2], XmNmappedWhenManaged, True);
6254 XtSetValues (dialog, args, 3);
6256 XtSetArg(args[0], XmNmappedWhenManaged, True);
6257 XtSetValues(dialogShell, args, 1);
6259 XtManageChild (dialog);
6260 XmStringFree(message_text);
6266 * This is the Callback when an error occurs while trying to create
6267 * the .dt folder or sub-folders. Application exits.
6271 DtErrExitCB (Widget dialog, XtPointer client_data, XtPointer call_data)
6273 XtPopdown (XtParent (dialog));
6274 FinalizeToolTalkSession();
6278 #if defined(CSRG_BASED)
6280 sigchld_handler(int signo) /* Do not use the arg signo at the moment */
6286 On DUX, the process remains in the ZOMBIE
6287 state untill parent invokes wait or waitpid.
6290 pid = waitpid(-1, &stat_loc, WNOHANG);
6291 /* Child exit handling code follows, if any */
6293 #endif /* CSRG_BASED */