"Fossies" - the Fresh Open Source Software Archive

Member "libgphoto2-2.5.27/libgphoto2/gphoto2-widget.c" (31 Jan 2021, 17658 Bytes) of package /linux/privat/libgphoto2-2.5.27.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gphoto2-widget.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.5.26_vs_2.5.27.

    1 /** \file
    2  *
    3  * \author Copyright 2000 Scott Fritzinger
    4  *
    5  * \par License
    6  * This library is free software; you can redistribute it and/or
    7  * modify it under the terms of the GNU Lesser General Public
    8  * License as published by the Free Software Foundation; either
    9  * version 2 of the License, or (at your option) any later version.
   10  *
   11  * \par
   12  * This library is distributed in the hope that it will be useful,
   13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   15  * Lesser General Public License for more details.
   16  *
   17  * \par
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the
   20  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   21  * Boston, MA  02110-1301  USA
   22  */
   23 #define _DARWIN_C_SOURCE
   24 #include "config.h"
   25 #include <gphoto2/gphoto2-widget.h>
   26 
   27 #include <stdlib.h>
   28 #include <string.h>
   29 
   30 #include <gphoto2/gphoto2-result.h>
   31 #include <gphoto2/gphoto2-port-log.h>
   32 
   33 /**
   34  * CameraWidget:
   35  *
   36  * The internals of the #CameraWidget are only visible to gphoto2. You can
   37  * only access them using the functions provided by gphoto2.
   38  **/
   39 struct _CameraWidget {
   40     CameraWidgetType type;
   41     char    label [256];
   42     char    info [1024];
   43     char    name [256];
   44 
   45     CameraWidget *parent;
   46 
   47     /* Current value of the widget */
   48     char   *value_string;
   49     int     value_int;
   50     float   value_float;
   51 
   52     /* For Radio and Menu */
   53     char    **choice;
   54     int     choice_count;
   55 
   56     /* For Range */
   57     float   min;
   58     float   max;
   59     float   increment;
   60 
   61     /* Child info */
   62     CameraWidget **children;
   63     int           children_count;
   64 
   65     /* Widget was changed */
   66     int     changed;
   67 
   68     /* Widget is read only */
   69     int readonly;
   70 
   71     /* Reference count */
   72     int     ref_count;
   73 
   74     /* Unique identifier */
   75     int     id;
   76 
   77     /* Callback */
   78     CameraWidgetCallback callback;
   79 };
   80 
   81 /**
   82  * \brief Create a new widget.
   83  *
   84  * The function creates a new #CameraWidget of specified type and with
   85  * given label.
   86  *
   87  * @param type the type
   88  * @param label the label
   89  * @param widget
   90  * @return a gphoto2 error code.
   91  *
   92  **/
   93 int
   94 gp_widget_new (CameraWidgetType type, const char *label,
   95            CameraWidget **widget)
   96 {
   97     static int i = 0;
   98 
   99     C_PARAMS (label && widget);
  100 
  101     C_MEM (*widget = calloc (1, sizeof (CameraWidget)));
  102 
  103     (*widget)->type = type;
  104     strcpy ((*widget)->label, label);
  105 
  106     /* set the value to nothing */
  107     (*widget)->value_int        = 0;
  108         (*widget)->value_float      = 0.0;
  109         (*widget)->value_string     = NULL;
  110 
  111         (*widget)->ref_count        = 1;
  112     (*widget)->choice_count     = 0;
  113     (*widget)->choice       = NULL;
  114     (*widget)->readonly         = 0;
  115     (*widget)->id           = i++;
  116 
  117         /* Clear all children pointers */
  118     free ((*widget)->children);
  119     (*widget)->children = NULL;
  120     (*widget)->children_count = 0;
  121 
  122     return (GP_OK);
  123 }
  124 
  125 /**
  126  * \brief Frees a CameraWidget
  127  *
  128  * @param widget the #CameraWidget to be freed
  129  * @return a gphoto2 error code.
  130  *
  131  **/
  132 int
  133 gp_widget_free (CameraWidget *widget)
  134 {
  135     int x;
  136     C_PARAMS (widget);
  137 
  138     /* Free children recursively */
  139     if ((widget->type == GP_WIDGET_WINDOW) ||
  140         (widget->type == GP_WIDGET_SECTION)) {
  141             for (x = 0; x < gp_widget_count_children (widget); x++)
  142             gp_widget_free (widget->children[x]);
  143         free (widget->children);
  144     }
  145     for (x = 0; x < widget->choice_count; x++)
  146         free (widget->choice[x]);
  147     free (widget->choice);
  148     free (widget->value_string);
  149     free (widget);
  150     return (GP_OK);
  151 }
  152 
  153 /**
  154  * \brief Increments the reference count for the CameraWidget
  155  *
  156  * @param widget a #CameraWidget you want to ref-count
  157  * @return a gphoto2 error code.
  158  *
  159  **/
  160 int
  161 gp_widget_ref (CameraWidget *widget)
  162 {
  163     C_PARAMS (widget);
  164 
  165     widget->ref_count += 1;
  166 
  167     return (GP_OK);
  168 }
  169 
  170 /**
  171  * \brief Decrements the reference count for the CameraWidget
  172  *
  173  * @param widget a CameraWidget you want to unref
  174  * @return a gphoto2 error code.
  175  *
  176  **/
  177 int
  178 gp_widget_unref (CameraWidget *widget)
  179 {
  180     C_PARAMS (widget);
  181 
  182     widget->ref_count -= 1;
  183 
  184     if (widget->ref_count == 0)
  185         gp_widget_free (widget);
  186 
  187     return (GP_OK);
  188 }
  189 
  190 /**
  191  * \brief Retrieves the information about the widget
  192  *
  193  * @param widget a #CameraWidget
  194  * @param info
  195  * @return a gphoto2 error code.
  196  *
  197  **/
  198 int
  199 gp_widget_get_info (CameraWidget *widget, const char **info)
  200 {
  201     C_PARAMS (widget && info);
  202 
  203     *info = widget->info;
  204     return (GP_OK);
  205 }
  206 
  207 
  208 /**
  209  * \brief Sets the information about the widget
  210  *
  211  * @param widget a #CameraWidget
  212  * @param info Information about above widget
  213  * @return a gphoto2 error code.
  214  *
  215  **/
  216 int
  217 gp_widget_set_info (CameraWidget *widget, const char *info)
  218 {
  219     C_PARAMS (widget && info);
  220 
  221     strcpy (widget->info, info);
  222     return (GP_OK);
  223 }
  224 
  225 /**
  226  * \brief Gets the name of the widget
  227  *
  228  * @param widget a #CameraWidget
  229  * @param name Name of above widget
  230  * @return a gphoto2 error code.
  231  *
  232  **/
  233 int
  234 gp_widget_get_name (CameraWidget *widget, const char **name)
  235 {
  236     C_PARAMS (widget && name);
  237 
  238     *name = widget->name;
  239     return (GP_OK);
  240 }
  241 
  242 /**
  243  * \brief Sets the name of the widget
  244  *
  245  * @param widget a #CameraWidget
  246  * @param name Name of above widget
  247  * @return a gphoto2 error code.
  248  *
  249  **/
  250 int
  251 gp_widget_set_name (CameraWidget *widget, const char *name)
  252 {
  253     C_PARAMS (widget && name);
  254 
  255     strcpy (widget->name, name);
  256     return (GP_OK);
  257 }
  258 
  259 
  260 
  261 /**
  262  * \brief Retrieves the unique id of the #CameraWidget
  263  *
  264  * @param widget a #CameraWidget
  265  * @param id
  266  * @return a gphoto2 error code.
  267  *
  268  **/
  269 int
  270 gp_widget_get_id (CameraWidget *widget, int *id)
  271 {
  272     C_PARAMS (widget && id);
  273 
  274     *id = widget->id;
  275     return (GP_OK);
  276 }
  277 
  278 /**
  279  * \brief Tells that the widget has been changed
  280  *
  281  * @param widget a #CameraWidget
  282  * @param changed a boolean whether we changed or not
  283  * @return a gphoto2 error code
  284  *
  285  * Sets the changed of the CameraWidget depending on
  286  * the changed parameter.
  287  *
  288  **/
  289 int
  290 gp_widget_set_changed (CameraWidget *widget, int changed)
  291 {
  292     C_PARAMS (widget);
  293 
  294     widget->changed = changed;
  295     return (GP_OK);
  296 }
  297 
  298 /**
  299  * \brief Tells that the widget is readonly
  300  *
  301  * @param widget a #CameraWidget
  302  * @param changed a boolean whether we are readonly or not
  303  * @return a gphoto2 error code
  304  *
  305  * Sets the readonly of the CameraWidget depending on
  306  * the changed parameter.
  307  *
  308  * Only useful when called from the camera driver.
  309  **/
  310 int
  311 gp_widget_set_readonly (CameraWidget *widget, int readonly)
  312 {
  313     C_PARAMS (widget);
  314 
  315     widget->readonly = readonly;
  316     return (GP_OK);
  317 }
  318 
  319 /**
  320  * \brief Retrieves the readonly state of the #CameraWidget
  321  *
  322  * @param widget a #CameraWidget
  323  * @param readonly
  324  * @return a gphoto2 error code.
  325  *
  326  **/
  327 int
  328 gp_widget_get_readonly (CameraWidget *widget, int *readonly)
  329 {
  330     C_PARAMS (widget && readonly);
  331 
  332     *readonly = widget->readonly;
  333     return (GP_OK);
  334 }
  335 
  336 /**
  337  * \brief Retrieves the type of the #CameraWidget
  338  *
  339  * @param widget a #CameraWidget
  340  * @param type
  341  * @return a gphoto2 error code.
  342  *
  343  **/
  344 int
  345 gp_widget_get_type (CameraWidget *widget, CameraWidgetType *type)
  346 {
  347     C_PARAMS (widget && type);
  348 
  349     *type = widget->type;
  350     return (GP_OK);
  351 }
  352 
  353 /**
  354  * \brief Retrieves the label of the #CameraWidget
  355  *
  356  * @param widget a #CameraWidget
  357  * @param label
  358  * @return a gphoto2 error code.
  359  *
  360  **/
  361 int
  362 gp_widget_get_label (CameraWidget *widget, const char **label)
  363 {
  364     C_PARAMS (widget && label);
  365 
  366     *label = widget->label;
  367     return (GP_OK);
  368 }
  369 
  370 /**
  371  * \brief Sets the value of the widget
  372  *
  373  * @param widget a #CameraWidget
  374  * @param value
  375  * @return a gphoto2 error code.
  376  *
  377  * Please pass
  378  * (char*) for GP_WIDGET_MENU, GP_WIDGET_TEXT, GP_WIDGET_RADIO,
  379  * (float) for GP_WIDGET_RANGE,
  380  * (int)   for GP_WIDGET_DATE, GP_WIDGET_TOGGLE, and
  381  * (CameraWidgetCallback) for GP_WIDGET_BUTTON.
  382  *
  383  **/
  384 int
  385 gp_widget_set_value (CameraWidget *widget, const void *value)
  386 {
  387     C_PARAMS (widget && value);
  388 
  389         switch (widget->type) {
  390     case GP_WIDGET_BUTTON:
  391         widget->callback = (CameraWidgetCallback) value;
  392         return (GP_OK);
  393     case GP_WIDGET_MENU:
  394     case GP_WIDGET_RADIO:
  395         case GP_WIDGET_TEXT:
  396         GP_LOG_D ("Setting value of widget '%s' to '%s'...",
  397             widget->label, (char*) value);
  398         if (widget->value_string) {
  399                     if (strcmp (widget->value_string, (char*) value))
  400                             widget->changed = 1;
  401                     free (widget->value_string);
  402             } else
  403                 widget->changed = 1;
  404             widget->value_string = strdup ((char*)value);
  405             return (GP_OK);
  406         case GP_WIDGET_RANGE:
  407                 if (widget->value_float != *((float*)value)) {
  408                     widget->value_float  = *((float*)value);
  409                     widget->changed = 1;
  410                 }
  411                 return (GP_OK);
  412     case GP_WIDGET_DATE:
  413         case GP_WIDGET_TOGGLE:
  414             if (widget->value_int != *((int*)value)) {
  415                 widget->value_int  = *((int*)value);
  416                 widget->changed = 1;
  417             }
  418             return (GP_OK);
  419     case GP_WIDGET_WINDOW:
  420     case GP_WIDGET_SECTION:
  421         default:
  422             return (GP_ERROR_BAD_PARAMETERS);
  423         }
  424 }
  425 
  426 /**
  427  * \brief Retrieves the value of the #CameraWidget
  428  *
  429  * @param widget a #CameraWidget
  430  * @param value
  431  * @return a gphoto2 error code.
  432  *
  433  **/
  434 int
  435 gp_widget_get_value (CameraWidget *widget, void *value)
  436 {
  437     C_PARAMS (widget && value);
  438 
  439         switch (widget->type) {
  440     case GP_WIDGET_BUTTON:
  441         *(CameraWidgetCallback*)value = widget->callback;
  442         return (GP_OK);
  443     case GP_WIDGET_MENU:
  444     case GP_WIDGET_RADIO:
  445         case GP_WIDGET_TEXT:
  446             *((char**)value) = widget->value_string;
  447             return (GP_OK);
  448         case GP_WIDGET_RANGE:
  449             *((float*)value) = widget->value_float;
  450             return (GP_OK);
  451         case GP_WIDGET_TOGGLE:
  452     case GP_WIDGET_DATE:
  453                 *((int*)value) = widget->value_int;
  454             return (GP_OK);
  455     case GP_WIDGET_SECTION:
  456     case GP_WIDGET_WINDOW:
  457         default:
  458         return (GP_ERROR_BAD_PARAMETERS);
  459         }
  460 }
  461 
  462 /**
  463  * \brief Appends a #CameraWidget to a #CameraWidget
  464  *
  465  * @param widget a #CameraWidget
  466  * @param child the #CameraWidget you would like to append to above
  467  * @return a gphoto2 error code.
  468  *
  469  **/
  470 int
  471 gp_widget_append (CameraWidget *widget, CameraWidget *child)
  472 {
  473     C_PARAMS (widget && child);
  474 
  475     /* Return if they can't have any children */
  476         C_PARAMS ((widget->type == GP_WIDGET_WINDOW) ||
  477                   (widget->type == GP_WIDGET_SECTION));
  478 
  479     C_MEM (widget->children = realloc(widget->children, sizeof(CameraWidget*)*(widget->children_count+1)));
  480     widget->children[widget->children_count] = child;
  481     widget->children_count += 1;
  482     child->parent = widget;
  483     child->changed = 0;
  484 
  485     return (GP_OK);
  486 }
  487 
  488 /**
  489  * \brief Prepends a #CameraWidget to a #CameraWidget
  490  *
  491  * @param widget a #CameraWidget
  492  * @param child the #CameraWidget you would like to prepend to above
  493  * @return a gphoto2 error code.
  494  *
  495  **/
  496 int
  497 gp_widget_prepend (CameraWidget *widget, CameraWidget *child)
  498 {
  499     int x;
  500 
  501     C_PARAMS (widget && child);
  502 
  503     /* Return if they can't have any children */
  504     C_PARAMS ((widget->type == GP_WIDGET_WINDOW) ||
  505           (widget->type == GP_WIDGET_SECTION));
  506 
  507     C_MEM (widget->children = realloc(widget->children, sizeof(CameraWidget*)*(widget->children_count+1)));
  508 
  509     /* Shift down 1 */
  510     for (x = widget->children_count; x > 0; x--)
  511         widget->children[x] = widget->children[x - 1];
  512 
  513     /* Prepend the child */
  514     widget->children[0] = child;
  515     widget->children_count += 1;
  516     child->parent = widget;
  517     child->changed = 0;
  518 
  519     return (GP_OK);
  520 }
  521 
  522 /**
  523  * \brief Counts the children of the #CameraWidget
  524  *
  525  * @param widget a #CameraWidget
  526  * @return a gphoto2 error code or number of children
  527  *
  528  **/
  529 int
  530 gp_widget_count_children (CameraWidget *widget)
  531 {
  532     C_PARAMS (widget);
  533 
  534     return (widget->children_count);
  535 }
  536 
  537 /**
  538  * \brief Retrieves the child number \c child_number of the parent
  539  *
  540  * @param widget a #CameraWidget
  541  * @param child_number the number of the child
  542  * @param child
  543  * @return a gphoto2 error code.
  544  *
  545  **/
  546 int
  547 gp_widget_get_child (CameraWidget *widget, int child_number,
  548              CameraWidget **child)
  549 {
  550     C_PARAMS (widget && child);
  551     C_PARAMS (child_number < widget->children_count);
  552 
  553     *child = widget->children[child_number];
  554     return (GP_OK);
  555 }
  556 
  557 /**
  558  * \brief Retrieves the child with label \c label of the #CameraWidget
  559  *
  560  * @param widget a #CameraWidget
  561  * @param label the label of the child
  562  * @param child
  563  * @return a gphoto2 error code.
  564  *
  565  **/
  566 int
  567 gp_widget_get_child_by_label (CameraWidget *widget, const char *label,
  568                   CameraWidget **child)
  569 {
  570     int x;
  571 
  572     C_PARAMS (widget && label && child);
  573 
  574     if (strcmp (widget->label, label) == 0) {
  575         *child = widget;
  576         return (GP_OK);
  577     }
  578 
  579     for (x = 0; x < widget->children_count; x++) {
  580         int result;
  581         CameraWidget *child_rec;
  582 
  583         result = gp_widget_get_child_by_label (widget->children[x],
  584                                label, &child_rec);
  585         if (result == GP_OK) {
  586             *child = child_rec;
  587             return (GP_OK);
  588         }
  589     }
  590 
  591     return (GP_ERROR_BAD_PARAMETERS);
  592 }
  593 
  594 /**
  595  * \brief Retrieves the child with id \c id of the widget
  596  *
  597  * @param widget a #CameraWidget
  598  * @param id the id of the child
  599  * @param child
  600  * @return a gphoto2 error code.
  601  *
  602  **/
  603 int
  604 gp_widget_get_child_by_id (CameraWidget *widget, int id, CameraWidget **child)
  605 {
  606     int x;
  607 
  608     C_PARAMS (widget && child);
  609 
  610     if (widget->id == id) {
  611         *child = widget;
  612         return (GP_OK);
  613     }
  614 
  615     for (x = 0; x < widget->children_count; x++) {
  616         int result;
  617         CameraWidget *child_rec;
  618 
  619         result = gp_widget_get_child_by_id (widget->children[x], id,
  620                             &child_rec);
  621         if (result == GP_OK) {
  622             *child = child_rec;
  623             return (GP_OK);
  624         }
  625     }
  626 
  627     return (GP_ERROR_BAD_PARAMETERS);
  628 }
  629 
  630 /**
  631  * \brief Retrieves the child with name \c name of the widget
  632  *
  633  * @param widget a #CameraWidget
  634  * @param name the name of the child
  635  * @return a gphoto2 error code.
  636  *
  637  **/
  638 int
  639 gp_widget_get_child_by_name (CameraWidget *widget, const char *name,
  640                  CameraWidget **child)
  641 {
  642     int x;
  643 
  644     C_PARAMS (widget && child);
  645 
  646     if (!strcmp (widget->name, name)) {
  647         *child = widget;
  648         return (GP_OK);
  649     }
  650 
  651     for (x = 0; x < widget->children_count; x++) {
  652         int result;
  653         CameraWidget *child_rec;
  654 
  655         result = gp_widget_get_child_by_name (widget->children[x], name,
  656                               &child_rec);
  657         if (result == GP_OK) {
  658             *child = child_rec;
  659             return (GP_OK);
  660         }
  661     }
  662 
  663     return (GP_ERROR_BAD_PARAMETERS);
  664 }
  665 
  666 /**
  667  * \brief Retrieves the parent of a CameraWidget
  668  *
  669  * @param widget a #CameraWidget
  670  * @param parent the pointer to the parent to return
  671  * @return a gphoto2 error code.
  672  *
  673  **/
  674 int
  675 gp_widget_get_parent (CameraWidget *widget, CameraWidget **parent)
  676 {
  677     C_PARAMS (widget && parent);
  678 
  679     *parent = widget->parent;
  680 
  681     return (GP_OK);
  682 }
  683 
  684 /**
  685  * \brief Retrieves the root of the #CameraWidget
  686  *
  687  * @param widget a #CameraWidget
  688  * @param root
  689  * @return a gphoto2 error code.
  690  *
  691  **/
  692 int
  693 gp_widget_get_root (CameraWidget *widget, CameraWidget **root)
  694 {
  695     C_PARAMS (widget && root);
  696 
  697     if (widget->parent)
  698         return (gp_widget_get_root (widget->parent, root));
  699     else {
  700         *root = widget;
  701         return (GP_OK);
  702     }
  703 }
  704 
  705 /**
  706  * \brief Sets some range parameters of the #CameraWidget
  707  *
  708  * @param range a #CameraWidget of type GP_WIDGET_RANGE
  709  * @param min
  710  * @param max
  711  * @param increment
  712  * @return a gphoto2 error code.
  713  *
  714  **/
  715 int
  716 gp_widget_set_range (CameraWidget *range, float min, float max, float increment)
  717 {
  718     C_PARAMS (range);
  719     C_PARAMS (range->type == GP_WIDGET_RANGE);
  720 
  721     range->min = min;
  722     range->max = max;
  723     range->increment = increment;
  724 
  725     return (GP_OK);
  726 }
  727 
  728 /**
  729  * \brief Retrieves some range parameters of the #CameraWidget
  730  *
  731  * @param range a #CameraWidget of type GP_WIDGET_RANGE
  732  * @param min
  733  * @param max
  734  * @param increment
  735  * @return a gphoto2 error code.
  736  *
  737  **/
  738 int
  739 gp_widget_get_range (CameraWidget *range, float *min, float *max,
  740              float *increment)
  741 {
  742     C_PARAMS (range && min && max && increment);
  743     C_PARAMS (range->type == GP_WIDGET_RANGE);
  744 
  745     *min = range->min;
  746     *max = range->max;
  747     *increment = range->increment;
  748 
  749     return (GP_OK);
  750 }
  751 
  752 /**
  753  * \brief Adds a choice to the #CameraWidget
  754  *
  755  * @param widget a #CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU
  756  * @param choice
  757  * @return a gphoto2 error code.
  758  *
  759  **/
  760 int
  761 gp_widget_add_choice (CameraWidget *widget, const char *choice)
  762 {
  763     C_PARAMS (widget && choice);
  764     C_PARAMS ((widget->type == GP_WIDGET_RADIO) ||
  765           (widget->type == GP_WIDGET_MENU));
  766 
  767     C_MEM (widget->choice = realloc (widget->choice, sizeof(char*)*(widget->choice_count+1)));
  768     widget->choice[widget->choice_count] = strdup(choice);
  769     widget->choice_count += 1;
  770     return (GP_OK);
  771 }
  772 
  773 /**
  774  * \brief Counts the choices of the #CameraWidget
  775  *
  776  * @param widget a #CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU
  777  * @return a gphoto2 error code or number of choices.
  778  *
  779  **/
  780 int
  781 gp_widget_count_choices (CameraWidget *widget)
  782 {
  783     C_PARAMS (widget);
  784     C_PARAMS ((widget->type == GP_WIDGET_RADIO) ||
  785           (widget->type == GP_WIDGET_MENU));
  786 
  787     return (widget->choice_count);
  788 }
  789 
  790 /**
  791  * \brief Retrieves the choice number \c choice_number
  792  *
  793  * @param widget a #CameraWidget of type GP_WIDGET_RADIO or GP_WIDGET_MENU
  794  * @param choice_number
  795  * @param choice
  796  * @return a gphoto2 error code
  797  *
  798  **/
  799 int
  800 gp_widget_get_choice (CameraWidget *widget, int choice_number,
  801               const char **choice)
  802 {
  803     C_PARAMS (widget && choice);
  804     C_PARAMS ((widget->type == GP_WIDGET_RADIO) ||
  805           (widget->type == GP_WIDGET_MENU));
  806     C_PARAMS (choice_number < widget->choice_count);
  807 
  808     *choice = widget->choice[choice_number];
  809     return (GP_OK);
  810 }
  811 
  812 /**
  813  * \brief Tells if the widget has been changed
  814  *
  815  * @param widget a #CameraWidget
  816  * @return a gphoto2 error code or changed flag.
  817  *
  818  * Returns 1 if the state of the #CameraWidget has been changed or 0 if not.
  819  *
  820  * Note: this formerly cleared the changed state. It no longer does with 2.5.11.
  821  *
  822  **/
  823 int
  824 gp_widget_changed (CameraWidget *widget)
  825 {
  826     C_PARAMS (widget);
  827 
  828         return widget->changed;
  829 }