Exemplo n.º 1
0
static Boolean apply_proc(Widget w)
{
  int status;
  Widget mem_scale = XtNameToWidget(XtParent(w), "mems_scale");
  static int mems;
  static DESCRIPTOR_LONG(mems_dsc,&mems);
  int nid;
  XtVaGetValues(mem_scale, XmNuserData, &nid, NULL);
  XmScaleGetValue(mem_scale, &mems);
  status = TreePutRecord(nid, &mems_dsc,0) & 1;
  if (!status)
    XmdsComplain(XtParent(w), "Error writing num memories");
  if (status)
    XmdsApplyAllXds(XtParent(w));
  return status & 1;
}
Exemplo n.º 2
0
static int Apply(Widget w)
{
  Widget list_w = XtNameToWidget(XtParent(w),"*interpreters");
  XtPointer  user_data;
  int nid;
  XmString *selections=NULL;
  String   list = 0;
  String   old_list;
  int      num;
  int      i;
  int      status = 1;
  XtVaGetValues(list_w, XmNuserData, &user_data, NULL);
  nid = (intptr_t)user_data;
  old_list = XmdsGetNidText(nid);
  XtVaGetValues(list_w, XmNselectedItems, &selections, XmNselectedItemCount, &num, NULL);
  for (i=0;i<num;i++)
  {
    String item;
    item = XmStringUnparse(selections[i], NULL, 0, XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
    if (item)
    {
      if (list)
      {
        list = XtRealloc(list, strlen(list) + strlen(item) + 2);
        strcat(list,item);
      }
      else
      {
        list = XtMalloc(strlen(item) + 2);
        strcpy(list,item);
      }
      strcat(list,"\n");
      XtFree(item);
    }
  }
  if ( (list && (old_list ? strcmp(old_list,list) : 1)) ||
       (!list && (old_list ? strlen(old_list) : 0)) )
  {
    if (list)
    {
      static struct descriptor list_dsc = {0, DTYPE_T, CLASS_S, 0};
      list_dsc.length = strlen(list);
      list_dsc.pointer = list;
      status = TreePutRecord(nid, &list_dsc,0) & 1;
      if (!status)
        XmdsComplain(XtParent(w), "Error writing interpreter selections");
    }
    else
    {
      struct descriptor list_dsc = {0, DTYPE_T, CLASS_S, 0};
      status = TreePutRecord(nid, &list_dsc,0) & 1;
      if (!status)
        XmdsComplain(XtParent(w), "Error writing interpreter selections");
    }
  }
  XtFree(list);
  XtFree(old_list);
  if (status)
    XmdsApplyAllXds(XtParent(w));
  return status & 1;
}