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

int gp_widget_add_choice ( CameraWidget widget,
const char *  choice 
)

Adds a choice to the CameraWidget.

Parameters:
widget a CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU
choice 
Returns:
a gphoto2 error code.

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

References CHECK_NULL, _CameraWidget::choice, _CameraWidget::choice_count, GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, GP_OK, GP_WIDGET_MENU, GP_WIDGET_RADIO, and _CameraWidget::type.

{
      char **choices;
      CHECK_NULL (widget && choice);
      if ((widget->type != GP_WIDGET_RADIO) &&
          (widget->type != GP_WIDGET_MENU))
            return (GP_ERROR_BAD_PARAMETERS);

      if (widget->choice_count) {
            choices = realloc (widget->choice, sizeof(char*)*(widget->choice_count+1));
      } else {
            choices = malloc (sizeof(char*));
      }
      if (!choices) return (GP_ERROR_NO_MEMORY);

      widget->choice = choices;
      widget->choice[widget->choice_count] = strdup(choice);
      widget->choice_count += 1;
      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index