/*
 * Initial main.c file generated by Glade. Edit as required.
 * Glade will not overwrite this file.
 */

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

#include <gnome.h>

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

/* Globals */
GtkWidget *window1;
GtkWidget *dlgAbout;
GtkWidget *dlgConfig;
GtkWidget *dlgSettings;

Options *options;
extern gboolean conf_changed;

int main (int argc, char *argv[])
{
#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);
#endif

  gnome_init ("gssh", VERSION, argc, argv);
  /* Load options */
  options=loadSettings(NULL);
  if(!options) {
    fprintf(stderr,"Warning ! Unable to load load configuration file ~/.gssh.xml !\n");
    fprintf(stderr,"Making a blank xml file...\n");
    if(saveSettings(NULL,NULL)) {
      fprintf(stderr,"Error creating a blank xml file !\n");
      exit(1);
    } else {
      fprintf(stderr,"Done. Starting up...\n");
      options=loadSettings(NULL);
      if(!options) {
        fprintf(stderr,"Error ! Couldn't load the configuration file that was just created !\n");
        exit(1);
      }
    }
  }
  conf_changed=0;
  atexit((void*)on_exit_app);
  /* Create and show main window */
  window1 = create_window1();
  gtk_widget_show(window1);
  /* Update combobox with the data loaded from the settings file */
  updateComboBox();
  /* Create configuration box */
  dlgConfig = create_window2();
  gtk_window_set_modal(GTK_WINDOW(dlgConfig),TRUE);
  /* Create host settings box */
  dlgSettings = create_window3();
  gtk_window_set_modal(GTK_WINDOW(dlgSettings),TRUE);
  gtk_main();
  return 0;
}

