Ejemplo n.º 1
0
int
main(int argc, char *argv[])
{
  if (uim_init() < 0) {
    fprintf(stderr, "uim_init() failed.\n");
    return -1;
  }

  if (uim_custom_enable()) {
    uim_bool succeeded;
    struct uim_custom *custom;

    custom = uim_custom_get("anthy-candidate-op-count");
    if (custom) {
      inspect_custom(custom);

      printf("\ntrying that modify the custom value to 100\n");
      custom->value->as_int = 100;  /* out of range */
      succeeded = uim_custom_set(custom);
      printf("succeeded = %s\n", succeeded ? "true" : "false");

      printf("\ncurrent status of struct uim_custom *custom\n");
      inspect_custom(custom);  /* shows 100 as value */
      uim_custom_free(custom);

      printf("\ncurrent status of real custom value\n");
      custom = uim_custom_get("anthy-candidate-op-count");
      inspect_custom(custom);  /* shows real value */

      printf("\ntrying that modify the custom value to 5\n");
      custom->value->as_int = 5;  /* valid */
      succeeded = uim_custom_set(custom);
      printf("succeeded = %s\n\n", succeeded ? "true" : "false");
      inspect_custom(custom);

      uim_custom_free(custom);
    }

    uim_custom_save();  /* save updated custom value into ~/.uim.d/customs/ */
  } else {
    fprintf(stderr, "uim_custom_enable() failed.\n");
    uim_quit();
    return -1;
  }

  uim_quit();

  return 0;
}
Ejemplo n.º 2
0
Archivo: qt4.cpp Proyecto: m8a/uim
/*
 * Building up GUI in accordance with Custom Type.
 */
UimCustomItemIface *GroupPageWidget::addCustom( QGroupBox *vbox, const char *custom_sym )
{
    UimCustomItemIface *w = 0;
    struct uim_custom *custom = uim_custom_get( custom_sym );
    if( custom )
    {
        switch( custom->type )
        {
        case UCustom_Bool:
            w = addCustomTypeBool( vbox, custom );
            break;
        case UCustom_Int:
            w = addCustomTypeInteger( vbox, custom );
            break;
        case UCustom_Str:
            w = addCustomTypeString( vbox, custom );
            break;
        case UCustom_Pathname:
            w = addCustomTypePathname( vbox, custom );
            break;
        case UCustom_Choice:
            w = addCustomTypeChoice( vbox, custom );
            break;
        case UCustom_OrderedList:
            w = addCustomTypeOrderedList( vbox, custom );
            break;
        case UCustom_Key:
            w = addCustomTypeKey( vbox, custom );
            break;
        case UCustom_Table:
            w = addCustomTypeTable( vbox, custom );
            break;
        default:
            w = 0;
            qWarning( "Invalid custom type: %d\n", custom->type );
            uim_custom_free( custom );
            break;
        }
    } else {
        qWarning( "Failed to get uim_custom object for %s.", custom_sym );
    }

    /* custom is freed by UimCustomItemIface's destructor */

    return w;
}
Ejemplo n.º 3
0
static uim_bool
dump_custom(const char *custom_sym)
{
  struct uim_custom *custom;
  char *def_literal;

  custom = uim_custom_get(custom_sym);
  if (custom) {
    /* human readable variable name and description */
    printf("\n;; %s\n;; %s\n", custom->label, custom->desc);

    def_literal = uim_custom_definition_as_literal(custom_sym);
    if (def_literal) {
      printf("%s\n", def_literal);
      free(def_literal);
    }
    uim_custom_free(custom);
  }

  return UIM_TRUE;
}