gphoto2-widget.c File Reference
`#include "config.h"`
`#include <gphoto2/gphoto2-widget.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <gphoto2/gphoto2-result.h>`
`#include <gphoto2/gphoto2-port-log.h>`

## Data Structures

struct | _CameraWidget

## Macros

#define | CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}

## Functions

int | gp_widget_new (CameraWidgetType type, const char *label, CameraWidget **widget)
| Create a new widget. More...
int | gp_widget_free (CameraWidget *widget)
| Frees a CameraWidget. More...
int | gp_widget_ref (CameraWidget *widget)
| Increments the reference count for the CameraWidget. More...
int | gp_widget_unref (CameraWidget *widget)
| Decrements the reference count for the CameraWidget. More...
int | gp_widget_get_info (CameraWidget *widget, const char **info)
| Retrieves the information about the widget. More...
int | gp_widget_set_info (CameraWidget *widget, const char *info)
| Sets the information about the widget. More...
int | gp_widget_get_name (CameraWidget *widget, const char **name)
| Gets the name of the widget. More...
int | gp_widget_set_name (CameraWidget *widget, const char *name)
| Sets the name of the widget. More...
int | gp_widget_get_id (CameraWidget *widget, int *id)
| Retrieves the unique id of the CameraWidget. More...
int | gp_widget_set_changed (CameraWidget *widget, int changed)
| Tells that the widget has been changed. More...
int | gp_widget_set_readonly (CameraWidget *widget, int readonly)
| Tells that the widget is readonly. More...
int | gp_widget_get_readonly (CameraWidget *widget, int *readonly)
| Retrieves the readonly state of the CameraWidget. More...
int | gp_widget_get_type (CameraWidget *widget, CameraWidgetType *type)
| Retrieves the type of the CameraWidget. More...
int | gp_widget_get_label (CameraWidget *widget, const char **label)
| Retrieves the label of the CameraWidget. More...
int | gp_widget_set_value (CameraWidget *widget, const void *value)
| Sets the value of the widget. More...
int | gp_widget_get_value (CameraWidget *widget, void *value)
| Retrieves the value of the CameraWidget. More...
int | gp_widget_append (CameraWidget *widget, CameraWidget *child)
| Appends a CameraWidget to a CameraWidget. More...
int | gp_widget_prepend (CameraWidget *widget, CameraWidget *child)
| Prepends a CameraWidget to a CameraWidget. More...
int | gp_widget_count_children (CameraWidget *widget)
| Counts the children of the CameraWidget. More...
int | gp_widget_get_child (CameraWidget *widget, int child_number, CameraWidget **child)
| Retrieves the child number `child_number` of the parent. More...
int | gp_widget_get_child_by_label (CameraWidget *widget, const char *label, CameraWidget **child)
| Retrieves the child with label `label` of the CameraWidget. More...
int | gp_widget_get_child_by_id (CameraWidget *widget, int id, CameraWidget **child)
| Retrieves the child with id `id` of the widget. More...
int | gp_widget_get_child_by_name (CameraWidget *widget, const char *name, CameraWidget **child)
| Retrieves the child with name `name` of the widget. More...
int | gp_widget_get_parent (CameraWidget *widget, CameraWidget **parent)
| Retrieves the parent of a CameraWidget. More...
int | gp_widget_get_root (CameraWidget *widget, CameraWidget **root)
| Retrieves the root of the CameraWidget. More...
int | gp_widget_set_range (CameraWidget *range, float min, float max, float increment)
| Sets some range parameters of the CameraWidget. More...
int | gp_widget_get_range (CameraWidget *range, float *min, float *max, float *increment)
| Retrieves some range parameters of the CameraWidget. More...
int | gp_widget_add_choice (CameraWidget *widget, const char *choice)
| Adds a choice to the CameraWidget. More...
int | gp_widget_count_choices (CameraWidget *widget)
| Counts the choices of the CameraWidget. More...
int | gp_widget_get_choice (CameraWidget *widget, int choice_number, const char **choice)
| Retrieves the choice number `choice_number`. More...
int | gp_widget_changed (CameraWidget *widget)
| Tells if the widget has been changed. More...

## Detailed Description

Author
  Copyright 2000 Scott Fritzinger

License
  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

## Function Documentation

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.

References GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, GP_OK, GP_WIDGET_MENU, and GP_WIDGET_RADIO.

int gp_widget_append | ( | CameraWidget * | widget,
|  | CameraWidget * | child
| ) |  |

Appends a CameraWidget to a CameraWidget.

Parameters

  widget | a CameraWidget
  child | the CameraWidget you would like to append to above

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, GP_OK, GP_WIDGET_SECTION, and GP_WIDGET_WINDOW.

int gp_widget_changed | ( | CameraWidget * | widget | ) |

Tells if the widget has been changed.

Parameters

  widget | a CameraWidget

Returns
  a gphoto2 error code or changed flag.

Returns 1 if the state of the CameraWidget has been changed or 0 if not. In addition, it resets the changed flag to 0.

int gp_widget_count_children | ( | CameraWidget * | widget | ) |

Counts the children of the CameraWidget.

Parameters

  widget | a CameraWidget

Returns
  a gphoto2 error code or number of children

Referenced by gp_widget_free().

int gp_widget_count_choices | ( | CameraWidget * | widget | ) |

Counts the choices of the CameraWidget.

Parameters

  widget | a CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU

Returns
  a gphoto2 error code or number of choices.

References GP_ERROR_BAD_PARAMETERS, GP_WIDGET_MENU, and GP_WIDGET_RADIO.

int gp_widget_free | ( | CameraWidget * | widget | ) |

Frees a CameraWidget.

Parameters

  widget | the CameraWidget to be freed

Returns
  a gphoto2 error code.

References GP_OK, gp_widget_count_children(), gp_widget_free(), GP_WIDGET_SECTION, and GP_WIDGET_WINDOW.

Referenced by gp_widget_free(), and gp_widget_unref().

int gp_widget_get_child | ( | CameraWidget * | widget,
|  | int | child_number,
|  | CameraWidget ** | child
| ) |  |

Retrieves the child number `child_number` of the parent.

Parameters

  widget | a CameraWidget
  child_number | the number of the child
  child |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, and GP_OK.

int gp_widget_get_child_by_id | ( | CameraWidget * | widget,
|  | int | id,
|  | CameraWidget ** | child
| ) |  |

Retrieves the child with id `id` of the widget.

Parameters

  widget | a CameraWidget
  id | the id of the child
  child |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_OK, and gp_widget_get_child_by_id().

Referenced by gp_widget_get_child_by_id().

int gp_widget_get_child_by_label | ( | CameraWidget * | widget,
|  | const char * | label,
|  | CameraWidget ** | child
| ) |  |

Retrieves the child with label `label` of the CameraWidget.

Parameters

  widget | a CameraWidget
  label | the label of the child
  child |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_OK, and gp_widget_get_child_by_label().

Referenced by gp_widget_get_child_by_label().

int gp_widget_get_child_by_name | ( | CameraWidget * | widget,
|  | const char * | name,
|  | CameraWidget ** | child
| ) |  |

Retrieves the child with name `name` of the widget.

Parameters

  widget | a CameraWidget
  name | the name of the child

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_OK, and gp_widget_get_child_by_name().

Referenced by gp_widget_get_child_by_name().

int gp_widget_get_choice | ( | CameraWidget * | widget,
|  | int | choice_number,
|  | const char ** | choice
| ) |  |

Retrieves the choice number `choice_number`.

Parameters

  widget | a CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU
  choice_number |
  choice |

Returns
  a gphoto2 error code

References GP_ERROR_BAD_PARAMETERS, GP_OK, GP_WIDGET_MENU, and GP_WIDGET_RADIO.

int gp_widget_get_id | ( | CameraWidget * | widget,
|  | int * | id
| ) |  |

Retrieves the unique id of the CameraWidget.

Parameters

  widget | a CameraWidget
  id |

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_info | ( | CameraWidget * | widget,
|  | const char ** | info
| ) |  |

Retrieves the information about the widget.

Parameters

  widget | a CameraWidget
  info |

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_label | ( | CameraWidget * | widget,
|  | const char ** | label
| ) |  |

Retrieves the label of the CameraWidget.

Parameters

  widget | a CameraWidget
  label |

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_name | ( | CameraWidget * | widget,
|  | const char ** | name
| ) |  |

Gets the name of the widget.

Parameters

  widget | a CameraWidget
  name | Name of above widget

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_parent | ( | CameraWidget * | widget,
|  | CameraWidget ** | parent
| ) |  |

Retrieves the parent of a CameraWidget.

Parameters

  widget | a CameraWidget
  parent | the pointer to the parent to return

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_range | ( | CameraWidget * | range,
|  | float * | min,
|  | float * | max,
|  | float * | increment
| ) |  |

Retrieves some range parameters of the CameraWidget.

Parameters

  range | a CameraWidget of type GP_WIDGET_RANGE
  min |
  max |
  increment |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_OK, and GP_WIDGET_RANGE.

int gp_widget_get_readonly | ( | CameraWidget * | widget,
|  | int * | readonly
| ) |  |

Retrieves the readonly state of the CameraWidget.

Parameters

  widget | a CameraWidget
  readonly |

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_root | ( | CameraWidget * | widget,
|  | CameraWidget ** | root
| ) |  |

Retrieves the root of the CameraWidget.

Parameters

  widget | a CameraWidget
  root |

Returns
  a gphoto2 error code.

References GP_OK, and gp_widget_get_root().

Referenced by gp_widget_get_root().

int gp_widget_get_type | ( | CameraWidget * | widget,
|  | CameraWidgetType * | type
| ) |  |

Retrieves the type of the CameraWidget.

Parameters

  widget | a CameraWidget
  type |

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_get_value | ( | CameraWidget * | widget,
|  | void * | value
| ) |  |

Retrieves the value of the CameraWidget.

Parameters

  widget | a CameraWidget
  value |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, 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, and GP_WIDGET_WINDOW.

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.

References GP_OK.

Referenced by camera_config_get().

int gp_widget_prepend | ( | CameraWidget * | widget,
|  | CameraWidget * | child
| ) |  |

Prepends a CameraWidget to a CameraWidget.

Parameters

  widget | a CameraWidget
  child | the CameraWidget you would like to prepend to above

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_ERROR_NO_MEMORY, GP_OK, GP_WIDGET_SECTION, and GP_WIDGET_WINDOW.

int gp_widget_ref | ( | CameraWidget * | widget | ) |

Increments the reference count for the CameraWidget.

Parameters

  widget | a CameraWidget you want to ref-count

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_set_changed | ( | CameraWidget * | widget,
|  | int | changed
| ) |  |

Tells that the widget has been changed.

Parameters

  widget | a CameraWidget
  changed | a boolean whether we changed or not

Returns
  a gphoto2 error code

Sets the changed of the CameraWidget depending on the changed parameter.

References GP_OK.

int gp_widget_set_info | ( | CameraWidget * | widget,
|  | const char * | info
| ) |  |

Sets the information about the widget.

Parameters

  widget | a CameraWidget
  info | Information about above widget

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_set_name | ( | CameraWidget * | widget,
|  | const char * | name
| ) |  |

Sets the name of the widget.

Parameters

  widget | a CameraWidget
  name | Name of above widget

Returns
  a gphoto2 error code.

References GP_OK.

int gp_widget_set_range | ( | CameraWidget * | range,
|  | float | min,
|  | float | max,
|  | float | increment
| ) |  |

Sets some range parameters of the CameraWidget.

Parameters

  range | a CameraWidget of type GP_WIDGET_RANGE
  min |
  max |
  increment |

Returns
  a gphoto2 error code.

References GP_ERROR_BAD_PARAMETERS, GP_OK, and GP_WIDGET_RANGE.

int gp_widget_set_readonly | ( | CameraWidget * | widget,
|  | int | readonly
| ) |  |

Tells that the widget is readonly.

Parameters

  widget | a CameraWidget
  changed | a boolean whether we are readonly or not

Returns
  a gphoto2 error code

Sets the readonly of the CameraWidget depending on the changed parameter.

Only useful when called from the camera driver.

References GP_OK.

int gp_widget_set_value | ( | CameraWidget * | widget,
|  | const void * | value
| ) |  |

Sets the value of the widget.

Parameters

  widget | a CameraWidget
  value |

Returns
  a gphoto2 error code.

Please pass (char*) for GP_WIDGET_MENU, GP_WIDGET_TEXT, GP_WIDGET_RADIO, (float) for GP_WIDGET_RANGE, (int) for GP_WIDGET_DATE, GP_WIDGET_TOGGLE, and (CameraWidgetCallback) for GP_WIDGET_BUTTON.

References 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, and GP_WIDGET_WINDOW.

int gp_widget_unref | ( | CameraWidget * | widget | ) |

Decrements the reference count for the CameraWidget.

Parameters

  widget | a CameraWidget you want to unref

Returns
  a gphoto2 error code.

References GP_OK, and gp_widget_free().