// generated by Fast Light User Interface Designer (fluid) version 1.0404

#include "gpio_conf.h"
#include "gettext.h"
#ifndef gettext_noop
#  define gettext_noop(text) text
#endif
#include "configuration.h"
#include "rigsupport.h"
#include "fl_digi.h"
#include <stdlib.h>

Fl_Button *btn_close_GPIO_config=(Fl_Button *)0;

static void cb_btn_close_GPIO_config(Fl_Button*, void*) {
  dlgGPIO_config->hide();
  progdefaults.changed = true;
}

Fl_Int_Input *gpio_ptt_line=(Fl_Int_Input *)0;

static void cb_gpio_ptt_line(Fl_Int_Input* o, void*) {
  progdefaults.gpio_ptt_line = atoi(o->value());
  progdefaults.enable_gpio_ptt = false;
  btn_enable_gpio_ptt->value(0);
  progdefaults.changed = true;
}

Fl_Check_Button *btn_enable_gpio_ptt=(Fl_Check_Button *)0;

static void cb_btn_enable_gpio_ptt(Fl_Check_Button* o, void*) {
  progdefaults.enable_gpio_ptt = o->value();
  progdefaults.changed = true;
}

Fl_Input *gpio_ptt_dev=(Fl_Input *)0;

static void cb_gpio_ptt_dev(Fl_Input* o, void*) {
  progdefaults.gpio_ptt_device = o->value();
  progdefaults.enable_gpio_ptt = false;
  btn_enable_gpio_ptt->value(0);
  progdefaults.changed = true;
}

Fl_Button *btn_select_gpio_ptt=(Fl_Button *)0;

static void cb_btn_select_gpio_ptt(Fl_Button*, void*) {
  Fl_Native_File_Chooser fnfc;
  fnfc.title("Select GPIO PTT device");
  fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
  fnfc.filter("GPIO devices\t*gpio*\n");
  fnfc.directory("/dev");           // default directory to use
  // Show native chooser
  switch ( fnfc.show() ) {
    case -1: break; // ERROR
    case  1: break; // CANCEL
    default: {
      gpio_ptt_dev->value(fnfc.filename());
      progdefaults.enable_gpio_ptt = false;
      btn_enable_gpio_ptt->value(0);
      break; // FILE CHOSEN
    }
  }
}

Fl_Check_Button *btn_enable_gpio_cw=(Fl_Check_Button *)0;

static void cb_btn_enable_gpio_cw(Fl_Check_Button* o, void*) {
  progdefaults.enable_gpio_cw = o->value();
  progdefaults.changed = true;
}

Fl_Int_Input *gpio_cw_line=(Fl_Int_Input *)0;

static void cb_gpio_cw_line(Fl_Int_Input* o, void*) {
  progdefaults.gpio_cw_line = atoi(o->value());
  progdefaults.enable_gpio_cw = false;
  btn_enable_gpio_cw->value(0);
  progdefaults.changed = true;
}

Fl_Input *gpio_cw_dev=(Fl_Input *)0;

static void cb_gpio_cw_dev(Fl_Input* o, void*) {
  progdefaults.gpio_cw_device = o->value();
  progdefaults.enable_gpio_cw = false;
  btn_enable_gpio_cw->value(0);
  progdefaults.changed = true;
}

Fl_Button *btn_select_gpio_cw=(Fl_Button *)0;

static void cb_btn_select_gpio_cw(Fl_Button*, void*) {
  Fl_Native_File_Chooser fnfc;
  fnfc.title("Select GPIO CW device");
  fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
  fnfc.filter("GPIO devices\t*gpio*\n");
  fnfc.directory("/dev");           // default directory to use
  // Show native chooser
  switch ( fnfc.show() ) {
    case -1: break; // ERROR
    case  1: break; // CANCEL
    default: {
      gpio_cw_dev->value(fnfc.filename());
      progdefaults.enable_gpio_ptt = false;
      btn_enable_gpio_cw->value(0);
      break; // FILE CHOSEN
    }
  }
}

Fl_Double_Window* make_gpio_conf_dialog() {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(324, 242, gettext("Configure GPIO"));
    w = o; (void)w;
    { btn_close_GPIO_config = new Fl_Button(230, 214, 80, 24, gettext("Close"));
      btn_close_GPIO_config->tooltip(gettext("Initialize the H/W PTT interface"));
      btn_close_GPIO_config->callback((Fl_Callback*)cb_btn_close_GPIO_config);
    } // Fl_Button* btn_close_GPIO_config
    { Fl_Group* o = new Fl_Group(2, 5, 320, 100);
      o->box(FL_ENGRAVED_BOX);
      { Fl_Int_Input* o = gpio_ptt_line = new Fl_Int_Input(78, 69, 92, 22, gettext("On Line"));
        gpio_ptt_line->tooltip(gettext("Enter GPIO line for PTT"));
        gpio_ptt_line->type(2);
        gpio_ptt_line->callback((Fl_Callback*)cb_gpio_ptt_line);
        static char linenbr[20];
        snprintf(linenbr, sizeof(linenbr), "%d", progdefaults.gpio_ptt_line);
        o->value(linenbr);
      } // Fl_Int_Input* gpio_ptt_line
      { Fl_Check_Button* o = btn_enable_gpio_ptt = new Fl_Check_Button(174, 69, 135, 22, gettext("Enable GPIO PTT"));
        btn_enable_gpio_ptt->tooltip(gettext("Set device & line, then enable"));
        btn_enable_gpio_ptt->down_box(FL_DOWN_BOX);
        btn_enable_gpio_ptt->callback((Fl_Callback*)cb_btn_enable_gpio_ptt);
        o->value(progdefaults.enable_gpio_ptt);
      } // Fl_Check_Button* btn_enable_gpio_ptt
      { Fl_Input* o = gpio_ptt_dev = new Fl_Input(5, 35, 240, 24, gettext("GPIO PTT device"));
        gpio_ptt_dev->tooltip(gettext("Select PTT device file"));
        gpio_ptt_dev->callback((Fl_Callback*)cb_gpio_ptt_dev);
        gpio_ptt_dev->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        o->value(progdefaults.gpio_ptt_device.c_str());
      } // Fl_Input* gpio_ptt_dev
      { btn_select_gpio_ptt = new Fl_Button(253, 35, 60, 24, gettext("Select"));
        btn_select_gpio_ptt->callback((Fl_Callback*)cb_btn_select_gpio_ptt);
      } // Fl_Button* btn_select_gpio_ptt
      o->end();
    } // Fl_Group* o
    { Fl_Group* o = new Fl_Group(2, 105, 322, 100);
      o->box(FL_ENGRAVED_BOX);
      { Fl_Check_Button* o = btn_enable_gpio_cw = new Fl_Check_Button(174, 171, 135, 22, gettext("Enable GPIO CW"));
        btn_enable_gpio_cw->tooltip(gettext("Set device & line, then enable"));
        btn_enable_gpio_cw->down_box(FL_DOWN_BOX);
        btn_enable_gpio_cw->callback((Fl_Callback*)cb_btn_enable_gpio_cw);
        o->value(progdefaults.enable_gpio_cw);
      } // Fl_Check_Button* btn_enable_gpio_cw
      { Fl_Int_Input* o = gpio_cw_line = new Fl_Int_Input(78, 171, 92, 22, gettext("On Line"));
        gpio_cw_line->tooltip(gettext("Enter GPIO line for CW"));
        gpio_cw_line->type(2);
        gpio_cw_line->callback((Fl_Callback*)cb_gpio_cw_line);
        static char linenbr[20];
        snprintf(linenbr, sizeof(linenbr), "%d", progdefaults.gpio_cw_line);
        o->value(linenbr);
      } // Fl_Int_Input* gpio_cw_line
      { Fl_Input* o = gpio_cw_dev = new Fl_Input(6, 130, 240, 24, gettext("GPIO CW device"));
        gpio_cw_dev->tooltip(gettext("Select PTT device file"));
        gpio_cw_dev->callback((Fl_Callback*)cb_gpio_cw_dev);
        gpio_cw_dev->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        o->value(progdefaults.gpio_cw_device.c_str());
      } // Fl_Input* gpio_cw_dev
      { btn_select_gpio_cw = new Fl_Button(253, 130, 60, 24, gettext("Select"));
        btn_select_gpio_cw->callback((Fl_Callback*)cb_btn_select_gpio_cw);
      } // Fl_Button* btn_select_gpio_cw
      o->end();
    } // Fl_Group* o
    o->end();
  } // Fl_Double_Window* o
  return w;
}
