コード例 #1
0
ファイル: library.c プロジェクト: Dvizhenka/libgphoto2
static int
camera_get_config (Camera *camera, CameraWidget **window, GPContext *context)
{
	CameraWidget *child;

	GP_DEBUG ("*** camera_get_config");

	gp_widget_new (GP_WIDGET_WINDOW,
			_("Picture Frame Configuration"), window);

	gp_widget_new (GP_WIDGET_TOGGLE,
			_("Synchronize frame data and time with PC"), &child);
	gp_widget_set_value (child, &camera->pl->syncdatetime);
	gp_widget_append (*window, child);

	gp_widget_new (GP_WIDGET_RADIO, _("Orientation"), &child);
	gp_widget_add_choice (child, orientation_to_string (0));
	gp_widget_add_choice (child, orientation_to_string (1));
	gp_widget_add_choice (child, orientation_to_string (2));
       	gp_widget_set_value (child,
			     orientation_to_string (camera->pl->orientation));
       	gp_widget_append (*window, child);

	return GP_OK;
}
コード例 #2
0
ファイル: puppy.c プロジェクト: nazgul77/libgphoto2
static int
camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) 
{
        CameraWidget *section, *turbo;
	char buf[1024];
	int val;

        gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window);
        gp_widget_set_name (*window, "config");

        gp_widget_new (GP_WIDGET_SECTION, _("Driver Settings"), &section);
	gp_widget_set_name (section, "driver");
        gp_widget_append (*window, section);

	gp_widget_new (GP_WIDGET_RADIO, _("Turbo mode"), &turbo);
        gp_widget_set_name (turbo, "turbo");
        gp_widget_add_choice (turbo,_("On"));
        gp_widget_add_choice (turbo,_("Off"));
        gp_widget_append (section, turbo);

        if (GP_OK == gp_setting_get("topfield","turbo", buf)) {
		if (!strcmp(buf,"no"))
			val = 0;
		else
			val = 1;
	} else {
		val = 1; /* enabled by default */
	}
        gp_widget_set_value ( turbo, val?_("On"):_("Off"));
	return GP_OK;
}
コード例 #3
0
ファイル: sierra-desc.c プロジェクト: rajbot/gphoto
static int 
camera_cam_desc_get_value (ValueNameType *val_name_p, CameraWidgetType widge, 
			   uint32_t reg_len, void *buff, int mask, 
			   CameraWidget *child)
{
	if ((widge == GP_WIDGET_RADIO) || (widge == GP_WIDGET_MENU)) {
		gp_widget_add_choice (child, _(val_name_p->name));
		GP_DEBUG ("get value %15s:\t%lld (0x%04llx)", 
			  val_name_p->name, (long long)val_name_p->u.value,
			  (long long unsigned) val_name_p->u.value);
		/* XXX where is endian handled? */
		if ((mask & *(int*) buff) == val_name_p->u.value) {
			gp_widget_set_value (child, _(val_name_p->name));
		}
	} else if (widge == GP_WIDGET_DATE) {
		GP_DEBUG ("get value date/time %s", ctime((time_t *) buff));
		gp_widget_set_value (child, (int*) buff);
	} else if (widge == GP_WIDGET_RANGE) {
		float float_val, increment;

		increment = val_name_p->u.range[2];
		if (increment == 0.0) {
			/* 
			 * Use a default value.
			 */
			increment = 1.0;
		}
		GP_DEBUG ("get value range:\t%08g:%08g increment %g (via %g)", 
		       val_name_p->u.range[0], val_name_p->u.range[1],
		       increment, val_name_p->u.range[2]);
		gp_widget_set_range (child, val_name_p->u.range[0], 
				     val_name_p->u.range[1], increment);
		/*
		 * Kluge: store the value in buff as a 4 byte int, even
		 * though we might have read 8 bytes or more.
		 */
		float_val = (*(int*) buff) * increment;
		gp_widget_set_value (child, &float_val);
	} else if (widge == GP_WIDGET_BUTTON) {
		GP_DEBUG ("get button");
		gp_widget_set_value (child, val_name_p->u.callback);
	} else {
		GP_DEBUG ("get value bad widget type %d", widge);
		return (GP_ERROR);
	}

	return (GP_OK);
}
コード例 #4
0
ファイル: qm150.c プロジェクト: AleksKolkov/libgphoto2
/*
 * List all informations about the camera
 */
static int
camera_get_config (Camera* camera, CameraWidget** window, GPContext *context)
{
	unsigned char cmd[2], buf[INFO_BUFFER];
	int ret;
        CameraWidget *widget;
        CameraWidget *section;
	time_t timestamp=0;
	float value_float;

	GP_DEBUG ("*** ENTER: camera_get_config ***");

	/* get informations about camera */
	cmd[0] = ESC;
	cmd[1] = GETCAMINFO;
	ret = gp_port_write (camera->port, (char*)cmd, sizeof(cmd));
	if (ret<GP_OK)
		return ret;
	ret = gp_port_read (camera->port, (char*)buf, INFO_BUFFER);
	if (ret<GP_OK)
		return ret;

	/* Informations manipulation */
	timestamp = (buf[TIMESTAMP_PTR] << 24) + (buf[TIMESTAMP_PTR+1] << 16)
		+ (buf[TIMESTAMP_PTR+2] << 8) + buf[TIMESTAMP_PTR+3];
	/*
	 * This timestamp start the 1 January 1980 at 00:00 
	 * but UNIX timestamp start the 1 January 1970 at 00:00
	 * so we calculate the UNIX timestamp with the camera's one
	 */
	timestamp += (8*365 + 2*366)*24*3600-3600;

	/* Window creation */
	gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window);

        /************************/
        /* Persistent Settings  */
        /************************/
        gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), &section);
        gp_widget_append (*window, section);

        /* Date */
        gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget);
        gp_widget_append (section, widget);
        gp_widget_set_value (widget, &timestamp);

        /* Auto Off Time */
        gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget);
        gp_widget_append (section, widget);
        gp_widget_set_range (widget, 1, 255, 1);
        value_float = ((buf[AUTO_OFF_PTR] << 8) + buf[AUTO_OFF_PTR+1]) / 60;
        gp_widget_set_value (widget, &value_float);


        /* Resolution */
        gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Low"));
        gp_widget_add_choice (widget, _("Medium"));
        gp_widget_add_choice (widget, _("High"));
        switch (buf[RESOLUTION_PTR]) {
	        case 1:
        	        gp_widget_set_value (widget, _("High"));
                	break;
	        case 2:
        	        gp_widget_set_value (widget, _("Low"));
	               	break;
		case 0:
        	        gp_widget_set_value (widget, _("Medium"));
                	break;
        }

        /* LCD */
        gp_widget_new (GP_WIDGET_RADIO, _("LCD"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("On"));
        gp_widget_add_choice (widget, _("Off"));
        switch (buf[LCD_STATE_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("On"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Off"));
                	break;
        }

        /* Icons */
        gp_widget_new (GP_WIDGET_RADIO, _("Icons"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("On"));
        gp_widget_add_choice (widget, _("Off"));
        switch (buf[ICON_STATE_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("On"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Off"));
                	break;
        }

        /****************/
        /* Localization */
        /****************/
        gp_widget_new (GP_WIDGET_SECTION, _("Localization"), &section);
        gp_widget_append (*window, section);

        /* Date format */
        gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Month/Day/Year"));
        gp_widget_add_choice (widget, _("Day/Month/Year"));
        gp_widget_add_choice (widget, _("Year/Month/Day"));
	switch (buf[DATE_FORMAT_PTR]) {
		case 0:
			gp_widget_set_value (widget, _("Month/Day/Year"));
			break;
		case 1:
			gp_widget_set_value (widget, _("Day/Month/Year"));
			break;
		case 2:
			gp_widget_set_value (widget, _("Year/Month/Day"));
			break;
	}

	/********************************/
        /* Session-persistent Settings  */
        /********************************/
        gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"),
                       &section);
        gp_widget_append (*window, section);

        /* Flash */
        gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Off"));
        gp_widget_add_choice (widget, _("On"));
        gp_widget_add_choice (widget, _("On, red-eye reduction"));
        gp_widget_add_choice (widget, _("Auto"));
        gp_widget_add_choice (widget, _("Auto, red-eye reduction"));
        switch (buf[FLASH_STATE_PTR]) {
	        case 2:
        	        gp_widget_set_value (widget, _("Off"));
                	break;
	        case 1:
			if (buf[RED_EYE_STATE_PTR] == 1)
	        	        gp_widget_set_value (widget, 
					_("On, red-eye reduction"));
			else
				gp_widget_set_value (widget, _("On"));
                	break;
	        case 0:
			if (buf[RED_EYE_STATE_PTR] == 1)
	        	        gp_widget_set_value (widget, 
					_("Auto, red-eye reduction"));
			else
				gp_widget_set_value (widget, _("Auto"));
                	break;
        }

        /* Exposure */
        gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget);
        gp_widget_append (section, widget);
        gp_widget_set_range (widget, -2, 2, 0.1);
	switch(buf[EXPOSURE_TIME_PTR]) {
		case 0:
			value_float = 0;
			break;
		case 1:
			value_float = 0.3;
			break;
		case 2:
			value_float = 0.5;
			break;
		case 3:
			value_float = 0.8;
			break;
		case 4:
			value_float = 1.0;
			break;
		case 5:
			value_float = 1.3;
			break;
		case 6:
			value_float = 1.5;
			break;
		case 7:
			value_float = 1.8;
			break;
		case 8:
			value_float = 2.0;
			break;
		case 0xF8:
			value_float = -2.0;
			break;
		case 0xF9:
			value_float = -1.8;
			break;
		case 0xFA:
			value_float = -1.5;
			break;
		case 0xFB:
			value_float = -1.3;
			break;
		case 0xFC:
			value_float = -1.0;
			break;
		case 0xFD:
			value_float = -0.8;
			break;
		case 0xFE:
			value_float = -0.5;
			break;
		case 0xFF:
			value_float = -0.3;
			break;
	}
        gp_widget_set_value (widget, &value_float);

       /* Focus */
        gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("2.0 m"));
	gp_widget_add_choice (widget, _("0.5 m"));
	gp_widget_add_choice (widget, _("0.1 m"));
        gp_widget_add_choice (widget, _("Auto"));
        switch (buf[FOCUS_PTR]) {
		case 0:
			gp_widget_set_value (widget, _("Auto"));
			break;
		case 1:
	                gp_widget_set_value (widget, _("2.0 m"));
	                break;
	        case 2:
        	        gp_widget_set_value (widget, _("0.5 m"));
                	break;
	        case 3:
        	        gp_widget_set_value (widget, _("0.1 m"));
                	break;
        }

       /* white balance */
        gp_widget_new (GP_WIDGET_RADIO, _("White balance"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Office"));
	gp_widget_add_choice (widget, _("Daylight"));
	gp_widget_add_choice (widget, _("Auto"));
        switch (buf[WHITE_BALANCE_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Auto"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Daylight"));
                	break;
	        case 2:
        	        gp_widget_set_value (widget, _("Office"));
                	break;
	}

       /* Sharpness */
        gp_widget_new (GP_WIDGET_RADIO, _("Sharpness"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Sharp"));
	gp_widget_add_choice (widget, _("Soft"));
	gp_widget_add_choice (widget, _("Auto"));
        switch (buf[SHARPNESS_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Auto"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Sharp"));
                	break;
	        case 2:
        	        gp_widget_set_value (widget, _("Soft"));
                	break;
	}

       /* Color */
        gp_widget_new (GP_WIDGET_RADIO, _("Color"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Light"));
	gp_widget_add_choice (widget, _("Deep"));
	gp_widget_add_choice (widget, _("Black and White"));
	gp_widget_add_choice (widget, _("Sepia"));
	gp_widget_add_choice (widget, _("Auto"));
        switch (buf[COLOR_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Auto"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Light"));
                	break;
	        case 2:
        	        gp_widget_set_value (widget, _("Deep"));
                	break;
	        case 3:
        	        gp_widget_set_value (widget, _("Black and White"));
                	break;
	        case 4:
        	        gp_widget_set_value (widget, _("Sepia"));
                	break;
	}

       /* Macro */
        gp_widget_new (GP_WIDGET_RADIO, _("Macro"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("On"));
	gp_widget_add_choice (widget, _("Off"));
        switch (buf[MACRO_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Off"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("On"));
                	break;
	}

       /* Zoom */
        gp_widget_new (GP_WIDGET_RADIO, _("Zoom"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("On"));
	gp_widget_add_choice (widget, _("Off"));
        switch (buf[ZOOM_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Off"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("On"));
                	break;
	}

       /* Capture */
        gp_widget_new (GP_WIDGET_RADIO, _("Capture"), &widget);
        gp_widget_append (section, widget);
	gp_widget_add_choice (widget, _("Single"));
	gp_widget_add_choice (widget, _("Sequence 9"));
        switch (buf[CAPTURE_TYPE_PTR]) {
	        case 0:
        	        gp_widget_set_value (widget, _("Single"));
                	break;
	        case 1:
        	        gp_widget_set_value (widget, _("Sequence 9"));
                	break;
	}

       /* Date display */
        gp_widget_new (GP_WIDGET_RADIO, _("Date display"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Anywhere"));
	gp_widget_add_choice (widget, _("Play mode"));
	gp_widget_add_choice (widget, _("Record mode"));
	gp_widget_add_choice (widget, _("Everywhere"));
        switch (buf[REC_DATE_DISP_PTR]) {
	        case 0:
			if (buf[PLAY_DATE_DISP_PTR] == 0)
				gp_widget_set_value (widget, _("Play mode"));
			else
        	        	gp_widget_set_value (widget, _("Anywhere"));
                	break;
	        case 1:
			if (buf[PLAY_DATE_DISP_PTR] == 0)
				gp_widget_set_value (widget, _("Everywhere"));
			else
        	        	gp_widget_set_value (widget, _("Record mode"));
                	break;
	}

        /************************/
        /* Volatile Settings    */
        /************************/
        gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), &section);
        gp_widget_append (*window, section);

        /* Self Timer */
        gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget);
        gp_widget_append (section, widget);
        gp_widget_add_choice (widget, _("Self Timer (next picture only)"));
        gp_widget_add_choice (widget, _("Normal"));
        switch (buf[TIMER_PTR]) {
	        case 1:
        	        gp_widget_set_value (widget, _("Self Timer ("
                	                     "next picture only)"));
	                break;
	        case 0:
        	        gp_widget_set_value (widget, _("Normal"));
                	break;
	        }
	return (GP_OK);
}
コード例 #5
0
ファイル: dc210.c プロジェクト: JohnChu/Snoopy
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"), &section);
	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"), &section);
	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"), &section);
	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"), &section);
	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;
}
コード例 #6
0
ファイル: sierra-desc.c プロジェクト: rajbot/gphoto
static int
camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p, 
			    CameraWidget *section, GPContext *context)
{
	int ind, vind, ret, value;
	int mask;
	char buff[1024];
	CameraWidget *child;
	RegisterDescriptorType *reg_desc_p;

	GP_DEBUG ("register %d", reg_p->reg_number);
	if (reg_p->reg_len == 0) {
		/*
		 * This is 0 for GP_WIDGET_BUTTON (callbacks), since is no
		 * register for call backs. Frontends "get" the value, and
		 * call the function directly.
		 */
		ret = GP_OK;
	} else if (reg_p->reg_len == 4) {
		int rval;
		ret = sierra_get_int_register (camera, reg_p->reg_number,
					       &rval,
					       context);
		reg_p->reg_value = rval;
	} else if (reg_p->reg_len == 8) {
		/*
		 * reg_value is 8 bytes maximum. If you need a bigger
		 * value, change the reg_value size, or allocate space on
		 * the fly and make a union with reg_value and a void*.
		 */
		ret = sierra_get_string_register (camera, reg_p->reg_number, 
					  -1, NULL, (unsigned char *)buff, (unsigned int *)&value, context);
		if ((ret == GP_OK) && value != reg_p->reg_len) {
			GP_DEBUG ("Bad length result %d", value);
			return (GP_ERROR);
		}
		memcpy (&reg_p->reg_value, buff, reg_p->reg_len);
	} else {
		GP_DEBUG ("Bad register length %d", reg_p->reg_number);
		return (GP_ERROR);
	}
	GP_DEBUG ("... '%s'.", gp_result_as_string (ret));
        if (ret < 0) {
		return (ret);
	}

	for (ind = 0; ind < reg_p->reg_desc_cnt; ind++) {
		reg_desc_p = &reg_p->reg_desc[ind];
		mask = reg_desc_p->regs_mask;
		GP_DEBUG ("window name is %s", reg_desc_p->regs_long_name);
		gp_widget_new (reg_desc_p->reg_widget_type, 
			       _(reg_desc_p->regs_long_name), &child);
		gp_widget_set_name (child, reg_desc_p->regs_short_name);
		/*
		 * Setting the info for the preference settings does not
		 * make sense like it does for an icon button. This is
		 * used as the tool-tip field (mouse over hint that pops
		 * up after a second in gtkam).  We don't want this used
		 * at all; setting it to space doesn't work well, so just
		 * set it to the same as regs_long_name.
		 */
		gp_widget_set_info (child,  _(reg_desc_p->regs_long_name));
		GP_DEBUG ("reg_value 0x%016llx", (long long unsigned)reg_p->reg_value);
		for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; vind++) {
			camera_cam_desc_get_value (&reg_desc_p->regs_value_names[vind],
				reg_desc_p->reg_widget_type, reg_p->reg_len,
				(char*) &reg_p->reg_value, mask, child);
		}
		/*
		 * For radio and menu values: if there has been no change, it
		 * means the value was not set, and so it is unknown.
		 */
		if (((reg_desc_p->reg_widget_type == GP_WIDGET_RADIO) || 
		     (reg_desc_p->reg_widget_type == GP_WIDGET_MENU)) && 
		      !gp_widget_changed (child)) {
			sprintf (buff, _("%lld (unknown)"), (long long)reg_p->reg_value);
			gp_widget_add_choice (child, buff);
			gp_widget_set_value (child, buff);
		}
		gp_widget_append (section, child);
	}
	return (GP_OK);
}
コード例 #7
0
ファイル: gphoto2-camera.c プロジェクト: axxel/libgphoto2
/**
 * Retrieve a single configuration \c widget for the \c camera.
 *
 * @param camera a #Camera
 * @param name the name of a configuration widget
 * @param widget a #CameraWidget
 * @param context a #GPContext
 * @return gphoto2 error code
 *
 * This \c widget will then contain the current and the possible values and the type.
 *
 */
int
gp_camera_get_single_config (Camera *camera, const char *name, CameraWidget **widget, GPContext *context)
{
	CameraWidget		*rootwidget, *child;
	CameraWidgetType	type;
	const char		*label;
	int			ret, ro;

	C_PARAMS (camera);
	CHECK_INIT (camera, context);

	if (camera->functions->get_single_config) {
		CHECK_RESULT_OPEN_CLOSE (camera, camera->functions->get_single_config (
						camera, name, widget, context), context);

		CAMERA_UNUSED (camera, context);
		return GP_OK;
	}

	if (!camera->functions->get_config) {
		gp_context_error (context, _("This camera does not provide any configuration options."));
		CAMERA_UNUSED (camera, context);
		return GP_ERROR_NOT_SUPPORTED;
	}
	/* emulate it ... */
	CHECK_OPEN (camera, context);

	ret = camera->functions->get_config ( camera, &rootwidget, context);
	if (ret != GP_OK) {
		CHECK_CLOSE (camera, context);
		CAMERA_UNUSED (camera, context);
		return ret;
	}
	ret = gp_widget_get_child_by_name (rootwidget, name, &child);
	if (ret != GP_OK) {
		gp_widget_free (rootwidget);
		CHECK_CLOSE (camera, context);
		CAMERA_UNUSED (camera, context);
		return ret;
	}

	/* We need to duplicate the widget, as we will free the widgettree */
	gp_widget_get_type (child, &type);
	gp_widget_get_label (child, &label);
	gp_widget_get_readonly (child, &ro);

	ret = gp_widget_new (type, label, widget);
	if (ret != GP_OK)
		goto out;
	gp_widget_set_name (*widget, name);
	gp_widget_set_readonly (*widget, ro);

	switch (type) {
        case GP_WIDGET_MENU:
        case GP_WIDGET_RADIO: {
		char *value;
		int i, nrofchoices;

		nrofchoices = gp_widget_count_choices (child);
		for (i = 0; i < nrofchoices; i++) {
			const char *choice;

			gp_widget_get_choice (child, i, &choice);
			gp_widget_add_choice (*widget, choice);
		}
		gp_widget_get_value (child, &value);
		gp_widget_set_value (*widget, value);
		break;
	}
        case GP_WIDGET_TEXT: {
		char *value;

		gp_widget_get_value (child, &value);
		gp_widget_set_value (*widget, value);
		break;
	}
        case GP_WIDGET_RANGE: {
		float value, rmin, rmax, rstep;

		gp_widget_get_range (child, &rmin, &rmax, &rstep);
		gp_widget_set_range (*widget, rmin, rmax, rstep);
		gp_widget_get_value (child, &value);
		gp_widget_set_value (*widget, &value);
                break;
	}
        case GP_WIDGET_TOGGLE:
        case GP_WIDGET_DATE: {
		int value;

		gp_widget_get_value (child, &value);
		gp_widget_set_value (*widget, &value);
                break;
	}
        case GP_WIDGET_BUTTON:
        case GP_WIDGET_SECTION:
        case GP_WIDGET_WINDOW:
        default:
                ret = GP_ERROR_BAD_PARAMETERS;
		break;
	}
out:
	gp_widget_free (rootwidget);
	CHECK_CLOSE (camera, context);
	CAMERA_UNUSED (camera, context);
	return ret;
}