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: Desktop.c /main/13 1999/09/10 09:42:26 mgreess $ */
24 /************************************<+>*************************************
25 ****************************************************************************
28 * COMPONENT_NAME: Desktop File Manager (dtfile)
30 * DESCRIPTION: Contains functions related to Desktop operations.
32 * FUNCTIONS: BuildDesktopLinks
34 * CalculateRootCoordinates
42 * DesktopObjectChanged
43 * DesktopObjectRemoved
52 * InitializeDesktopGrid
53 * InitializeDesktopWindows
54 * InitializeNewWorkspaces
59 * ProcessBufferDropOnFolderDT
61 * ProcessDropOnDesktopObject
62 * ProcessMoveCopyLinkDT
69 * RemoveMovedObjectFromDT
79 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
80 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
81 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
82 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
84 ****************************************************************************
85 ************************************<+>*************************************/
86 #include <sys/types.h>
94 #include <Xm/MwmUtil.h>
95 #include <X11/ShellP.h>
96 #include <X11/Shell.h>
97 #include <X11/Xutil.h>
98 #include <X11/Xatom.h>
101 #include <X11/extensions/shape.h>
104 #include <Xm/DrawingA.h>
105 #include <Xm/Frame.h>
106 #include <Xm/PushBG.h>
107 #include <Xm/RowColumn.h>
108 #include <Xm/CascadeBG.h>
109 #include <Xm/LabelG.h>
110 #include <Xm/SeparatoG.h>
111 #include <Xm/VirtKeys.h>
114 #include <Dt/IconP.h>
115 #include <Dt/IconFile.h>
116 #include <Dt/Connect.h>
120 #include <Dt/UserMsg.h>
121 #include <Dt/DtNlUtils.h>
123 #include <Xm/DragIcon.h>
124 #include <Xm/DragC.h>
126 #include <Dt/HourGlass.h>
128 #include <Dt/ActionP.h>
129 #include <Dt/Action.h>
130 #include <Dt/Session.h>
131 #include <Dt/SharedProcs.h>
136 #include "SharedProcs.h"
142 #include "SharedMsgs.h"
144 extern char *dt_path;
146 /* Don't use '#define'; leads to multiple copies of the string */
147 static char DESKTOP_SAVE_NAME[] = ".!dtdesktop";
149 DesktopData *desktop_data;
150 Widget widget_dragged;
151 DesktopRec *sacredDesktop;
152 unsigned char *desktop_grid;
153 unsigned short int desktop_grid_size;
156 static void ProcessNewViewDT ( DesktopRec *desktopWindow ) ;
157 static void ProcessMoveCopyLinkDT ( char *command,
158 DesktopRec *desktopWindow,
159 DtDndDropCallbackStruct *drop_parameters ) ;
160 static void ProcessBufferDropOnFolderDT ( char *command,
161 DesktopRec *desktopWindow,
162 DtDndDropCallbackStruct *drop_parameters ) ;
163 static FileViewData * BuildNewOrderlist(
164 FileViewData *order_list,
169 Boolean is_registered,
171 static void FreeDesktopWindow ( DesktopRec *desktopWindow ) ;
172 static void FreeCachedIcons ( int iconsToBeFreed ) ;
173 static void CreatePopupMenu ( Widget drawA ) ;
174 static void popupMenu (
176 XtPointer client_data,
177 XtPointer call_data) ;
178 static void OpenFolder (
180 XtPointer client_data,
181 XtPointer call_data) ;
182 static void renameDT (
184 XtPointer client_data,
185 XtPointer call_data) ;
186 static void BuildDesktopLinks ( Display *display ) ;
187 static int InitializeNewWorkspaces (
189 char *workspaceName) ;
190 static void TimerEvent(
193 static void DropOnDesktopObject (
195 XtPointer client_data,
196 XtPointer call_data) ;
197 static void DrawAInput (
199 XtPointer client_data,
201 Boolean *contDispatch) ;
202 static void CalculateRootCoordinates (
209 static int GetWorkspaceNum(
210 char *workspace_name,
212 int *workspace_index);
213 static void FreeUpOldWorkspace(
214 int oldNumWorkspaces,
220 #define NULL_STRING "NULL"
223 /************************************************************************
225 * InitializeDesktopWindows
227 ************************************************************************/
230 InitializeDesktopWindows(
239 Widget pu_shell, frame, drawA;
240 XtTranslations trans_table;
242 if(desktop_data == NULL)
244 desktop_data = (DesktopDataPtr)XtMalloc(sizeof(DesktopData));
245 desktop_data->desktopWindows =
246 (DesktopRec ** )XtMalloc(sizeof(DesktopRec *) * number_cache);
248 desktop_data->popupMenu = (PopupRec *)XtMalloc(sizeof(PopupRec));
249 desktop_data->popupMenu->popup = NULL;
250 desktop_data->popupMenu->action_pane_file_type = NULL;
251 desktop_data->numCachedIcons = 0;
252 desktop_data->popup_name_count = 0;
253 desktop_data->numIconsUsed = 0;
254 new_size = number_cache;
257 * Build desktop directories and get the number of workspaces for
260 BuildDesktopLinks(display);
264 new_size = number_cache + desktop_data->numCachedIcons +
265 desktop_data->numIconsUsed;
266 desktop_data->desktopWindows =
267 (DesktopRec ** )XtRealloc((char *)desktop_data->desktopWindows,
268 sizeof(DesktopRec *) * new_size);
271 for(i = desktop_data->numCachedIcons + desktop_data->numIconsUsed;
274 desktop = (DesktopRec *)XtMalloc(sizeof(DesktopRec));
275 popup_name = (char *)XtMalloc(strlen("popup_name") + 11);
276 sprintf( popup_name, "popup_name%d", desktop_data->popup_name_count);
279 XtSetArg (args[n], XmNmwmFunctions, NULL); n++;
280 XtSetArg (args[n], XmNmwmDecorations, NULL); n++;
281 XtSetArg (args[n], XmNallowShellResize, True); n++;
282 XtSetArg (args[n], XmNvisual, CopyFromParent); n++;
283 desktop->shell = pu_shell =
284 XtCreatePopupShell(popup_name,
285 topLevelShellWidgetClass, toplevel, args, n);
286 /* We need to save the background color for the popup shell. When
287 * we activate a text edit widget for the label of a workspace object,
288 * the shell's background_pixel color will change. If we don't save
289 * the old background color and reuse the icon gadget, the background
292 XtSetArg(args[0], XmNbackground, &desktop->background);
293 XtGetValues(desktop->shell, args, 1);
299 XtSetArg (args[n], XmNmarginWidth, 1); n++;
300 XtSetArg (args[n], XmNmarginHeight, 1); n++;
301 XtSetArg (args[n], XmNshadowThickness, 2); n++;
302 XtSetArg (args[n], XmNshadowType, XmSHADOW_OUT); n++;
303 XtSetArg (args[n], XmNautoUnmanage, False); n++;
304 XtSetArg (args[n], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP); n++;
305 desktop->frame = frame = XmCreateFrame(pu_shell, "frame", args, n);
306 XtManageChild (frame);
309 XtSetArg (args[n], XmNmarginWidth, 1); n++;
310 XtSetArg (args[n], XmNmarginHeight, 1); n++;
311 XtSetArg (args[n], XmNshadowThickness, 0); n++;
312 XtSetArg (args[n], XmNautoUnmanage, False); n++;
313 XtSetArg (args[n], XmNbackgroundPixmap, XmUNSPECIFIED_PIXMAP); n++;
314 desktop->drawA = drawA = XmCreateDrawingArea(frame, "drawA", args, n);
315 XtManageChild (drawA);
318 if(desktop_data->popupMenu->popup == NULL)
320 CreatePopupMenu(drawA);
321 sacredDesktop = desktop;
324 XmAddToPostFromList(desktop_data->popupMenu->popup, drawA);
326 /* set up translations in main edit widget */
327 trans_table = XtParseTranslationTable(translations_da);
329 /* set up translations in main edit widget */
330 XtOverrideTranslations(drawA, trans_table);
332 /* Event handler for posting popup menu */
333 XtAddEventHandler(drawA, ButtonPressMask, False,
334 DrawAInput, (XtPointer)desktop);
336 /* Callback for handling selection */
337 XtAddCallback(drawA, XmNinputCallback,
338 FileWindowInputCallback, (XtPointer)desktop);
340 /* Event handler for detecting drag threshold surpassed */
341 XtAddEventHandler(drawA, Button1MotionMask|Button2MotionMask,
342 False, (XtEventHandler)FileIconMotion, NULL);
345 XtSetArg (args[n], XmNfillMode, XmFILL_TRANSPARENT); n++;
346 XtSetArg (args[n], XmNarmColor, white_pixel); n++;
348 XtSetArg (args[n], XmNshadowThickness, 2); n++;
350 XtSetArg (args[n], XmNshadowThickness, 0); n++;
352 XtSetArg (args[n], XmNfontList, user_font); n++;
353 XtSetArg (args[n], XmNspacing, 3); n++;
354 if( keybdFocusPolicy == XmEXPLICIT)
356 XtSetArg (args[n], XmNtraversalOn, True); n++;
361 XtSetArg (args[n], XmNtraversalOn, False); n++;
362 XtSetArg (args[n], XmNhighlightThickness, 0); n++;
364 XtSetArg (args[n], XmNborderType, DtNON_RECTANGLE); n++;
365 XtSetArg (args[n], "drawShadow", True); n++;
366 if(desktopIconType == LARGE)
367 XtSetArg (args[n], XmNpixmapPosition, XmPIXMAP_TOP);
369 XtSetArg (args[n], XmNpixmapPosition, XmPIXMAP_LEFT);
371 desktop->iconGadget = _DtCreateIcon (drawA, "desktop_icon", args, n);
372 XtManageChild (desktop->iconGadget);
373 XtAddCallback (desktop->iconGadget, XmNhelpCallback,
374 (XtCallbackProc)DTHelpRequestCB, NULL);
376 desktop->view = UNSET_VALUE;
377 desktop->order = UNSET_VALUE;
378 desktop->direction = UNSET_VALUE;
379 desktop->positionEnabled = UNSET_VALUE;
380 desktop->restricted_directory = NULL;
381 desktop->title= NULL;
382 desktop->helpVol = NULL;
383 desktop->toolbox = False;
384 desktop->registered = False;
385 desktop->text = NULL;
386 desktop->root_x = -1;
387 desktop->root_y = -1;
388 desktop->workspace_name = NULL;
389 desktop->workspace_num = 0;
390 desktop->file_name = NULL;
392 desktop_data->numCachedIcons++;
393 desktop_data->popup_name_count++;
395 desktop_data->desktopWindows[i] = desktop;
403 DesktopRec *desktopWindow)
405 XSync(XtDisplay(desktopWindow->shell), 0);
407 SetHotRects(desktopWindow->file_view_data,
409 (XtPointer) desktopWindow);
411 XtRemoveAllCallbacks(desktopWindow->iconGadget, XmNcallback);
412 XtAddCallback (desktopWindow->iconGadget,
414 (XtCallbackProc)IconCallback,
415 desktopWindow->file_view_data);
419 /**********************************************************************
421 * BuildNewOrderlist - builds a new file_view for a Desktop object.
422 * If the order_list is NULL, then stat the file and build it
423 * from there. If order_list in not NULL then use it to build the
426 **********************************************************************/
427 static FileViewData *
429 FileViewData *order_list,
434 Boolean is_registered,
437 FileViewData *file_view_data;
441 file_view_data = (FileViewData *)XtMalloc(sizeof(FileViewData));
442 file_view_data->directory_set =
443 (XtPointer)XtMalloc(sizeof(DirectorySet));
445 ((DirectorySet *)file_view_data->directory_set)->file_count = 1;
446 ((DirectorySet *)file_view_data->directory_set)->file_view_data = NULL;
447 ((DirectorySet *)file_view_data->directory_set)->order_list = NULL;
448 ((DirectorySet *)file_view_data->directory_set)->filtered_file_count = 0;
449 ((DirectorySet *)file_view_data->directory_set)->invisible_file_count = 0;
450 ((DirectorySet *)file_view_data->directory_set)->file_mgr_data = NULL;
452 file_view_data->parent =
453 file_view_data->next =
454 file_view_data->desc = NULL;
455 file_view_data->filtered = False;
456 file_view_data->displayed = True;
457 file_view_data->registered = is_registered;
458 file_view_data->ts = tsNotRead;
459 file_view_data->ndir =
460 file_view_data->nfile =
461 file_view_data->nnew = 0;
462 file_view_data->widget = icon;
463 file_view_data->treebtn = NULL;
464 file_view_data->position_info = NULL;
466 if(order_list != NULL)
468 file_view_data->file_data = file_data =
469 (FileData *)XtMalloc(sizeof(FileData));
471 file_data->link = NULL;
472 file_data->next = NULL;
473 file_data->is_subdir = False;
474 file_data->is_broken = False;
476 file_data->file_name = XtNewString(order_list->file_data->file_name);
477 file_data->action_name = XtNewString(order_list->file_data->action_name);
478 file_data->physical_type = order_list->file_data->physical_type;
479 file_data->logical_type = order_list->file_data->logical_type;
480 file_data->errnum = order_list->file_data->errnum;
481 file_data->stat = order_list->file_data->stat;
483 ((DirectorySet *)file_view_data->directory_set)->name =
484 XtNewString( ((DirectorySet *)order_list->directory_set)->name );
490 full_dir_name = ResolveLocalPathName(hostName, dirName, NULL,
491 home_host_name, &tt_status);
492 if( TT_OK == tt_status )
494 FileData2 file_data2;
497 DtEliminateDots (full_dir_name);
499 if (strcmp(file, ".") == 0) {
500 ReadFileData2(&file_data2, full_dir_name, NULL,IsToolBox);
502 ReadFileData2(&file_data2, full_dir_name, file,IsToolBox);
504 file_view_data->file_data = FileData2toFileData(&file_data2, &n);
505 XtFree(full_dir_name);
506 full_dir_name = NULL;
509 ((DirectorySet *)file_view_data->directory_set)->name =
510 XtNewString(dirName);
513 return(file_view_data);
517 /************************************************************************
519 * DesktopObjectRemoved()
520 * Called when it is detected that an object that a desktop icon
521 * refers to no longer exists. Removes the icon window from the
522 * screen and removes the object from the list of desktop objects.
524 ***********************************************************************/
527 DesktopObjectRemoved( DesktopRec *desktopWindow )
529 WorkspaceRec * workSpace;
532 /* Remove the object from the screen*/
533 XtPopdown(desktopWindow->shell);
534 XWithdrawWindow(XtDisplay(desktopWindow->shell),
535 XtWindow(desktopWindow->shell),
536 XDefaultScreen(XtDisplay(desktopWindow->shell)));
539 File manager has 2 lists to deal with when a file is on the desktop
540 1. desktop_data->desktopWindows and
541 2. desktop_data->workspaceData[n]->selectedDTWindows
543 list 1 contains all files that are on desktop.
544 list 2 contains all files on desktop that are SELECTED.
546 At this point, for some reason, the file is no longer present
547 in the system. Remove it/them from both lists.
549 NOTE: This is very inefficient code but have no other
550 implementation choices. Prefer trash to do it, but all trash
551 handlers are designed to accept ICCCM message for deleting a file.
552 Prefer the operating system to notify when a file is being deleted,
556 for( j = 0; j < desktop_data->numWorkspaces; ++j )
558 workSpace = desktop_data->workspaceData[j];
559 for( k = 0; k < workSpace->files_selected; ++k )
561 if( workSpace->selectedDTWindows[k] == desktopWindow )
563 for( l = k; l < workSpace->files_selected; ++l )
565 workSpace->selectedDTWindows[l] =
566 workSpace->selectedDTWindows[l+1];
568 --(workSpace->files_selected);
574 FreeDesktopWindow(desktopWindow);
578 /************************************************************************
580 * DesktopObjectChanged()
581 * Called when is detected that an object that a desktop icon
582 * refers has changed its data type. Updates the icon pixmap to
583 * reflect the new type.
585 ***********************************************************************/
588 DesktopObjectChanged( DesktopRec *desktopWindow )
592 PixmapData *pixmapData;
594 /* remove text widget, if any */
595 if(desktopWindow->text)
597 XtUnmanageChild(desktopWindow->text);
598 XtDestroyWidget(desktopWindow->text);
599 desktopWindow->text = NULL;
602 /* update icon pixmap */
603 file_data = desktopWindow->file_view_data->file_data;
604 pixmapData = _DtRetrievePixmapData(
605 file_data->logical_type,
606 file_data->file_name,
607 desktopWindow->dir_linked_to,
608 desktopWindow->shell,
612 XtSetArg (args[0], XmNimageName, pixmapData->iconFileName);
614 XtSetArg(args[0], XmNimageName, NULL);
615 XtSetValues(desktopWindow->iconGadget, args, 1);
617 _DtCheckAndFreePixmapData(
618 file_data->logical_type,
619 desktopWindow->shell,
620 (DtIconGadget) desktopWindow->iconGadget,
623 GenerateShape(desktopWindow);
630 DesktopRec *desktopWindow,
642 XSizeHints wmSizeHints;
643 PixmapData *pixmapData;
644 Dimension width, height;
645 Dimension gadgetWidth, gadgetHeight;
646 Position gadgetX, gadgetY, drawAX, drawAY;
650 /* get the colors to use for the desktop window */
651 background = desktopWindow->background;
652 XtSetArg (args[0], XmNcolormap, &colormap);
653 XtGetValues (desktopWindow->shell, args, 1);
655 XmGetColors (XtScreen(desktopWindow->shell), colormap, background,
656 &foreground, &top_shadow, &bottom_shadow, &select);
658 /* set the background color for both the frame and the DrawingA */
660 XtSetArg (args[0], XmNbackground, background);
662 XtSetArg (args[0], XmNbackground, select);
664 XtSetValues (desktopWindow->frame, args, 1);
665 XtSetValues (desktopWindow->drawA, args, 1);
667 /* set up the icon label and pixmap */
668 if(desktopWindow->file_view_data->file_data->action_name != NULL)
669 icon_label = XmStringCreateLocalized (
670 desktopWindow->file_view_data->file_data->action_name);
672 icon_label = XmStringCreateLocalized (desktopWindow->title);
673 XtSetArg (args[0], XmNstring, icon_label);
675 pixmapData = _DtRetrievePixmapData(
676 desktopWindow->file_view_data->file_data->logical_type,
677 desktopWindow->file_view_data->file_data->file_name,
678 desktopWindow->dir_linked_to,
679 desktopWindow->shell,
682 XtSetArg (args[1], XmNimageName, pixmapData->iconFileName);
684 XtSetArg (args[1], XmNimageName, NULL);
686 /* set up the icon colors */
688 XtSetArg (args[2], XmNforeground, foreground);
690 if (select == white_pixel)
692 XtSetArg (args[3], XmNbackground, white_pixel);
693 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
694 XtSetArg (args[5], XmNpixmapForeground, black_pixel);
696 else if (select == black_pixel)
698 XtSetArg (args[3], XmNbackground, black_pixel);
699 XtSetArg (args[4], XmNpixmapBackground, white_pixel);
700 XtSetArg (args[5], XmNpixmapForeground, black_pixel);
705 XtSetArg (args[3], XmNbackground, background);
707 XtSetArg (args[3], XmNbackground, select);
709 XtSetArg (args[4], XmNpixmapBackground, top_shadow);
710 XtSetArg (args[5], XmNpixmapForeground, bottom_shadow);
712 XtSetArg (args[6], XmNuserData,
713 (DirectorySet *)desktopWindow->file_view_data->directory_set);
715 XtSetValues (desktopWindow->iconGadget, args, 7);
717 XmStringFree(icon_label);
719 _DtCheckAndFreePixmapData(
720 desktopWindow->file_view_data->file_data->logical_type,
721 desktopWindow->shell,
722 (DtIconGadget) desktopWindow->iconGadget,
725 /* Set userData, so that help system can obtain the desktop info */
726 XtSetArg(args[0], XmNuserData, (XtPointer)desktopWindow);
727 XtSetValues(desktopWindow->frame, args, 1);
729 XtSetMappedWhenManaged(desktopWindow->shell, False);
730 XtRealizeWidget (desktopWindow->shell);
732 /* Set the proper workspaces if needed */
733 _DtEncapSetWorkSpaceHints(desktopWindow->shell,
734 desktopWindow->workspace_name);
737 XtSetMappedWhenManaged(desktopWindow->shell, True);
739 /* get the width and the heighth of the icon gadget */
740 XtSetArg (args[0], XmNwidth, &gadgetWidth);
741 XtSetArg (args[1], XmNheight, &gadgetHeight);
742 XtSetArg (args[2], XmNx, &gadgetX);
743 XtSetArg (args[3], XmNy, &gadgetY);
744 XtGetValues(desktopWindow->iconGadget, args, 4);
746 XtSetArg (args[0], XmNx, &drawAX);
747 XtSetArg (args[1], XmNy, &drawAY);
748 XtGetValues(desktopWindow->drawA, args, 2);
750 width = gadgetWidth + (Dimension)(2*gadgetX) + (Dimension)(2*drawAX);
751 height = gadgetHeight + (Dimension)(2*gadgetY) + (Dimension)(2*drawAY);
755 CalculateRootCoordinates(desktopWindow->workspace_num, width, height,
759 desktopWindow->root_x = rX;
760 desktopWindow->root_y = rY;
762 XtSetArg (args[0], XmNx, rX);
763 XtSetArg (args[1], XmNy, rY);
764 XtSetArg (args[2], XmNwidth, width);
765 XtSetArg (args[3], XmNheight, height);
766 XtSetValues (desktopWindow->shell, args, 4);
768 /* force the Window Manager to map it where I want it */
769 if (XtWindow(desktopWindow->shell) != 0)
771 XGetNormalHints(XtDisplay(desktopWindow->shell),
772 XtWindow(desktopWindow->shell), &wmSizeHints);
773 wmSizeHints.flags = USPosition | USSize;
774 XSetNormalHints(XtDisplay(desktopWindow->shell),
775 XtWindow(desktopWindow->shell), &wmSizeHints);
776 XSync(XtDisplay(desktopWindow->shell), 0);
779 wm = (WMShellWidget)desktopWindow->shell;
780 wm->wm.size_hints.flags = USPosition | USSize;
783 GenerateShape(desktopWindow);
786 /* map the Window on the root window */
787 XtPopup(desktopWindow->shell, XtGrabNone);
788 XSync(XtDisplay(desktopWindow->shell), False);
790 RegisterIconDropsDT(desktopWindow);
792 XtSetArg (args[0], XmNwidth, &width);
793 XtSetArg (args[1], XmNheight, &height);
794 XtGetValues(desktopWindow->shell, args, 2);
796 RegisterInGrid((int)width, (int)height, rX, rY,
797 desktopWindow->workspace_num, True);
805 static char * desktopFileName = NULL;
809 DesktopRec *desktopWindow;
810 char *full_path = NULL;
811 char *rDir, *title, *helpVol;
814 /* Build the name which the desktop data will be saved */
815 if (desktopFileName == NULL)
817 desktopFileName = XtMalloc(strlen(DESKTOP_SAVE_NAME) + 1);
818 sprintf(desktopFileName, "%s", DESKTOP_SAVE_NAME);
824 /* Construct full filename */
825 fileName = ResolveLocalPathName(home_host_name,
826 desktop_dir, desktopFileName,
827 home_host_name, &tt_status);
829 case HOME_DIR_RESTORE:
830 full_path = (char *)XtMalloc(strlen(dt_path) + strlen("/home") + 1);
831 sprintf( full_path, "%s/home", dt_path );
832 fileName = ResolveLocalPathName(home_host_name,
833 full_path, desktopFileName,
834 home_host_name, &tt_status);
839 full_path = (char *)XtMalloc(strlen(dt_path) + strlen("/current")+1);
840 sprintf( full_path, "%s/current", dt_path );
841 fileName = ResolveLocalPathName(home_host_name,
842 full_path, desktopFileName,
843 home_host_name, &tt_status);
849 if(desktop_data->numIconsUsed == 0)
857 /* Assume read-only directory, if we can't open the file */
858 if ((fptr = fopen(fileName, "w+")) == NULL)
865 chmod(fileName, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
866 XtFree((char *)fileName); fileName = NULL;
868 fprintf(fptr, "%d\n", desktop_data->numIconsUsed);
870 for(i = 0; i < desktop_data->numIconsUsed; i++)
872 desktopWindow = desktop_data->desktopWindows[i];
874 if(desktopWindow->restricted_directory != NULL )
875 rDir = XtNewString(desktopWindow->restricted_directory);
877 rDir = XtNewString(NULL_STRING);
879 if(desktopWindow->title != NULL )
880 title = XtNewString(desktopWindow->title);
882 title = XtNewString(NULL_STRING);
884 if(desktopWindow->helpVol != NULL )
885 helpVol = XtNewString(desktopWindow->helpVol);
887 helpVol = XtNewString(NULL_STRING);
889 fprintf(fptr, "%s\n%s\n%s\n%s\n%s\n%s\n%d %d %d %d %d %d %d\n",
890 desktopWindow->file_name,
891 desktopWindow->workspace_name,
892 desktopWindow->dir_linked_to,
896 desktopWindow->toolbox,
898 desktopWindow->order,
899 desktopWindow->direction,
900 desktopWindow->positionEnabled,
901 desktopWindow->root_x,
902 desktopWindow->root_y);
904 /* if not normal restore (ie save current or home) remove the entry */
905 if(session == CURRENT_DIR_RESTORE)
907 FileViewData *file_view_data;
908 DirectorySet *directory_set;
910 file_view_data = desktopWindow->file_view_data;
911 directory_set = (DirectorySet *)file_view_data->directory_set;
913 XtRemoveAllCallbacks(desktop_data->desktopWindows[i]->iconGadget,
915 XtFree((char *)directory_set->file_mgr_data);
916 directory_set->file_mgr_data = NULL;
917 XtFree((char *)directory_set->name);
918 directory_set->name = NULL;
919 XtFree((char *)directory_set);
920 directory_set = NULL;
921 FreeFileData(file_view_data->file_data, True);
922 if(file_view_data->label)
924 XtFree((char *)file_view_data->label);
925 file_view_data->label = NULL;
927 XtFree((char *)file_view_data);
928 file_view_data = NULL;
929 XtFree(desktop_data->desktopWindows[i]->workspace_name);
930 desktop_data->desktopWindows[i]->workspace_name = NULL;
931 XtFree(desktop_data->desktopWindows[i]->host);
932 desktop_data->desktopWindows[i]->host = NULL;
933 XtFree(desktop_data->desktopWindows[i]->dir_linked_to);
934 desktop_data->desktopWindows[i]->dir_linked_to = NULL;
935 XtFree(desktop_data->desktopWindows[i]->title);
936 desktop_data->desktopWindows[i]->title = NULL;
937 XtFree(desktop_data->desktopWindows[i]->helpVol);
938 desktop_data->desktopWindows[i]->helpVol = NULL;
939 XtFree(desktop_data->desktopWindows[i]->restricted_directory);
940 desktop_data->desktopWindows[i]->restricted_directory = NULL;
941 desktop_data->desktopWindows[i]->restricted_directory = NULL;
943 desktop_data->desktopWindows[i]->root_x = -1;
944 desktop_data->desktopWindows[i]->root_y = -1;
946 desktop_data->desktopWindows[i]->view = UNSET_VALUE;
947 desktop_data->desktopWindows[i]->order = UNSET_VALUE;
948 desktop_data->desktopWindows[i]->direction = UNSET_VALUE;
949 desktop_data->desktopWindows[i]->positionEnabled = UNSET_VALUE;
950 desktop_data->desktopWindows[i]->toolbox = False;
951 desktop_data->desktopWindows[i]->title = NULL;
952 desktop_data->desktopWindows[i]->helpVol = NULL;
953 desktop_data->desktopWindows[i]->restricted_directory = NULL;
955 desktop_data->desktopWindows[i]->file_view_data = NULL;
968 if(session == CURRENT_DIR_RESTORE)
970 desktop_data->numCachedIcons += desktop_data->numIconsUsed;
971 desktop_data->numIconsUsed = 0;
972 fileName = ResolveLocalPathName(home_host_name,
973 desktop_dir, desktopFileName,
974 home_host_name, &tt_status);
975 if( TT_OK == tt_status )
989 static char * desktopFileName = NULL;
990 char *fileName = NULL, *full_path = NULL, *ptr = NULL;
991 char *workSpace = NULL;
992 char *message = NULL;
993 int i, j, numWindows, count, index, bufferSize;
996 DesktopRec *desktopWindow;
997 Boolean status = FALSE;
1000 struct stat stat_buf;
1002 /* Build the name which the desktop data will be saved */
1003 if (desktopFileName == NULL)
1005 desktopFileName = XtMalloc(strlen(DESKTOP_SAVE_NAME) + 1);
1006 sprintf(desktopFileName, "%s", DESKTOP_SAVE_NAME);
1011 /* Construct full filename */
1012 fileName = ResolveLocalPathName(home_host_name,
1013 desktop_dir, desktopFileName,
1014 home_host_name, &tt_status);
1018 status = DtSessionRestorePath(toplevel, &full_path, session);
1023 if (stat(full_path, &stat_buf) != 0)
1030 ptr = strrchr(full_path, '/');
1033 /* Construct full filename */
1034 fileName = ResolveLocalPathName(home_host_name,
1035 full_path, desktopFileName,
1036 home_host_name, &tt_status);
1042 /* Assume no file if the open fails */
1043 if ((fptr = fopen(fileName, "r")) == NULL)
1051 /* Load the number of entries */
1052 count = fscanf(fptr, "%d\n", &numWindows);
1062 /* make sure there are enough predefined desktop windows to hold the
1064 if(numWindows >= desktop_data->numCachedIcons)
1065 InitializeDesktopWindows(numWindows + 5 - desktop_data->numCachedIcons,
1068 count = index = desktop_data->numIconsUsed;
1070 bufferSize = 2*MAX_PATH + 370;
1071 message = (char *)XtMalloc(bufferSize);
1073 /* read the data for each Window, then popup that window */
1074 for (i = count; i < numWindows + count; i++)
1076 int len = 0, toolbox = False, view = UNSET_VALUE,
1077 order = UNSET_VALUE, direction = UNSET_VALUE,
1078 positionEnabled = UNSET_VALUE;
1080 desktopWindow = desktop_data->desktopWindows[index];
1082 if (fgets(message, bufferSize, fptr))
1084 len = strlen(message); message[len-1] = 0x0;
1085 desktopWindow->file_name = XtNewString(message);
1088 desktopWindow->file_name = NULL;
1090 if (fgets(message, bufferSize, fptr))
1092 len = strlen(message); message[len-1] = 0x0;
1093 workSpace = XtNewString(message);
1098 if (fgets(message, bufferSize, fptr))
1100 len = strlen(message); message[len-1] = 0x0;
1101 desktopWindow->dir_linked_to = XtNewString(message);
1104 desktopWindow->dir_linked_to = NULL;
1106 { /* Construct the full path and check for the file or link
1108 If it's not there on the file system, don't bother
1112 struct stat stat_buf;
1114 if (strcmp(desktopWindow->dir_linked_to, "/") == 0)
1116 path = (char *) XtMalloc(strlen(desktopWindow->dir_linked_to) +
1117 strlen(desktopWindow->file_name) + 1);
1118 sprintf(path, "%s%s", desktopWindow->dir_linked_to,
1119 desktopWindow->file_name);
1123 path = (char *) XtMalloc(strlen(desktopWindow->dir_linked_to) +
1124 strlen(desktopWindow->file_name) + 2);
1125 sprintf(path, "%s/%s", desktopWindow->dir_linked_to,
1126 desktopWindow->file_name);
1129 if( stat(path, &stat_buf) != 0
1130 && lstat(path, &stat_buf) != 0 )
1132 XtFree(desktopWindow->file_name);
1133 desktopWindow->file_name = NULL;
1136 XtFree(desktopWindow->dir_linked_to);
1137 desktopWindow->dir_linked_to = NULL;
1147 if (fgets(message, bufferSize, fptr))
1149 len = strlen(message); message[len-1] = 0x0;
1150 if( strcmp(message, NULL_STRING) == 0 )
1151 desktopWindow->restricted_directory = NULL;
1153 desktopWindow->restricted_directory = XtNewString(message);
1156 desktopWindow->restricted_directory = NULL;
1158 if (fgets(message, bufferSize, fptr))
1160 len = strlen(message); message[len-1] = 0x0;
1161 if( strcmp(message, NULL_STRING) == 0 )
1162 desktopWindow->title = NULL;
1164 desktopWindow->title = XtNewString(message);
1167 desktopWindow->title = NULL;
1169 if (fgets(message, bufferSize, fptr))
1171 len = strlen(message); message[len-1] = 0x0;
1172 if( strcmp(message, NULL_STRING) == 0 )
1173 desktopWindow->helpVol = NULL;
1175 desktopWindow->helpVol = XtNewString(message);
1178 desktopWindow->helpVol = NULL;
1180 if (fgets(message, bufferSize, fptr))
1182 sscanf( message, "%d %d %d %d %d %d %d\n",
1183 &toolbox, &view, &order, &direction, &positionEnabled, &rX, &rY );
1188 desktopWindow->toolbox = (char)toolbox;
1189 desktopWindow->view = (char)view;
1190 desktopWindow->order = (char)order;
1191 desktopWindow->direction = (char)direction;
1192 desktopWindow->positionEnabled = (Boolean)positionEnabled;
1194 /* set up the workspace number */
1196 for(j = 0; j < desktop_data->numWorkspaces; j++)
1198 if(strcmp(workSpace, desktop_data->workspaceData[j]->name) == 0)
1201 desktopWindow->workspace_name = workSpace;
1202 desktopWindow->workspace_num =
1203 desktop_data->workspaceData[j]->number;
1210 desktopWindow->workspace_num = 1;
1211 desktopWindow->workspace_name =
1212 (char *)XtMalloc(strlen(desktop_data->workspaceData[0]->name) + 1);
1213 strcpy(desktopWindow->workspace_name,
1214 desktop_data->workspaceData[0]->name);
1219 desktopWindow->host = XtNewString(home_host_name);
1221 desktopWindow->file_view_data =
1222 BuildNewOrderlist(NULL, desktopWindow->iconGadget,
1223 desktopWindow->host,
1224 desktopWindow->dir_linked_to,
1225 desktopWindow->file_name,
1226 desktopWindow->registered,
1227 desktopWindow->toolbox);
1229 MakeDesktopWindow(desktopWindow, rX, rY);
1230 desktopWindow->registered = desktopWindow->file_view_data->registered;
1232 desktop_data->numIconsUsed++;
1233 desktop_data->numCachedIcons--;
1243 SaveDesktopInfo(NORMAL_RESTORE);
1249 DesktopRec *desktopWindow)
1252 DesktopRec *tempDesktopWindow;
1253 FileViewData *file_view_data;
1254 DirectorySet *directory_set;
1255 Dimension width, height;
1258 file_view_data = desktopWindow->file_view_data;
1259 directory_set = (DirectorySet *)file_view_data->directory_set;
1260 tempDesktopWindow = desktopWindow;
1262 XtSetArg (args[0], XmNwidth, &width);
1263 XtSetArg (args[1], XmNheight, &height);
1264 XtGetValues(desktopWindow->shell, args, 2);
1266 RegisterInGrid((int)width, (int)height, desktopWindow->root_x,
1267 desktopWindow->root_y, desktopWindow->workspace_num, False);
1269 if(desktopWindow->text != NULL)
1271 XtUnmanageChild(desktopWindow->text);
1272 XtDestroyWidget(desktopWindow->text);
1273 desktopWindow->text = NULL;
1276 for(i = 0; i < desktop_data->numIconsUsed; i++)
1277 if(desktopWindow == desktop_data->desktopWindows[i])
1280 /* circulate this */
1281 for(;i < desktop_data->numIconsUsed - 1; i++)
1283 desktop_data->desktopWindows[i] =
1284 desktop_data->desktopWindows[i + 1];
1287 /* clear all memory used by the desktop window */
1288 desktop_data->desktopWindows[i] = tempDesktopWindow;
1289 XtRemoveAllCallbacks(desktop_data->desktopWindows[i]->iconGadget,
1291 XtFree((char *)directory_set->file_mgr_data);
1292 directory_set->file_mgr_data = NULL;
1293 XtFree((char *)directory_set->name);
1294 directory_set->name = NULL;
1295 XtFree((char *)directory_set);
1296 directory_set = NULL;
1297 FreeFileData(file_view_data->file_data, True);
1298 if(file_view_data->label)
1300 XtFree((char *)file_view_data->label);
1301 file_view_data->label = NULL;
1303 XtFree((char *)file_view_data);
1304 file_view_data = NULL;
1305 XtFree(desktop_data->desktopWindows[i]->restricted_directory);
1306 desktop_data->desktopWindows[i]->restricted_directory = NULL;
1307 XtFree(desktop_data->desktopWindows[i]->title);
1308 desktop_data->desktopWindows[i]->title = NULL;
1309 XtFree(desktop_data->desktopWindows[i]->helpVol);
1310 desktop_data->desktopWindows[i]->helpVol = NULL;
1311 XtFree(desktop_data->desktopWindows[i]->workspace_name);
1312 desktop_data->desktopWindows[i]->workspace_name = NULL;
1313 XtFree(desktop_data->desktopWindows[i]->host);
1314 desktop_data->desktopWindows[i]->host = NULL;
1315 XtFree(desktop_data->desktopWindows[i]->dir_linked_to);
1316 desktop_data->desktopWindows[i]->dir_linked_to = NULL;
1317 XtFree(desktop_data->desktopWindows[i]->file_name);
1318 desktop_data->desktopWindows[i]->file_name = NULL;
1320 desktop_data->desktopWindows[i]->restricted_directory = NULL;
1321 desktop_data->desktopWindows[i]->title = NULL;
1322 desktop_data->desktopWindows[i]->helpVol = NULL;
1323 desktop_data->desktopWindows[i]->workspace_name = NULL;
1324 desktop_data->desktopWindows[i]->host = NULL;
1325 desktop_data->desktopWindows[i]->dir_linked_to = NULL;
1326 desktop_data->desktopWindows[i]->file_name = NULL;
1328 desktop_data->desktopWindows[i]->root_x = -1;
1329 desktop_data->desktopWindows[i]->root_y = -1;
1331 desktop_data->desktopWindows[i]->file_view_data = NULL;
1332 desktop_data->numIconsUsed--;
1333 desktop_data->numCachedIcons++;
1335 /* now lets check the number of cached Icons, if its too large free some
1339 if(desktop_data->numCachedIcons > MAX_CACHED_ICONS)
1340 FreeCachedIcons(desktop_data->numCachedIcons - MAX_CACHED_ICONS);
1342 SaveDesktopInfo(NORMAL_RESTORE);
1350 XtPointer client_data,
1352 Boolean *contDispatch)
1354 XmManagerWidget action_pane;
1355 DesktopRec *desktopWindow;
1356 XButtonEvent *bevent;
1358 int i, j, num_children, num_of_files;
1359 static int beventx = -1;
1360 static int beventy = -1;
1362 /* if a drag is active, don't do anything. */
1367 bevent = (XButtonEvent *)event;
1368 desktop_data->event = *bevent;
1369 desktopWindow = (DesktopRec *) client_data;
1371 /* first decide whether more than one file is selected */
1372 for(i = 0; i < desktop_data->numWorkspaces; i++)
1374 if(desktop_data->workspaceData[i]->number == desktopWindow->workspace_num)
1379 for(j = 0; j < desktop_data->workspaceData[i]->files_selected; j++)
1381 /* we need to check to see if the dt object this popup is on is
1383 if(desktop_data->workspaceData[i]->selectedDTWindows[j] == desktopWindow)
1385 /* it is in the selected list */
1386 num_of_files = desktop_data->workspaceData[i]->files_selected;
1391 if(num_of_files > 1)
1393 /* we have more than one files selected,
1394 Set userData, so that help system can obtain the desktop info */
1395 XtSetArg(args[0], XmNuserData,
1396 (XtPointer)desktop_data->workspaceData[i]->selectedDTWindows);
1397 XtSetValues(desktop_data->popupMenu->popup, args, 1);
1399 XtRemoveAllCallbacks(desktop_data->popupMenu->removeDT,
1400 XmNactivateCallback);
1401 XtAddCallback(desktop_data->popupMenu->removeDT, XmNactivateCallback,
1403 (XtPointer) desktop_data->workspaceData[i]->selectedDTWindows[0]);
1404 XtRemoveAllCallbacks(desktop_data->popupMenu->openFolder,
1405 XmNactivateCallback);
1406 XtAddCallback(desktop_data->popupMenu->openFolder, XmNactivateCallback,
1407 OpenFolder, (XtPointer) NULL);
1409 XtRemoveAllCallbacks(desktop_data->popupMenu->rename,
1410 XmNactivateCallback);
1411 XtAddCallback(desktop_data->popupMenu->rename, XmNactivateCallback,
1412 renameDT, (XtPointer) NULL);
1414 /* unsensitise the "Open Parent Folder" and "Rename" options */
1415 XtSetSensitive(desktop_data->popupMenu->openFolder, False);
1416 XtSetSensitive(desktop_data->popupMenu->rename, False);
1418 /* Unmanage all action menu buttons. */
1419 action_pane = (XmManagerWidget) desktop_data->popupMenu->popup;
1421 num_children = action_pane->composite.num_children;
1422 for (i = 7; i < num_children; i++)
1424 XtUnmanageChild (action_pane->composite.children[i]);
1429 /* No point in continuing any further if any of these pointers
1431 if(!desktop_data->popupMenu || !desktopWindow->file_view_data)
1433 /* we have zero or one files selected, so just put up the popup for
1436 /* Set userData, so that help system can obtain the desktop info */
1437 XtSetArg(args[0], XmNuserData, client_data);
1438 XtSetValues(desktop_data->popupMenu->popup, args, 1);
1440 XtRemoveAllCallbacks(desktop_data->popupMenu->removeDT,
1441 XmNactivateCallback);
1442 XtAddCallback(desktop_data->popupMenu->removeDT, XmNactivateCallback,
1443 RemoveDT, (XtPointer) desktopWindow);
1445 XtRemoveAllCallbacks(desktop_data->popupMenu->openFolder,
1446 XmNactivateCallback);
1447 XtAddCallback(desktop_data->popupMenu->openFolder, XmNactivateCallback,
1448 OpenFolder, (XtPointer) desktopWindow);
1450 XtRemoveAllCallbacks(desktop_data->popupMenu->rename,
1451 XmNactivateCallback);
1453 if( desktopWindow->toolbox == False )
1454 { /* Sensitize rename
1456 XtSetSensitive(desktop_data->popupMenu->rename, True);
1457 XtAddCallback(desktop_data->popupMenu->rename, XmNactivateCallback,
1458 renameDT, (XtPointer) desktopWindow);
1461 { /* Don't allow user to rename the objects in the tool box.
1462 These things are action labels.
1464 XtSetSensitive(desktop_data->popupMenu->rename, False);
1468 XtSetSensitive(desktop_data->popupMenu->openFolder, True);
1470 XtFree(desktop_data->popupMenu->action_pane_file_type);
1471 desktop_data->popupMenu->action_pane_file_type = NULL;
1472 desktop_data->popupMenu->action_pane_file_type = XtNewString(
1473 desktopWindow->file_view_data->file_data->logical_type);
1475 UpdateActionMenuPane ((XtPointer)desktopWindow, (FileMgrRec *)NULL,
1476 desktop_data->popupMenu->action_pane_file_type,
1477 DESKTOP, 7, desktop_data->popupMenu->popup,
1478 desktopWindow->file_view_data->file_data->physical_type);
1480 if(desktopWindow->file_view_data->file_data->physical_type == DtDIRECTORY
1481 && desktopWindow->file_name )
1485 ptr = DtStrrchr(desktopWindow->title, ':');
1489 if(strcmp(root_title, ptr) == 0)
1490 { /* The desktop object is a ROOT directory */
1491 XtSetSensitive(desktop_data->popupMenu->openFolder, False);
1492 XtSetSensitive(desktop_data->popupMenu->rename, False);
1493 XtRemoveAllCallbacks(desktop_data->popupMenu->rename,
1494 XmNactivateCallback);
1503 Dimension width, height;
1504 int displayWidth, displayHeight;
1507 XtSetArg (args[0], XmNwidth, &width);
1508 XtSetArg (args[1], XmNheight, &height);
1509 XtGetValues(XtParent(desktop_data->popupMenu->popup), args, 2);
1511 displayWidth = DisplayWidth(XtDisplay(w), DefaultScreen(XtDisplay(w)));
1512 displayHeight = DisplayHeight(XtDisplay(w), DefaultScreen(XtDisplay(w)));
1514 g = (DtIconGadget)desktopWindow->iconGadget;
1517 beventx = desktopWindow->root_x + g->icon.pixmap_width/2;
1519 if((Dimension)(beventx + width) > (Dimension)displayWidth)
1520 beventx = displayWidth - width - 4;
1523 beventy = desktopWindow->root_y +
1524 desktopWindow->iconGadget->core.height/2;
1526 if((Dimension)(beventy + height) > (Dimension)displayHeight)
1527 beventy = beventy - height - 1;
1529 XtSetArg (args[0], XmNx, beventx);
1530 XtSetArg (args[1], XmNy, beventy);
1531 XtSetValues(XtParent(desktop_data->popupMenu->popup), args, 2);
1537 beventx = bevent->x_root;
1538 beventy = bevent->y_root;
1539 XmMenuPosition(desktop_data->popupMenu->popup,
1540 (XButtonPressedEvent *)bevent);
1543 XtManageChild(desktop_data->popupMenu->popup);
1547 /**********************************************************************
1549 * RemoveDT - Callback from the Desktop Popup menu to 'Remove From
1550 * Desktop'. Popdown's and Free the desktop window passed in
1551 * in the client_data pointer. Then checks to see if any other
1552 * desktop window is pointing to the file in the File Manager the
1553 * removed desktop object was pointing to. If there's not, it
1554 * removes the file from the desktop list.
1556 ************************************************************************/
1559 RemoveDT (Widget w, XtPointer client_data, XtPointer call_data)
1561 DesktopRec *desktopWindow = (DesktopRec *) client_data;
1562 int i, j, num_of_files;
1563 Boolean selected = False;
1565 /* first decide whether more than one file is selected */
1566 for(i = 0; i < desktop_data->numWorkspaces; i++)
1568 if(desktop_data->workspaceData[i]->number == desktopWindow->workspace_num)
1572 /* next determine if the file is really in the selected list */
1574 for(j = 0; j < desktop_data->workspaceData[i]->files_selected; j++)
1576 /* we need to check to see if the dt object this popup is on is
1578 if(desktop_data->workspaceData[i]->selectedDTWindows[j] == desktopWindow)
1580 /* it is in the selected list */
1581 num_of_files = desktop_data->workspaceData[i]->files_selected;
1586 if(num_of_files == 0)
1591 for(j = 0; j < num_of_files; j++)
1594 desktopWindow = desktop_data->workspaceData[i]->selectedDTWindows[j];
1596 XtPopdown(desktopWindow->shell);
1597 XWithdrawWindow(XtDisplay(desktopWindow->shell),
1598 XtWindow(desktopWindow->shell),
1599 XDefaultScreen(XtDisplay(desktopWindow->shell)));
1601 FreeDesktopWindow(desktopWindow);
1603 desktop_data->workspaceData[i]->files_selected--;
1609 RemoveMovedObjectFromDT (Widget w, XtPointer client_data, int file_cnt,
1612 DesktopRec *desktopWindow = (DesktopRec *) client_data;
1613 int i, j, k, m, num_of_files;
1614 Boolean selected = False;
1615 char filename[MAX_PATH] ;
1617 /* first decide whether more than one file is selected */
1618 for(i = 0; i < desktop_data->numWorkspaces; i++)
1620 if(desktop_data->workspaceData[i]->number == desktopWindow->workspace_num)
1624 /* next determine if the file is really in the selected list */
1626 for(j = 0; j < desktop_data->workspaceData[i]->files_selected; j++)
1628 /* we need to check to see if the dt object this popup is on is
1630 if(desktop_data->workspaceData[i]->selectedDTWindows[j] == desktopWindow)
1632 /* it is in the selected list */
1633 num_of_files = desktop_data->workspaceData[i]->files_selected;
1638 if(num_of_files == 0)
1643 for(k = 0; k < num_of_files; k++)
1646 desktopWindow = desktop_data->workspaceData[i]->selectedDTWindows[k];
1647 for(j = 0; j < file_cnt; j++) {
1648 strcpy(filename, desktopWindow->dir_linked_to) ;
1649 strcat(filename, "/") ;
1650 strcat(filename, desktopWindow->file_name) ;
1651 if (!strcmp(filename, file_list[j])) {
1652 XtPopdown(desktopWindow->shell);
1653 XWithdrawWindow(XtDisplay(desktopWindow->shell),
1654 XtWindow(desktopWindow->shell),
1655 XDefaultScreen(XtDisplay(desktopWindow->shell)));
1657 FreeDesktopWindow(desktopWindow);
1659 desktop_data->workspaceData[i]->files_selected--;
1660 for (m = k ; m < num_of_files - 1 ; m++) {
1661 desktop_data->workspaceData[i]->selectedDTWindows[m] =
1662 desktop_data->workspaceData[i]->selectedDTWindows[m + 1];
1669 #endif /* SUN_PERF */
1674 XtPointer client_data,
1675 XtPointer call_data)
1677 DesktopRec *desktopWindow;
1678 DirectorySet *directory_data;
1679 FileViewData *file_view_data;
1680 FileMgrData *file_mgr_data;
1681 FileMgrRec *file_mgr_rec;
1682 DialogData *dialog_data;
1685 desktopWindow = (DesktopRec *) client_data;
1686 file_view_data = desktopWindow->file_view_data;
1688 if (desktopWindow->toolbox)
1690 DtActionArg *action_args;
1693 action_args = (DtActionArg *) XtCalloc(1, sizeof(DtActionArg));
1696 action_args[0].argClass = DtACTION_FILE;
1697 action_args[0].u.file.name = desktopWindow->dir_linked_to;
1700 pwd_dir = XtNewString(desktopWindow->dir_linked_to);
1701 DtActionInvoke(desktopWindow->shell, "OpenParentAppGroup", action_args, 1,
1702 NULL, NULL, pwd_dir, True, NULL, NULL);
1708 initiating_view = (XtPointer) NULL;
1710 if(desktopWindow->restricted_directory != NULL)
1712 special_view = True;
1713 special_treeType = SINGLE_DIRECTORY;
1714 special_viewType = desktopWindow->view;
1715 special_orderType = desktopWindow->order;
1716 special_directionType = desktopWindow->direction;
1717 special_randomType = desktopWindow->positionEnabled;
1718 special_restricted = XtNewString(desktopWindow->restricted_directory);
1719 if(desktopWindow->title == NULL)
1720 special_title = NULL;
1722 special_title = XtNewString(desktopWindow->title);
1723 special_helpVol = XtNewString(desktopWindow->helpVol);
1724 if(desktopWindow->toolbox)
1725 dialog_data = GetNewView(desktopWindow->host,
1726 desktopWindow->dir_linked_to,
1727 desktopWindow->restricted_directory,
1730 dialog_data = GetNewView(desktopWindow->host,
1731 desktopWindow->dir_linked_to,
1736 dialog_data = GetNewView(desktopWindow->host,
1737 desktopWindow->dir_linked_to,
1741 if (openDirType == NEW && dialog_data == NULL)
1744 if( dialog_data == NULL )
1747 file_mgr_data = (FileMgrData *) dialog_data->data;
1748 directory_data = file_mgr_data->directory_set[0];
1750 for (j = 0; j < directory_data->file_count; j++)
1752 file_view_data = directory_data->file_view_data[j];
1754 if (file_view_data->filtered != True &&
1755 strcmp(desktopWindow->file_name,
1756 file_view_data->file_data->file_name) == 0)
1758 SelectFile (file_mgr_data, file_view_data);
1763 if(!directory_data->file_count)
1764 file_mgr_data->desktop_file = XtNewString(desktopWindow->file_name);
1766 file_mgr_data->desktop_file = NULL;
1768 file_mgr_rec = (FileMgrRec *)file_mgr_data->file_mgr_rec;
1770 /* Initially, all menubuttons are sensitive */
1771 file_mgr_rec->menuStates = (RENAME | MOVE | DUPLICATE | LINK | TRASH |
1772 MODIFY | CHANGEDIR | PREFERENCES | FILTER |
1773 FIND | CREATE_DIR | CREATE_FILE | SETTINGS |
1774 CLEAN_UP | MOVE_UP |
1775 HOME | CHANGE_DIR | TERMINAL);
1777 if (file_mgr_data->selected_file_count == 0)
1778 ActivateNoSelect(file_mgr_rec);
1779 else if (file_mgr_data->selected_file_count == 1)
1780 ActivateSingleSelect(file_mgr_rec,
1781 file_mgr_data->selection_list[0]->file_data->logical_type);
1783 ActivateMultipleSelect(file_mgr_rec);
1785 PositionFileView(file_view_data, file_mgr_data);
1792 XtPointer client_data,
1793 XtPointer call_data)
1795 DesktopRec *desktopWindow;
1796 FileViewData *file_view_data;
1798 desktopWindow = (DesktopRec *) client_data;
1799 file_view_data = desktopWindow->file_view_data;
1801 CreateNameChangeDialog(desktopWindow->iconGadget, file_view_data,
1802 (XtPointer)desktopWindow, DESKTOP);
1806 SelectDTFile (DesktopRec *desktopWindow)
1808 int selection_count;
1814 Screen *currentScreen;
1816 char *workspace_name;
1819 /* Get the current workspace */
1820 display = XtDisplay(desktop_data->desktopWindows[0]->shell);
1821 screen = XDefaultScreen(display);
1822 currentScreen = XScreenOfDisplay(display, screen);
1823 rootWindow = RootWindowOfScreen(currentScreen);
1825 if(DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent) == Success)
1827 workspace_name = XGetAtomName (display, pCurrent);
1828 CleanUpWSName(workspace_name);
1831 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
1833 for(i = 0; i < desktop_data->numWorkspaces; i++)
1835 if(strcmp(workspace_name, desktop_data->workspaceData[i]->name) == 0)
1837 desktop_data->workspaceData[i]->files_selected++;
1839 desktop_data->workspaceData[i]->selectedDTWindows =
1841 XtRealloc ((char *) desktop_data->workspaceData[i]->selectedDTWindows,
1842 sizeof(DesktopRec *) *(desktop_data->workspaceData[i]->files_selected + 2));
1844 /* Add to the front of the list */
1845 for (j = desktop_data->workspaceData[i]->files_selected; j > 0; j--)
1847 desktop_data->workspaceData[i]->selectedDTWindows[j] = desktop_data->workspaceData[i]->selectedDTWindows[j-1];
1849 desktop_data->workspaceData[i]->selectedDTWindows[0] = desktopWindow;
1853 SetToSelectColors (desktopWindow->iconGadget, desktopWindow->frame,
1855 XSync(display, False);
1860 DeselectAllDTFiles (
1861 WorkspaceRec *workspaceData)
1863 int selection_count;
1866 selection_count = workspaceData->files_selected;
1868 for (i = 0; i < selection_count; i++)
1870 SetToNormalColors (workspaceData->selectedDTWindows[i]->iconGadget,
1871 workspaceData->selectedDTWindows[i]->frame,
1872 workspaceData->selectedDTWindows[i]->frame,
1876 if (workspaceData->selectedDTWindows != NULL)
1878 XtFree ((char *) workspaceData->selectedDTWindows);
1879 workspaceData->selectedDTWindows = NULL;
1882 workspaceData->selectedDTWindows =
1883 (DesktopRec **) XtMalloc (sizeof (DesktopRec *));
1884 workspaceData->selectedDTWindows[0] = NULL;
1885 workspaceData->files_selected = 0;
1891 WorkspaceRec *workspaceData,
1892 DesktopRec *desktopWindow)
1894 int selection_count;
1899 selection_count = workspaceData->files_selected;
1900 workspaceData->files_selected--;
1902 for (i = 0; i < selection_count; i++)
1903 if (workspaceData->selectedDTWindows[i] == desktopWindow)
1906 for (j = i; j < selection_count - 1; j++)
1907 workspaceData->selectedDTWindows[j] =
1908 workspaceData->selectedDTWindows[j + 1];
1910 workspaceData->selectedDTWindows = (DesktopRec **)
1911 XtRealloc ((char *) workspaceData->selectedDTWindows,
1912 sizeof(DesktopRec *) * selection_count);
1913 workspaceData->selectedDTWindows[selection_count - 1] = NULL;
1915 SetToNormalColors (desktopWindow->iconGadget, desktopWindow->frame,
1916 desktopWindow->frame, LINK_FILE);
1923 XtPointer client_data,
1924 XtPointer call_data)
1926 DesktopRec *desktopWindow;
1930 desktopWindow = (DesktopRec *) client_data;
1932 XtSetArg (args[0], XmNuserData, (XtPointer) &command);
1933 XtGetValues (w, args, 1);
1935 RunDTCommand(command, desktopWindow, NULL);
1942 DesktopRec *desktopWindow,
1943 DtDndDropCallbackStruct *drop_parameters)
1946 if ((strcmp(openNewView, command) == 0) ||
1947 (strcmp(openInPlace, command) == 0))
1949 char *ltype = desktopWindow->file_view_data->file_data->logical_type;
1951 /* If the folder is locked, don't allow user to go into it */
1952 if( strcmp( ltype, LT_FOLDER_LOCK ) == 0 )
1954 char *tmpStr, *title, *msg;
1956 tmpStr = GETMESSAGE(9, 6, "Action Error");
1957 title = XtNewString(tmpStr);
1958 msg = (char *)XtMalloc(
1959 strlen( GETMESSAGE(30, 1, "Cannot read from %s") )
1960 + strlen( desktopWindow->file_view_data->file_data->file_name )
1962 sprintf( msg, GETMESSAGE(30, 1, "Cannot read from %s"),
1963 desktopWindow->file_view_data->file_data->file_name );
1964 _DtMessage(desktopWindow->shell,
1965 title, msg, NULL, HelpRequestCB );
1973 /* this statement applies to the case where a user traverses down the *
1974 * part of the directory tree containing the application manager *
1975 * directories or the trash directory */
1976 if( (strcmp(ltype, LT_AGROUP) == 0) ||
1977 (strstr(ltype, LT_AGROUP_SUBDIR)) ||
1978 (strcmp(ltype, LT_TRASH) == 0) )
1980 ProcessAction(command,
1981 desktopWindow->file_view_data,
1983 desktopWindow->host,
1984 desktopWindow->dir_linked_to,
1985 desktopWindow->restricted_directory,
1986 desktopWindow->shell);
1990 ProcessNewViewDT(desktopWindow);
1994 else if ((strcmp (command, "FILESYSTEM_MOVE") == 0) ||
1995 (strcmp (command, "FILESYSTEM_COPY") == 0) ||
1996 (strcmp (command, "FILESYSTEM_LINK") == 0))
1998 if (drop_parameters->dropData->protocol == DtDND_FILENAME_TRANSFER)
1999 ProcessMoveCopyLinkDT(command, desktopWindow, drop_parameters);
2001 ProcessBufferDropOnFolderDT(command, desktopWindow, drop_parameters);
2006 ProcessAction(command,
2007 desktopWindow->file_view_data,
2009 desktopWindow->host,
2010 desktopWindow->dir_linked_to,
2011 desktopWindow->restricted_directory,
2012 desktopWindow->shell);
2017 /************************************************************************
2021 ************************************************************************/
2025 DesktopRec *desktopWindow)
2027 char directory_name[MAX_PATH];
2029 sprintf(directory_name, "%s/%s", desktopWindow->dir_linked_to,
2030 desktopWindow->file_name);
2031 DtEliminateDots (directory_name);
2033 initiating_view = (XtPointer) NULL;
2034 if(desktopWindow->restricted_directory == NULL)
2036 GetNewView (desktopWindow->host, directory_name, NULL, NULL, 0);
2040 special_view = True;
2041 special_treeType = SINGLE_DIRECTORY;
2042 special_viewType = desktopWindow->view;
2043 special_orderType = desktopWindow->order;
2044 special_directionType = desktopWindow->direction;
2045 special_randomType = desktopWindow->positionEnabled;
2046 special_restricted = XtNewString(desktopWindow->restricted_directory);
2047 if(desktopWindow->title == NULL)
2048 special_title = NULL;
2050 special_title = XtNewString(desktopWindow->title);
2051 special_helpVol = XtNewString(desktopWindow->helpVol);
2052 if(desktopWindow->toolbox)
2053 GetNewView (desktopWindow->host, directory_name,
2054 desktopWindow->restricted_directory, NULL, 0);
2056 GetNewView (desktopWindow->host, directory_name, NULL, NULL, 0);
2061 /************************************************************************
2063 * ProcessMoveCopyLinkDT
2065 ************************************************************************/
2068 ProcessMoveCopyLinkDT (
2070 DesktopRec *desktopWindow,
2071 DtDndDropCallbackStruct *drop_parameters)
2073 unsigned int modifiers = 0;
2077 FileViewData * file_view_data;
2078 Boolean error = FALSE;
2080 /***************************************************/
2081 /* if no drop_parameters, there is nothing to move */
2082 /***************************************************/
2083 if (!drop_parameters)
2086 /***************************************************/
2087 /* extract file and host sets from drop parameters */
2088 /***************************************************/
2089 numFiles = drop_parameters->dropData->numItems;
2090 _DtSetDroppedFileInfo(drop_parameters, &file_set, &host_set);
2093 /******************************/
2094 /* set movement modifier mask */
2095 /******************************/
2096 if( (initiating_view != NULL) &&
2097 (((FileMgrData *)initiating_view)->toolbox) )
2099 /* if initiating_view is a toolbox, the transfer must be */
2101 modifiers = ControlMask;
2105 if (strcmp(command, "FILESYSTEM_COPY") == 0)
2106 modifiers = ControlMask;
2107 else if (strcmp(command, "FILESYSTEM_LINK") == 0)
2108 modifiers = ShiftMask;
2113 /*************************************************************/
2114 /* is the desktop object linked to any of the dropped files? */
2115 /*************************************************************/
2116 file_view_data = desktopWindow->file_view_data;
2117 if (file_view_data->file_data->physical_type == DtDIRECTORY)
2119 char dir_name[MAX_PATH];
2121 sprintf(dir_name, "%s/%s", desktopWindow->dir_linked_to,
2122 desktopWindow->file_name);
2123 DtEliminateDots(dir_name);
2125 for (i=0; i < numFiles; i++)
2127 if (strcmp(dir_name, file_set[i]) == 0 &&
2128 strcmp(desktopWindow->host, host_set[i]) == 0)
2134 GETMESSAGE(11,16, "A folder cannot be moved into itself.\n%s");
2135 msg = XtNewString(tmpStr);
2136 FileOperationError(file_view_data->widget, msg, dir_name);
2146 CheckMoveType((FileMgrData *)NULL, file_view_data,
2147 (DirectorySet *)(file_view_data->directory_set),
2148 desktopWindow, file_set, host_set, modifiers,
2149 numFiles, drop_parameters->x, drop_parameters->y, DESKTOP);
2151 /***************************/
2152 /* free file and host sets */
2153 /***************************/
2154 _DtFreeDroppedFileInfo(numFiles, file_set, host_set);
2158 /************************************************************************
2160 * ProcessBufferDropOnFolderDT
2162 ************************************************************************/
2165 ProcessBufferDropOnFolderDT (
2167 DesktopRec *desktopWindow,
2168 DtDndDropCallbackStruct *drop_parameters)
2171 char ** file_set = NULL;
2172 char ** host_set = NULL;
2173 BufferInfo *buffer_set = NULL;
2174 char directory[MAX_PATH];
2175 FileViewData *file_view_data = desktopWindow->file_view_data;
2178 /********************************************/
2179 /* if no drop_parameters, or invalid params */
2180 /* then disallow the drop */
2181 /********************************************/
2182 if (!drop_parameters)
2185 /* if dropped on a folder icon and file_view_data */
2186 /* is NULL, disallow the drop */
2187 if (file_view_data == NULL)
2191 /***************************************************/
2192 /* extract file and host sets from drop parameters */
2193 /***************************************************/
2194 num_of_buffers = drop_parameters->dropData->numItems;
2196 /* Allocate memory for file and buffer structures */
2197 file_set = (char **)XtMalloc(sizeof(char **) * num_of_buffers );
2198 host_set = (char **)XtMalloc(sizeof(char **) * num_of_buffers);
2199 buffer_set = (BufferInfo * )XtMalloc (sizeof (BufferInfo) * num_of_buffers);
2201 _DtSetDroppedBufferInfo(file_set, buffer_set, host_set, drop_parameters);
2207 DPRINTF(("ProcessBufferDropOnFolderDT...Buffers dropped on Folder icon %s\n",
2208 file_view_data->file_data->file_name));
2210 sprintf(directory,"%s/%s",
2211 ((DirectorySet *)file_view_data->directory_set)->name,
2212 file_view_data->file_data->file_name);
2213 DtEliminateDots(directory);
2215 DPRINTF (("Copying buffer to %s\n", directory));
2216 MakeFilesFromBuffersDT(file_view_data, directory, file_set, host_set,
2217 buffer_set, num_of_buffers,
2218 desktopWindow, NULL, NULL);
2221 /******************************/
2222 /* free file_set + buffer_set */
2223 /******************************/
2224 _DtFreeDroppedBufferInfo (file_set, buffer_set, host_set, num_of_buffers);
2235 DesktopRec *desktopWindow;
2236 char tmp_filename[MAX_PATH];
2237 Boolean onDesktop = False;
2238 Boolean Link = False;
2239 char *filesOnDesktop;
2240 char *filename1,*filename2;
2241 int newLen, stat_result;
2242 Tt_status tt_status;
2243 static Tt_message dummy_msg = NULL;
2244 struct stat stat_buf;
2248 if(dummy_msg == NULL)
2249 dummy_msg = tt_message_create();
2252 for(i = 0; i < file_count; i++)
2254 /* Let's check to see if file coming in is a link, if it is let's
2255 * test it instead of where it is linked to.
2257 stat_result = lstat (file_set[i], &stat_buf);
2258 if (stat_result == 0 && (stat_buf.st_mode & S_IFMT) == S_IFLNK)
2260 filename1 = XtNewString(file_set[i]);
2265 tt_status = tt_message_file_set(dummy_msg, file_set[i]);
2266 filename1 = tt_message_file(dummy_msg);
2269 for(j = 0; j < desktop_data->numIconsUsed; j++)
2271 desktopWindow = desktop_data->desktopWindows[j];
2274 if( strcmp( desktopWindow->dir_linked_to, "/" ) != 0 )
2275 sprintf(tmp_filename, "%s/%s", desktopWindow->dir_linked_to,
2276 desktopWindow->file_view_data->file_data->file_name);
2278 sprintf(tmp_filename, "%s%s", desktopWindow->dir_linked_to,
2279 desktopWindow->file_view_data->file_data->file_name);
2281 strcpy( tmp_filename, desktopWindow->dir_linked_to );
2283 filename2 = XtNewString(tmp_filename);
2286 tt_status = tt_message_file_set (dummy_msg, tmp_filename);
2287 filename2 = tt_message_file(dummy_msg);
2289 filename2 = (char *)XtRealloc(filename2, strlen(filename2)
2290 + strlen(desktopWindow->file_view_data->file_data->file_name)
2292 strcat(filename2, "/");
2293 strcat(filename2, desktopWindow->file_view_data->file_data->file_name);
2295 if( strcmp( filename1, filename2 ) == 0 )
2297 *IsToolBox = desktopWindow->toolbox;
2298 if(onDesktop == False)
2300 filesOnDesktop = (char *)XtMalloc(strlen(filename1) + 10);
2301 sprintf( filesOnDesktop, "\n %s\n", filename1);
2306 newLen = strlen(filesOnDesktop) + strlen(filename1) + 6;
2307 filesOnDesktop = (char *)XtRealloc(filesOnDesktop, newLen);
2308 sprintf(filesOnDesktop, "%s %s\n", filesOnDesktop, filename1);
2325 return(filesOnDesktop);
2332 * This function handles button 1 selection in a desktop icon.
2336 ProcessDTSelection (
2337 DesktopRec * desktopRec,
2338 XButtonEvent * event)
2342 Screen *currentScreen;
2344 char *workspace_name;
2345 Boolean toggle_select = False;
2348 if (event->state & ControlMask)
2349 toggle_select = True;
2351 screen = XDefaultScreen(XtDisplay(desktopRec->shell));
2352 currentScreen = XScreenOfDisplay(XtDisplay(desktopRec->shell), screen);
2353 rootWindow = RootWindowOfScreen(currentScreen);
2355 if(DtWsmGetCurrentWorkspace(XtDisplay(desktopRec->shell), rootWindow,
2356 &pCurrent) == Success)
2358 workspace_name = XGetAtomName (XtDisplay(desktopRec->shell), pCurrent);
2359 CleanUpWSName(workspace_name);
2362 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
2364 for(i = 0; i < desktop_data->numWorkspaces; i++)
2366 if(strcmp(workspace_name, desktop_data->workspaceData[i]->name) == 0)
2368 if(toggle_select == False)
2369 DeselectAllDTFiles(desktop_data->workspaceData[i]);
2372 for(j = 0;j < desktop_data->workspaceData[i]->files_selected; j++)
2374 if(desktop_data->workspaceData[i]->selectedDTWindows[j] ==
2377 DeselectDTFile(desktop_data->workspaceData[i], desktopRec);
2383 desktop_data->workspaceData[i]->files_selected++;
2385 desktop_data->workspaceData[i]->selectedDTWindows =
2386 (DesktopRec **) XtRealloc ((char *)
2387 desktop_data->workspaceData[i]->selectedDTWindows,
2388 sizeof(DesktopRec *) *
2389 (desktop_data->workspaceData[i]->files_selected + 2));
2391 /* Add to the front of the list */
2392 for (j = desktop_data->workspaceData[i]->files_selected; j > 0; j--)
2394 desktop_data->workspaceData[i]->selectedDTWindows[j] =
2395 desktop_data->workspaceData[i]->selectedDTWindows[j-1];
2398 desktop_data->workspaceData[i]->selectedDTWindows[0] = desktopRec;
2402 XtFree(workspace_name);
2404 SetToSelectColors (desktopRec->iconGadget, desktopRec->frame, LINK_FILE);
2409 UnpostDTTextField (void)
2412 DesktopRec *desktopWindow;
2415 for(i = 0; i < desktop_data->numIconsUsed; i++)
2417 desktopWindow = desktop_data->desktopWindows[i];
2418 if(desktopWindow->text)
2420 XtUnmanageChild(desktopWindow->text);
2422 GenerateShape(desktopWindow);
2424 XtDestroyWidget(desktopWindow->text);
2425 desktopWindow->text = NULL;
2434 DesktopRec * desktopRec,
2435 FileViewData * fileViewData)
2439 Screen *currentScreen;
2441 char *workspace_name;
2444 screen = XDefaultScreen(XtDisplay(desktopRec->shell));
2445 currentScreen = XScreenOfDisplay(XtDisplay(desktopRec->shell), screen);
2446 rootWindow = RootWindowOfScreen(currentScreen);
2448 if(DtWsmGetCurrentWorkspace(XtDisplay(desktopRec->shell), rootWindow,
2449 &pCurrent) == Success)
2451 workspace_name = XGetAtomName (XtDisplay(desktopRec->shell), pCurrent);
2452 CleanUpWSName(workspace_name);
2455 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
2458 for(i = 0; i < desktop_data->numWorkspaces; i++)
2460 if(strcmp(workspace_name, desktop_data->workspaceData[i]->name) == 0)
2462 for(j = 0;j < desktop_data->workspaceData[i]->files_selected; j++)
2464 if(desktop_data->workspaceData[i]->selectedDTWindows[j] ==
2467 XtFree(workspace_name);
2471 XtFree(workspace_name);
2475 XtFree(workspace_name);
2479 /***********************************************************************
2481 * RegisterPanelInGrid - Registers the Dtwm planel in grid
2483 * Arguments: workspace - workspace number
2484 * displayWidth - width of worspace screen
2485 * displayHaight - height of workspace screen
2487 ************************************************************************/
2489 void RegisterPanelInGrid(int workspace, int displayWidth, int displayHeight )
2491 /* want to take out space where the FP lays ... Note this only for the
2492 default size of the FP. Right now there is no dynamic way of registering
2493 the FP no matter what size it is */
2494 #define EXPECTED_PANEL_WIDTH 1105
2495 #define EXPECTED_PANEL_HEIGHT 83
2496 RegisterInGrid(EXPECTED_PANEL_WIDTH, EXPECTED_PANEL_HEIGHT,
2497 /* the panel is expected to be horizontally centered */
2498 (displayWidth > EXPECTED_PANEL_WIDTH) ?
2499 (displayWidth - EXPECTED_PANEL_WIDTH) / 2 : 0,
2500 /* the panel is expected to be at the bottom of the screen */
2501 (displayHeight > EXPECTED_PANEL_HEIGHT) ?
2502 (displayHeight - EXPECTED_PANEL_HEIGHT) : displayHeight,
2506 /***********************************************************************
2508 * InitializeDesktopGrid
2510 ************************************************************************/
2513 InitializeDesktopGrid( int displayWidth, int displayHeight)
2517 desktop_grid_size = desktop_data->numWorkspaces * numColumns * numRows;
2518 desktop_grid = (Boolean *)XtCalloc(1, desktop_grid_size);
2520 for(i = 1; i <= desktop_data->numWorkspaces; i++)
2522 RegisterPanelInGrid(i, displayWidth, displayHeight);
2536 int rowHeight, columnWidth;
2537 int desktop_grid_index;
2540 if(desktopIconType == LARGE)
2542 row = rY / PIXELS_PER_ROW_LARGE;
2543 column = rX / PIXELS_PER_COLUMN_LARGE;
2544 rowHeight = (rY + height) / PIXELS_PER_ROW_LARGE;
2545 columnWidth = (rX + width) / PIXELS_PER_COLUMN_LARGE;
2549 row = rY / PIXELS_PER_ROW_SMALL;
2550 column = rX / PIXELS_PER_COLUMN_SMALL;
2551 rowHeight = (rY + height) / PIXELS_PER_ROW_SMALL;
2552 columnWidth = (rX + width) / PIXELS_PER_COLUMN_SMALL;
2555 if (columnWidth >= numColumns)
2557 columnWidth = numColumns - 1;
2559 if (rowHeight >= numRows)
2561 rowHeight = numRows - 1;
2564 desktop_grid_index = (workspace - 1) * numColumns * numRows;
2566 for (i = (column > 0) ? column : 0; i <= columnWidth ; i++)
2568 for (j = (row > 0) ? row : 0; j <= rowHeight ; j++)
2572 /* increase count of objects at given cell */
2573 desktop_grid[ desktop_grid_index + (i * numRows) + j] ++;
2577 /* decrease count of objects at given cell */
2578 if (desktop_grid[ desktop_grid_index + (i * numRows) + j] > 0)
2580 desktop_grid[ desktop_grid_index + (i * numRows) + j] --;
2592 XtPointer client_data,
2593 XtPointer call_data)
2596 FileMgrRec *file_mgr_rec;
2597 DialogData * dialog_data;
2598 FileMgrData * file_mgr_data;
2599 FileViewData * file_view_data;
2605 XmUpdateDisplay (w);
2607 if(client_data != 0)
2610 mbar = XmGetPostedFromWidget(XtParent(w));
2612 XtSetArg(args[0], XmNuserData, &file_mgr_rec);
2613 XtGetValues(mbar, args, 1);
2615 /* Ignore accelerators when we're insensitive */
2616 if(client_data == NULL)
2617 if ((file_mgr_rec->menuStates & PUT_ON_DESKTOP) == 0)
2620 /* Ignore accelerators received after we're unposted */
2621 if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
2623 file_mgr_data = (FileMgrData *) dialog_data->data;
2625 /* get the file_view_data object from which the menu was invoked */
2626 if (client_data == NULL)
2627 file_view_data = NULL;
2630 file_view_data = file_mgr_data->popup_menu_icon;
2631 if (!file_mgr_data->selected_file_count && file_view_data == NULL)
2632 /* the object has gone away (probably deleted) */
2635 file_mgr_data->popup_menu_icon = NULL; /* Reset it, we don't need it */
2637 /* No need to see the selection_list if file_view_data is NULL */
2642 for(i = 0; i < file_mgr_data->selected_file_count; i++)
2644 if(file_mgr_data->selection_list[i] == file_view_data)
2646 file_view_data = NULL;
2653 EndIndex = desktop_data->numIconsUsed;
2654 if(file_view_data == NULL)
2656 for (i = 0; i < file_mgr_data->selected_file_count; i++)
2658 if (file_mgr_data->toolbox)
2662 path = _DtGetSelectedFilePath(file_mgr_data->selection_list[i]);
2663 path = _DtResolveAppManPath(path,
2664 file_mgr_data->restricted_directory);
2665 ptr = strrchr(path, '/');
2668 file_name = ptr + 1;
2670 SetupDesktopWindow (XtDisplay(w), file_mgr_data, file_mgr_rec,
2671 file_name, file_mgr_data->host,
2673 -1, -1, NULL,EndIndex);
2681 directory = ((DirectorySet *)
2682 (file_mgr_data->selection_list[i]->directory_set))->name;
2683 file_name = file_mgr_data->selection_list[i]->file_data->file_name;
2685 SetupDesktopWindow (XtDisplay(w), file_mgr_data, file_mgr_rec,
2686 file_name, file_mgr_data->host,
2688 -1, -1, NULL,EndIndex);
2694 if (file_mgr_data->toolbox)
2698 path = _DtGetSelectedFilePath(file_view_data);
2699 path = _DtResolveAppManPath(path, file_mgr_data->restricted_directory);
2700 ptr = strrchr(path, '/');
2703 file_name = ptr + 1;
2705 SetupDesktopWindow (XtDisplay(w), file_mgr_data, file_mgr_rec,
2706 file_name, file_mgr_data->host,
2708 -1, -1, NULL,EndIndex);
2716 directory = ((DirectorySet *)(file_view_data->directory_set))->name;
2717 file_name = file_view_data->file_data->file_name;
2718 SetupDesktopWindow (XtDisplay(w), file_mgr_data, file_mgr_rec,
2719 file_name, file_mgr_data->host,
2720 file_mgr_data->current_directory, -1, -1, NULL,EndIndex);
2727 CalculateRootCoordinates (
2734 int row = 0, column = 0;
2735 Boolean rDirection = False, cDirection = False, whichFirst = False;
2736 Boolean error = False;
2737 int numGridsR, numGridsC, i, j;
2739 if(desktopIconType == LARGE)
2741 numGridsC = (width / PIXELS_PER_COLUMN_LARGE) + 1;
2742 numGridsR = (height / PIXELS_PER_ROW_LARGE) + 1;
2746 numGridsC = (width / PIXELS_PER_COLUMN_SMALL) + 1;
2747 numGridsR = (height / PIXELS_PER_ROW_SMALL) + 1;
2751 * set up where to get the first grid spot and which directions to
2752 * search for one until one is found. For directions True means in the
2753 * positive direction. If whichFirst is True then row is moved first.
2755 switch( desktopPlacement )
2757 case (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_TOP_SECONDARY):
2758 case (OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_LEFT_SECONDARY):
2763 if(desktopPlacement & OBJ_PLACE_LEFT_PRIMARY)
2769 case (OBJ_PLACE_LEFT_PRIMARY | OBJ_PLACE_BOTTOM_SECONDARY):
2770 case (OBJ_PLACE_BOTTOM_PRIMARY | OBJ_PLACE_LEFT_SECONDARY):
2771 row = numRows - numGridsR;
2775 if(desktopPlacement & OBJ_PLACE_LEFT_PRIMARY)
2781 case (OBJ_PLACE_RIGHT_PRIMARY | OBJ_PLACE_TOP_SECONDARY):
2782 case (OBJ_PLACE_TOP_PRIMARY | OBJ_PLACE_RIGHT_SECONDARY):
2784 column = numColumns - numGridsC;
2787 if(desktopPlacement & OBJ_PLACE_RIGHT_PRIMARY)
2793 case (OBJ_PLACE_RIGHT_PRIMARY | OBJ_PLACE_BOTTOM_SECONDARY):
2794 case (OBJ_PLACE_BOTTOM_PRIMARY | OBJ_PLACE_RIGHT_SECONDARY):
2795 row = numRows - numGridsR;
2796 column = numColumns - numGridsC;
2799 if(desktopPlacement & OBJ_PLACE_RIGHT_PRIMARY)
2808 * Given the information which is set up above, find the first availible
2809 * spot in the grid where the Desktop Icon can be placed. NOTE: if the
2810 * Icon turns out to be bigger then the size of the grid, this may have
2811 * to be recalculated. But we won't know the size until we do a realize
2813 ws_num = ((ws_num - 1) * numColumns * numRows);
2816 if(desktop_grid[ws_num + (column * numRows) + row] == 0)
2818 if(numGridsR == 1 && numGridsC == 1)
2820 if(desktopIconType == LARGE)
2822 *root_x = column * PIXELS_PER_COLUMN_LARGE;
2823 *root_y = row * PIXELS_PER_ROW_LARGE;
2827 *root_x = column * PIXELS_PER_COLUMN_SMALL;
2828 *root_y = row * PIXELS_PER_ROW_SMALL;
2833 for(i = 0; i < numGridsR; i++)
2835 for(j = 0; j < numGridsC; j++)
2837 if(desktop_grid[ws_num + ((column + j) * numRows) + (row + i)] > 0)
2848 if(desktopIconType == LARGE)
2850 *root_x = column * PIXELS_PER_COLUMN_LARGE;
2851 *root_y = row * PIXELS_PER_ROW_LARGE;
2855 *root_x = column * PIXELS_PER_COLUMN_SMALL;
2856 *root_y = row * PIXELS_PER_ROW_SMALL;
2865 * area taken so let get the next grid depending on rDirection,
2866 * cDirection and whchis is first
2879 if(column + numGridsC - 1 >= numColumns)
2905 if(column + numGridsC - 1 >= numColumns)
2928 if(column >= numColumns)
2934 if( row + numGridsR - 1 >= numRows)
2956 column = numColumns - 1;
2960 if( row + numGridsR - 1>= numRows)
2983 SetupDesktopWindow (
2985 FileMgrData *file_mgr_data,
2986 FileMgrRec *file_mgr_rec,
2996 char title_buf[256];
2997 Boolean restricted_top;
2998 DesktopRec *desktopWindow;
3003 Screen *currentScreen;
3005 char * workspace_name;
3006 char *ptr, * directory_name;
3007 Tt_status tt_status;
3010 DPRINTF(("SetupDesktopWindow: %s\n", file_name));
3013 * Get the host, directory, and file name for the real file
3016 /* get the full path and eliminate dots */
3017 directory_name = ResolveLocalPathName(hst_name,
3022 if( TT_OK != tt_status )
3023 { /* Should pop up an error dialog.
3028 DtEliminateDots(directory_name);
3030 /* check if this is a restricted directory */
3031 restricted_top = file_mgr_data &&
3032 file_mgr_data->restricted_directory &&
3033 strcmp(directory_name,
3034 file_mgr_data->restricted_directory) == 0;
3036 /* separate the rest of the path into directory and file name */
3037 ptr = strrchr(directory_name, '/');
3038 if (*(ptr + 1) != '\0')
3047 * Get the window title
3049 if (restricted_top && file_mgr_data->title)
3050 title = file_mgr_data->title;
3051 else if (strcmp(file_name, ".") != 0)
3055 sprintf(title_buf, "%s:%s", home_host_name, root_title);
3060 screen = XDefaultScreen(display);
3061 currentScreen = XScreenOfDisplay(display, screen);
3062 rootWindow = RootWindowOfScreen(currentScreen);
3064 /* want to get the current workspace so that the window maps
3065 to the right workspace */
3066 if (DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent) == Success)
3068 workspace_name = XGetAtomName (display, pCurrent);
3069 CleanUpWSName(workspace_name);
3072 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
3074 desktop_data->event.type = INVALID_TYPE;
3077 /* determine the workspace number */
3078 for(j = 0; j < desktop_data->numWorkspaces; j++)
3080 if(strcmp(workspace_name, desktop_data->workspaceData[j]->name) == 0)
3082 ws_num = desktop_data->workspaceData[j]->number;
3087 /* if the workspace number is still -1, it means there are new
3088 workspaces, so lets go initialize them */
3090 ws_num = InitializeNewWorkspaces(display, workspace_name);
3093 /* loop through the current objects on the desktop and see if one
3094 with the same name is already in this workspace. If it is,
3095 don't map the window and put out a warning message telling
3097 for(i = 0; i < EndIndex; i++)
3099 if (strcmp(desktop_data->desktopWindows[i]->title, title) == 0 &&
3100 strcmp(desktop_data->desktopWindows[i]->workspace_name,
3101 workspace_name) == 0)
3106 tmpStr = (GETMESSAGE(28,11, "An object named:\n\n %s\n\nalready exists on the backdrop in this Workspace.\nYou cannot put another object with the same name on the Workspace.\nTo have both objects on the Workspace, rename one of them."));
3107 msg = XtNewString(tmpStr);
3108 FileOperationError(file_mgr_rec->main, msg, title);
3111 XtFree(workspace_name);
3112 workspace_name = NULL;
3113 XtFree(directory_name);
3114 directory_name = NULL;
3119 /* get the next available cached iconWindow and use it to map
3120 this topLevelWindow */
3121 desktopWindow = desktop_data->desktopWindows[desktop_data->numIconsUsed];
3122 desktop_data->numIconsUsed++;
3123 desktop_data->numCachedIcons--;
3125 /* store some of the data needed for the Desktop object */
3126 desktopWindow->host = XtNewString(home_host_name);
3127 if( *directory_name == 0x0 )
3128 desktopWindow->dir_linked_to = XtNewString("/");
3130 desktopWindow->dir_linked_to = XtNewString(directory_name);
3131 desktopWindow->file_name = XtNewString(file_name);
3132 desktopWindow->title = XtNewString(title);
3134 desktopWindow->workspace_name = workspace_name;
3135 desktopWindow->workspace_num = ws_num;
3137 if (file_mgr_data != NULL)
3139 if (file_mgr_data->restricted_directory == NULL)
3140 desktopWindow->restricted_directory = NULL;
3142 desktopWindow->restricted_directory =
3143 XtNewString(file_mgr_data->restricted_directory);
3145 if (file_mgr_data->helpVol == NULL)
3146 desktopWindow->helpVol = NULL;
3148 desktopWindow->helpVol = XtNewString(file_mgr_data->helpVol);
3150 desktopWindow->view = file_mgr_data->view;
3151 desktopWindow->order = file_mgr_data->order;
3152 desktopWindow->direction = file_mgr_data->direction;
3153 desktopWindow->positionEnabled = file_mgr_data->positionEnabled;
3154 desktopWindow->toolbox = file_mgr_data->toolbox;
3156 else /* there is no file_mgr_data associated with this file, so it
3157 must be "Put On Desktop" but not from a File Manager View
3160 /* store the directory the file is linked to */
3161 /* need to determine the toolbox dir !!!*/
3163 desktopWindow->restricted_directory = NULL;
3165 desktopWindow->restricted_directory = XtNewString(type);
3166 desktopWindow->helpVol = NULL;
3167 desktopWindow->toolbox = False;
3168 desktopWindow->view = UNSET_VALUE;
3169 desktopWindow->order = UNSET_VALUE;
3170 desktopWindow->direction = UNSET_VALUE;
3171 desktopWindow->positionEnabled = UNSET_VALUE;
3174 desktopWindow->file_view_data = BuildNewOrderlist(
3175 NULL /* @@@ use cached info if possible! */,
3176 desktopWindow->iconGadget,
3178 desktopWindow->dir_linked_to,
3180 desktopWindow->registered,
3181 desktopWindow->toolbox);
3183 MakeDesktopWindow(desktopWindow, root_x, root_y);
3184 desktopWindow->registered = desktopWindow->file_view_data->registered;
3186 /* go cache some more windows if there isn't enough cached */
3187 if (desktop_data->numCachedIcons < 5)
3188 InitializeDesktopWindows(5, display);
3190 /* go save the current state of the desktop */
3191 SaveDesktopInfo(NORMAL_RESTORE);
3193 XtFree(directory_name);
3194 directory_name = NULL;
3196 if(openDirType == NEW)
3197 ForceMyIconOpen(desktopWindow->host, NULL);
3199 if( checkBrokenLink != 0 && checkBrokenLinkTimerId == 0 )
3201 checkBrokenLinkTimerId = XtAppAddTimeOut(
3202 XtWidgetToApplicationContext( toplevel ),
3203 checkBrokenLink * 1000,
3204 TimerEventBrokenLinks,
3216 DesktopRec *desktop;
3217 DesktopRec *tmpDesktop;
3219 new_size = (desktop_data->numCachedIcons + desktop_data->numIconsUsed) -
3221 for(i = desktop_data->numCachedIcons + desktop_data->numIconsUsed;
3224 desktop = desktop_data->desktopWindows[i - 1];
3225 if(desktop == sacredDesktop)
3227 desktop = desktop_data->desktopWindows[desktop_data->numIconsUsed];
3228 desktop_data->desktopWindows[desktop_data->numIconsUsed] =
3231 XtDestroyWidget(desktop->shell);
3232 XtFree((char *)desktop);
3235 desktop_data->numCachedIcons--;
3237 desktop_data->desktopWindows =
3238 (DesktopRec ** )XtRealloc((char *)desktop_data->desktopWindows,
3239 sizeof(DesktopRec *) * new_size);
3246 Widget popupBtns[15];
3247 XmString label_string;
3256 * IF YOU ADD ANY NEW MENU ITEMS TO THE DESKTOP POPUP MENU, THEN YOU
3257 * MUST ALSO ADD A CHECK FOR IT IN DTHelpRequestCB() [in HelpCB.c],
3258 * SINCE THAT FUNCTION HAS A SPECIAL CHECK FOR EACH MENU BUTTON!
3262 XtSetArg(args[n], XmNwhichButton, bMenuButton); n++;
3263 desktop_data->popupMenu->popup =
3264 XmCreatePopupMenu(drawA, "DTPopup", args, n);
3266 XtAddCallback (desktop_data->popupMenu->popup, XmNmapCallback,
3267 popupMenu, (XtPointer) NULL);
3268 XtAddCallback (desktop_data->popupMenu->popup, XmNhelpCallback,
3269 (XtCallbackProc)DTHelpRequestCB,
3270 HELP_DESKTOP_POPUP_MENU_STR);
3272 label_string = XmStringCreateLocalized((GETMESSAGE(28,4, "Workspace Object")));
3273 XtSetArg (args[0], XmNlabelString, label_string);
3274 popupBtns[0] = (Widget) XmCreateLabelGadget(desktop_data->popupMenu->popup,
3276 popupBtns[1] = XmCreateSeparatorGadget(desktop_data->popupMenu->popup,
3278 popupBtns[2] = XmCreateSeparatorGadget(desktop_data->popupMenu->popup,
3280 XmStringFree (label_string);
3282 label_string = XmStringCreateLocalized((GETMESSAGE(28,5, "Remove From Workspace")));
3283 XtSetArg (args[0], XmNlabelString, label_string);
3284 mnemonic = ((char *)GETMESSAGE(28, 6, "R"));
3285 XtSetArg (args[1], XmNmnemonic, mnemonic[0]);
3286 desktop_data->popupMenu->removeDT = popupBtns[3] =
3287 XmCreatePushButtonGadget (desktop_data->popupMenu->popup,
3289 XmStringFree (label_string);
3290 XtAddCallback (desktop_data->popupMenu->removeDT, XmNhelpCallback,
3291 (XtCallbackProc)DTHelpRequestCB,
3292 HELP_DESKTOP_POPUP_MENU_STR);
3295 label_string = XmStringCreateLocalized ((GETMESSAGE(28,7, "Open Parent Folder")));
3296 XtSetArg (args[0], XmNlabelString, label_string);
3297 mnemonic = ((char *)GETMESSAGE(28, 8, "O"));
3298 XtSetArg (args[1], XmNmnemonic, mnemonic[0]);
3299 desktop_data->popupMenu->openFolder = popupBtns[4] =
3300 XmCreatePushButtonGadget (desktop_data->popupMenu->popup,
3302 XmStringFree (label_string);
3303 XtAddCallback (desktop_data->popupMenu->openFolder, XmNhelpCallback,
3304 (XtCallbackProc)DTHelpRequestCB,
3305 HELP_DESKTOP_POPUP_MENU_STR);
3307 label_string = XmStringCreateLocalized ((GETMESSAGE(20,128, "Rename")));
3308 XtSetArg (args[0], XmNlabelString, label_string);
3309 mnemonic = ((char *)GETMESSAGE(20, 129, "n"));
3310 XtSetArg (args[1], XmNmnemonic, mnemonic[0]);
3311 desktop_data->popupMenu->rename = popupBtns[5] =
3312 XmCreatePushButtonGadget (desktop_data->popupMenu->popup,
3314 XmStringFree (label_string);
3315 XtAddCallback (desktop_data->popupMenu->rename, XmNhelpCallback,
3316 (XtCallbackProc)DTHelpRequestCB,
3317 HELP_DESKTOP_POPUP_MENU_STR);
3319 popupBtns[6] = XmCreateSeparatorGadget(desktop_data->popupMenu->popup,
3322 XtManageChildren(popupBtns, 7);
3328 XtPointer client_data,
3329 XtPointer call_data)
3332 Boolean found = False;
3334 XmAnyCallbackStruct * callback;
3337 callback = (XmAnyCallbackStruct *) call_data;
3338 event = (XEvent *) callback->event;
3340 shell = XmGetPostedFromWidget(w);
3341 for(i = 0; i < desktop_data->numIconsUsed; i++)
3343 if(desktop_data->desktopWindows[i]->shell == shell ||
3344 desktop_data->desktopWindows[i]->drawA == shell)
3352 DrawAInput(desktop_data->popupMenu->popup,
3353 (XtPointer)desktop_data->desktopWindows[i],
3354 event, (Boolean *)NULL);
3362 DesktopRec *desktopWindow)
3364 Dimension shadowThickness, highlightThickness;
3365 Dimension pixmapWidth, pixmapHeight;
3366 Dimension stringWidth, stringHeight;
3368 unsigned char flags;
3369 unsigned char pixmapPosition;
3370 unsigned char alignment;
3377 XtSetArg (args[0], XmNshadowThickness, &shadowThickness);
3378 XtSetArg (args[1], XmNhighlightThickness, &highlightThickness);
3379 XtSetArg (args[2], XmNpixmapPosition, &pixmapPosition);
3380 XtSetArg (args[3], XmNalignment, &alignment);
3381 XtGetValues (desktopWindow->iconGadget, args, 4);
3383 g = (DtIconGadget)desktopWindow->iconGadget;
3384 pixmapWidth = g->icon.pixmap_width;
3385 pixmapHeight = g->icon.pixmap_height;
3386 stringWidth = g->icon.string_width;
3387 stringHeight = g->icon.cache->string_height;
3389 _DtIconGetIconRects((DtIconGadget)desktopWindow->iconGadget,
3390 &flags, &rect[0], &rect[1]);
3392 switch ((int) pixmapPosition)
3395 if(alignment != XmALIGNMENT_CENTER)
3400 rect[0].width += 2*shadowThickness;
3401 rect[0].height += 2*shadowThickness;
3406 rect[1].width += 2*shadowThickness;
3407 rect[1].height += 2*shadowThickness;
3409 if(rect[0].width > rect[1].width)
3410 rect[1].width = rect[0].width;
3412 else /* is XmALIGNMENT_CENTER */
3414 if(stringWidth > pixmapWidth)
3419 rect[0].width += 2*shadowThickness;
3420 rect[0].height += 2*shadowThickness;
3425 rect[1].width += 2*shadowThickness;
3426 rect[1].height += 2*shadowThickness;
3428 if(rect[0].width > rect[1].width)
3429 rect[1].width = rect[0].width;
3436 rect[0].width += 2*shadowThickness;
3437 rect[0].height += 2*shadowThickness;
3440 rect[1].x = rect[0].x;
3442 rect[1].width = rect[0].width;
3443 rect[1].height += 2*shadowThickness;
3449 if((Dimension)(stringHeight+5) >= pixmapHeight)
3451 if(pixmapHeight == 0)
3461 rect[1].width += 2*shadowThickness;
3462 rect[1].height += 2*shadowThickness;
3467 rect[1].y = rect[0].y + 1;
3469 rect[1].width += 2*shadowThickness;
3470 if(pixmapHeight > stringHeight)
3471 rect[1].height += 2*shadowThickness +
3472 (pixmapHeight - stringHeight);
3474 rect[1].height += 2*shadowThickness;
3478 rect[0].y = rect[1].y;
3479 rect[0].width += shadowThickness;
3480 rect[0].height = rect[1].height;
3488 rect[0].width += 2*shadowThickness;
3489 rect[0].height += 2*shadowThickness;
3494 rect[1].width += 2*shadowThickness;
3495 rect[1].height += 2*shadowThickness;
3500 XShapeCombineRectangles(XtDisplay(desktopWindow->shell),
3501 XtWindow(desktopWindow->shell),
3502 ShapeBounding, 0, 0, &rect[0], 2,
3503 ShapeSet, Unsorted);
3511 struct stat statBuf;
3515 Screen *currentScreen;
3516 int i, screen, result;
3519 /* Build the 'Desktop' directory */
3520 desktop_dir = XtMalloc(strlen(users_home_dir) + strlen(DESKTOP_DIR) + 2);
3521 sprintf(desktop_dir, "%s%s", users_home_dir, DESKTOP_DIR);
3522 if (stat(desktop_dir, &statBuf) < 0)
3523 mkdir(desktop_dir, S_IRUSR|S_IWUSR|S_IXUSR);
3525 /* Now build the list of workspaces */
3526 screen = XDefaultScreen(display);
3527 currentScreen = XScreenOfDisplay(display, screen);
3528 rootWindow = RootWindowOfScreen(currentScreen);
3530 retry = retryLoadDesktopInfo;
3536 result = DtWsmGetWorkspaceList (display, rootWindow, &paWS, &numInfo);
3537 if (result == Success)
3539 desktop_data->numWorkspaces = (int)numInfo;
3544 desktop_data->numWorkspaces = 1;
3550 desktop_data->workspaceData = (WorkspaceRec **)
3551 XtMalloc(sizeof(WorkspaceRec *) * desktop_data->numWorkspaces);
3552 for (i=0; i < desktop_data->numWorkspaces; i++)
3554 WorkspaceRec *workspaceData;
3556 workspaceData = (WorkspaceRec *)XtMalloc(sizeof(WorkspaceRec));
3558 if(result == Success)
3560 workspaceData->name = XGetAtomName (display, paWS[i]);
3561 CleanUpWSName(workspaceData->name);
3564 workspaceData->name = XtNewString("One");
3565 workspaceData->number = i + 1;
3566 workspaceData->files_selected = 0;
3567 workspaceData->selectedDTWindows =
3568 (DesktopRec **) XtMalloc (sizeof (DesktopRec *));
3569 workspaceData->selectedDTWindows[0] = NULL;
3570 workspaceData->primaryHelpDialog = NULL;
3571 workspaceData->secondaryHelpDialogCount = 0;
3572 workspaceData->secondaryHelpDialogList = NULL;
3574 desktop_data->workspaceData[i] = workspaceData;
3577 if (result == Success)
3579 XFree ((char *) paWS);
3585 InitializeNewWorkspaces (
3587 char *workspaceName)
3589 struct stat statBuf;
3593 Screen *currentScreen;
3594 int i, j, k, screen;
3597 /* Now build the directories for each desktop (i.e. workspace) */
3598 screen = XDefaultScreen(display);
3599 currentScreen = XScreenOfDisplay(display, screen);
3600 rootWindow = RootWindowOfScreen(currentScreen);
3602 if (DtWsmGetWorkspaceList (display, rootWindow, &paWS, &numInfo) == Success)
3604 if(numInfo <= desktop_data->numWorkspaces)
3606 /* should never get here, just put the new object in ws 0 */
3610 /* go realloc room for the workspace Data */
3611 desktop_data->workspaceData = (WorkspaceRec **) XtRealloc(
3612 (char *)desktop_data->workspaceData,
3613 sizeof(WorkspaceRec *) * numInfo);
3615 /* now initialize the new workspaces */
3616 for(i=0; i < numInfo - desktop_data->numWorkspaces; i++)
3618 WorkspaceRec *workspaceData;
3620 workspaceData = (WorkspaceRec *)XtMalloc(sizeof(WorkspaceRec));
3622 for(j=0; j < numInfo; j++)
3624 workspaceData->name = XGetAtomName (display, paWS[j]);
3625 CleanUpWSName(workspaceData->name);
3627 for(k=0; k<desktop_data->numWorkspaces; k++)
3629 if(strcmp(workspaceData->name,
3630 desktop_data->workspaceData[k]->name) == 0)
3640 workspaceData->number = desktop_data->numWorkspaces + i + 1;
3641 workspaceData->files_selected = 0;
3642 workspaceData->selectedDTWindows =
3643 (DesktopRec **) XtMalloc (sizeof (DesktopRec *));
3644 workspaceData->selectedDTWindows[0] = NULL;
3645 workspaceData->primaryHelpDialog = NULL;
3646 workspaceData->secondaryHelpDialogCount = 0;
3647 workspaceData->secondaryHelpDialogList = NULL;
3649 desktop_data->workspaceData[desktop_data->numWorkspaces + i] =
3652 XFree ((char *) paWS);
3656 /* now lets add more desktop grids for the new workspaces */
3658 desktop_grid_size = numInfo * numColumns * numRows;
3659 desktop_grid = (Boolean *)XtRealloc((char *)desktop_grid,desktop_grid_size);
3660 for(i = desktop_data->numWorkspaces; i < numInfo; i++)
3662 for(j = 0; j < numColumns; j++)
3663 for(k = 0; k < numRows; k++)
3664 desktop_grid[(i * numRows * numColumns) +
3665 (j * numRows) + k] = 0;
3667 RegisterPanelInGrid( i + 1,
3668 DisplayWidth(display,screen),
3669 DisplayHeight(display, screen));
3672 desktop_data->numWorkspaces = numInfo;
3674 /* now determine which workspace the new object is in */
3675 for(j = 0; j < desktop_data->numWorkspaces; j++)
3677 if(strcmp(workspaceName, desktop_data->workspaceData[j]->name) == 0)
3678 return(desktop_data->workspaceData[j]->number);
3681 /* should never get here */
3685 /************************************************************************
3688 * This function is called when dtfile does an _DtActionInvoke. All
3689 * it does is turn off the Hourglass cursor.
3691 ************************************************************************/
3698 _DtTurnOffHourGlass (widget);
3702 /**********************************************************************
3704 * CleanUpWSName - routine which makes sure there are no spaces, "/",
3705 * "'", and ":" in a workspace name. If there are it changes them to
3708 *********************************************************************/
3711 char *workspace_name)
3715 /* the workspace name could be something other than "One" "Two" etc.
3716 if the user has change his/her xrdb. Need to check for characters
3717 in the name which will break us.
3720 ptr = DtStrchr(workspace_name, ' ');
3724 ptr = DtStrchr(ptr, ' ');
3730 ptr = DtStrchr(workspace_name, '/');
3734 ptr = DtStrchr(ptr, '/');
3740 ptr = DtStrchr(workspace_name, ':');
3744 ptr = DtStrchr(ptr, ':');
3750 ptr = DtStrchr(workspace_name, '\'');
3754 ptr = DtStrchr(ptr, '\'');
3759 /**********************************************************************
3761 * CheckDesktoMarquee - given a x, y, width, and height determine
3762 * whether a desktop objects pixmap falls within the bounded
3763 * region. If it does select it. If it is selected and no
3764 * longer is in the bounded region, deslect it.
3766 ***********************************************************************/
3768 CheckDesktopMarquee(
3777 Screen *currentScreen;
3779 char *workspace_name;
3780 Dimension shadowThickness;
3781 XRectangle pixmapRect;
3782 XRectangle labelRect;
3783 XRectangle incoming_rect;
3784 unsigned char pixmapPosition;
3786 WorkspaceRec *workspaceData = NULL;
3787 unsigned char flags;
3791 Boolean pointInRegion;
3793 if(desktop_data->numIconsUsed <= 0)
3796 /* Create a region with the incoming x, y, width, and height */
3797 incoming_rect.x = (short)x;
3798 incoming_rect.y = (short)y;
3799 incoming_rect.width = (unsigned short)width;
3800 incoming_rect.height = (unsigned short)height;
3801 region = XCreateRegion();
3802 XUnionRectWithRegion (&incoming_rect, region, region);
3804 /* Get the current workspace */
3805 display = XtDisplay(desktop_data->desktopWindows[0]->shell);
3806 screen = XDefaultScreen(display);
3807 currentScreen = XScreenOfDisplay(display, screen);
3808 rootWindow = RootWindowOfScreen(currentScreen);
3810 if(DtWsmGetCurrentWorkspace(display, rootWindow, &pCurrent) == Success)
3812 workspace_name = XGetAtomName (display, pCurrent);
3813 CleanUpWSName(workspace_name);
3816 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
3818 for(i = 0; i < desktop_data->numWorkspaces; i++)
3820 if(strcmp(workspace_name, desktop_data->workspaceData[i]->name) == 0)
3822 workspaceData = desktop_data->workspaceData[i];
3827 /* This shouldn't happen, but... */
3830 fprintf(stderr, "%s: workspaceData == NULL!\n", __FUNCTION__);
3834 /* now lets loop through the icons used, first check to see if they are
3835 * in the same workspace. If not continue else we need to check to see
3836 * if they are in the region passed in.
3838 for(i = 0; i < desktop_data->numIconsUsed; i++)
3840 if(strcmp(desktop_data->desktopWindows[i]->workspace_name,
3841 workspace_name) != 0)
3844 /* first we need to get the pixmap region for the desktop object */
3845 g = (DtIconGadget)desktop_data->desktopWindows[i]->iconGadget;
3846 shadowThickness = g->gadget.shadow_thickness;
3847 pixmapPosition = g->icon.cache->pixmap_position;
3849 _DtIconGetIconRects((DtIconGadget)g, &flags, &pixmapRect, &labelRect);
3851 switch ((int) pixmapPosition)
3853 case XmPIXMAP_TOP: /* 0 */
3854 case XmPIXMAP_LEFT: /* 2 */
3855 if( flags & XmPIXMAP_RECT )
3857 pixmapRect.x = pixmapRect.x + desktop_data->desktopWindows[i]->root_x + 1;
3858 pixmapRect.y = pixmapRect.y + desktop_data->desktopWindows[i]->root_y + 1;
3859 pixmapRect.width += 2*shadowThickness;
3860 pixmapRect.height += 2*shadowThickness;
3862 /* now lets check to see if the upper left and lower right corners
3863 * of the pixmap falls within the passed in region
3865 pointInRegion = (XPointInRegion(region, pixmapRect.x, pixmapRect.y) &&
3866 XPointInRegion(region, pixmapRect.x + pixmapRect.width,
3867 pixmapRect.y + pixmapRect.height));
3869 else if( flags & XmLABEL_RECT )
3870 { /* For the ones that don't have pixmap */
3871 labelRect.x = labelRect.x + desktop_data->desktopWindows[i]->root_x + 1;
3872 labelRect.y = labelRect.y + desktop_data->desktopWindows[i]->root_y + 1;
3873 labelRect.width += 2*shadowThickness;
3874 labelRect.height += 2*shadowThickness;
3876 /* now lets check to see if the upper left and lower right corners
3877 * of the pixmap falls within the passed in region
3879 pointInRegion = (XPointInRegion(region, labelRect.x, labelRect.y) &&
3880 XPointInRegion(region, labelRect.x + labelRect.width,
3881 labelRect.y + labelRect.height));
3884 pointInRegion = False;
3888 /* it falls within the region, lets see if its already
3892 for(j = 0; j < workspaceData->files_selected; j++)
3894 if(workspaceData->selectedDTWindows[j] ==
3895 desktop_data->desktopWindows[i])
3905 /* its not already selected, so lets select it ... */
3906 workspaceData->files_selected++;
3908 workspaceData->selectedDTWindows =
3909 (DesktopRec **) XtRealloc ((char *)
3910 workspaceData->selectedDTWindows,
3911 sizeof(DesktopRec *) *
3912 (workspaceData->files_selected + 2));
3914 /* Add to the front of the list */
3915 for (j = workspaceData->files_selected; j > 0; j--)
3917 workspaceData->selectedDTWindows[j] =
3918 workspaceData->selectedDTWindows[j-1];
3921 workspaceData->selectedDTWindows[0] =
3922 desktop_data->desktopWindows[i];
3923 SetToSelectColors ((Widget)g,
3924 desktop_data->desktopWindows[i]->frame,
3926 XSync(display, False);
3930 /* its pixmap is not it the region so lets see if it is
3931 * selected. If it is lets deslect it.
3933 for(j = 0; j < workspaceData->files_selected; j++)
3935 if(workspaceData->selectedDTWindows[j] ==
3936 desktop_data->desktopWindows[i])
3938 DeselectDTFile (workspaceData,
3939 desktop_data->desktopWindows[i]);
3940 XSync(display, False);
3948 XDestroyRegion (region);
3949 XtFree(workspace_name);
3954 ProcessDropOnDesktopObject (
3956 DtDndDropCallbackStruct *dropInfo,
3957 DesktopRec *desktopWindow)
3959 char *command = NULL;
3961 /******************/
3962 /* transfer phase */
3963 /******************/
3964 if (dropInfo->reason != DtCR_DND_DROP_ANIMATE)
3966 DPRINTF(("DropOnObject: Transfer Callback\n"));
3968 /* In case when the drag is from non File Manager client */
3970 initiating_view = NULL;
3972 /* check for invalid trash drop */
3973 if (FileFromTrash(dropInfo->dropData->data.files[0]))
3975 if (InvalidTrashDragDrop(dropInfo->operation,
3977 desktopWindow->shell))
3979 dropInfo->status = DtDND_FAILURE;
3984 command = TypeToAction(dropInfo->operation,
3985 desktopWindow->file_view_data->file_data->logical_type);
3987 (strncmp("FILESYSTEM_", command, strlen("FILESYSTEM_")) != 0) &&
3988 dropInfo->dropData->protocol == DtDND_BUFFER_TRANSFER)
3989 dropInfo->completeMove = True;
3991 /* set the complete move flag to False since we will be handling */
3992 /* the deletion of the original file */
3993 dropInfo->completeMove = False;
3996 /******************************************/
3997 /* animate phase, retrieve action and run */
3998 /******************************************/
4002 TypeToAction(dropInfo->operation,
4003 desktopWindow->file_view_data->file_data->logical_type);
4006 RunDTCommand (command,
4009 DtDtsFreeAttributeValue(command);
4016 DropOnDesktopObject (
4018 XtPointer client_data,
4019 XtPointer call_data)
4021 DtDndDropCallbackStruct *dropInfo = (DtDndDropCallbackStruct *)call_data;
4023 switch (dropInfo -> dropData->protocol)
4025 case DtDND_FILENAME_TRANSFER:
4026 case DtDND_BUFFER_TRANSFER:
4027 ProcessDropOnDesktopObject (w, dropInfo, (DesktopRec *) client_data);
4030 dropInfo->status = DtDND_FAILURE;
4037 Atom deleted_ws_atom,
4039 XtPointer client_data)
4044 Screen *currentScreen;
4046 char *workspace_name,*old_workspace_name;
4048 int numInfo,oldNumWorkspaces,old_ws_num,ws_num;
4049 int i,j,k,retry,result,old_index,new_index;
4051 display = XtDisplay(w);
4052 screen = XDefaultScreen(display);
4053 currentScreen = XScreenOfDisplay(display, screen);
4054 rootWindow = RootWindowOfScreen(currentScreen);
4055 oldNumWorkspaces = desktop_data->numWorkspaces;
4057 old_workspace_name = XGetAtomName (display, deleted_ws_atom);
4059 if( type == DtWSM_MODIFY_WORKSPACE_TYPE_DELETE )
4061 retry = retryLoadDesktopInfo;
4064 /* Get total new number of workspaces */
4067 result = DtWsmGetWorkspaceList (display, rootWindow, &paWS, &numInfo);
4068 if (result == Success)
4070 desktop_data->numWorkspaces = (int)numInfo;
4075 desktop_data->numWorkspaces = 1;
4080 /* Get the current workspace */
4081 if(DtWsmGetCurrentWorkspace(display,rootWindow,&pCurrent) == Success)
4083 workspace_name = XGetAtomName (display, pCurrent);
4084 CleanUpWSName(workspace_name);
4087 workspace_name = XtNewString(desktop_data->workspaceData[0]->name);
4089 /* determine the workspaces number of deleted and current*/
4090 old_ws_num = GetWorkspaceNum(old_workspace_name,oldNumWorkspaces,&old_index);
4091 ws_num = GetWorkspaceNum(workspace_name,oldNumWorkspaces,&new_index);
4093 /* Free up or reassign any workspace data in the deleted workspace */
4094 FreeUpOldWorkspace(oldNumWorkspaces,old_ws_num,ws_num,old_index,new_index);
4096 /* Look up for the duplication of workspace objects in the new workspace */
4097 for(i=0;i<desktop_data->numIconsUsed;i++)
4098 { /* Those objects whose workspace number matches the deleted workspace number */
4099 if (desktop_data->desktopWindows[i]->workspace_num == old_ws_num)
4100 { /* Look up in all of the workspace objects */
4101 for(j=0;j<desktop_data->numIconsUsed;j++)
4102 { /* Those objects in the current workspace */
4103 if (j!= i && desktop_data->desktopWindows[j]->workspace_num == ws_num)
4105 /* If there is an object matching the old workspace object delete the old */
4106 if(strcmp(desktop_data->desktopWindows[j]->file_name,desktop_data
4107 ->desktopWindows[i]->file_name) == 0)
4109 ws_num = GetWorkspaceNum(workspace_name,desktop_data->
4110 numWorkspaces, &new_index);
4112 k<desktop_data->workspaceData[new_index]->files_selected;k++)
4114 /* Adjust the selectedDTWindows of current to accommadate the old list */
4115 if(desktop_data->workspaceData[new_index]->
4116 selectedDTWindows[k] == desktop_data->desktopWindows[i])
4118 desktop_data->workspaceData[new_index]->
4119 selectedDTWindows[k] = NULL;
4120 for(;k<desktop_data->workspaceData[new_index]->files_selected;k++)
4121 desktop_data->workspaceData[new_index]->
4122 selectedDTWindows[k] = desktop_data->
4123 workspaceData[new_index]-> selectedDTWindows[k+1];
4124 desktop_data->workspaceData[new_index]->files_selected--;
4128 XtPopdown(desktop_data->desktopWindows[i]->shell);
4129 XWithdrawWindow(XtDisplay(desktop_data->desktopWindows[i]->shell),
4130 XtWindow(desktop_data->desktopWindows[i]->shell),
4131 XDefaultScreen(XtDisplay(desktop_data->desktopWindows[i]->shell)));
4132 FreeDesktopWindow(desktop_data->desktopWindows[i]);
4133 i--; /* To make sure that other icons are also covered */
4138 if(j == desktop_data->numIconsUsed)
4140 desktop_data->desktopWindows[i]->workspace_num = ws_num;
4141 XtFree(desktop_data->desktopWindows[i]->workspace_name);
4142 desktop_data->desktopWindows[i]->workspace_name = NULL;
4143 desktop_data->desktopWindows[i]->workspace_name =
4144 XtNewString(workspace_name);
4149 else if( type == DtWSM_MODIFY_WORKSPACE_TYPE_ADD )
4151 InitializeNewWorkspaces(display, old_workspace_name);
4153 XFree(old_workspace_name);
4157 GetWorkspaceNum(char *workspace_name,
4159 int *workspace_index)
4163 for(j = 0; j < NumWorkspaces; j++)
4165 if(strcmp(workspace_name, desktop_data->workspaceData[j]->name) == 0)
4167 ws_num = desktop_data->workspaceData[j]->number;
4171 *workspace_index = (j == NumWorkspaces)?-1:j;
4176 int oldNumWorkspaces,
4182 int j,numnewfiles,numoldfiles;
4184 if(old_ws_num==-1 || old_index==-1 ||
4185 desktop_data->workspaceData[old_index]==NULL) /* Something is wrong */
4187 numnewfiles = desktop_data->workspaceData[new_index]->files_selected;
4188 numoldfiles = desktop_data->workspaceData[old_index]->files_selected;
4191 desktop_data->workspaceData[new_index]->selectedDTWindows=(DesktopRec **)
4192 XtRealloc((XtPointer) desktop_data->workspaceData[new_index]->selectedDTWindows,
4193 sizeof(DesktopRec *) * ( numnewfiles+numoldfiles));
4194 for(j=numnewfiles;j< numnewfiles+numoldfiles;j++)
4196 desktop_data->workspaceData[new_index]->selectedDTWindows[j] =
4197 desktop_data->workspaceData[old_index]->selectedDTWindows[j-numnewfiles];
4199 XtFree((XtPointer) desktop_data->workspaceData[old_index]->selectedDTWindows);
4200 desktop_data->workspaceData[old_index]->selectedDTWindows = NULL;
4201 desktop_data->workspaceData[new_index]->files_selected = numnewfiles+numoldfiles;
4204 numnewfiles=desktop_data->workspaceData[new_index]->secondaryHelpDialogCount;
4205 numoldfiles=desktop_data->workspaceData[old_index]->secondaryHelpDialogCount;
4208 desktop_data->workspaceData[new_index]->secondaryHelpDialogList=
4209 (DialogData **) XtRealloc((XtPointer) desktop_data->workspaceData[old_index]->
4210 secondaryHelpDialogList,sizeof(DialogData *) * ( numnewfiles+numoldfiles));
4211 for(j=numnewfiles;j< numnewfiles+numoldfiles;j++)
4213 desktop_data->workspaceData[new_index]->secondaryHelpDialogList[j] =
4214 desktop_data->workspaceData[old_index]->secondaryHelpDialogList[j-ws_num];
4216 desktop_data->workspaceData[new_index]->secondaryHelpDialogCount = numnewfiles+numoldfiles;
4218 /* Move up the workspaceData */
4219 XtFree((XtPointer) desktop_data->workspaceData[old_index]);
4220 desktop_data->workspaceData[old_index] = NULL;
4221 for(j=old_index; j<desktop_data->numWorkspaces;j++)
4222 desktop_data->workspaceData[j] = desktop_data->workspaceData[j+1];
4223 desktop_data->workspaceData[j] = NULL;
4225 /************************************************************************
4227 ************************************************************************/
4230 PutOnWorkspaceHandler(
4233 DesktopRec * desktopWindow;
4234 struct stat fileInfo;
4235 char title[256], invalidWorkspace = 0x0;
4236 int numArgs, i, screen, ws;
4237 char * fullName, * fileName = NULL, * dirName = NULL, * workspace = NULL;
4238 char * requestWorkspace = NULL;
4240 fullName = tt_message_file( ttMsg );
4242 if( tt_is_err( tt_ptr_error( fullName ) ) )
4243 { /* No file name */
4244 tt_message_reply( ttMsg );
4245 tttk_message_destroy( ttMsg );
4249 if (NULL != fullName) DtEliminateDots( fullName );
4251 if(NULL==fullName ||
4252 (stat(fullName, &fileInfo) != 0 && lstat(fullName, &fileInfo) != 0))
4254 char *template, *errorMsg, *dialogTitle, *errorName;
4256 /* File does not exist */
4257 tt_message_reply(ttMsg);
4258 tttk_message_destroy(ttMsg);
4260 dialogTitle = XtNewString(GETMESSAGE(20, 84, "Put in Workspace"));
4262 template = XtNewString(
4265 "Object:\n\n %s\n\ndoes not exist in the file system."));
4266 if (NULL == fullName)
4269 errorName = fullName;
4270 errorMsg = (char *) XtMalloc(strlen(template) + strlen(errorName) + 1);
4271 sprintf(errorMsg, template, errorName);
4272 _DtMessage(toplevel, dialogTitle, errorMsg, NULL, HelpRequestCB);
4276 if (NULL != fullName) tt_free(fullName);
4280 numArgs = tt_message_args_count( ttMsg );
4281 if( tt_is_err( tt_int_error( numArgs ) ) )
4286 tt_message_reply( ttMsg );
4287 tttk_message_destroy( ttMsg );
4291 for( i = 0; i < numArgs; ++i )
4295 vtype = tt_message_arg_type( ttMsg, i );
4298 || (tt_is_err( tt_ptr_error( vtype ))) )
4301 if( strcmp( vtype, "-workspace" ) == 0 )
4303 requestWorkspace = tt_message_arg_val( ttMsg, i );
4308 /* separate the rest of the path into directory and file name */
4309 if( strcmp( fullName, "/" ) == 0 )
4311 sprintf( title, "%s:%s", home_host_name, root_title );
4312 fileName = XtNewString( "." );
4313 dirName = XtNewString( "/" );
4318 ptr = strrchr( fullName, '/' );
4319 if( ptr == fullName )
4321 strcpy( title, ptr + 1 );
4322 dirName = XtNewString( "/" );
4323 fileName = XtNewString( ptr + 1 );
4325 else if( *(ptr + 1) != '\0' )
4327 char savedChar = *ptr;
4329 dirName = XtNewString( fullName );
4331 strcpy( title, ptr + 1 );
4332 fileName = XtNewString( ptr + 1 );
4336 tt_message_reply( ttMsg );
4337 tttk_message_destroy( ttMsg );
4339 tt_free( fullName );
4344 tt_free( fullName );
4345 workspace = XtNewString( requestWorkspace );
4346 tt_free( requestWorkspace );
4348 if( strcmp( workspace, "current" ) == 0 )
4353 Screen * currentScreen;
4356 XtFree( workspace );
4358 /* Get the current workspace */
4359 display = XtDisplay( toplevel );
4360 screen = XDefaultScreen( display );
4361 currentScreen = XScreenOfDisplay( display, screen );
4362 rootWindow = RootWindowOfScreen( currentScreen );
4364 if( DtWsmGetCurrentWorkspace( display, rootWindow, &pCurrent ) == Success )
4365 workspace = XGetAtomName( display, pCurrent );
4367 workspace = XtNewString( desktop_data->workspaceData[0]->name );
4371 /* determine the workspace number
4373 for( i = 0; i < desktop_data->numWorkspaces; ++i )
4375 if( strcmp( workspace, desktop_data->workspaceData[i]->name ) == 0 )
4377 ws = desktop_data->workspaceData[i]->number - 1;
4383 { /* Invalid workspace
4384 choose workspace one
4387 XtFree( workspace );
4388 workspace = XtNewString( "ws0" );
4389 invalidWorkspace = 0x1;
4392 for( i = 0; i < desktop_data->numIconsUsed; ++i )
4394 if( strcmp( desktop_data->desktopWindows[i]->title, title ) == 0
4395 && strcmp( desktop_data->desktopWindows[i]->workspace_name,
4398 char * template, * errorMsg, * dialogTitle;
4400 dialogTitle = XtNewString(GETMESSAGE(20,84,"Put in Workspace"));
4401 if( invalidWorkspace )
4402 template = XtNewString( GETMESSAGE(28,12, "An invalid workspace was passed. The default workspace will be\nworkspace one and an object named:\n\n %s\n\nalready exists on the backdrop in this Workspace.\nYou cannot put another object with the same name on the Workspace.\nTo have both objects on the Workspace, rename one of them."));
4404 template = XtNewString( GETMESSAGE(28,11, "An object named:\n\n %s\n\nalready exists on the backdrop in this Workspace.\nYou cannot put another object with the same name on the Workspace.\nTo have both objects on the Workspace, rename one of them."));
4405 errorMsg = (char *) XtMalloc( strlen( template )
4406 + strlen( title ) + 1 );
4407 sprintf( errorMsg, template, title );
4408 _DtMessage( toplevel, dialogTitle, errorMsg, NULL, HelpRequestCB );
4411 XtFree( workspace );
4414 XtFree( dialogTitle );
4417 tt_message_reply( ttMsg );
4418 tttk_message_destroy( ttMsg );
4424 /* get the next available cached iconWindow and use it to map
4425 this topLevelWindow */
4426 desktopWindow = desktop_data->desktopWindows[desktop_data->numIconsUsed];
4427 desktop_data->numIconsUsed++;
4428 desktop_data->numCachedIcons--;
4430 /* store some of the data needed for the Desktop object */
4431 desktopWindow->host = XtNewString( home_host_name );
4432 desktopWindow->dir_linked_to = dirName;
4433 desktopWindow->file_name = fileName;
4434 desktopWindow->title = XtNewString( title );
4436 desktopWindow->workspace_name = XtNewString( desktop_data->workspaceData[ws]->name );
4437 desktopWindow->workspace_num = desktop_data->workspaceData[ws]->number;
4438 desktopWindow->restricted_directory = NULL;
4439 desktopWindow->helpVol = NULL;
4440 desktopWindow->toolbox = False;
4441 desktopWindow->view = UNSET_VALUE;
4442 desktopWindow->order = UNSET_VALUE;
4443 desktopWindow->direction = UNSET_VALUE;
4444 desktopWindow->positionEnabled = UNSET_VALUE;
4446 desktopWindow->file_view_data = BuildNewOrderlist(
4447 NULL /* @@@ use cached info if possible! */,
4448 desktopWindow->iconGadget,
4450 desktopWindow->dir_linked_to,
4452 desktopWindow->registered,
4453 desktopWindow->toolbox );
4455 MakeDesktopWindow( desktopWindow, -1, -1 );
4456 desktopWindow->registered = desktopWindow->file_view_data->registered;
4458 /* go cache some more windows if there isn't enough cached */
4459 if( desktop_data->numCachedIcons < 5 )
4460 InitializeDesktopWindows( 5, XtDisplay( toplevel ) );
4462 /* go save the current state of the desktop */
4463 SaveDesktopInfo( NORMAL_RESTORE );
4465 tt_message_reply( ttMsg );
4466 tttk_message_destroy( ttMsg );
4468 XtFree( workspace );
4470 if( checkBrokenLink != 0 && checkBrokenLinkTimerId == 0 )
4472 checkBrokenLinkTimerId = XtAppAddTimeOut(
4473 XtWidgetToApplicationContext( toplevel ),
4474 checkBrokenLink * 1000,
4475 TimerEventBrokenLinks,