Beispiel #1
0
static void
SetValues(
        ChangeDirRec *change_dir_rec,
        ChangeDirData *change_dir_data )
{
   Arg args[4];
   char *tmp_str, *host_name;
   XmString host_string;
   DialogData * dialog_data;
   FileMgrData * file_mgr_data;

   dialog_data = _DtGetInstanceData (change_dir_data->file_mgr_rec);
   file_mgr_data = (FileMgrData *) dialog_data->data;

   if(change_dir_data->string_path)
      XmStringFree (change_dir_data->string_path);

   if( restrictMode
       && file_mgr_data->toolbox == False )
      change_dir_data->string_path =
              XmStringCreateLocalized( users_home_dir);
   else if( file_mgr_data->restricted_directory )
      change_dir_data->string_path =
        XmStringCreateLocalized( file_mgr_data->current_directory);
   else
      change_dir_data->string_path = NULL;

   XtSetArg (args[0], XmNlistItemCount, change_dir_data->list_count);
   XtSetArg (args[1], XmNlistVisibleItemCount, change_dir_data->visible_count);
   XtSetArg (args[2], XmNtextString, change_dir_data->string_path);
   XtSetArg (args[3], XmNlistItems, change_dir_data->history_list);

   XtSetValues (change_dir_rec->change_dir, args, 4);

   if( change_dir_data->string_path )
   {
      Widget text;

      text = XmSelectionBoxGetChild(change_dir_rec->change_dir, XmDIALOG_TEXT);
      XtAddCallback (text, XmNmodifyVerifyCallback,
                     (XtCallbackProc)TextChange, (XtPointer)file_mgr_data );
      XtAddCallback (text, XmNmotionVerifyCallback,
                     (XtCallbackProc)TextChange, (XtPointer)file_mgr_data );
      XtAddCallback (text, XmNvalueChangedCallback,
                     (XtCallbackProc)TextChange, (XtPointer)file_mgr_data );
   }

   tmp_str = GETMESSAGE(2, 16, "System Name: ");
   host_name = XtMalloc(strlen(tmp_str) + strlen(change_dir_data->host_name)+1);
   sprintf(host_name, "%s%s", tmp_str, change_dir_data->host_name);
   host_string = XmStringCreateLocalized (host_name);
   XtSetArg (args[0], XmNlabelString, host_string);
   XtSetValues (XmSelectionBoxGetChild (change_dir_rec->change_dir,
                                        XmDIALOG_LIST_LABEL), args, 1);

   XtFree(host_name);
   XmStringFree(host_string);
}
Beispiel #2
0
void
DropOnChangeView (
     Widget w,
     XtPointer client_data,
     XtPointer call_data)
{
   DtDndDropCallbackStruct *fileList = (DtDndDropCallbackStruct *)call_data;
   FileMgrRec *file_mgr_rec;
   DialogData * dialog_data;
   ChangeDirData * change_dir_data;
   ChangeDirRec * change_dir_rec;
   FileMgrData * file_mgr_data;
   Widget selection_box;
   char *full_path_name;
   int  numFiles;

   numFiles = fileList->dropData->numItems;

   /* if multiple selection, ignore all but the last one */

   if (numFiles > 0 && fileList->reason == DtCR_DND_DROP_ANIMATE)
   {
      file_mgr_rec = (FileMgrRec *) client_data;
      dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
      file_mgr_data = (FileMgrData *) dialog_data->data;

      full_path_name = XtNewString(fileList->dropData->data.files[numFiles-1]);

      if (CheckRestrictedDir(file_mgr_rec, file_mgr_data,
                             &full_path_name, False) == 0)
      {
         change_dir_data = (ChangeDirData *) file_mgr_data->change_dir->data;
         change_dir_rec =
              (ChangeDirRec *)_DtGetDialogInstance(file_mgr_data->change_dir);
         if (change_dir_rec)
            selection_box = change_dir_rec->change_dir;
         else
            selection_box = NULL;

         TryToChangeDir(False, full_path_name, file_mgr_data, file_mgr_rec,
                        change_dir_data, selection_box, NULL, NULL,
                        GoToNewDir);
      }
      XtFree(full_path_name);
   }

   fileList->status = DtDND_FAILURE;
}
Beispiel #3
0
void
ChangeDirectoryToParent(
      FileMgrRec * file_mgr_rec,
      char *directory)
{
   DialogData * dialog_data;
   ChangeDirData * change_dir_data;
   ChangeDirRec * change_dir_rec;
   FileMgrData * file_mgr_data;
   Widget selection_box;
   char * tmpStr;
   int rc;

   /*  Get the change dir data record  */

   dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
   file_mgr_data = (FileMgrData *) dialog_data->data;
   change_dir_data = (ChangeDirData *) file_mgr_data->change_dir->data;
   change_dir_rec =(ChangeDirRec *)_DtGetDialogInstance(file_mgr_data->change_dir);

   if (change_dir_rec)
      selection_box = change_dir_rec->change_dir;
   else
      selection_box = NULL;

   /* check if user attempts to go outside restricted directory */
   rc = CheckRestrictedDir (file_mgr_rec, file_mgr_data, &directory, True);

   /*  Process the string representing a directory to verify  */
   /*  that it is a valid path.                               */
   if (rc == 0)
   {
      TryToChangeDir(False, directory, file_mgr_data, file_mgr_rec,
                     change_dir_data, selection_box, NULL, NULL,
                     GoToNewDir);
   }

}
Beispiel #4
0
void
ShowPreferencesDialog(
        Widget w,
        XtPointer client_data,
        XtPointer callback )
{
   FileMgrRec  * file_mgr_rec;
   DialogData  * dialog_data;
   FileMgrData * file_mgr_data;
   PreferencesRec *preferences_rec;
   Arg args[1];
   Widget mbar;
   char *tmpStr, *tempStr;



   /*  Set the menu item to insensitive to prevent multiple  */
   /*  dialogs from being posted and get the area under the  */
   /*  menu pane redrawn.                                    */

   if (w)
   {
      mbar = XmGetPostedFromWidget(XtParent(w));
      XmUpdateDisplay (w);
      XtSetArg(args[0], XmNuserData, &file_mgr_rec);
      XtGetValues(mbar, args, 1);

      /* Ignore accelerators when we're insensitive */
      if ((file_mgr_rec->menuStates & PREFERENCES) == 0)
      {
         XSetInputFocus(XtDisplay(w),
                        XtWindow(file_mgr_rec->preferencesBtn_child),
                        RevertToParent, CurrentTime);
         return;
      }
   }
   else
   {
      /* Done only during a restore session */
      file_mgr_rec = (FileMgrRec *)client_data;
   }


   /* Ignore accelerators received after we're unposted */
   if ((dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec)) == NULL)
      return;
   file_mgr_data = (FileMgrData *) dialog_data->data;

   file_mgr_rec->menuStates &= ~ PREFERENCES;

   _DtShowDialog (file_mgr_rec->shell, NULL, (XtPointer)file_mgr_rec, 
               file_mgr_data->preferences, PreferencesChange,
	       (XtPointer)file_mgr_rec, PreferencesClose,
	       (XtPointer)file_mgr_rec, NULL, False, False, NULL, NULL);

   /* set the title */
   preferences_rec = (PreferencesRec *)_DtGetDialogInstance(
                                        file_mgr_data->preferences);

   if(file_mgr_data->title != NULL &&
           (strcmp(file_mgr_data->helpVol, DTFILE_HELP_NAME) != 0 ||
            strcmp(file_mgr_data->title, "Trash Can") == 0))
   {
      tmpStr = GETMESSAGE(23, 1, "Set View Options");
      tempStr = (char *)XtMalloc(strlen(tmpStr) +
                                 strlen(file_mgr_data->title) + 5);
      sprintf(tempStr, "%s - %s", file_mgr_data->title, tmpStr);
   }
   else
   {
      tmpStr = (GETMESSAGE(23,22, "File Manager - Set View Options"));
      tempStr = XtNewString(tmpStr);
   }
   XtSetArg (args[0], XmNtitle, tempStr);
   XtSetValues (preferences_rec->shell, args, 1);
   XtFree(tempStr);
   file_mgr_rec->preferencesBtn_child=preferences_rec->shell;
}
Beispiel #5
0
static void
PreferencesChange(
        XtPointer client_data,
        DialogData *old_dialog_data,
        DialogData *new_dialog_data,
        XtPointer call_data )
{
   FileMgrRec  * file_mgr_rec = (FileMgrRec *) client_data;
   DialogData  * dialog_data;
   FileMgrData * file_mgr_data;
   XtPointer save_data;
   PreferencesData * preferences_data;
   unsigned char *viewP;
   FileViewData  *branch;
   int i;

   dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
   file_mgr_data = (FileMgrData *) dialog_data->data;

   save_data = file_mgr_data->preferences->data;
   file_mgr_data->preferences->data = new_dialog_data->data;
   new_dialog_data->data = save_data;
   _DtFreeDialogData (new_dialog_data);


   preferences_data = (PreferencesData *) (file_mgr_data->preferences->data);

   if (file_mgr_data->show_type != preferences_data->show_type	||
       file_mgr_data->tree_files != preferences_data->tree_files ||
       file_mgr_data->view_single != preferences_data->view_single ||
       file_mgr_data->view_tree != preferences_data->view_tree ||
       file_mgr_data->order != preferences_data->order		||
       file_mgr_data->direction != preferences_data->direction  ||
       file_mgr_data->positionEnabled != preferences_data->positionEnabled ||
       file_mgr_data->show_iconic_path != preferences_data->show_iconic_path ||
       file_mgr_data->show_current_dir != preferences_data->show_current_dir ||
       file_mgr_data->show_status_line != preferences_data->show_status_line)
   {
      /*
       * Depending upon which of the preferences values changed, positioning
       * may need to be disabled, and the preferences dialog updated.
       */
      if (((file_mgr_data->order != preferences_data->order) ||
          (file_mgr_data->direction != preferences_data->direction)) &&
          (file_mgr_data->positionEnabled == RANDOM_ON))
      {
         /* Discard positioning info */
         file_mgr_data->grid_height = 0;
         file_mgr_data->grid_width = 0;
         if(file_mgr_data->object_positions)
            FreePositionInfo(file_mgr_data);
      }

      /*
       * In tree mode, if we switch from showing files "always" to "choose",
       * change all branches from tsAll back to tsDirs.
       */
      if (file_mgr_data->tree_files == TREE_FILES_ALWAYS &&
          preferences_data->tree_files == TREE_FILES_CHOOSE)
      {
        for (i = 0; i < file_mgr_data->directory_count; i++)
        {
           branch = file_mgr_data->directory_set[i]->sub_root;
           if (branch->ts == tsAll)
           {
              branch->ts = tsDirs;
              UpdateBranchList(file_mgr_data, file_mgr_data->directory_set[i]);
           }
        }
      }

      if (preferences_data->show_type == MULTIPLE_DIRECTORY)
        viewP = &preferences_data->view_tree;
      else
        viewP = &preferences_data->view_single;
      if (file_mgr_data->view != *viewP)
      {
         file_mgr_data->newSize = True;
      }
      else
      { 
         if (file_mgr_data->show_type != preferences_data->show_type) 
            file_mgr_data->newSize = True;
         else
            file_mgr_data->newSize = False;
      }
      file_mgr_data->show_type = preferences_data->show_type;
      file_mgr_data->tree_files = preferences_data->tree_files;
      file_mgr_data->view = *viewP;
      file_mgr_data->view_single = preferences_data->view_single;
      file_mgr_data->view_tree = preferences_data->view_tree;
      file_mgr_data->order = preferences_data->order;
      file_mgr_data->direction = preferences_data->direction;
      file_mgr_data->show_iconic_path = preferences_data->show_iconic_path;
      file_mgr_data->show_current_dir = preferences_data->show_current_dir;
      file_mgr_data->show_status_line = preferences_data->show_status_line;
      if (file_mgr_data->positionEnabled == preferences_data->positionEnabled)
         FileMgrRedisplayFiles (file_mgr_rec, file_mgr_data, False);
      else
      {
         file_mgr_data->positionEnabled = preferences_data->positionEnabled;
         FileMgrRedisplayFiles (file_mgr_rec, file_mgr_data, True);
      }
   
      if(openDirType == NEW)
         ForceMyIconOpen(file_mgr_data->host, NULL);
   }
}
Beispiel #6
0
void 
HelpRequestCB(
        Widget w,
        XtPointer clientData,
        XtPointer callData )

{
   XtPointer recordStruct;
   DialogData * dialogData;
   Arg args[8];
   int n;
   String topicTitle = NULL;
   int helpType;
   Boolean freeClientData;
   String fileType;
   String strVal;
   char *vol;
   char *locId;

   /* Refresh the display */
   /* printf ("in HelpRequestCB: clientdata=\"%s\"\n",(char *)clientData); */
   XmUpdateDisplay(w);

   if (recordStruct = LocateRecordStructure(w))
   {
      if (dialogData = _DtGetInstanceData(recordStruct))
      {
         if (IsMainWinDialog(dialogData))
         {
            FileMgrData * fileMgrData = (FileMgrData *)dialogData->data;
            FileMgrRec * fileMgrRec = (FileMgrRec *)recordStruct;

            /* Check for item help */
            if (clientData && strcmp(clientData, HELP_HELP_MODE_STR) == 0)
            {
              if( !ProcessItemHelp( fileMgrRec->shell ) )
              {
                char *tmpStr, *title, *msg;

                tmpStr = GetSharedMessage(ITEM_HELP_ERROR_TITLE);
                title = XtNewString(tmpStr);

                if( fileMgrData->toolbox )
                {
                  tmpStr = GetSharedMessage( AMITEM_HELP_ERROR );
                  msg = XtNewString(tmpStr);
                }
                else
                {
                  tmpStr = GetSharedMessage( ITEM_HELP_ERROR ),
                  msg = XtNewString(tmpStr);
                }

                _DtMessage(fileMgrRec->shell, title, msg, NULL,
                           HelpRequestCB);
                XtFree(title);
                XtFree(msg);
              }
              return;
            }
            /* Item help comes in with a NULL client data */
            if (clientData)
            {
               fileType = NULL;
               topicTitle = NULL;
               helpType = DtHELP_TYPE_TOPIC;
               freeClientData = False;
            }
            else
            {
               if(fileMgrData->selected_file_count > 1)
               {
                 Widget warn;
                 String s;
                 XmString xmstr;

                 n=0;
                 XtSetArg(args[n], XmNokLabelString, okXmString);                        n++;
                 XtSetArg(args[n], XmNcancelLabelString, cancelXmString);                n++;
                 s = GETMESSAGE(29,10, "Help is not available for multiple selected objects.");
                 xmstr = XmStringCreateLocalized(s);

                 XtSetArg(args[n], XmNmessageString, xmstr);                             n++;
                 XtSetArg(args[n], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));   n++;

                 warn = XmCreateWarningDialog(fileMgrRec->shell, "warn_msg", args, n);

                 XtUnmanageChild(XmMessageBoxGetChild(warn,XmDIALOG_HELP_BUTTON));
                 XtManageChild(warn);
                 XmStringFree(xmstr);

                 return;
               }

               /* Action/Filetype Help */
               topicTitle = GetSharedMessage(ACTION_FT_HELP_TITLE);
               helpType = DtHELP_TYPE_DYNAMIC_STRING;
               fileType = NULL;

               /* Determine string, and set clientData accordingly */
               if ((clientData =
                      MapIconWidgetToFileType(w, fileMgrData)) == NULL)
               {
                  /* Not a file icon; is it an action menu item? */
                  if (!IsMenuWidget(w, fileMgrRec, fileMgrData, &strVal, 
                                    &fileType))
                  {
                     if (! IsFilterIcon(w, fileMgrData, &strVal))
                        return;
                  }
                  clientData = (XtPointer)strVal;
               }
               freeClientData = True;
            }

            /* printf ("topic = %s\n", clientData); */

            /* Special check for 'Using Help'; required different volume */
            locId = (char *)clientData;
            if ((w == *usingHelp) && (strcmp(locId, HELP_HOME_TOPIC) == 0))
               vol = "Help4Help";
            else
               vol = fileMgrData->helpVol;

            if (fileMgrData->primaryHelpDialog)
            {
               ReusePrimaryHelpWindow( fileMgrData->primaryHelpDialog, 
                                       clientData, vol, topicTitle,
                                       fileType, helpType);
            }
            else
            {
               /* Create the main help window for this view */
               ShowHelpDialog(fileMgrRec->shell, (XtPointer)fileMgrRec,
			      MAIN_HELP_DIALOG, 
                              NULL, clientData, vol,
                              topicTitle, fileType, helpType);
            }

            if (freeClientData)
            {
               XtFree(fileType);
               XtFree(clientData);
            }
         }
      }
   }
      else if (clientData)
      {
         Widget mainHelpDialog=NULL;
         Arg args[10];
         int i=0;

         XtSetArg(args[0],XmNuserData,&mainHelpDialog);
         XtGetValues(w,args,1);

         XtSetArg(args[i], DtNhelpType,(unsigned char) DtHELP_TYPE_TOPIC); i++;
         XtSetArg(args[i], DtNhelpVolume, DTFILE_HELP_NAME); i++;
         XtSetArg(args[i], DtNlocationId, clientData); i++;
         XtSetArg(args[i], XmNtitle, (GETMESSAGE(29,1, "File Manager Help")));i++;
         if(!mainHelpDialog || ( mainHelpDialog && !XtIsManaged(mainHelpDialog)) )
	 {

             mainHelpDialog = DtCreateHelpDialog(w, "mainHelpDialog", args, i);
             XtAddCallback(mainHelpDialog, DtNcloseCallback,
                       closeCB_mainHelpDialog,
                       (XtPointer)NULL);
             XtManageChild(mainHelpDialog);
	     XtSetArg(args[0],XmNuserData,mainHelpDialog);
	     XtSetValues(w,args,1);
	 }
	 else
           XtSetValues(mainHelpDialog, args, i);
      }
}
Beispiel #7
0
static void
OkCallback(
        Widget selection_box,
        ChangeDirApply *apply_data,
        XmSelectionBoxCallbackStruct *callback_data )
{
   DialogData * dialog_data;
   ChangeDirData * change_dir_data;
   FileMgrRec * file_mgr_rec;
   FileMgrData * file_mgr_data;
   char *strValue;
   char *value = NULL;
   int result;
   char message_buf[MAX_PATH + 100];
   char * tmpStr;
   char * title;
   char * msg;


   /*  Get the change dir data record  */

   dialog_data = _DtGetInstanceData (apply_data->change_dir_rec);
   change_dir_data = (ChangeDirData *) dialog_data->data;

   file_mgr_rec = (FileMgrRec *) change_dir_data->file_mgr_rec;
   dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
   file_mgr_data = (FileMgrData *) dialog_data->data;

   value = (char *) _XmStringUngenerate((XmString)callback_data->value,
                                        XmFONTLIST_DEFAULT_TAG,
                                        XmCHARSET_TEXT, XmCHARSET_TEXT);

   if ( value == NULL)
   {
       tmpStr = GetSharedMessage(CHANGE_DIR_ERROR_TITLE);
      title = XtNewString(tmpStr);
      tmpStr = (char *) GETMESSAGE(2, 11, "Cannot get the new folder name.");
      msg = XtNewString(tmpStr);

      _DtMessage(selection_box, title, message_buf, NULL, HelpRequestCB);

      XtFree(title);
      XtFree(msg);
      return;
   }

   strValue = XtNewString(value);
   if(file_mgr_data->toolbox && strValue[0] != '/')
      result = CheckRestrictedDir(file_mgr_rec, file_mgr_data, &strValue, True);
   else
      result = CheckRestrictedDir(file_mgr_rec, file_mgr_data, &strValue,False);

   /*  Process the string representing a directory to verify  */
   /*  that it is a valid path.                               */
   if (result == 0)
   {
      TryToChangeDir(True, (char *)strValue, file_mgr_data,
                     file_mgr_rec, change_dir_data, selection_box, apply_data,
                     callback_data, apply_data->callback);
   }

   XtFree(value);
   XtFree(strValue);
}
Beispiel #8
0
void
ChangeToNewDir (
       Widget text_field,
       XtPointer client_data,
       XmAnyCallbackStruct * callback_data )
{
   DialogData * dialog_data;
   ChangeDirData * change_dir_data;
   ChangeDirRec * change_dir_rec;
   FileMgrRec * file_mgr_rec;
   FileMgrData * file_mgr_data;
   char * value;
   Widget selection_box;
   Arg args[1];
   char * tmpStr;
   int rc;

   /*  Get the change dir data record  */

   file_mgr_rec = (FileMgrRec *) client_data;
   dialog_data = _DtGetInstanceData ((XtPointer)file_mgr_rec);
   file_mgr_data = (FileMgrData *) dialog_data->data;
   change_dir_data = (ChangeDirData *) file_mgr_data->change_dir->data;
   change_dir_rec =(ChangeDirRec *)_DtGetDialogInstance(file_mgr_data->change_dir);

   if (change_dir_rec)
      selection_box = change_dir_rec->change_dir;
   else
      selection_box = NULL;

   value = (char *)XmTextFieldGetString(text_field);

   /* check if user attempts to go outside restricted directory */
   rc = CheckRestrictedDir (file_mgr_rec, file_mgr_data, &value, True);

/*
   This code will de-activate the text widget.
   HCI requests that if the switch is not successful, don't de-activate it
   so user has a change to go back and correct it without having to pop it
   up again.

   XmProcessTraversal(file_mgr_rec->file_window, XmTRAVERSE_CURRENT);
   XtSetArg (args[0], XmNallowShellResize, False);
   XtSetValues (file_mgr_rec->shell, args, 1);
   XtUnmanageChild(file_mgr_rec->current_directory_text);
   XtSetArg (args[0], XmNallowShellResize, True);
   XtSetValues (file_mgr_rec->shell, args, 1);
   file_mgr_data->fast_cd_enabled = False;
*/

   /*  Process the string representing a directory to verify  */
   /*  that it is a valid path.                               */
   if (rc == 0)
   {
     if( TryToChangeDir(False, value, file_mgr_data, file_mgr_rec,
                        change_dir_data, selection_box, NULL, NULL,
                        GoToNewDir) )
       /* de-activate the text widget */
       UnpostTextPath( file_mgr_data );
   }

   XtFree(value);
}