/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <dirent.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  g_object_set_data_full (G_OBJECT (component), name, \
    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  g_object_set_data (G_OBJECT (component), name, widget)


#define DEVICEPATH   "/dev"
#define COMNAME      "ttyS"


void CheckTtyPort(GtkWidget *port);
void SetupUsbTty(GtkWidget *cbo_UsbTty);
void SetupTty(GtkWidget *cbo_Tty);


GtkWidget*
create_window1 (void)
{
  GtkWidget *window1;
  GtkWidget *alignment1;
  GtkWidget *vpaned1;
  GtkWidget *vbox1;
  GtkWidget *hbox12;
  GtkWidget *label21;
  GtkWidget *cbo_UsbTty;
  GtkWidget *frame1;
  GtkWidget *alignment2;
  GtkWidget *combobox1;
  GtkWidget *label20;
  GtkWidget *notebook1;
  GtkWidget *vbox2;
  GtkWidget *hbox2;
  GtkWidget *label5;
  GtkWidget *txt_FileName;
  GtkWidget *btn_WriteOpen;
  GtkWidget *hpaned1;
  GtkWidget *hbox3;
  GtkWidget *label6;
  GtkWidget *lbl_WriteStartTime;
  GtkWidget *hbox4;
  GtkWidget *label8;
  GtkWidget *lbl_WriteEndTime;
  GtkWidget *btn_Write;
  GtkWidget *hbox13;
  GtkWidget *label23;
  GtkWidget *txt_WriteSize;
  GtkWidget *WriteTab;
  GtkWidget *vbox3;
  GtkWidget *hbox5;
  GtkWidget *label10;
  GtkWidget *txt_ReadFile;
  GtkWidget *hpaned2;
  GtkWidget *hbox6;
  GtkWidget *label11;
  GtkWidget *lbl_ReadStartTime;
  GtkWidget *hbox7;
  GtkWidget *label13;
  GtkWidget *lbl_ReadEndTime;
  GtkWidget *bnt_Read;
  GtkWidget *hbox14;
  GtkWidget *label24;
  GtkWidget *txt_ReadSize;
  GtkWidget *ReadTab;
  GtkWidget *vbox4;
  GtkWidget *hbox8;
  GtkWidget *label15;
  GtkWidget *txt_WriteRead_Read;
  GtkWidget *hbox9;
  GtkWidget *label16;
  GtkWidget *txt_WriteRead_Write;
  GtkWidget *btn_WriteRead_WriteOpen;
  GtkWidget *hpaned3;
  GtkWidget *hbox10;
  GtkWidget *label17;
  GtkWidget *lbl_WriteRead_StartTime;
  GtkWidget *hbox11;
  GtkWidget *label19;
  GtkWidget *lbl_WriteRead_EndTime;
  GtkWidget *hpaned4;
  GtkWidget *btn_WriteRead;
  GtkWidget *hbox15;
  GtkWidget *label25;
  GtkWidget *txt_WriteRead_ReadSize;
  GtkWidget *WriteReadTab;
  GtkWidget *vbox5;
  GtkWidget *hbox16;
  GtkWidget *label27;
  GtkWidget *cbo_Parity;
  GtkWidget *hbox17;
  GtkWidget *label28;
  GtkWidget *cbo_StopBit;
  GtkWidget *hbox18;
  GtkWidget *label29;
  GtkWidget *cbo_DataBit;
  GtkWidget *label26;
	
  GtkTooltips *tooltips;
  
  
  tooltips = gtk_tooltips_new ();
  window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_set_name (window1, "window1");
  gtk_window_set_title (GTK_WINDOW (window1), _("Megawin USB2COM -- COM "));

	//------------------------------------------------------------//
	// set size
	gtk_window_set_default_size(GTK_WINDOW(window1), 550, 350);
  alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_set_name (alignment1, "alignment1");
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (window1), alignment1);

  vpaned1 = gtk_vpaned_new ();
  gtk_widget_set_name (vpaned1, "vpaned1");
  gtk_widget_show (vpaned1);
  gtk_container_add (GTK_CONTAINER (alignment1), vpaned1);
  gtk_container_set_border_width (GTK_CONTAINER (vpaned1), 10);
  gtk_paned_set_position (GTK_PANED (vpaned1), 125);

  vbox1 = gtk_vbox_new (TRUE, 0);
  gtk_widget_set_name (vbox1, "vbox1");
  gtk_widget_show (vbox1);
  gtk_paned_pack1 (GTK_PANED (vpaned1), vbox1, FALSE, TRUE);

  hbox12 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox12, "hbox12");
  gtk_widget_show (hbox12);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox12, TRUE, TRUE, 0);

  label21 = gtk_label_new (_("Line   "));
  gtk_widget_set_name (label21, "label21");
  gtk_widget_show (label21);
  gtk_box_pack_start (GTK_BOX (hbox12), label21, FALSE, FALSE, 0);

  cbo_UsbTty = gtk_combo_box_new_text ();
  gtk_widget_set_name (cbo_UsbTty, "cbo_UsbTty");
  gtk_widget_show (cbo_UsbTty);
  gtk_box_pack_start (GTK_BOX (hbox12), cbo_UsbTty, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (cbo_UsbTty), 10);
  //------------------------------//
 
  SetupTty(cbo_UsbTty);
  //-----------------------------//

  frame1 = gtk_frame_new (NULL);
  gtk_widget_set_name (frame1, "frame1");
  gtk_widget_show (frame1);
  gtk_box_pack_start (GTK_BOX (vbox1), frame1, TRUE, TRUE, 0);
  gtk_frame_set_shadow_type (GTK_FRAME (frame1), GTK_SHADOW_NONE);

  alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
  gtk_widget_set_name (alignment2, "alignment2");
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (frame1), alignment2);
  gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0);

  combobox1 = gtk_combo_box_new_text ();
  gtk_widget_set_name (combobox1, "combobox1");
  gtk_widget_show (combobox1);
  gtk_container_add (GTK_CONTAINER (alignment2), combobox1);
  gtk_container_set_border_width (GTK_CONTAINER (combobox1), 5);
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("1200"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("2400"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("4800"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("9600"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("19200"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("38400"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("57600"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (combobox1), _("115200"));
  //=--------------------------------------------------------------//
  gtk_tooltips_set_tip ( tooltips, combobox1, _("pick a baudrate"), NULL);
  gtk_combo_box_set_active (GTK_COMBO_BOX (combobox1), 3);
  //=--------------------------------------------------------------//
  label20 = gtk_label_new (_("<b>Baud Rate</b>"));
  gtk_widget_set_name (label20, "label20");
  gtk_widget_show (label20);
  gtk_frame_set_label_widget (GTK_FRAME (frame1), label20);
  gtk_label_set_use_markup (GTK_LABEL (label20), TRUE);

  notebook1 = gtk_notebook_new ();
  gtk_widget_set_name (notebook1, "notebook1");
  gtk_widget_show (notebook1);
  gtk_paned_pack2 (GTK_PANED (vpaned1), notebook1, TRUE, TRUE);
  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook1), GTK_POS_LEFT);

  vbox2 = gtk_vbox_new (TRUE, 0);
  gtk_widget_set_name (vbox2, "vbox2");
  gtk_widget_show (vbox2);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox2);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox2, "hbox2");
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

  label5 = gtk_label_new (_("File Name "));
  gtk_widget_set_name (label5, "label5");
  gtk_widget_show (label5);
  gtk_box_pack_start (GTK_BOX (hbox2), label5, FALSE, FALSE, 0);
  gtk_widget_set_size_request (label5, 88, 30);

  txt_FileName = gtk_entry_new ();
  gtk_widget_set_name (txt_FileName, "txt_FileName");
  gtk_widget_show (txt_FileName);
  gtk_box_pack_start (GTK_BOX (hbox2), txt_FileName, TRUE, TRUE, 0);
  gtk_widget_set_size_request (txt_FileName, 160, 30);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_FileName), 8226);

  btn_WriteOpen = gtk_button_new_with_mnemonic (_("Open"));
  gtk_widget_set_name (btn_WriteOpen, "btn_WriteOpen");
  gtk_widget_show (btn_WriteOpen);
  gtk_box_pack_start (GTK_BOX (hbox2), btn_WriteOpen, FALSE, FALSE, 0);

  hpaned1 = gtk_hpaned_new ();
  gtk_widget_set_name (hpaned1, "hpaned1");
  gtk_widget_show (hpaned1);
  gtk_box_pack_start (GTK_BOX (vbox2), hpaned1, TRUE, TRUE, 0);
  gtk_paned_set_position (GTK_PANED (hpaned1), 140);

  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox3, "hbox3");
  gtk_widget_show (hbox3);
  gtk_paned_pack1 (GTK_PANED (hpaned1), hbox3, FALSE, TRUE);

  label6 = gtk_label_new (_("Start Time: "));
  gtk_widget_set_name (label6, "label6");
  gtk_widget_show (label6);
  gtk_box_pack_start (GTK_BOX (hbox3), label6, FALSE, FALSE, 0);

  lbl_WriteStartTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_WriteStartTime, "lbl_WriteStartTime");
  gtk_widget_show (lbl_WriteStartTime);
  gtk_box_pack_start (GTK_BOX (hbox3), lbl_WriteStartTime, FALSE, FALSE, 0);

  hbox4 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox4, "hbox4");
  gtk_widget_show (hbox4);
  gtk_paned_pack2 (GTK_PANED (hpaned1), hbox4, TRUE, TRUE);

  label8 = gtk_label_new (_("End Time: "));
  gtk_widget_set_name (label8, "label8");
  gtk_widget_show (label8);
  gtk_box_pack_start (GTK_BOX (hbox4), label8, FALSE, FALSE, 0);

  lbl_WriteEndTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_WriteEndTime, "lbl_WriteEndTime");
  gtk_widget_show (lbl_WriteEndTime);
  gtk_box_pack_start (GTK_BOX (hbox4), lbl_WriteEndTime, FALSE, FALSE, 0);

  btn_Write = gtk_button_new_with_mnemonic (_("Write"));
  gtk_widget_set_name (btn_Write, "btn_Write");
  gtk_widget_show (btn_Write);
  gtk_box_pack_start (GTK_BOX (vbox2), btn_Write, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (btn_Write), 10);

  hbox13 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox13, "hbox13");
  gtk_widget_show (hbox13);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox13, FALSE, FALSE, 0);

  label23 = gtk_label_new (_("File Size: "));
  gtk_widget_set_name (label23, "label23");
  gtk_widget_show (label23);
  gtk_box_pack_start (GTK_BOX (hbox13), label23, FALSE, FALSE, 0);

  txt_WriteSize = gtk_entry_new ();
  gtk_widget_set_name (txt_WriteSize, "txt_WriteSize");
  gtk_widget_show (txt_WriteSize);
  gtk_box_pack_start (GTK_BOX (hbox13), txt_WriteSize, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_WriteSize), 8226);

  WriteTab = gtk_label_new (_("Write"));
  gtk_widget_set_name (WriteTab, "WriteTab");
  gtk_widget_show (WriteTab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), WriteTab);
  gtk_widget_set_size_request (WriteTab, 50, -1);

  vbox3 = gtk_vbox_new (TRUE, 0);
  gtk_widget_set_name (vbox3, "vbox3");
  gtk_widget_show (vbox3);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox3);

  hbox5 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox5, "hbox5");
  gtk_widget_show (hbox5);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox5, TRUE, TRUE, 0);

  label10 = gtk_label_new (_("File Name: "));
  gtk_widget_set_name (label10, "label10");
  gtk_widget_show (label10);
  gtk_box_pack_start (GTK_BOX (hbox5), label10, FALSE, FALSE, 0);
  gtk_widget_set_size_request (label10, 88, 30);
  gtk_label_set_single_line_mode (GTK_LABEL (label10), TRUE);

  txt_ReadFile = gtk_entry_new ();
  gtk_widget_set_name (txt_ReadFile, "txt_ReadFile");
  gtk_widget_show (txt_ReadFile);
  gtk_box_pack_start (GTK_BOX (hbox5), txt_ReadFile, TRUE, TRUE, 0);
  gtk_widget_set_size_request (txt_ReadFile, 100, 30);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_ReadFile), 8226);

  hpaned2 = gtk_hpaned_new ();
  gtk_widget_set_name (hpaned2, "hpaned2");
  gtk_widget_show (hpaned2);
  gtk_box_pack_start (GTK_BOX (vbox3), hpaned2, FALSE, FALSE, 0);
  gtk_paned_set_position (GTK_PANED (hpaned2), 140);

  hbox6 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox6, "hbox6");
  gtk_widget_show (hbox6);
  gtk_paned_pack1 (GTK_PANED (hpaned2), hbox6, FALSE, TRUE);

  label11 = gtk_label_new (_("Start Time: "));
  gtk_widget_set_name (label11, "label11");
  gtk_widget_show (label11);
  gtk_box_pack_start (GTK_BOX (hbox6), label11, FALSE, FALSE, 0);
  gtk_widget_set_size_request (label11, -1, 18);

  lbl_ReadStartTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_ReadStartTime, "lbl_ReadStartTime");
  gtk_widget_show (lbl_ReadStartTime);
  gtk_box_pack_start (GTK_BOX (hbox6), lbl_ReadStartTime, FALSE, FALSE, 0);

  hbox7 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox7, "hbox7");
  gtk_widget_show (hbox7);
  gtk_paned_pack2 (GTK_PANED (hpaned2), hbox7, TRUE, TRUE);

  label13 = gtk_label_new (_("End Time: "));
  gtk_widget_set_name (label13, "label13");
  gtk_widget_show (label13);
  gtk_box_pack_start (GTK_BOX (hbox7), label13, FALSE, FALSE, 0);

  lbl_ReadEndTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_ReadEndTime, "lbl_ReadEndTime");
  gtk_widget_show (lbl_ReadEndTime);
  gtk_box_pack_start (GTK_BOX (hbox7), lbl_ReadEndTime, FALSE, FALSE, 0);

  bnt_Read = gtk_button_new_with_mnemonic (_("Read"));
  gtk_widget_set_name (bnt_Read, "bnt_Read");
  gtk_widget_show (bnt_Read);
  gtk_box_pack_start (GTK_BOX (vbox3), bnt_Read, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (bnt_Read), 10);

  hbox14 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox14, "hbox14");
  gtk_widget_show (hbox14);
  gtk_box_pack_start (GTK_BOX (vbox3), hbox14, TRUE, TRUE, 0);

  label24 = gtk_label_new (_("File Size: "));
  gtk_widget_set_name (label24, "label24");
  gtk_widget_show (label24);
  gtk_box_pack_start (GTK_BOX (hbox14), label24, FALSE, FALSE, 0);

  txt_ReadSize = gtk_entry_new ();
  gtk_widget_set_name (txt_ReadSize, "txt_ReadSize");
  gtk_widget_show (txt_ReadSize);
  gtk_box_pack_start (GTK_BOX (hbox14), txt_ReadSize, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_ReadSize), 8226);

  ReadTab = gtk_label_new (_("Read"));
  gtk_widget_set_name (ReadTab, "ReadTab");
  gtk_widget_show (ReadTab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), ReadTab);
  gtk_widget_set_size_request (ReadTab, 30, -1);

  vbox4 = gtk_vbox_new (TRUE, 0);
  gtk_widget_set_name (vbox4, "vbox4");
  gtk_widget_show (vbox4);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox4);

  hbox8 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox8, "hbox8");
  gtk_widget_show (hbox8);
  gtk_box_pack_start (GTK_BOX (vbox4), hbox8, TRUE, TRUE, 0);

  label15 = gtk_label_new (_("Read File Name: "));
  gtk_widget_set_name (label15, "label15");
  gtk_widget_show (label15);
  gtk_box_pack_start (GTK_BOX (hbox8), label15, FALSE, FALSE, 0);

  txt_WriteRead_Read = gtk_entry_new ();
  gtk_widget_set_name (txt_WriteRead_Read, "txt_WriteRead_Read");
  gtk_widget_show (txt_WriteRead_Read);
  gtk_box_pack_start (GTK_BOX (hbox8), txt_WriteRead_Read, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_WriteRead_Read), 8226);

  hbox9 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox9, "hbox9");
  gtk_widget_show (hbox9);
  gtk_box_pack_start (GTK_BOX (vbox4), hbox9, TRUE, TRUE, 0);

  label16 = gtk_label_new (_("Write File Name: "));
  gtk_widget_set_name (label16, "label16");
  gtk_widget_show (label16);
  gtk_box_pack_start (GTK_BOX (hbox9), label16, FALSE, FALSE, 0);

  txt_WriteRead_Write = gtk_entry_new ();
  gtk_widget_set_name (txt_WriteRead_Write, "txt_WriteRead_Write");
  gtk_widget_show (txt_WriteRead_Write);
  gtk_box_pack_start (GTK_BOX (hbox9), txt_WriteRead_Write, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_WriteRead_Write), 8226);

  btn_WriteRead_WriteOpen = gtk_button_new_with_mnemonic (_("Open"));
  gtk_widget_set_name (btn_WriteRead_WriteOpen, "btn_WriteRead_WriteOpen");
  gtk_widget_show (btn_WriteRead_WriteOpen);
  gtk_box_pack_start (GTK_BOX (hbox9), btn_WriteRead_WriteOpen, FALSE, FALSE, 0);

  hpaned3 = gtk_hpaned_new ();
  gtk_widget_set_name (hpaned3, "hpaned3");
  gtk_widget_show (hpaned3);
  gtk_box_pack_start (GTK_BOX (vbox4), hpaned3, TRUE, TRUE, 0);
  gtk_paned_set_position (GTK_PANED (hpaned3), 140);

  hbox10 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox10, "hbox10");
  gtk_widget_show (hbox10);
  gtk_paned_pack1 (GTK_PANED (hpaned3), hbox10, FALSE, TRUE);

  label17 = gtk_label_new (_("Start Time: "));
  gtk_widget_set_name (label17, "label17");
  gtk_widget_show (label17);
  gtk_box_pack_start (GTK_BOX (hbox10), label17, FALSE, FALSE, 0);

  lbl_WriteRead_StartTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_WriteRead_StartTime, "lbl_WriteRead_StartTime");
  gtk_widget_show (lbl_WriteRead_StartTime);
  gtk_box_pack_start (GTK_BOX (hbox10), lbl_WriteRead_StartTime, FALSE, FALSE, 0);

  hbox11 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox11, "hbox11");
  gtk_widget_show (hbox11);
  gtk_paned_pack2 (GTK_PANED (hpaned3), hbox11, TRUE, TRUE);

  label19 = gtk_label_new (_("End Time: "));
  gtk_widget_set_name (label19, "label19");
  gtk_widget_show (label19);
  gtk_box_pack_start (GTK_BOX (hbox11), label19, FALSE, FALSE, 0);

  lbl_WriteRead_EndTime = gtk_label_new (_("0"));
  gtk_widget_set_name (lbl_WriteRead_EndTime, "lbl_WriteRead_EndTime");
  gtk_widget_show (lbl_WriteRead_EndTime);
  gtk_box_pack_start (GTK_BOX (hbox11), lbl_WriteRead_EndTime, FALSE, FALSE, 0);

  hpaned4 = gtk_hpaned_new ();
  gtk_widget_set_name (hpaned4, "hpaned4");
  gtk_widget_show (hpaned4);
  gtk_box_pack_start (GTK_BOX (vbox4), hpaned4, FALSE, FALSE, 0);
  gtk_paned_set_position (GTK_PANED (hpaned4), 315);

  btn_WriteRead = gtk_button_new_with_mnemonic (_("Write / Read"));
  gtk_widget_set_name (btn_WriteRead, "btn_WriteRead");
  gtk_widget_show (btn_WriteRead);
  gtk_paned_pack1 (GTK_PANED (hpaned4), btn_WriteRead, FALSE, TRUE);
  gtk_container_set_border_width (GTK_CONTAINER (btn_WriteRead), 10);
  
  
  hbox15 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox15, "hbox15");
  gtk_widget_show (hbox15);
  gtk_box_pack_start (GTK_BOX (vbox4), hbox15, TRUE, TRUE, 0);

  label25 = gtk_label_new (_("file size: "));
  gtk_widget_set_name (label25, "label25");
  gtk_widget_show (label25);
  gtk_box_pack_start (GTK_BOX (hbox15), label25, FALSE, FALSE, 0);

  txt_WriteRead_ReadSize = gtk_entry_new ();
  gtk_widget_set_name (txt_WriteRead_ReadSize, "txt_WriteRead_ReadSize");
  gtk_widget_show (txt_WriteRead_ReadSize);
  gtk_box_pack_start (GTK_BOX (hbox15), txt_WriteRead_ReadSize, TRUE, TRUE, 0);
  gtk_entry_set_invisible_char (GTK_ENTRY (txt_WriteRead_ReadSize), 8226);

  WriteReadTab = gtk_label_new (_("Write / Read "));
  gtk_widget_set_name (WriteReadTab, "WriteReadTab");
  gtk_widget_show (WriteReadTab);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 2), WriteReadTab);
 
	
  vbox5 = gtk_vbox_new (FALSE, 0);
  gtk_widget_set_name (vbox5, "vbox5");
  gtk_widget_show (vbox5);
  gtk_container_add (GTK_CONTAINER (notebook1), vbox5);

  hbox16 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox16, "hbox16");
  gtk_widget_show (hbox16);
  gtk_box_pack_start (GTK_BOX (vbox5), hbox16, TRUE, TRUE, 0);

  label27 = gtk_label_new (_("Parity     :  "));
  gtk_widget_set_name (label27, "label27");
  gtk_widget_show (label27);
  gtk_box_pack_start (GTK_BOX (hbox16), label27, FALSE, FALSE, 0);

  cbo_Parity = gtk_combo_box_entry_new_text ();
  gtk_widget_set_name (cbo_Parity, "cbo_Parity");
  gtk_widget_show (cbo_Parity);
  gtk_box_pack_start (GTK_BOX (hbox16), cbo_Parity, TRUE, TRUE, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_Parity), _("None"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_Parity), _("Odd"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_Parity), _("Even"));
 //----------------------------------------------------------//
  gtk_combo_box_set_active (GTK_COMBO_BOX (cbo_Parity), 0);

  hbox17 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox17, "hbox17");
  gtk_widget_show (hbox17);
  gtk_box_pack_start (GTK_BOX (vbox5), hbox17, TRUE, TRUE, 0);

  label28 = gtk_label_new (_("Stop Bits : "));
  gtk_widget_set_name (label28, "label28");
  gtk_widget_show (label28);
  gtk_box_pack_start (GTK_BOX (hbox17), label28, FALSE, FALSE, 0);

  cbo_StopBit = gtk_combo_box_entry_new_text ();
  gtk_widget_set_name (cbo_StopBit, "cbo_StopBit");
  gtk_widget_show (cbo_StopBit);
  gtk_box_pack_start (GTK_BOX (hbox17), cbo_StopBit, TRUE, TRUE, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_StopBit), _("1"));
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_StopBit), _("2"));
	//----------------------------------------------------------//
  gtk_combo_box_set_active (GTK_COMBO_BOX (cbo_StopBit), 0);

  hbox18 = gtk_hbox_new (FALSE, 0);
  gtk_widget_set_name (hbox18, "hbox18");
  gtk_widget_show (hbox18);
  gtk_box_pack_start (GTK_BOX (vbox5), hbox18, TRUE, TRUE, 0);

  label29 = gtk_label_new (_("Data Bits : "));
  gtk_widget_set_name (label29, "label29");
  gtk_widget_show (label29);
  gtk_box_pack_start (GTK_BOX (hbox18), label29, FALSE, FALSE, 0);

  cbo_DataBit = gtk_combo_box_entry_new_text ();
  gtk_widget_set_name (cbo_DataBit, "cbo_DataBit");
  gtk_widget_show (cbo_DataBit);
  gtk_box_pack_start (GTK_BOX (hbox18), cbo_DataBit, TRUE, TRUE, 0);
  gtk_combo_box_append_text (GTK_COMBO_BOX (cbo_DataBit), _("8"));
	//----------------------------------------------------------//
  gtk_combo_box_set_active (GTK_COMBO_BOX (cbo_DataBit), 0);

  label26 = gtk_label_new (_("Setting"));
  gtk_widget_set_name (label26, "label26");
  gtk_widget_show (label26);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 3), label26);

  g_signal_connect ((gpointer) window1, "destroy",
                    G_CALLBACK (on_window1_destroy),
                    NULL);
  g_signal_connect ((gpointer) cbo_UsbTty, "changed",
                    G_CALLBACK (on_cbo_UsbTty_changed),
                    NULL);
  g_signal_connect ((gpointer) combobox1, "changed",
                    G_CALLBACK (on_combobox1_changed),
                    NULL);
  g_signal_connect ((gpointer) notebook1, "switch_page",
                    G_CALLBACK (on_notebook1_switch_page),
                    NULL);
  
  g_signal_connect ((gpointer) btn_Write, "clicked",
                    G_CALLBACK (on_btn_Write_clicked),
                    NULL);
  g_signal_connect ((gpointer) txt_WriteSize, "changed",
                    G_CALLBACK (on_txt_WriteSize_changed),
                    NULL);
  g_signal_connect ((gpointer) bnt_Read, "clicked",
                    G_CALLBACK (on_bnt_Read_clicked),
                    NULL);
  g_signal_connect ((gpointer) txt_ReadSize, "changed",
                    G_CALLBACK (on_txt_ReadSize_changed),
                    NULL);
  
  g_signal_connect ((gpointer) btn_WriteRead, "clicked",
                    G_CALLBACK (on_btn_WriteRead_clicked),
                    NULL);
  //-----------------------------------------------------//
 
  g_signal_connect ((gpointer) btn_WriteOpen, "clicked",
					 G_CALLBACK (on_btn_WriteOpen_clicked),
								 (gpointer)window1);
  
  g_signal_connect ((gpointer) btn_WriteRead_WriteOpen, "clicked",
					 G_CALLBACK (on_btn_WriteRead_WriteOpen_clicked),
								 (gpointer)window1);
	
  g_signal_connect ((gpointer) cbo_Parity, "changed",
                    G_CALLBACK (on_cbo_Parity_changed),
                    NULL);
  g_signal_connect ((gpointer) cbo_StopBit, "changed",
                    G_CALLBACK (on_cbo_StopBit_changed),
                    NULL);
  g_signal_connect ((gpointer) cbo_DataBit, "changed",
                    G_CALLBACK (on_cbo_DataBit_changed),
                    NULL);
  //-----------------------------------------------------//
  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (window1, window1, "window1");
  GLADE_HOOKUP_OBJECT (window1, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (window1, vpaned1, "vpaned1");
  GLADE_HOOKUP_OBJECT (window1, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (window1, hbox12, "hbox12");
  GLADE_HOOKUP_OBJECT (window1, label21, "label21");
  GLADE_HOOKUP_OBJECT (window1, cbo_UsbTty, "cbo_UsbTty");
  GLADE_HOOKUP_OBJECT (window1, frame1, "frame1");
  GLADE_HOOKUP_OBJECT (window1, alignment2, "alignment2");
  GLADE_HOOKUP_OBJECT (window1, combobox1, "combobox1");
  GLADE_HOOKUP_OBJECT (window1, label20, "label20");
  GLADE_HOOKUP_OBJECT (window1, notebook1, "notebook1");
  GLADE_HOOKUP_OBJECT (window1, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (window1, hbox2, "hbox2");
  GLADE_HOOKUP_OBJECT (window1, label5, "label5");
  GLADE_HOOKUP_OBJECT (window1, txt_FileName, "txt_FileName");
  GLADE_HOOKUP_OBJECT (window1, btn_WriteOpen, "btn_WriteOpen");
  GLADE_HOOKUP_OBJECT (window1, hpaned1, "hpaned1");
  GLADE_HOOKUP_OBJECT (window1, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (window1, label6, "label6");
  GLADE_HOOKUP_OBJECT (window1, lbl_WriteStartTime, "lbl_WriteStartTime");
  GLADE_HOOKUP_OBJECT (window1, hbox4, "hbox4");
  GLADE_HOOKUP_OBJECT (window1, label8, "label8");
  GLADE_HOOKUP_OBJECT (window1, lbl_WriteEndTime, "lbl_WriteEndTime");
  GLADE_HOOKUP_OBJECT (window1, btn_Write, "btn_Write");
  GLADE_HOOKUP_OBJECT (window1, hbox13, "hbox13");
  GLADE_HOOKUP_OBJECT (window1, label23, "label23");
  GLADE_HOOKUP_OBJECT (window1, txt_WriteSize, "txt_WriteSize");
  GLADE_HOOKUP_OBJECT (window1, WriteTab, "WriteTab");
  GLADE_HOOKUP_OBJECT (window1, vbox3, "vbox3");
  GLADE_HOOKUP_OBJECT (window1, hbox5, "hbox5");
  GLADE_HOOKUP_OBJECT (window1, label10, "label10");
  GLADE_HOOKUP_OBJECT (window1, txt_ReadFile, "txt_ReadFile");
  GLADE_HOOKUP_OBJECT (window1, hpaned2, "hpaned2");
  GLADE_HOOKUP_OBJECT (window1, hbox6, "hbox6");
  GLADE_HOOKUP_OBJECT (window1, label11, "label11");
  GLADE_HOOKUP_OBJECT (window1, lbl_ReadStartTime, "lbl_ReadStartTime");
  GLADE_HOOKUP_OBJECT (window1, hbox7, "hbox7");
  GLADE_HOOKUP_OBJECT (window1, label13, "label13");
  GLADE_HOOKUP_OBJECT (window1, lbl_ReadEndTime, "lbl_ReadEndTime");
  GLADE_HOOKUP_OBJECT (window1, bnt_Read, "bnt_Read");
  GLADE_HOOKUP_OBJECT (window1, hbox14, "hbox14");
  GLADE_HOOKUP_OBJECT (window1, label24, "label24");
  GLADE_HOOKUP_OBJECT (window1, txt_ReadSize, "txt_ReadSize");
  GLADE_HOOKUP_OBJECT (window1, ReadTab, "ReadTab");
  GLADE_HOOKUP_OBJECT (window1, vbox4, "vbox4");
  GLADE_HOOKUP_OBJECT (window1, hbox8, "hbox8");
  GLADE_HOOKUP_OBJECT (window1, label15, "label15");
  GLADE_HOOKUP_OBJECT (window1, txt_WriteRead_Read, "txt_WriteRead_Read");
  GLADE_HOOKUP_OBJECT (window1, hbox9, "hbox9");
  GLADE_HOOKUP_OBJECT (window1, label16, "label16");
  GLADE_HOOKUP_OBJECT (window1, txt_WriteRead_Write, "txt_WriteRead_Write");
  GLADE_HOOKUP_OBJECT (window1, btn_WriteRead_WriteOpen, "btn_WriteRead_WriteOpen");
  GLADE_HOOKUP_OBJECT (window1, hpaned3, "hpaned3");
  GLADE_HOOKUP_OBJECT (window1, hbox10, "hbox10");
  GLADE_HOOKUP_OBJECT (window1, label17, "label17");
  GLADE_HOOKUP_OBJECT (window1, lbl_WriteRead_StartTime, "lbl_WriteRead_StartTime");
  GLADE_HOOKUP_OBJECT (window1, hbox11, "hbox11");
  GLADE_HOOKUP_OBJECT (window1, label19, "label19");
  GLADE_HOOKUP_OBJECT (window1, lbl_WriteRead_EndTime, "lbl_WriteRead_EndTime");
  GLADE_HOOKUP_OBJECT (window1, hpaned4, "hpaned4");
  GLADE_HOOKUP_OBJECT (window1, btn_WriteRead, "btn_WriteRead");
  GLADE_HOOKUP_OBJECT (window1, hbox15, "hbox15");
  GLADE_HOOKUP_OBJECT (window1, label25, "label25");
  GLADE_HOOKUP_OBJECT (window1, txt_WriteRead_ReadSize, "txt_WriteRead_ReadSize");
  GLADE_HOOKUP_OBJECT (window1, WriteReadTab, "WriteReadTab");
  GLADE_HOOKUP_OBJECT (window1, vbox5, "vbox5");
  GLADE_HOOKUP_OBJECT (window1, hbox16, "hbox16");
  GLADE_HOOKUP_OBJECT (window1, label27, "label27");
  GLADE_HOOKUP_OBJECT (window1, cbo_Parity, "cbo_Parity");
  GLADE_HOOKUP_OBJECT (window1, hbox17, "hbox17");
  GLADE_HOOKUP_OBJECT (window1, label28, "label28");
  GLADE_HOOKUP_OBJECT (window1, cbo_StopBit, "cbo_StopBit");
  GLADE_HOOKUP_OBJECT (window1, hbox18, "hbox18");
  GLADE_HOOKUP_OBJECT (window1, label29, "label29");
  GLADE_HOOKUP_OBJECT (window1, cbo_DataBit, "cbo_DataBit");
  GLADE_HOOKUP_OBJECT (window1, label26, "label26");


  return window1;
}

void SetupUsbTty(GtkWidget *cbo_UsbTty)
{
	
	CheckTtyPort(cbo_UsbTty);
	//gtk_combo_box_set_active(GTK_COMBO_BOX (cbo_UsbTty), 0);
	
}

void SetupTty(GtkWidget *cbo_Tty)
{
		
	CheckTtyPort(cbo_Tty);
	//gtk_combo_box_set_active(GTK_COMBO_BOX (cbo_Tty), 0);
}


void CheckTtyPort(GtkWidget *port)
{
	
	int i;
	DIR * dp;
	struct dirent *filename;
	gchar tmpName[6];
	
	gchar out[256];
	
	dp = opendir(DEVICEPATH);
	if (!dp)
	{
		
		sprintf(out,"not able to open %s direcotry to check ttyS# port !", DEVICEPATH);
		MessageBox(out);
		
		
		//fprintf(stderr,"open directory error\n");
		return 0;
	}
	while (filename=readdir(dp)) // read file name
	{		
		// is it ttyS#
		if ( 0 == strncmp( filename->d_name,
			 COMNAME,
	4 )){
		
		gtk_combo_box_append_text (GTK_COMBO_BOX (port), filename->d_name);
			
							
	}// if
	}
		
}

void MessageBox(gchar *message)
{
	GtkWidget *dialog, *dg_label, *dg_OK;
	
	dialog = gtk_dialog_new();
	dg_label = gtk_label_new (message);
	dg_OK = gtk_button_new_with_label("OK");
	gtk_signal_connect_object(GTK_OBJECT (dg_OK), "clicked", gtk_widget_destroy, GTK_OBJECT(dialog));
	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area), dg_OK);
	gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox), dg_label);
	gtk_widget_show_all (dialog);
	gtk_widget_grab_focus(dialog);

	
}


