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

int gp_widget_new ( CameraWidgetType  type,
const char *  label,
CameraWidget **  widget 
)

Create a new widget.

The function creates a new CameraWidget of specified type and with given label.

Parameters:
type the type
label the label
widget 
Returns:
a gphoto2 error code.

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

References CHECK_NULL, and GP_OK.

Referenced by camera_config_get().

{
      int x;
      static int i = 0;

      CHECK_NULL (label && widget);

      *widget = (CameraWidget*) malloc (sizeof (CameraWidget));
      memset (*widget, 0, sizeof (CameraWidget));

      (*widget)->type = type;
      strcpy ((*widget)->label, label);
      
      /* set the value to nothing */
      (*widget)->value_int          = 0;
        (*widget)->value_float      = 0.0;
        (*widget)->value_string     = NULL;

        (*widget)->ref_count        = 1;
      (*widget)->choice_count       = 0;
      (*widget)->id                 = i++;

        /* Clear all children pointers */
      memset ((*widget)->children, 0, sizeof((*widget)->children));
      (*widget)->children_count = 0;

      /* Clear out the choices */
      for (x = 0; x < sizeof((*widget)->choice)/sizeof((*widget)->choice[0]); x++)
            strcpy ((*widget)->choice[x], "");

      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index