/*
 * 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 <gtk/gtk.h>

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

extern  GtkWidget *window, *notebook;
extern  GtkWidget *username_entry, *register_username_entry;
extern  GtkWidget *register_password_confirm_entry;
extern  GtkWidget *nick_availability_entry;
char *userdefined_nickname;
extern GtkWidget *register_username_entry;
extern GtkWidget *page4_connect_button;
extern GtkWidget *page1_connect_button;

int
main (int argc, char *argv[])
{

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

  gtk_set_locale ();
  gtk_init (&argc, &argv);

  add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */

  if (argv[1] == 0)
	{
	g_print("This program cannot be run by itself\n");
	g_print("Please run 'ubuntu-live-support' instead\n");
	gtk_main_quit();
	return 1;
	} 

  if (argv[2] == 0)
	{
	g_print("This program cannot be run by itself\n");
	g_print("Please run 'ubuntu-live-support' instead\n");
	gtk_main_quit();
	return 1;
	} 

  if (argv[3] == 0)
	{
	g_print("This program cannot be run by itself\n");
	g_print("Please run 'ubuntu-live-support' instead\n");
	gtk_main_quit();
	return 1;
	} 

  else

	{
  	window = create_window ();
  	gtk_widget_show (window);
	gtk_widget_set_sensitive (page1_connect_button, FALSE);
	gtk_widget_set_sensitive (page4_connect_button, FALSE);
	gtk_widget_set_sensitive (register_username_entry, FALSE);
  	gtk_entry_set_text(GTK_ENTRY (username_entry), argv[1]);
	gtk_entry_set_text(GTK_ENTRY (nick_availability_entry), argv[2]);
	if (!strcmp(argv[3],"register")) {
	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 4);
	}
	if (!strcmp(argv[3],"login")) {
	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
	}
	if (!strcmp(argv[3],"main")) {
	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
	}
	if (!strcmp(argv[3],"check")) {
	gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 3);
	}
	userdefined_nickname = gtk_entry_get_text(GTK_ENTRY(nick_availability_entry));
  	gtk_entry_set_text(GTK_ENTRY (register_username_entry), userdefined_nickname);

  	gtk_main ();

  	return 0;
	}

}

