Esempio n. 1
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;
}
Esempio n. 2
0
static void
ReusePrimaryHelpWindow(
   DialogData * primaryHelpDialog,
   char * idString,
   char * volume,
   char * topicTitle,
   char * fileType,
   int helpType )

{
   HelpData * helpData;
   HelpRec * helpRec;
   String helpString = NULL;
   int n;
   Arg args[10];

   /* Reuse the existing main help window for this view */
   helpData = (HelpData *)primaryHelpDialog->data;
   XtFree(helpData->idString);
   XtFree(helpData->volString);
   XtFree(helpData->topicTitle);
   XtFree(helpData->fileType);
   helpData->idString = XtNewString(idString);
   helpData->volString = XtNewString(volume);
   helpData->topicTitle = XtNewString(topicTitle);
   helpData->fileType = XtNewString(fileType);
   helpData->helpType = helpType;
   helpRec = (HelpRec *) _DtGetDialogInstance(primaryHelpDialog);
   n = 0;
   XtSetArg(args[n], DtNhelpType, (unsigned char )helpType); n++;
   XtSetArg(args[n], DtNhelpType, helpType); n++;
   if (helpType == DtHELP_TYPE_TOPIC)
   {
      XtSetArg(args[n], DtNlocationId, helpData->idString); n++;
   }
   else
   {
      helpString = MapFileTypeToHelpString(helpData->idString,
                                           helpData->fileType);
      XtSetArg(args[n], DtNstringData, helpString); n++;
      XtSetArg(args[n], DtNtopicTitle, helpData->topicTitle); n++;
   }
   XtSetValues(helpRec->helpDialog, args, n);
   XtFree(helpString);
}
Esempio n. 3
0
static void
WriteResourceValues(
        DialogData *values,
        int fd,
        char **name_list )
{
   ChangeDirData * change_dir_data = (ChangeDirData *) values->data;
   ChangeDirRec * change_dir_rec;

   /*  If the dialog is currently displayed, update the geometry  */
   /*  fields to their current values.                            */

   if (change_dir_data->displayed == True)
   {
      _DtGenericUpdateWindowPosition(values);
      change_dir_rec = (ChangeDirRec *) _DtGetDialogInstance (values);
   }

   _DtDialogPutResources (fd, name_list, CHANGEDIRECTORY, values->data,
                          resources, changeDirClass->resource_count);
}
Esempio n. 4
0
static Boolean
IsFilterIcon(
   Widget w,
   FileMgrData * fileMgrData,
   String * ftName )

{
   Arg args[2];
   DialogData * filterEditDialogData;
   FilterData * filterData;
   FilterRec * filterRec;
   FTData * filterEntryData;

   filterEditDialogData = fileMgrData->filter_edit;
   if (!filterEditDialogData)
      return(False);

   filterData = (FilterData *)filterEditDialogData->data;

   if (!filterData->displayed)
      return(False);

   filterRec = (FilterRec *) _DtGetDialogInstance(filterEditDialogData);

   /* Check if the parent of the widget is the filter's drawingArea */
   if (XtParent(w) != filterRec->file_window)
      return(False);

   /*
    * Each icon in the filter dialog has attached as its userData a
    * pointer to a structure of information about the associated
    * filetype; get this structure, to get the filetype index.
    */
   XtSetArg(args[0], XmNuserData, &filterEntryData);
   XtGetValues(w, args, 1);
   *ftName = XtNewString(filterEntryData->filetype);
   return (True);
}
Esempio n. 5
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);
   }

}
Esempio n. 6
0
File: PrefsP.c Progetto: juddy/edcde
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;
}
Esempio n. 7
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);
}