static void activateCB_AF_ApplyButton( Widget UxWidget, XtPointer UxClientData, XtPointer UxCallbackArg) { FiletypeData *pFtD; /**************************************************************************/ /* Check if fields are valid. */ /**************************************************************************/ if (!AddFiletypeCheckFields()) { /***********************************************************************/ /* Get FiletypeData structure that was allocated when Add button on */ /* the CreateActionAppShell interface was activated. */ /***********************************************************************/ XtVaGetValues(AddFiletype, XmNuserData, &pFtD, NULL); /***********************************************************************/ /* Get all values from gui */ /***********************************************************************/ readAFFromGUI(pFtD); /***********************************************************************/ /* Set the variable that indicates that Apply button was used. */ /***********************************************************************/ pFtD->fsInternal |= CA_FT_APPLY; /***********************************************************************/ /* If in edit mode, then don't do apply type things. */ /***********************************************************************/ if (!(pFtD->fsInternal & CA_FT_EDIT)) { /********************************************************************/ /* Update the Filetype listbox with this new filetype */ /********************************************************************/ if (XmListItemExists(CA_FiletypesList, XmStringCreateSimple("NONE"))) { XmListDeleteItem(CA_FiletypesList, XmStringCreateSimple("NONE")); } AddFiletypeToList(); /********************************************************************/ /* Update FiletypeData array within the ActionData structure */ /********************************************************************/ UpdateFiletypeDataArray(pFtD); } } }
static void Reset(Widget w) { int status; Widget list_w = XtNameToWidget(XtParent(w),"*interpreters"); static struct descriptor_d cli = {0, DTYPE_T, CLASS_D, 0}; static DESCRIPTOR(initial, "_I=0"); static DESCRIPTOR(clis, "(clis()[_I++]//\"\\0\")"); XtPointer user_data; int nid; String selections; String selection; int ctx = 0; int first = 1; XtVaGetValues(list_w, XmNuserData, &user_data, NULL); nid = (intptr_t)user_data; XmListDeselectAllItems(list_w); XmListDeleteAllItems(list_w); TdiExecute(&initial,&cli MDS_END_ARG); while ((status=TdiExecute(&clis, &cli MDS_END_ARG)&1 && cli.length > 0 && strlen(cli.pointer) > 0)) { XmString item; item = XmStringCreateSimple(cli.pointer); if (!XmListItemExists(list_w,item)) XmListAddItem(list_w,item,0); XmStringFree(item); } selections = XmdsGetNidText(nid); for (selection=strtok(selections,"\n");selection;selection=strtok(0,"\n")) { XmString item = XmStringCreateSimple(selection); XmListSelectItem(list_w, item, 0); if (first) { first = 0; XmListSetItem(list_w, item); } XmStringFree(item); } XtFree(selections); return; }
extern void blist_init_ui(Calendar *c) { int i; XmString xmstr; BlistData *bd; Browselist *bl = (Browselist *)c->browselist; XtVaSetValues(bl->form, XmNresizePolicy, XmRESIZE_NONE, NULL); XmListDeleteAllItems(bl->browse_list); for (i = 1; i <= bl->blist_data->count; i++) { bd = (BlistData *)CmDataListGetData(bl->blist_data, i); if (bd && bd->name && bd->tag != BLIST_DELETE) { xmstr = XmStringCreateLocalized(bd->name); if (!XmListItemExists(bl->browse_list, xmstr)) XmListAddItem(bl->browse_list, xmstr, 0); XmStringFree(xmstr); } } XmTextFieldSetString(bl->username, ""); XtVaSetValues(bl->form, XmNresizePolicy, XmRESIZE_ANY, NULL); }
/***************************************************************************** TryToChangeDir INPUT: OUTPUT: DESCRIPTION: This function is used both by the ChangeDir dialog, and the FileMgr dialog's text field; it attempts to verify the incoming string, and then change to the indicated directory. NOTE: *****************************************************************************/ static Boolean TryToChangeDir( Boolean isFromDialog, char * incoming_string, FileMgrData * file_mgr_data, FileMgrRec * file_mgr_rec, ChangeDirData * change_dir_data, Widget selection_box, ChangeDirApply * apply_data, XmSelectionBoxCallbackStruct * callback_data, void (*callback)()) { char * new_directory; char * host; char * path; struct stat stat_buf; Widget list; XmString path_string; XmString host_string; Arg args[1]; char * message_buf; char * tmpStr; char * title; char * msg; Boolean rc = True; char *restricted = NULL; new_directory = XtNewString(incoming_string); if ((new_directory) && (strcmp(new_directory, "") != 0)) { _DtPathFromInput(new_directory, file_mgr_data->current_directory, &host, &path); } else { tmpStr = GetSharedMessage(CHANGE_DIR_ERROR_TITLE); title = XtNewString(tmpStr); tmpStr = GETMESSAGE(2,18, "Destination Folder name is missing.\nType in a folder name or select a folder from the list."); msg = XtNewString(tmpStr); if(isFromDialog) _DtMessage(selection_box, title, msg, NULL, HelpRequestCB); else _DtMessage(file_mgr_rec->current_directory_text, title, msg, NULL, HelpRequestCB); XtFree(title); XtFree(msg); return False; } /* Don't allow access to the desktop directory */ if (path) { char *ttpath = (char *) GetTTPath(path); char *dtpath = (char *) GetTTPath(desktop_dir); if( ttpath && strcmp(ttpath, dtpath) == 0) { restricted = ttpath; XtFree(path); path = NULL; } } /* Stat the file and see if it is a valid directory. (If the current view is restricted, make sure that the new directory doesn't violate the directory restrictions. If so, refilter the displayed file set to show the files in this directory. */ if ((path) &&(stat(path, &stat_buf) == 0) &&((stat_buf.st_mode & S_IFMT) == S_IFDIR) &&(CheckRestrictedDir(file_mgr_rec, file_mgr_data, &path, False) == 0)) { /* Check for read/xcute permission */ if (CheckAccess(path, R_OK | X_OK)) { tmpStr = GETMESSAGE(9, 6, "Action Error"); title = XtNewString(tmpStr); msg = (char *)XtMalloc(strlen(GETMESSAGE(30, 1, "Cannot read from %s")) + strlen(new_directory) + 1); sprintf(msg, GETMESSAGE(30, 1, "Cannot read from %s"), new_directory); if(isFromDialog) _DtMessage(selection_box, title, msg, NULL, HelpRequestCB); else _DtMessage(file_mgr_rec->current_directory_text, title, msg, NULL, HelpRequestCB); XtFree(title); XtFree(msg); return; } else { if (selection_box) { /* Adjust the selection box elements to add the text item into the list. */ list = XmSelectionBoxGetChild(selection_box, XmDIALOG_LIST); path_string = XmStringCreateLocalized(path); if (XmListItemExists(list, path_string)) XmListDeselectAllItems(list); else XmListAddItem(list, path_string, 0); XmListSelectItem(list, path_string, False); XmListSetBottomPos(list, 0); XmStringFree(path_string); } /* Clear out the text string */ if (isFromDialog) { if(restrictMode) XtSetArg(args[0], XmNtextString, XmStringCreateLocalized(users_home_dir)); else XtSetArg(args[0], XmNtextString, NULL); XtSetValues(selection_box, args, 1); } else { if(!file_mgr_data || !file_mgr_data->restricted_directory) XmTextFieldSetString(file_mgr_rec->current_directory_text, incoming_string); } /* Update the change directory host name field and the host name indicator widget in the dialog. */ XtFree((char *) change_dir_data->host_name); change_dir_data->host_name = XtNewString(host); if (selection_box) { tmpStr = GETMESSAGE(2, 16, "System Name: "); message_buf = XtMalloc(strlen(tmpStr) + strlen(change_dir_data->host_name) + 1); sprintf(message_buf, "%s%s", tmpStr, change_dir_data->host_name); host_string = XmStringCreateLocalized(message_buf); XtSetArg(args[0], XmNlabelString, host_string); XtSetValues(XmSelectionBoxGetChild(selection_box,XmDIALOG_LIST_LABEL), args, 1); XtFree(message_buf); XmStringFree(host_string); XmUpdateDisplay (selection_box); } /* Call the encapsulation change data callback */ if (isFromDialog) (*callback)(selection_box, apply_data->client_data, path); else (*callback)(file_mgr_data, path); } } else { tmpStr = GetSharedMessage(CHANGE_DIR_ERROR_TITLE); title = XtNewString(tmpStr); if(restricted) { tmpStr = GETMESSAGE(2,20,"You cannot switch to folder:\n\n%s\n\nYou are not allowed to view this folder\nbecause it is a restricted folder."); path = restricted; } else tmpStr = GETMESSAGE(2,19,"The following folder name is invalid.\n\n%s"); if(path) { message_buf = XtMalloc(strlen(tmpStr) + strlen(path) + 1); sprintf(message_buf, tmpStr, path); } else { message_buf = XtMalloc(strlen(tmpStr) + strlen(new_directory) + 1); sprintf(message_buf, tmpStr, new_directory); } if (isFromDialog) _DtMessage(selection_box, title, message_buf, NULL, HelpRequestCB); else _DtMessage(file_mgr_rec->current_directory_text, title, message_buf, NULL, HelpRequestCB); XtFree(title); XtFree(message_buf); rc = False; } if (path) XtFree((char *) path); XtFree((char *) host); XtFree((char *) new_directory); return rc; }