Exemplo n.º 1
0
static void spinbn_set_value(GuiSpinBtn *spin, efloat value)
{
	GuiEntry *entry = GUI_ENTRY_DATA(spin->entry);
	echar buf[200], *p;
	eint  len;

	e_sprintf(buf, _("%f"), spin->value);
	p = e_strchr(buf, '.');
	if (spin->digits > 0)
		p[spin->digits + 1] = 0;
	else
		p[spin->digits] = 0;
	len = e_strlen(buf);

	if (value == spin->value
			&& len == entry->nchar
			&& !e_strncmp(buf, entry->chars, len))
		return;

	if (value < spin->min)
		spin->value = spin->max;
	else if (value > spin->max)
		spin->value = spin->min;
	else
		spin->value = value;

	e_sprintf(buf, _("%f"), spin->value);
	p = e_strchr(buf, '.');
	if (spin->digits > 0)
		p[spin->digits + 1] = 0;
	else
		p[spin->digits] = 0;

	egui_set_strings(spin->entry, buf);
}
Exemplo n.º 2
0
Arquivo: gif.c Projeto: guygal/egui
static int gif_get_extension(GifContext *context)
{
	int retval;
	int empty_block = false;

	if (context->extension_flag) {
		if (!context->extension_label &&
				!gif_read(context, &context->extension_label , 1))
			return -1;

		switch (context->extension_label) {
		case 0xf9:			/* Graphic Control Extension */
			retval = get_data_block(context, (euchar *)context->block_buf, NULL);
			if (retval != 0) return retval;

			if (context->frame == NULL) {
				context->gif89.disposal = (context->block_buf[0] >> 2) & 0x7;
				context->gif89.input_flag = (context->block_buf[0] >> 1) & 0x1;
				context->gif89.delay_time = LM_to_uint(context->block_buf[1], context->block_buf[2]);

				if ((context->block_buf[0] & 0x1) != 0)
					context->gif89.transparent = context->block_buf[3];
				else
					context->gif89.transparent = -1;
			}

			/* Now we've successfully loaded this one, we continue on our way */
			context->block_count = 0;
			context->extension_flag = false;
			break;

		case 0xff: /* application extension */
			if (!context->in_loop_extension) { 
				retval = get_data_block(context, (euchar *)context->block_buf, NULL);
				if (retval != 0)
					return retval;
				if (!e_strncmp(context->block_buf, _("NETSCAPE2.0"), 11) ||
						!e_strncmp(context->block_buf, _("ANIMEXTS1.0"), 11)) {
					context->in_loop_extension = true;
				}
				context->block_count = 0;
			}

			if (context->in_loop_extension) {
				do {
					retval = get_data_block(context, (euchar *)context->block_buf, &empty_block);
					if (retval != 0)
						return retval;
					if (context->is_anim && context->block_buf[0] == 0x01) {
						context->anim->loop = context->block_buf[1] + (context->block_buf[2] << 8);
						if (context->anim->loop != 0) 
							context->anim->loop++;
					}
					context->block_count = 0;
				} while (!empty_block);

				context->in_loop_extension = false;
				context->extension_flag = false;
				goto step;
			}
			break;
		default:
			break;
		}
	}