Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_widget_set_value ( CameraWidget widget,
const void *  value 

Sets the value of the widget.

widget a CameraWidget
a gphoto2 error code.
Please pass (char*) for GP_WIDGET_MENU, GP_WIDGET_TEXT, (float) for GP_WIDGET_RANGE, (int) for GP_WIDGET_DATE, GP_WIDGET_TOGGLE, GP_WIDGET_RADIO, and (CameraWidgetCallback) for GP_WIDGET_BUTTON.

Definition at line 348 of file gphoto2-widget.c.

References _CameraWidget::callback, _CameraWidget::changed, CHECK_NULL, GP_ERROR_BAD_PARAMETERS, gp_log(), GP_LOG_DEBUG, GP_OK, GP_WIDGET_BUTTON, GP_WIDGET_DATE, GP_WIDGET_MENU, GP_WIDGET_RADIO, GP_WIDGET_RANGE, GP_WIDGET_SECTION, GP_WIDGET_TEXT, GP_WIDGET_TOGGLE, GP_WIDGET_WINDOW, _CameraWidget::type, _CameraWidget::value_float, _CameraWidget::value_int, and _CameraWidget::value_string.

      CHECK_NULL (widget && value);

        switch (widget->type) {
      case GP_WIDGET_BUTTON:
            widget->callback = (CameraWidgetCallback) value;
            return (GP_OK);
      case GP_WIDGET_MENU:
      case GP_WIDGET_RADIO:
        case GP_WIDGET_TEXT:
            gp_log (GP_LOG_DEBUG, "gphoto2-widget", "Setting value to "
                  "'%s'...", (char*) value);
              if (widget->value_string) {
                  if (strcmp (widget->value_string, (char*) value))
                              widget->changed = 1;
                  free (widget->value_string);
            } else
                  widget->changed = 1;
            widget->value_string = strdup ((char*)value);
            return (GP_OK);
        case GP_WIDGET_RANGE:
                  if (widget->value_float != *((float*)value)) {
                  widget->value_float  = *((float*)value);
                  widget->changed = 1;
                  return (GP_OK);
      case GP_WIDGET_DATE:
        case GP_WIDGET_TOGGLE:
            if (widget->value_int != *((int*)value)) {
                  widget->value_int  = *((int*)value);
                  widget->changed = 1;
              return (GP_OK);
      case GP_WIDGET_WINDOW:
            return (GP_ERROR_BAD_PARAMETERS);

Generated by  Doxygen 1.6.0   Back to index