int photo_camera::photo_camera_find_widget_by_name( std::string name, CameraWidget **child, CameraWidget **root) { int error_code; // Get camera configuration error_code = gp_camera_get_config( camera_, root, context_ ); if (error_code != GP_OK) { photo_reporter::error( "gp_camera_get_config()"); return error_code; } // Find child of configuration by name if( gp_widget_get_child_by_name( *root, name.c_str(), child ) == GP_OK ) { return GP_OK; } // Find child of configuration by label if( gp_widget_get_child_by_label( *root, name.c_str(), child ) == GP_OK ) { return GP_OK; } // If full name is not found, search for last subname. // name delimeter is '/' size_t found_index = name.length(); while( found_index == name.length() ) { found_index = name.rfind( '/' ); if( found_index == std::string::npos ) // No subname, we already failed this search above { gp_context_error( context_,"%s not found in configuration tree.", name.c_str() ); gp_widget_free( *root ); return GP_ERROR; } if( found_index == name.length() - 1 ) // end of string, cut it off { name = name.substr( 0, found_index ); } } name = name.substr( found_index, name.length() - 1 ); // Find child using if( gp_widget_get_child_by_name( *root, name.c_str(), child ) == GP_OK ) { return GP_OK; } if( gp_widget_get_child_by_label( *root, name.c_str(), child ) == GP_OK ) { return GP_OK; } // all matches have failed gp_context_error( context_, "%s not found in configuration tree.", name.c_str() ); gp_widget_free( *root ); return GP_ERROR; }
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); }
/** * @brief CameraHandler::findWidgetByName * @param p * @param name * @param child * @param rootConfig * @return */ int QTLCamera::findWidgetByName(const char *name, CameraWidget **child, CameraWidget **rootConfig) { int rc; rc = gp_camera_get_config(params->camera, rootConfig, params->context); if (rc != GP_OK) { return rc; } rc = gp_widget_get_child_by_name(*rootConfig, name, child); if (rc != GP_OK) { rc = gp_widget_get_child_by_label(*rootConfig, name, child); } if (rc != GP_OK) { char *part, *s, *newname; newname = strdup(name); if (!newname) { return GP_ERROR_NO_MEMORY; } *child = *rootConfig; part = newname; while (part[0] == '/') { part++; } while (1) { CameraWidget *tmp; s = strchr(part,'/'); if (s) { *s = '\0'; } rc = gp_widget_get_child_by_name(*child, part, &tmp); if (rc != GP_OK) { rc = gp_widget_get_child_by_label(*child, part, &tmp); } if (rc != GP_OK) { break; } *child = tmp; if (!s) { // end of path break; } part = s + 1; while (part[0] == '/') { part++; } } if (s) { // If we have stuff left over, we failed. qDebug() << newname << "not found in configuration tree."; free(newname); gp_widget_free(*rootConfig); return GP_ERROR; } free (newname); } return GP_OK; }
/* * This function looks up a label or key entry of * a configuration widget. * The functions descend recursively, so you can just * specify the last component. */ int _lookup_widget(CameraWidget*widget, const char *key, CameraWidget **child) { int ret = gp_widget_get_child_by_name (widget, key, child); if (ret < GP_OK) { ret = gp_widget_get_child_by_label (widget, key, child); } return ret; }
CameraWidget* Widget::get_gp_child(const char *name_or_label) const { CameraWidget* child; int ret = gp_widget_get_child_by_name(widget, name_or_label, &child); if (ret < GP_OK) ret = gp_widget_get_child_by_label(widget, name_or_label, &child); if (ret < GP_OK) throw std::out_of_range("no widget found"); return child; }
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 *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 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; }
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); }