Пример #1
0
void OH_GetInstituteDialog_UpdateList(GWEN_DIALOG *dlg)
{
  OH_GETINST_DIALOG *xdlg;
  const OH_INSTITUTE_SPEC_LIST *sl;

  assert(dlg);
  xdlg=GWEN_INHERIT_GETDATA(GWEN_DIALOG, OH_GETINST_DIALOG, dlg);
  assert(xdlg);

  /* clear bank info list */
  GWEN_Dialog_SetIntProperty(dlg, "listBox", GWEN_DialogProperty_ClearValues, 0, 0, 0);
  OH_InstituteSpec_List_Clear(xdlg->matchingSpecList);
  OH_InstituteData_free(xdlg->selectedData);
  xdlg->selectedData=NULL;

  sl=OfxHome_GetSpecs(xdlg->ofxHome);
  if (sl) {
    GWEN_BUFFER *tbuf;
    const OH_INSTITUTE_SPEC *os;
    const char *s;

    s=GWEN_Dialog_GetCharProperty(dlg, "nameEdit", GWEN_DialogProperty_Value, 0, NULL);
    tbuf=GWEN_Buffer_new(0, 256, 0, 1);
    os=OH_InstituteSpec_List_First(sl);
    while (os) {
      const char *bname;

      bname=OH_InstituteSpec_GetName(os);
      /* only add matching entries */
      if ((s && bname && GWEN_Text_StrCaseStr(bname, s)!=NULL) ||
          !(s && *s)) {
        OH_InstituteSpec_List_Add(OH_InstituteSpec_dup(os), xdlg->matchingSpecList);
        createListBoxString(os, tbuf);

        GWEN_Dialog_SetCharProperty(dlg,
                                    "listBox",
                                    GWEN_DialogProperty_AddValue,
                                    0,
                                    GWEN_Buffer_GetStart(tbuf),
                                    0);
        GWEN_Buffer_Reset(tbuf);
      }
      os=OH_InstituteSpec_List_Next(os);
    }

    GWEN_Buffer_free(tbuf);
  }

  if (GWEN_Dialog_GetIntProperty(dlg, "listBox", GWEN_DialogProperty_Value, 0, -1)>=0)
    GWEN_Dialog_SetIntProperty(dlg, "okButton", GWEN_DialogProperty_Enabled, 0, 1, 0);
  else
    GWEN_Dialog_SetIntProperty(dlg, "okButton", GWEN_DialogProperty_Enabled, 0, 0, 0);
}
Пример #2
0
static void createListBoxString(const OH_INSTITUTE_SPEC *os, GWEN_BUFFER *tbuf) {
  const char *s;
  char numbuf[32];

  s=OH_InstituteSpec_GetName(os);
  if (s && *s) {
    GWEN_Buffer_AppendString(tbuf, s);
    snprintf(numbuf, sizeof(numbuf)-1, " (%d)", OH_InstituteSpec_GetId(os));
    numbuf[sizeof(numbuf)-1]=0;
    GWEN_Buffer_AppendString(tbuf, numbuf);
  }
  else {
    snprintf(numbuf, sizeof(numbuf)-1, "%d", OH_InstituteSpec_GetId(os));
    numbuf[sizeof(numbuf)-1]=0;
    GWEN_Buffer_AppendString(tbuf, numbuf);
  }
}