/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */
#include "config.h"

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include "ADM_toolkit/toolkit_gtk_include.h"
#include "ADM_toolkit/toolkit_gtk.h"

#include "ADM_assert.h" 

#include "ADM_library/default.h"

//___________________________________
#include "ADM_editor/ADM_edit.hxx"
#include "ADM_video/ADM_genvideo.hxx"

#include "ADM_encoder/ADM_vidEncode.hxx"
#include "ADM_encoder/adm_encoder.h"
#include "ADM_encoder/adm_encmjpeg_param.h"
  

static GtkWidget	*create_dialog1 (void);
static     GtkObject *hscaleAdj;

uint8_t DIA_mjpegCodecSetting(COMPRES_PARAMS *param)
{
	MJPEGConfig *config=(MJPEGConfig *)param->extraSettings;
	ADM_assert(sizeof(MJPEGConfig)==param->extraSettingsLen);
	uint8_t ret=0;
	GtkWidget *dialog;
	
	dialog=create_dialog1();
	gtk_register_dialog(dialog);
	#define TSET(a,b) if(b) 		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog,#a)),1);
	#define TGET(a,b)	if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog,#a)))) \
							{ b=1;;} else b=0;
	TSET(checkbuttonUV,(config->swapped));
	gtk_adjustment_set_value( GTK_ADJUSTMENT(hscaleAdj),(  gdouble  ) config->qual );
	
	if(gtk_dialog_run(GTK_DIALOG(dialog))==GTK_RESPONSE_OK)
	{
		
			TGET(checkbuttonUV,(config->swapped));
			config->qual=(int)floor(GTK_ADJUSTMENT(hscaleAdj)->value);
			ret=1;
	
	}
	gtk_unregister_dialog(dialog);
	gtk_widget_destroy(dialog);
	
	return ret;
}   
  
GtkWidget	*create_dialog1 (void)
{
  GtkWidget *dialog1;
  GtkWidget *dialog_vbox1;
  GtkWidget *vbox1;
  GtkWidget *label1;
  GtkWidget *hscaleQual;
  GtkWidget *checkbuttonUV;
  GtkWidget *dialog_action_area1;
  GtkWidget *cancelbutton1;
  GtkWidget *okbutton1;

  dialog1 = gtk_dialog_new ();
  gtk_window_set_title (GTK_WINDOW (dialog1), _("Mjpeg Codec settings"));

  dialog_vbox1 = GTK_DIALOG (dialog1)->vbox;
  gtk_widget_show (dialog_vbox1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);

  label1 = gtk_label_new (_("Quality"));
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (vbox1), label1, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT);

  hscaleAdj=gtk_adjustment_new (0, 0, 100, 0, 0, 0);
  hscaleQual = gtk_hscale_new (GTK_ADJUSTMENT (hscaleAdj));
  gtk_widget_show (hscaleQual);
  gtk_box_pack_start (GTK_BOX (vbox1), hscaleQual, FALSE, FALSE, 0);
  gtk_scale_set_digits (GTK_SCALE (hscaleQual), 0);

  checkbuttonUV = gtk_check_button_new_with_mnemonic (_("Swap U & V"));
  gtk_widget_show (checkbuttonUV);
  gtk_box_pack_start (GTK_BOX (vbox1), checkbuttonUV, FALSE, FALSE, 0);

  dialog_action_area1 = GTK_DIALOG (dialog1)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), cancelbutton1, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);

  okbutton1 = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (dialog1), okbutton1, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog1, "dialog1");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_vbox1, "dialog_vbox1");
  GLADE_HOOKUP_OBJECT (dialog1, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (dialog1, label1, "label1");
  GLADE_HOOKUP_OBJECT (dialog1, hscaleQual, "hscaleQual");
  GLADE_HOOKUP_OBJECT (dialog1, checkbuttonUV, "checkbuttonUV");
  GLADE_HOOKUP_OBJECT_NO_REF (dialog1, dialog_action_area1, "dialog_action_area1");
  GLADE_HOOKUP_OBJECT (dialog1, cancelbutton1, "cancelbutton1");
  GLADE_HOOKUP_OBJECT (dialog1, okbutton1, "okbutton1");

  return dialog1;
}

