/*---------------------------------------------------------------------------
	Read entried from dialog box
*/
void read ( GtkWidget *dialog )
{

gchar *s;

#define READ_ENTRY(widget_name)   gtk_editable_get_chars(GTK_EDITABLE (WID(widget_name)), 0, -1);

			s=READ_ENTRY(entryLeft);;
			left=(uint32_t)atoi(s);
			s=READ_ENTRY(entryRight);;
			right=(uint32_t)atoi(s);
			s=READ_ENTRY(entryTop);;
			top=(uint32_t)atoi(s);
			s=READ_ENTRY(entryBottom);;
			bottom=(uint32_t)atoi(s);

			if((top+bottom)>height)
				{
					top=bottom=0;
				}
			if((left+right)>width)
				{
					left=right=0;
				}

}
uint8_t DIA_pipe(char **cmd,char **param)
{
	GtkWidget *dialog;

	char *str;
	uint8_t ret=0;

	gint r;

#define FILL_ENTRY(widget_name,value) {		 \
gtk_editable_delete_text(GTK_EDITABLE(lookup_widget(dialog,#widget_name)), 0,-1);\
gtk_editable_insert_text(GTK_EDITABLE(lookup_widget(dialog,#widget_name)), str, strlen(str), &r);}

	dialog=create_dialog1();
	gtk_transient(dialog);
	*cmd=NULL;
	*param=NULL;

	if(!prefs->get(PIPE_CMD,&str)) str=NULL;
	if(str)
	{
		FILL_ENTRY(entryName,left);
	}
	if(!prefs->get(PIPE_PARAM,&str)) str=NULL;
	if(str)
	{
		FILL_ENTRY(entryParam,left);
	}

	ret=0;
	if(gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK)
	{

		// gchar *s;
		// uint32_t val1;
#define READ_ENTRY(widget_name)   gtk_editable_get_chars(GTK_EDITABLE (lookup_widget(dialog,#widget_name)), 0, -1);

			str=READ_ENTRY(entryName);
			if(strlen(str))
			{
				*cmd=ADM_strdup(str);;
				prefs->set(PIPE_CMD,str);
			}
			str=READ_ENTRY(entryName);
			if(strlen(str))
			{
				*param=ADM_strdup(str);;
				prefs->set(PIPE_PARAM,str);
			}
			ret=1;
	}

	gtk_widget_destroy(dialog);

	return ret;

}
uint8_t DIA_lame(char **lame)
{
	GtkWidget *dialog;

	char *str;
	uint8_t ret=0;

	gint r;

#define FILL_ENTRY(widget_name,value) {		 \
gtk_editable_delete_text(GTK_EDITABLE(lookup_widget(dialog,#widget_name)), 0,-1);\
gtk_editable_insert_text(GTK_EDITABLE(lookup_widget(dialog,#widget_name)), str, strlen(str), &r);}

	dialog=create_dialog1();
	gtk_transient(dialog);
	*lame=NULL;

	if(!prefs->get(LAME_CLI,&str)) str=NULL;
	if(str)
	{
		FILL_ENTRY(entry1,left);
	}
	ret=0;
	if(gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK)
	{

#define READ_ENTRY(widget_name)   gtk_editable_get_chars(GTK_EDITABLE (lookup_widget(dialog,#widget_name)), 0, -1);

			str=READ_ENTRY(entry1);
			if(strlen(str))
			{
				*lame=ADM_strdup(str);;
				prefs->set(LAME_CLI,str);
			}
			ret=1;
	}

	gtk_widget_destroy(dialog);

	return ret;

}
void QtCurveShadowConfiguration::load(KConfig *cfg)
{
    KConfigGroup               group(cfg, CFG_GROUP);
    QtCurveShadowConfiguration def(m_colorGroup);

    READ_ENTRY("Size", m_size);
    READ_ENTRY("HOffset", m_hOffset);
    READ_ENTRY("VOffset", m_vOffset);
    READ_ENTRY("ColorType", m_colorType);
    READ_ENTRY("ShadowType", m_shadowType);

    if(CT_CUSTOM==m_colorType)
        READ_ENTRY("Color", m_color);
    if(m_size<MIN_SIZE || m_size>MAX_SIZE)
        m_size=def.shadowSize();
    if(m_hOffset<MIN_OFFSET || m_hOffset>MAX_OFFSET)
        m_hOffset=def.horizontalOffset();
    if(m_vOffset<MIN_OFFSET || m_vOffset>MAX_OFFSET)
        m_vOffset=def.verticalOffset();
    setColorType((ColorType)m_colorType);
}
/*----------------------------------------------*/
uint8_t DIA_resize(uint32_t *width,uint32_t *height,uint32_t *alg,uint32_t originalw, uint32_t originalh,uint32_t fps1000)
{


	char str[100];
	uint8_t ret=0;


	if(fps1000>24600 && fps1000<25400)
	{
		aprintf("Pal\n");
		pal=1;
	}
	else
	{
		aprintf("NTSC\n");
		pal=0;
	}

	ow=originalw;
	oh=originalh;

	iw=*width;
	ih=*height;
	dialog=create_dialog1();
	gtk_transient(dialog);
	erx=ery=0;

	double val;
	val=100.*iw;
	if(ow) val=val/ow;
	adj_angle=	gtk_range_get_adjustment (GTK_RANGE(WID(hscale1)));
	gtk_adjustment_set_value( GTK_ADJUSTMENT(adj_angle),(  gdouble  ) val );

	// remember algo
 	gtk_option_menu_set_history (GTK_OPTION_MENU (WID(optionmenu1)), *alg);


	#define CONNECT(w,x) gtk_signal_connect(GTK_OBJECT(lookup_widget(dialog,#w)), #x, \
		       GTK_SIGNAL_FUNC(drag), NULL)

		       	CONNECT(hscale1,drag_data_received);
			CONNECT(hscale1,drag_motion);
			CONNECT(hscale1,drag_data_get);
			CONNECT(hscale1,drag_begin);

			gtk_signal_connect(GTK_OBJECT(adj_angle),"value_changed",    GTK_SIGNAL_FUNC(drag), NULL);

	write();

	ret=0;
	uint8_t stop=0;
	while(!stop)
	{
		switch(gtk_dialog_run(GTK_DIALOG(dialog)))
		{
			case GTK_RESPONSE_OK:
				gchar *s;

				s=READ_ENTRY(entry_width);;
				*width=(uint32_t)atoi(s);
				s=READ_ENTRY(entry_height);;
				*height=(uint32_t)atoi(s);
				*alg= getRangeInMenu(lookup_widget(dialog,"optionmenu1"));
				ret=1;
				stop=1;
				break;
		default:			
		case GTK_RESPONSE_CANCEL:
				stop=1;
				break;
		case GTK_RESPONSE_APPLY:
				drag(NULL,NULL);
				break;
							
		}

	}
	gtk_widget_destroy(dialog);

	return ret;

}