static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { CameraWidget *child; int ret; GP_DEBUG ("*** camera_set_config"); ret = gp_widget_get_child_by_label (window, _("Synchronize frame data and time with PC"), &child); if (ret == GP_OK) gp_widget_get_value (child, &camera->pl->syncdatetime); ret = gp_widget_get_child_by_label (window, _("Orientation"), &child); if (ret == GP_OK) { char *value; int orientation; gp_widget_get_value (child, &value); orientation = string_to_orientation (value); if (orientation < 0) return orientation; camera->pl->orientation = orientation; } return GP_OK; }
static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { CameraWidget *widget; FujiDate date; time_t t; struct tm *tm; const char *id; /* Date & Time */ if ((gp_widget_get_child_by_label (window, _("Date & Time"), &widget) >= 0) && gp_widget_changed (widget)) { CR (gp_widget_get_value (widget, &t)); tm = localtime (&t); date.year = tm->tm_year; date.month = tm->tm_mon; date.day = tm->tm_mday; date.hour = tm->tm_hour; date.min = tm->tm_min; date.sec = tm->tm_sec; CR (fuji_date_set (camera, date, context)); } /* ID */ if ((gp_widget_get_child_by_label (window, _("ID"), &widget) >= 0) && gp_widget_changed (widget)) { CR (gp_widget_get_value (widget, &id)); CR (fuji_id_set (camera, id, context)); } return (GP_OK); }
static int show_range_int (CmdConfig *cmd_config, CameraWidget *range) { CDKSLIDER *slider = NULL; float value, min, max, increment; const char *label; char title[1024]; int selection; CHECK (gp_widget_get_value (range, &value)); CHECK (gp_widget_get_label (range, &label)); snprintf (title, sizeof (title), "<C></5>%s", label); CHECK (gp_widget_get_range (range, &min, &max, &increment)); slider = newCDKSlider (cmd_config->screen, CENTER, CENTER, title, _("Value: "), '-', 50, (int) value, min, max, increment, MAX (increment, (max - min)/20.0), TRUE, FALSE); if (!slider) return (GP_ERROR); selection = activateCDKSlider (slider, 0); if (slider->exitType == vNORMAL) { value = selection; gp_widget_set_value (range, &value); set_config (cmd_config); } destroyCDKSlider (slider); return (GP_OK); }
static int show_toggle (CmdConfig *cmd_config, CameraWidget *toggle) { CDKITEMLIST *list = NULL; int value, selection; const char *label; char title[1024], *info[] = {N_("Yes"), N_("No")}; CHECK (gp_widget_get_value (toggle, &value)); CHECK (gp_widget_get_label (toggle, &label)); snprintf (title, sizeof (title), "<C></5>%s", label); list = newCDKItemlist (cmd_config->screen, CENTER, CENTER, title, "", info, 2, 1 - value, TRUE, FALSE); if (!list) return (GP_ERROR); selection = activateCDKItemlist (list, 0); if (list->exitType == vNORMAL) { selection = 1 - selection; gp_widget_set_value (toggle, &selection); set_config (cmd_config); } destroyCDKItemlist (list); return (GP_OK); }
static int show_text (CmdConfig *cmd_config, CameraWidget *text) { CDKENTRY *entry = NULL; const char *label, *value; char title[1024], *info; CHECK (gp_widget_get_value (text, &value)); CHECK (gp_widget_get_label (text, &label)); snprintf (title, sizeof (title), "<C></5>%s", label); entry = newCDKEntry (cmd_config->screen, CENTER, CENTER, title, _("Value: "), A_NORMAL, ' ', vMIXED, 40, 0, 256, TRUE, FALSE); if (!entry) return (GP_ERROR); setCDKEntryValue (entry, (char*) value); info = activateCDKEntry (entry, 0); if (entry->exitType == vNORMAL) { gp_widget_set_value (text, info); set_config (cmd_config); } destroyCDKEntry (entry); return (GP_OK); }
QVariant GPhotoCameraWorker::parameter(const QString &name) { CameraWidget *root; int ret = gp_camera_get_config(m_camera, &root, m_context); if (ret < GP_OK) { qWarning() << "Unable to get root option from gphoto"; return QVariant(); } CameraWidget *option; ret = gp_widget_get_child_by_name(root, qPrintable(name), &option); if (ret < GP_OK) { qWarning() << "Unable to get config widget from gphoto"; return QVariant(); } CameraWidgetType type; ret = gp_widget_get_type(option, &type); if (ret < GP_OK) { qWarning() << "Unable to get config widget type from gphoto"; return QVariant(); } if (type == GP_WIDGET_RADIO) { char *value; ret = gp_widget_get_value(option, &value); if (ret < GP_OK) { qWarning() << "Unable to get value for option" << qPrintable(name) << "from gphoto"; return QVariant(); } else { return QString::fromLocal8Bit(value); } } else if (type == GP_WIDGET_TOGGLE) { int value; ret = gp_widget_get_value(option, &value); if (ret < GP_OK) { qWarning() << "Unable to get value for option" << qPrintable(name) << "from gphoto"; return QVariant(); } else { return value == 0 ? false : true; } } else { qWarning() << "Options of type" << type << "are currently not supported"; } return QVariant(); }
int camera_auto_focus(Camera *camera, GPContext *context, int onoff) { CameraWidget *widget = NULL, *child = NULL; CameraWidgetType type; int ret,val; ret = gp_camera_get_config (camera, &widget, context); if (ret < GP_OK) { fprintf (stderr, "camera_get_config failed: %d\n", ret); return ret; } ret = _lookup_widget (widget, "autofocusdrive", &child); if (ret < GP_OK) { fprintf (stderr, "lookup 'autofocusdrive' failed: %d\n", ret); goto out; } /* check that this is a toggle */ ret = gp_widget_get_type (child, &type); if (ret < GP_OK) { fprintf (stderr, "widget get type failed: %d\n", ret); goto out; } switch (type) { case GP_WIDGET_TOGGLE: break; default: fprintf (stderr, "widget has bad type %d\n", type); ret = GP_ERROR_BAD_PARAMETERS; goto out; } ret = gp_widget_get_value (child, &val); if (ret < GP_OK) { fprintf (stderr, "could not get widget value: %d\n", ret); goto out; } val = onoff; ret = gp_widget_set_value (child, &val); if (ret < GP_OK) { fprintf (stderr, "could not set widget value to 1: %d\n", ret); goto out; } ret = gp_camera_set_config (camera, widget, context); if (ret < GP_OK) { fprintf (stderr, "could not set config tree to autofocus: %d\n", ret); goto out; } out: gp_widget_free (widget); return ret; }
int get_config_value_string (Camera *camera, const char *key, char **str, GPContext *context) { CameraWidget *widget = NULL, *child = NULL; CameraWidgetType type; int ret; char *val; ret = gp_camera_get_config (camera, &widget, context); if (ret < GP_OK) { fprintf (stderr, "camera_get_config failed: %d\n", ret); return ret; } ret = _lookup_widget (widget, key, &child); if (ret < GP_OK) { fprintf (stderr, "lookup widget failed: %d\n", ret); goto out; } /* This type check is optional, if you know what type the label * has already. If you are not sure, better check. */ ret = gp_widget_get_type (child, &type); if (ret < GP_OK) { fprintf (stderr, "widget get type failed: %d\n", ret); goto out; } switch (type) { case GP_WIDGET_MENU: case GP_WIDGET_RADIO: case GP_WIDGET_TEXT: break; default: fprintf (stderr, "widget has bad type %d\n", type); ret = GP_ERROR_BAD_PARAMETERS; goto out; } /* This is the actual query call. Note that we just * a pointer reference to the string, not a copy... */ ret = gp_widget_get_value (child, &val); if (ret < GP_OK) { fprintf (stderr, "could not query widget value: %d\n", ret); goto out; } /* Create a new copy for our caller. */ *str = strdup (val); out: gp_widget_free (widget); return ret; }
static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { CameraWidget *w; char *wvalue; int val; char str[16]; GP_DEBUG ("camera_set_config()"); gp_widget_get_child_by_label (window, _("Exposure level on preview"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); camera->pl->exposure = MAX(MIN_EXPOSURE,MIN(MAX_EXPOSURE,atoi(wvalue))); gp_setting_set ("dimera3500", "exposure", wvalue); GP_DEBUG ("set exposure"); } gp_widget_get_child_by_label (window, _("Automatic exposure adjustment on preview"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &val); camera->pl->auto_exposure = val; sprintf(str, "%d", val); gp_setting_set ("dimera3500", "auto_exposure", str); GP_DEBUG ("set auto_exposure"); } gp_widget_get_child_by_label (window, _("Automatic flash on capture"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &val); camera->pl->auto_flash = val; sprintf(str, "%d", val); gp_setting_set ("dimera3500", "auto_flash", str); GP_DEBUG ("set auto_flash"); } GP_DEBUG ("done configuring driver."); return GP_OK; }
static int camera_set_config (Camera *c, CameraWidget *window, GPContext *co) { CameraWidget *w; const char *v_char; time_t time; RicohMode mode; /* We need to be in record mode to set settings. */ CR (ricoh_get_mode (c, co, &mode)); if (mode != RICOH_MODE_RECORD) CR (ricoh_set_mode (c, co, RICOH_MODE_RECORD)); /* Copyright */ CR (gp_widget_get_child_by_name (window, "copyright", &w)); if (gp_widget_changed (w)) { CR (gp_widget_get_value (w, &v_char)); CR (ricoh_set_copyright (c, co, v_char)); } /* Date */ CR (gp_widget_get_child_by_name (window, "date", &w)); if (gp_widget_changed (w)) { CR (gp_widget_get_value (w, &time)); CR (ricoh_set_date (c, co, time)); } R_CHECK_RADIO (c, co, window, resolution, N_("Resolution")) R_CHECK_RADIO (c, co, window, exposure, N_("Exposure")) R_CHECK_RADIO (c, co, window, white_level, N_("White level")) R_CHECK_RADIO (c, co, window, macro, N_("Macro")) R_CHECK_RADIO (c, co, window, zoom, N_("Zoom")) R_CHECK_RADIO (c, co, window, flash, N_("Flash")) R_CHECK_RADIO (c, co, window, rec_mode, N_("Record Mode")) R_CHECK_RADIO (c, co, window, compression, N_("Compression")) return (GP_OK); }
static int show_date (CmdConfig *cmd_config, CameraWidget *date) { CDKCALENDAR *calendar = NULL; int day, month, year, selection; time_t time; struct tm *date_info; const char *label; char title[1024]; gp_widget_get_value (date, &time); date_info = localtime (&time); /* Month in CDK starts with 1 */ day = date_info->tm_mday; month = date_info->tm_mon + 1; year = date_info->tm_year + 1900; gp_widget_get_label (date, &label); snprintf (title, sizeof (title), "<C></5>%s", label); /* Create the calendar */ calendar = newCDKCalendar (cmd_config->screen, CENTER, CENTER, title, day, month, year, COLOR_PAIR(16)|A_BOLD, COLOR_PAIR(24)|A_BOLD, COLOR_PAIR(32)|A_BOLD, COLOR_PAIR(40)|A_REVERSE, TRUE, FALSE); if (!calendar) return (GP_ERROR); drawCDKCalendar (calendar, TRUE); selection = activateCDKCalendar (calendar, 0); if (calendar->exitType == vNORMAL) { date_info = localtime (&time); /* Month in CDK starts with 1 */ date_info->tm_mday = calendar->day; date_info->tm_mon = calendar->month - 1; date_info->tm_year = calendar->year - 1900; time = mktime (date_info); gp_widget_set_value (date, &time); set_config (cmd_config); } destroyCDKCalendar (calendar); return (GP_OK); }
static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { CameraWidget *child; int ret; GP_DEBUG ("*** camera_set_config"); ret = gp_widget_get_child_by_label (window, _("Synchronize frame data and time with PC"), &child); if (ret == GP_OK) gp_widget_get_value (child, &camera->pl->syncdatetime); return GP_OK; }
static int show_radio (CmdConfig *cmd_config, CameraWidget *radio) { CDKITEMLIST *list = NULL; const char *label, *value, *current_value; char title[1024], *items[100]; int x, count, current = 0, selection, found; gp_widget_get_label (radio, &label); snprintf (title, sizeof (title), "<C></5>%s", label); gp_widget_get_value (radio, ¤t_value); count = gp_widget_count_choices (radio); /* Check if the current value is in the list */ current = found = 0; for (x = 0; x < count; x++) { gp_widget_get_choice (radio, x, &value); if (!strcmp (value, current_value)) { current = x; found = 1; break; } } if (!found) items[0] = copyChar ((char *) current_value); /* Add all items */ for (x = 0; x < count; x++) { gp_widget_get_choice (radio, x, &value); items[x + 1 - found] = copyChar ((char *) value); } list = newCDKItemlist (cmd_config->screen, CENTER, CENTER, title, _("Value: "), items, count, current, TRUE, FALSE); if (!list) return (GP_ERROR); selection = activateCDKItemlist (list, 0); if (list->exitType == vNORMAL) { gp_widget_get_choice (radio, selection, &value); gp_widget_set_value (radio, (void *) value); set_config (cmd_config); } destroyCDKItemlist (list); return (GP_OK); }
const char*dt_camctl_camera_get_property(const dt_camctl_t *c,const dt_camera_t *cam,const char *property_name) { dt_camctl_t *camctl=(dt_camctl_t *)c; if( !cam && (cam = camctl->active_camera) == NULL && (cam = camctl->wanted_camera) == NULL ) { dt_print(DT_DEBUG_CAMCTL,"[camera_control] failed to get property from camera, camera==NULL\n"); return NULL; } dt_camera_t *camera=(dt_camera_t *)cam; dt_pthread_mutex_lock( &camera->config_lock ); const char *value=NULL; CameraWidget *widget; if( gp_widget_get_child_by_name ( camera->configuration, property_name, &widget) == GP_OK) { gp_widget_get_value ( widget , &value); } dt_pthread_mutex_unlock( &camera->config_lock); return value; }
static int show_range_float (CmdConfig *cmd_config, CameraWidget *range) { #ifdef HAVE_CDK_20010421 return (show_range_int (cmd_config, range)); #else CDKFSCALE *fscale = NULL; float value, min, max, increment; const char *label; char title[1024]; float selection; CHECK (gp_widget_get_value (range, &value)); CHECK (gp_widget_get_label (range, &label)); snprintf (title, sizeof (title), "<C></5>%s", label); CHECK (gp_widget_get_range (range, &min, &max, &increment)); fscale = newCDKFScale (cmd_config->screen, CENTER, CENTER, title, _("Value: "), A_STANDOUT, 50, value, min, max, increment, MAX (increment, (max - min) / 20.0), get_digits (increment), TRUE, FALSE); if (!fscale) return (GP_ERROR); selection = activateCDKFScale (fscale, 0); if (fscale->exitType == vNORMAL) { value = selection; gp_widget_set_value (range, &value); set_config (cmd_config); } destroyCDKFScale (fscale); return (GP_OK); #endif }
static int show_time (CmdConfig *cmd_config, CameraWidget *date) { CDKENTRY *entry = NULL; const char *label, *info; char title[1024], time_string[9]; time_t time; struct tm *date_info; gp_widget_get_label (date, &label); snprintf (title, sizeof (title), "<C></5>%s", label); entry = newCDKEntry (cmd_config->screen, CENTER, CENTER, title, _("Time: "), A_NORMAL, ' ', vMIXED, 40, 0, 8, TRUE, FALSE); if (!entry) return (GP_ERROR); gp_widget_get_value (date, &time); date_info = localtime (&time); snprintf (time_string, sizeof (time_string), "%2i:%02i:%02i", date_info->tm_hour, date_info->tm_min, date_info->tm_sec); setCDKEntryValue (entry, time_string); setCDKEntryPreProcess (entry, time_preprocess, NULL); info = activateCDKEntry (entry, 0); if (entry->exitType == vNORMAL) { date_info = localtime (&time); sscanf (info, "%d:%d:%d", &date_info->tm_hour, &date_info->tm_min, &date_info->tm_sec); time = mktime (date_info); gp_widget_set_value (date, &time); set_config (cmd_config); } destroyCDKEntry (entry); return (GP_OK); }
bool Image_GPhoto::doGetProperty(const string& name, string& value) { lock_guard<recursive_mutex> lock(_gpMutex); if (_selectedCameraIndex == -1) { Log::get() << Log::WARNING << "Image_GPhoto::" << __FUNCTION__ << " - A camera must be selected before trying to capture" << Log::endl; return false; } GPhotoCamera* camera = &(_cameras[_selectedCameraIndex]); CameraWidget* widget; if (gp_widget_get_child_by_name(camera->configuration, name.c_str(), &widget) == GP_OK) { const char* cvalue = nullptr; gp_widget_get_value(widget, &cvalue); value = string(cvalue); return true; } return false; }
static int camera_config_set (Camera *camera, CameraWidget *window, GPContext *context) { int ret; CameraWidget *turbo; ret = gp_widget_get_child_by_name (window, "turbo", &turbo); if (ret != GP_OK) { gp_log (GP_LOG_ERROR, "camera_config_set", "did not find turbo menu entry?\n"); return GP_OK; } if (gp_widget_changed (turbo)) { const char* val; int ival; ret = gp_widget_get_value (turbo, &val); if (ret == GP_OK) { ival = !strcmp (val, _("On")); gp_log (GP_LOG_DEBUG, "camera_config_set", "val %s, ival %d\n", val, ival); gp_setting_set ("topfield", "turbo", ival?"yes":"no"); } } return GP_OK; }
void GPhotoCameraWorker::logOption(const char *name) { CameraWidget *root; int ret = gp_camera_get_config(m_camera, &root, m_context); if (ret < GP_OK) { qWarning() << "Unable to get root option from gphoto"; return; } CameraWidget *option; ret = gp_widget_get_child_by_name(root, name, &option); if (ret < GP_OK) qWarning() << "Unable to get config widget from gphoto"; CameraWidgetType type; ret = gp_widget_get_type(option, &type); if (ret < GP_OK) qWarning() << "Unable to get config widget type from gphoto"; char *value; ret = gp_widget_get_value(option, &value); qDebug() << "Option" << type << name << value; if (type == GP_WIDGET_RADIO) { int count = gp_widget_count_choices(option); qDebug() << "Choices count:" << count; for (int i = 0; i < count; ++i) { const char* choice; gp_widget_get_choice(option, i, &choice); qDebug() << " value:" << choice; } } gp_widget_free(option); }
void GPConfigDlg::appendWidget(QWidget* parent, CameraWidget* widget) { QWidget* newParent = parent; CameraWidgetType widget_type; const char* widget_name; const char* widget_info; const char* widget_label; float widget_value_float; int widget_value_int; const char* widget_value_string; gp_widget_get_type(widget, &widget_type); gp_widget_get_label(widget, &widget_label); gp_widget_get_info(widget, &widget_info); gp_widget_get_name(widget, &widget_name); // gphoto2 doesn't seem to have any standard for i18n QString whats_this = QString::fromLocal8Bit(widget_info); // Add this widget to parent switch (widget_type) { case GP_WIDGET_WINDOW: { setCaption(widget_label); break; } case GP_WIDGET_SECTION: { if (!d->tabWidget) { d->tabWidget = new QTabWidget(parent); parent->layout()->addWidget(d->tabWidget); } QWidget* tab = new QWidget(d->tabWidget); // widgets are to be aligned vertically in the tab QVBoxLayout* tabLayout = new QVBoxLayout(tab, marginHint(), spacingHint()); d->tabWidget->insertTab(tab, widget_label); KVBox* tabContainer = new KVBox(tab); tabContainer->setSpacing(spacingHint()); tabLayout->addWidget(tabContainer); newParent = tabContainer; tabLayout->addStretch(); break; } case GP_WIDGET_TEXT: { gp_widget_get_value(widget, &widget_value_string); Q3Grid* grid = new Q3Grid(2, Qt::Horizontal, parent); parent->layout()->addWidget(grid); grid->setSpacing(spacingHint()); new QLabel(QString::fromLocal8Bit(widget_label) + ':', grid); QLineEdit* lineEdit = new QLineEdit(widget_value_string, grid); d->wmap.insert(widget, lineEdit); if (!whats_this.isEmpty()) { grid->setWhatsThis(whats_this); } break; } case GP_WIDGET_RANGE: { float widget_low; float widget_high; float widget_increment; gp_widget_get_range(widget, &widget_low, &widget_high, &widget_increment); gp_widget_get_value(widget, &widget_value_float); Q3GroupBox* groupBox = new Q3GroupBox(1, Qt::Horizontal, widget_label, parent); parent->layout()->addWidget(groupBox); QSlider* slider = new QSlider( (int)widget_low, (int)widget_high, (int)widget_increment, (int)widget_value_float, Qt::Horizontal, groupBox); d->wmap.insert(widget, slider); if (!whats_this.isEmpty()) { groupBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_TOGGLE: { gp_widget_get_value(widget, &widget_value_int); QCheckBox* checkBox = new QCheckBox(widget_label, parent); parent->layout()->addWidget(checkBox); checkBox->setChecked(widget_value_int); d->wmap.insert(widget, checkBox); if (!whats_this.isEmpty()) { checkBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_RADIO: { gp_widget_get_value(widget, &widget_value_string); int count = gp_widget_count_choices(widget); // for less than 5 options, align them horizontally Q3ButtonGroup* buttonGroup; if (count > 4) { buttonGroup = new Q3VButtonGroup(widget_label, parent); } else { buttonGroup = new Q3HButtonGroup(widget_label, parent); } parent->layout()->addWidget(buttonGroup); for (int i = 0; i < count; ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); new QRadioButton(widget_choice, buttonGroup); if (!strcmp(widget_value_string, widget_choice)) { buttonGroup->setButton(i); } } d->wmap.insert(widget, buttonGroup); if (!whats_this.isEmpty()) { buttonGroup->setWhatsThis(whats_this); } break; } case GP_WIDGET_MENU: { gp_widget_get_value(widget, &widget_value_string); QComboBox* comboBox = new KComboBox(parent); parent->layout()->addWidget(comboBox); comboBox->clear(); for (int i = 0; i < gp_widget_count_choices(widget); ++i) { const char* widget_choice; gp_widget_get_choice(widget, i, &widget_choice); comboBox->insertItem(widget_choice); if (!strcmp(widget_value_string, widget_choice)) { comboBox->setCurrentItem(i); } } d->wmap.insert(widget, comboBox); if (!whats_this.isEmpty()) { comboBox->setWhatsThis(whats_this); } break; } case GP_WIDGET_BUTTON: { // TODO // I can't see a way of implementing this. Since there is // no way of telling which button sent you a signal, we // can't map to the appropriate widget->callback QLabel* label = new QLabel(i18n("Button (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } case GP_WIDGET_DATE: { // TODO QLabel* label = new QLabel(i18n("Date (not supported by KControl)"), parent); parent->layout()->addWidget(label); break; } default: return; } // Append all this widgets children for (int i = 0; i < gp_widget_count_children(widget); ++i) { CameraWidget* widget_child; gp_widget_get_child(widget, i, &widget_child); appendWidget(newParent, widget_child); } // Things that must be done after all children were added /* switch (widget_type) { case GP_WIDGET_SECTION: { tabLayout->addItem( new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); break; } } */ }
bool photo_camera::photo_camera_get_config( std::string param, char** value ) { CameraWidget *root, *child; const char *label; CameraWidgetType type; // Locate the widget that corresponds to this parameter if( photo_camera_find_widget_by_name( param, &child, &root ) != GP_OK ) { photo_reporter::error( "photo_camera_find_widget_by_name()"); return false; } // Get the widget label if( gp_widget_get_label(child, &label) != GP_OK ) { photo_reporter::error( "gp_widget_get_label()"); gp_widget_free( root ); return false; } // Get the widget type if( gp_widget_get_type( child, &type ) != GP_OK ) { photo_reporter::error( "gp_widget_get_type()"); gp_widget_free( root ); return false; } switch( type ) { case GP_WIDGET_TEXT: // char* char *txt; if( gp_widget_get_value( child, &txt ) != GP_OK ) { gp_context_error( context_, "Failed to retrieve value of text widget %s.", param.c_str() ); } *value = txt; break; case GP_WIDGET_RANGE: // float float f, t,b,s; if( gp_widget_get_range( child, &b, &t, &s ) != GP_OK ) { gp_context_error( context_, "Failed to retrieve values of range widget %s.", param.c_str() ); } if( gp_widget_get_value( child, &f ) != GP_OK ) { gp_context_error( context_, "Failed to value of range widget %s.", param.c_str() ); } sprintf( *value, "%f", f ); break; case GP_WIDGET_TOGGLE: // int { int t; if( gp_widget_get_value( child, &t ) != GP_OK ) { gp_context_error( context_,"Failed to retrieve values of toggle widget %s.", param.c_str() ); } sprintf( *value, "%d", t ); break; } case GP_WIDGET_DATE: // int { int error_code, t; time_t working_time; struct tm *localtm; char timebuf[200]; if( gp_widget_get_value( child, &t ) != GP_OK ) { gp_context_error( context_,"Failed to retrieve values of date/time widget %s.", param.c_str() ); break; } working_time = t; localtm = localtime( &working_time ); error_code = strftime( timebuf, sizeof(timebuf), "%c", localtm ); sprintf( *value, "%s", timebuf ); break; } case GP_WIDGET_MENU: case GP_WIDGET_RADIO: //char* char *current; if( gp_widget_get_value (child, ¤t) != GP_OK ) { gp_context_error( context_,"Failed to retrieve values of radio widget %s.", param.c_str() ); } sprintf( *value, "%s", current ); break; // No values, so nothing to return case GP_WIDGET_WINDOW: case GP_WIDGET_SECTION: case GP_WIDGET_BUTTON: default: break; } gp_widget_free( root ); return true; }
static int camera_cam_desc_set_widget (Camera *camera, CameraRegisterType *reg_p, CameraWidget *window, GPContext *context) { int ind, vind, ret; union value_in { char *charp; int val; float flt; } value_in; CameraWidget *child; RegisterDescriptorType *reg_desc_p; GP_DEBUG ("register %d", reg_p->reg_number); for (ind = 0; ind < reg_p->reg_desc_cnt; ind++) { reg_desc_p = ®_p->reg_desc[ind]; GP_DEBUG ("window name is %s", reg_desc_p->regs_long_name); if ((gp_widget_get_child_by_label (window, _(reg_desc_p->regs_long_name), &child) >= 0) && gp_widget_changed (child)) { gp_widget_get_value (child, &value_in); for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; vind++) { ret = camera_cam_desc_set_value (camera, reg_p, reg_desc_p, ®_desc_p->regs_value_names[vind], &value_in, context); if (ret == GP_OK) { /* * Something got set, mark the * widget as changed, so the user * can repeat any actions - like * going to the "next" picture by * repeatedly hitting apply while * in operation play mode. * * This has the side affect of * changing whatever was just set * twice when using the apply in * gtkam - once when applied and * once when OK. */ gp_widget_set_changed (child, 1); } if (ret <= 0) { /* * Value was set (GP_OK is 0), or * some an error occurred (< 0), * don't bother checking any other * value/name pairs. */ break; } } } } return (GP_OK); }
void _camera_configuration_merge(const dt_camctl_t *c,const dt_camera_t *camera,CameraWidget *source, CameraWidget *destination, gboolean notify_all) { int childs = 0; const char *sk; const char *stv; CameraWidget *dw; const char *dtv; CameraWidgetType type; // If source widget has childs let's recurse into each children if( ( childs = gp_widget_count_children ( source ) ) > 0 ) { CameraWidget *child = NULL; for( int i = 0 ; i < childs ; i++) { gp_widget_get_child( source, i, &child ); //gp_widget_get_name( source, &sk ); _camera_configuration_merge( c, camera,child, destination, notify_all ); } } else { gboolean changed = TRUE; gp_widget_get_type( source, &type ); // Get the two keys to compare gp_widget_get_name( source, &sk ); gp_widget_get_child_by_name ( destination, sk, &dw); // // First of all check if widget has change accessibility // /// TODO: Resolve this 2.4.8 libgphoto2 dependency /* int sa,da; gp_widget_get_readonly( source, &sa ); gp_widget_get_readonly( dw, &da ); if( notify_all || ( sa != da ) ) { // update destination widget to new accessibility if differ then notify of the change if( ( sa != da ) ) gp_widget_set_readonly( dw, sa ); _dispatch_camera_property_accessibility_changed(c, camera,sk, ( sa == 1 ) ? TRUE: FALSE) ; } */ // // Lets compare values and notify on change or by notifyAll flag // if( type == GP_WIDGET_MENU || type == GP_WIDGET_TEXT || type == GP_WIDGET_RADIO ) { // Get source and destination value to be compared gp_widget_get_value( source, &stv ); gp_widget_get_value( dw, &dtv ); if( ( ( stv && dtv ) && strcmp( stv, dtv ) != 0 ) && ( changed = TRUE ) ) { gp_widget_set_value( dw, stv ); // Dont flag this change as changed, otherwise a read-only widget might get tried // to update the camera configuration... gp_widget_set_changed( dw, 0 ); } if( ( stv && dtv ) && ( notify_all || changed ) ) _dispatch_camera_property_value_changed(c,camera,sk,stv); } } }
/** * Get property. * @see DigitalCameraCapture for more information about returned double type. */ double DigitalCameraCapture::getProperty(int propertyId) const { CameraWidget * widget = NULL; double output = 0; if (propertyId < 0) { widget = getWidget(-propertyId); } else { switch (propertyId) { // gphoto2 cap featured case CV_CAP_PROP_GPHOTO2_PREVIEW: return preview; case CV_CAP_PROP_GPHOTO2_WIDGET_ENUMERATE: if (rootWidget == NULL) return 0; return (intptr_t) widgetInfo.c_str(); case CV_CAP_PROP_GPHOTO2_RELOAD_CONFIG: return 0; // Trigger, only by set case CV_CAP_PROP_GPHOTO2_RELOAD_ON_CHANGE: return reloadOnChange; case CV_CAP_PROP_GPHOTO2_COLLECT_MSGS: return collectMsgs; case CV_CAP_PROP_GPHOTO2_FLUSH_MSGS: lastFlush = msgsBuffer.str(); msgsBuffer.str(""); msgsBuffer.clear(); return (intptr_t) lastFlush.c_str(); default: widget = getGenericProperty(propertyId, output); /* no break */ } } if (widget == NULL) return output; try { CameraWidgetType type; CR(gp_widget_get_type(widget, &type)); switch (type) { case GP_WIDGET_MENU: case GP_WIDGET_RADIO: { int cnt = 0, i; const char * current; CR(gp_widget_get_value(widget, ¤t)); CR(cnt = gp_widget_count_choices(widget)); for (i = 0; i < cnt; i++) { const char *choice; CR(gp_widget_get_choice(widget, i, &choice)); if (std::strcmp(choice, current) == 0) { return i; } } return -1; } case GP_WIDGET_TOGGLE: { int value; CR(gp_widget_get_value(widget, &value)); return value; } case GP_WIDGET_RANGE: { float value; CR(gp_widget_get_value(widget, &value)); return value; } default: { char* value; CR(gp_widget_get_value(widget, &value)); return (intptr_t) value; } } } catch (GPhoto2Exception & e) { char buf[128] = ""; sprintf(buf, "cannot get property: %d", propertyId); message(WARNING, (const char *) buf, e); return 0; } }
/** * Print widget description in @param os. * @return real widget ID (if config was reloaded couple of times * then IDs won't be the same) */ int DigitalCameraCapture::widgetDescription(std::ostream &os, CameraWidget * widget) const { const char * label, *name, *info; int id, readonly; CameraWidgetType type; CR(gp_widget_get_id(widget, &id)); CR(gp_widget_get_label(widget, &label)); CR(gp_widget_get_name(widget, &name)); CR(gp_widget_get_info(widget, &info)); CR(gp_widget_get_type(widget, &type)); CR(gp_widget_get_readonly(widget, &readonly)); if ((type == GP_WIDGET_WINDOW) || (type == GP_WIDGET_SECTION) || (type == GP_WIDGET_BUTTON)) { readonly = 1; } os << (id - noOfWidgets) << separator << label << separator << name << separator << info << separator << readonly << separator; switch (type) { case GP_WIDGET_WINDOW: { os << "window" << separator /* no value */<< separator; break; } case GP_WIDGET_SECTION: { os << "section" << separator /* no value */<< separator; break; } case GP_WIDGET_TEXT: { os << "text" << separator; char *txt; CR(gp_widget_get_value(widget, &txt)); os << txt << separator; break; } case GP_WIDGET_RANGE: { os << "range" << separator; float f, t, b, s; CR(gp_widget_get_range(widget, &b, &t, &s)); CR(gp_widget_get_value(widget, &f)); os << "(" << b << ":" << t << ":" << s << "):" << f << separator; break; } case GP_WIDGET_TOGGLE: { os << "toggle" << separator; int t; CR(gp_widget_get_value(widget, &t)); os << t << separator; break; } case GP_WIDGET_RADIO: case GP_WIDGET_MENU: { if (type == GP_WIDGET_RADIO) { os << "radio" << separator; } else { os << "menu" << separator; } int cnt = 0, i; char *current; CR(gp_widget_get_value(widget, ¤t)); CR(cnt = gp_widget_count_choices(widget)); os << "("; for (i = 0; i < cnt; i++) { const char *choice; CR(gp_widget_get_choice(widget, i, &choice)); os << i << ":" << choice; if (i + 1 < cnt) { os << ";"; } } os << "):" << current << separator; break; } case GP_WIDGET_BUTTON: { os << "button" << separator /* no value */<< separator; break; } case GP_WIDGET_DATE: { os << "date" << separator; int t; time_t xtime; struct tm *xtm; char timebuf[200]; CR(gp_widget_get_value(widget, &t)); xtime = t; xtm = localtime(&xtime); strftime(timebuf, sizeof(timebuf), "%c", xtm); os << t << ":" << timebuf << separator; break; } } return id; }
/* Manual focusing a camera... * xx is -3 / -2 / -1 / 0 / 1 / 2 / 3 */ int camera_manual_focus (Camera *camera, int xx, GPContext *context) { CameraWidget *widget = NULL, *child = NULL; CameraWidgetType type; int ret; float rval; char *mval; ret = gp_camera_get_config (camera, &widget, context); if (ret < GP_OK) { fprintf (stderr, "camera_get_config failed: %d\n", ret); return ret; } ret = _lookup_widget (widget, "manualfocusdrive", &child); if (ret < GP_OK) { fprintf (stderr, "lookup 'manualfocusdrive' failed: %d\n", ret); goto out; } /* check that this is a toggle */ ret = gp_widget_get_type (child, &type); if (ret < GP_OK) { fprintf (stderr, "widget get type failed: %d\n", ret); goto out; } switch (type) { case GP_WIDGET_RADIO: { int choices = gp_widget_count_choices (child); ret = gp_widget_get_value (child, &mval); if (ret < GP_OK) { fprintf (stderr, "could not get widget value: %d\n", ret); goto out; } if (choices == 7) { /* see what Canon has in EOS_MFDrive */ ret = gp_widget_get_choice (child, xx+4, (const char**)&mval); if (ret < GP_OK) { fprintf (stderr, "could not get widget choice %d: %d\n", xx+2, ret); goto out; } fprintf(stderr,"manual focus %d -> %s\n", xx, mval); } ret = gp_widget_set_value (child, mval); if (ret < GP_OK) { fprintf (stderr, "could not set widget value to 1: %d\n", ret); goto out; } break; } case GP_WIDGET_RANGE: ret = gp_widget_get_value (child, &rval); if (ret < GP_OK) { fprintf (stderr, "could not get widget value: %d\n", ret); goto out; } switch (xx) { /* Range is on Nikon from -32768 <-> 32768 */ case -3: rval = -1024;break; case -2: rval = -512;break; case -1: rval = -128;break; case 0: rval = 0;break; case 1: rval = 128;break; case 2: rval = 512;break; case 3: rval = 1024;break; default: rval = xx; break; /* hack */ } fprintf(stderr,"manual focus %d -> %f\n", xx, rval); ret = gp_widget_set_value (child, &rval); if (ret < GP_OK) { fprintf (stderr, "could not set widget value to 1: %d\n", ret); goto out; } break; default: fprintf (stderr, "widget has bad type %d\n", type); ret = GP_ERROR_BAD_PARAMETERS; goto out; } ret = gp_camera_set_config (camera, widget, context); if (ret < GP_OK) { fprintf (stderr, "could not set config tree to autofocus: %d\n", ret); goto out; } out: gp_widget_free (widget); return ret; }
bool Widget::Traits<bool>::read(const Widget& widget) { int val; gp_widget_get_value(widget.widget, &val); return static_cast<bool>(val); }
/** * @brief QTLCamera::_getWidgets * @param widgetList * @param widget * @param prefix */ void QTLCamera::_getWidgets(vector<QTLWidget> *widgetList, CameraWidget *widget, char *prefix) { int rc, n; char *newprefix; const char *label, *name, *uselabel; CameraWidgetType type; CameraWidget *rootConfig, *child; QTLWidget qtlWidget; gp_widget_get_label(widget, &label); gp_widget_get_name(widget, &name); gp_widget_get_type(widget, &type); if (strlen(name)) { uselabel = name; } else { uselabel = label; } n = gp_widget_count_children(widget); newprefix = new char[strlen(prefix) + 1 + strlen(uselabel) + 1]; if (!newprefix) { return; } sprintf(newprefix, "%s/%s", prefix, uselabel); //XXX Was this supposed to be a conditional for the whole section? // Assuming yes due to indenting. qDebug() << "\tDetected widget: " << uselabel; if ((type != GP_WIDGET_WINDOW) && (type != GP_WIDGET_SECTION)) { rc = findWidgetByName(uselabel, &child, &rootConfig); rc = gp_widget_get_type(child, &type); rc = gp_widget_get_label(child, &label); if (type == GP_WIDGET_RADIO) { int count, i; char *current; rc = gp_widget_get_value(child, ¤t); if (rc == GP_OK) { count = gp_widget_count_choices(child); if (type == GP_WIDGET_MENU) { } else { for (i=0; i<count; i++) { const char *choice; rc = gp_widget_get_choice(child, i, &choice); qtlWidget.choices.push_back(choice); qDebug() << "\t\tDetected choice: " << choice; } qtlWidget.title = label; qtlWidget.name = name; qtlWidget.defaultChoice = current; qtlWidget.choiceLabel = uselabel; params->widgetList->push_back(qtlWidget); } } } } for (int i = 0; i < n; i++) { CameraWidget *child; rc = gp_widget_get_child(widget, i, &child); if (rc != GP_OK) { continue; } _getWidgets(widgetList, child, newprefix); } free(newprefix); }
static int camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) { CameraWidget *section, *widget; CameraAbilities abilities; GPPortSettings settings; int i; char * wvalue; char stringbuffer[12]; dc210_status status; if (dc210_get_status(camera, &status) == GP_ERROR) return GP_ERROR; gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); gp_widget_new (GP_WIDGET_SECTION, _("File"), §ion); gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, _("JPEG")); gp_widget_add_choice (widget, _("FlashPix")); switch (status.file_type){ case DC210_FILE_TYPE_JPEG: gp_widget_set_value (widget, _("JPEG")); break; case DC210_FILE_TYPE_FPX: gp_widget_set_value (widget, _("FlashPix")); break; }; gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, _("640 x 480")); gp_widget_add_choice (widget, _("1152 x 864")); switch (status.resolution){ case DC210_FILE_640: gp_widget_set_value (widget, _("640 x 480")); break; case DC210_FILE_1152: gp_widget_set_value (widget, _("1152 x 864")); break; default: DC210_DEBUG("Undefined value for file resolution.\n"); break; }; gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, _("Low (best quality)")); gp_widget_add_choice (widget, _("Medium (better quality)")); gp_widget_add_choice (widget, _("High (good quality)")); switch (status.compression_type){ case DC210_LOW_COMPRESSION: gp_widget_set_value (widget, _("Low (best quality)")); break; case DC210_MEDIUM_COMPRESSION: gp_widget_set_value (widget, _("Medium (better quality)")); break; case DC210_HIGH_COMPRESSION: gp_widget_set_value (widget, _("High (good quality)")); break; }; gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_SECTION, _("Capture"), §ion); gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */ gp_widget_add_choice (widget, "51 mm"); gp_widget_add_choice (widget, "41 mm"); gp_widget_add_choice (widget, "34 mm"); gp_widget_add_choice (widget, "29 mm"); gp_widget_add_choice (widget, _("Macro")); switch (status.zoom){ case DC210_ZOOM_58: gp_widget_set_value (widget, _("58 mm")); break; case DC210_ZOOM_51: gp_widget_set_value (widget, _("51 mm")); break; case DC210_ZOOM_41: gp_widget_set_value (widget, _("41 mm")); break; case DC210_ZOOM_34: gp_widget_set_value (widget, _("34 mm")); break; case DC210_ZOOM_29: gp_widget_set_value (widget, _("29 mm")); break; case DC210_ZOOM_MACRO: gp_widget_set_value (widget, _("Macro")); break; }; gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget); gp_widget_append (section, widget); for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ gp_widget_add_choice (widget, exp_comp[i]); if (status.exp_compensation + 4 == i) gp_widget_set_value (widget, exp_comp[i]); }; gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, _("Auto")); gp_widget_add_choice (widget, _("Force")); gp_widget_add_choice (widget, _("None")); switch (status.flash){ case DC210_FLASH_AUTO: gp_widget_set_value (widget, _("Auto")); break; case DC210_FLASH_FORCE: gp_widget_set_value (widget, _("Force")); break; case DC210_FLASH_NONE: gp_widget_set_value (widget, _("None")); break; }; gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget); gp_widget_append (section, widget); gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("Off")); if (status.preflash) gp_widget_set_value (widget, _("On")); else gp_widget_set_value (widget, _("Off")); gp_widget_get_value (widget, &wvalue); gp_widget_new (GP_WIDGET_SECTION, _("Other"), §ion); gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_system_time_callback); gp_widget_set_info (widget, _("Set clock in camera")); gp_camera_get_abilities(camera, &abilities); gp_port_get_settings (camera->port, &settings); gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget); gp_widget_append (section, widget); for (i = 0; i < sizeof(abilities.speed); i++){ if (abilities.speed[i] == 0) break; snprintf(stringbuffer, 12, "%d", abilities.speed[i]); gp_widget_add_choice (widget, stringbuffer); if (settings.serial.speed == abilities.speed[i]) gp_widget_set_value (widget, stringbuffer); }; gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, status.album_name); gp_widget_set_info (widget, _("Name to set on card when formatting.")); gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_format_callback); gp_widget_set_info (widget, _("Format card and set album name.")); #ifdef DEBUG gp_widget_new (GP_WIDGET_SECTION, _("Debug"), §ion); gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget); gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_debug_callback); gp_widget_set_info (widget, _("Execute predefined command\nwith parameter values.")); #endif return GP_OK; }
static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { CameraWidget *w, *w2; char *wvalue, *w2value; int i; gp_widget_get_child_by_label (window, _("File type"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); if (wvalue[0] == 'J') dc210_set_file_type(camera, DC210_FILE_TYPE_JPEG); else dc210_set_file_type(camera, DC210_FILE_TYPE_FPX); }; gp_widget_get_child_by_label (window, _("File resolution"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case '6': dc210_set_resolution(camera, DC210_FILE_640); break; case '1': dc210_set_resolution(camera, DC210_FILE_1152); break; }; }; gp_widget_get_child_by_label (window, _("File compression"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case 'L': dc210_set_compression(camera, DC210_LOW_COMPRESSION); break; case 'M': dc210_set_compression(camera, DC210_MEDIUM_COMPRESSION); break; case 'H': dc210_set_compression(camera, DC210_HIGH_COMPRESSION); }; }; gp_widget_get_child_by_label (window, _("Zoom"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case '5': if (wvalue[1] == '8') dc210_set_zoom(camera, DC210_ZOOM_58); else dc210_set_zoom(camera, DC210_ZOOM_51); break; case '4': dc210_set_zoom(camera, DC210_ZOOM_41); break; case '3': dc210_set_zoom(camera, DC210_ZOOM_34); break; case '2': dc210_set_zoom(camera, DC210_ZOOM_29); break; case 'M': dc210_set_zoom(camera, DC210_ZOOM_MACRO); break; }; }; gp_widget_get_child_by_label (window, _("Exposure compensation"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ if (strncmp(wvalue, exp_comp[i], 4) == 0){ dc210_set_exp_compensation(camera, i - 4); break; }; }; }; gp_widget_get_child_by_label (window, _("Port speed"), &w); if (gp_widget_changed (w)) { gp_widget_get_value (w, &wvalue); dc210_set_speed(camera, atoi(wvalue)); }; gp_widget_get_child_by_label (window, _("Flash"), &w); gp_widget_get_child_by_label (window, _("Red eye flash"), &w2); if (gp_widget_changed (w) || gp_widget_changed(w2)) { gp_widget_get_value (w, &wvalue); gp_widget_get_value (w2, &w2value); switch(wvalue[0]){ case 'A': dc210_set_flash(camera, DC210_FLASH_AUTO, w2value[1] == 'n' ? 1 : 0); break; case 'F': dc210_set_flash(camera, DC210_FLASH_FORCE, w2value[1] == 'n' ? 1 : 0); break; case 'N': dc210_set_flash(camera, DC210_FLASH_NONE, 0); gp_widget_set_value(w2, _("Off")); break; }; }; return GP_OK; }