// Fill the pids in DISP_NRS static void getPIDs(Widget selectionList, IntArray& disp_nrs) { static const IntArray empty; disp_nrs = empty; XmStringTable selected_items; int selected_items_count = 0; assert(XmIsList(selectionList)); XtVaGetValues(selectionList, XmNselectedItemCount, &selected_items_count, XmNselectedItems, &selected_items, XtPointer(0)); for (int i = 0; i < selected_items_count; i++) { String _item; XmStringGetLtoR(selected_items[i], LIST_CHARSET, &_item); string item(_item); XtFree(_item); int p = ps_pid(item); if (p > 0) disp_nrs += p; } }
// Get the selected item ids static void get_items(Widget selectionList, StringArray& itemids) { static const StringArray empty; itemids = empty; XmStringTable selected_items; int selected_items_count = 0; assert(XmIsList(selectionList)); XtVaGetValues(selectionList, XmNselectedItemCount, &selected_items_count, XmNselectedItems, &selected_items, XtPointer(0)); for (int i = 0; i < selected_items_count; i++) { String _item; XmStringGetLtoR(selected_items[i], LIST_CHARSET, &_item); string item(_item); XtFree(_item); itemids += item; } }
/*ARGSUSED*/ static void openCB(Widget w,int client_data,XmFileSelectionBoxCallbackStruct *call_data) { if (client_data==DIALOG_CANCEL) { /* do nothing if cancel is selected. */ XtUnmanageChild(open_dialog); return; } else if (client_data==DIALOG_ALL) { /* Add all the listed files */ Arg al[10]; int ac; Widget the_list; int nbfile; XmStringTable files; char *text; int i; the_list=XmFileSelectionBoxGetChild(open_dialog,XmDIALOG_LIST); if (!XmIsList(the_list)) { fprintf(stderr, "PANIC: List are not what they used to be" NLS); exit(1); } ac=0; XtSetArg(al[ac], XmNitemCount, &nbfile); ac++; XtSetArg(al[ac], XmNitems, &files); ac++; XtGetValues(the_list, al, ac); m_pipe_int_write(MOTIF_EXPAND); m_pipe_int_write(nbfile); for (i=0;i<nbfile;i++) { XmStringGetLtoR(files[i],char_set,&text); m_pipe_string_write(text); XtFree(text); } XtUnmanageChild(open_dialog); } else { /* get filename from file selection box and add it to the list*/ char *text; m_pipe_int_write(MOTIF_EXPAND); m_pipe_int_write(1); XmStringGetLtoR(call_data->value,char_set,&text); m_pipe_string_write(text); XtFree(text); XtUnmanageChild(open_dialog); } }
/* * File selection box callback */ void openCB(Widget w,int client_data,XmFileSelectionBoxCallbackStruct *call_data) { if (client_data==DIALOG_CANCEL) { /* do nothing if cancel is selected. */ XtUnmanageChild(open_dialog); return; } else if (client_data==DIALOG_ALL) { /* Add all the listed files */ Arg al[10]; int ac; Widget the_list; int nbfile; XmStringTable files; int i; the_list=XmFileSelectionBoxGetChild(open_dialog,XmDIALOG_LIST); if (!XmIsList(the_list)) { printf("PANIC: List are not what they used to be\n"); exit; } ac=0; XtSetArg(al[ac], XmNitemCount, &nbfile); ac++; XtSetArg(al[ac], XmNitems, &files); ac++; XtGetValues(the_list, al, ac); for (i=0;i<nbfile;i++) XmListAddItemUnselected(file_list,files[i],0); } else { /* get filename from file selection box and add it to the list*/ XmListAddItemUnselected(file_list,call_data->value,0); XtUnmanageChild(open_dialog); } }
void DtcmProcessPress( Widget w, XEvent *event, String *params, Cardinal *num_params) { int i, action, cur_item; int *selected_positions, nselected_positions; /* * This action happens when Button1 is pressed and the Selection * and Transfer are integrated on Button1. It is passed two * parameters: the action to call when the event is a selection, * and the action to call when the event is a transfer. */ if (*num_params != 2 || !XmIsList(w)) return; action = SELECTION_ACTION; cur_item = XmListYToPos(w, event->xbutton.y); if (cur_item > 0) { XtVaGetValues(w, XmNselectedPositions, &selected_positions, XmNselectedPositionCount, &nselected_positions, NULL); for (i=0; i<nselected_positions; i++) { if (cur_item == selected_positions[i]) { /* * The determination of whether this is a transfer drag * cannot be made until a Motion event comes in. It is * not a drag as soon as a ButtonUp event happens. */ XEvent new_event; XPeekIfEvent( XtDisplay(w), &new_event, lookForButton, (XPointer)event); switch (new_event.type) { case MotionNotify: action = TRANSFER_ACTION; break; case ButtonRelease: action = SELECTION_ACTION; break; } break; } } } XtCallActionProc(w, params[action], event, params, *num_params); }