/* Generated by GOB (v0.93.3) on Sat May 20 15:34:30 2000
   (do not edit directly) */

#define GOB_VERSION_MAJOR 0
#define GOB_VERSION_MINOR 93
#define GOB_VERSION_PATCHLEVEL 3

#include "balsa-druid-page-user.h"


#line 30 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"

#include <sys/types.h>
#include <sys/stat.h>

#include "balsa-druid-page-error.h"
#include "balsa-app.h"

#line 20 "balsa-druid-page-user.c"
/* self casting macros */
#define SELF(x) BALSA_DRUID_PAGE_USER(x)
#define IS_SELF(x) BALSA_IS_DRUID_PAGE_USER(x)
#define SELF_CLASS(x) BALSA_DRUID_PAGE_USER_CLASS(x)

struct _BalsaDruidPageUserPrivate {
#line 39 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	GtkWidget *name;
#line 40 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	GtkWidget *email;
#line 41 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	GtkWidget *smtp;
#line 42 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	GtkWidget *localmaildir;
#line 43 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	EntryMaster emaster;
#line 45 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	EntryData ed0;
#line 46 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	EntryData ed1;
#line 47 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	EntryData ed2;
#line 48 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	EntryData ed3;
#line 45 "balsa-druid-page-user.c"
};
/* here are local prototypes */
static void balsa_druid_page_user_class_init (BalsaDruidPageUserClass *c) G_GNUC_UNUSED;
static void balsa_druid_page_user_init (BalsaDruidPageUser *self) G_GNUC_UNUSED;
static void balsa_druid_page_user_construct (BalsaDruidPage *self) G_GNUC_UNUSED;
static void balsa_druid_page_user_prepare (GnomeDruidPage *_self, GtkWidget *druid) G_GNUC_UNUSED;
static gboolean balsa_druid_page_user_next (GnomeDruidPage *_self, GtkWidget *druid) G_GNUC_UNUSED;
static void balsa_druid_page_user_finalize (GtkObject *o) G_GNUC_UNUSED;

/* pointer to the class of our parent */
static BalsaDruidPageClass *parent_class = NULL;

guint
balsa_druid_page_user_get_type (void)
{
	static guint type = 0;

	if (!type) {
		static const GtkTypeInfo info = {
			"BalsaDruidPageUser",
			sizeof (BalsaDruidPageUser),
			sizeof (BalsaDruidPageUserClass),
			(GtkClassInitFunc) balsa_druid_page_user_class_init,
			(GtkObjectInitFunc) balsa_druid_page_user_init,
			/* reserved_1 */ NULL,
			/* reserved_2 */ NULL,
			(GtkClassInitFunc) NULL,
		};

		type = gtk_type_unique (balsa_druid_page_get_type(), &info);
	}

	return type;
}


#ifdef __GNUC__
static const typeof(&balsa_druid_page_user_new) new __attribute__ ((__unused__)) = balsa_druid_page_user_new;
#define new(args...) balsa_druid_page_user_new(##args)
#else /* __GNUC__ */
static GtkObject *(* new) (BalsaInitDruid *druid) = balsa_druid_page_user_new;
#endif /* __GNUC__ */

/* a macro for creating a new object of our type */
#define GET_NEW ((BalsaDruidPageUser *)gtk_type_new(balsa_druid_page_user_get_type()))

static void 
balsa_druid_page_user_class_init (BalsaDruidPageUserClass *c)
{
	BalsaDruidPageClass *balsa_druid_page_class = (BalsaDruidPageClass *)c;
	GnomeDruidPageClass *gnome_druid_page_class = (GnomeDruidPageClass *)c;
	GtkObjectClass *gtk_object_class = (GtkObjectClass *)c;

	parent_class = gtk_type_class (balsa_druid_page_get_type ());

#line 101 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	balsa_druid_page_class->construct = balsa_druid_page_user_construct;
#line 111 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	gnome_druid_page_class->prepare = balsa_druid_page_user_prepare;
#line 127 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	gnome_druid_page_class->next = balsa_druid_page_user_next;
#line 107 "balsa-druid-page-user.c"
	gtk_object_class->finalize = balsa_druid_page_user_finalize;
return;
}
#line 58 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
static void 
balsa_druid_page_user_init (BalsaDruidPageUser *self)
#line 114 "balsa-druid-page-user.c"
{
	self->_priv = g_new0 (BalsaDruidPageUserPrivate, 1);
 {
#line 58 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"

		GtkTable *table;
		GtkLabel *label;
		gchar *preset;
		char hostbuf[512];

		self->_priv->emaster.setbits = 0;
		self->_priv->emaster.numentries = 0;
		self->_priv->emaster.donemask = 0;
		self->_priv->ed0.master = &( self->_priv->emaster );
		self->_priv->ed1.master = &( self->_priv->emaster );
		self->_priv->ed2.master = &( self->_priv->emaster );
		self->_priv->ed3.master = &( self->_priv->emaster );

		table = GTK_TABLE( gtk_table_new( 5, 2, FALSE ) );

		label = GTK_LABEL( gtk_label_new( _("Please enter information about yourself.") ) );
		gtk_label_set_justify( label, GTK_JUSTIFY_CENTER );
		gtk_label_set_line_wrap( label, TRUE );
		gtk_table_attach( table, GTK_WIDGET( label ), 0, 2, 0, 1,
			GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 
			8, 4 );

		preset = g_get_real_name();
		balsa_init_add_table_entry( table, 0, _("Name:"), preset, &( self->_priv->ed0 ), GTK_WIDGET( self ), &( self->_priv->name ) );
		
		gethostname( hostbuf, 511 );
		preset = g_strconcat( g_get_user_name(), "@", hostbuf, NULL );
		balsa_init_add_table_entry( table, 1, _("Email address:"), preset, &( self->_priv->ed1 ), GTK_WIDGET( self ), &( self->_priv->email ) );
		g_free( preset );

		preset = "localhost";
		balsa_init_add_table_entry( table, 2, _("SMTP Server:"), preset, &( self->_priv->ed2 ), GTK_WIDGET( self ), &( self->_priv->smtp ) );

		preset = g_strconcat( g_get_home_dir(), "/mail", NULL );
		balsa_init_add_table_entry( table, 3, _("Local Mail Directory:"), preset, &( self->_priv->ed3 ), GTK_WIDGET( self ), &( self->_priv->localmaildir ) );
		g_free( preset );

		gtk_box_pack_start( GTK_BOX( (GNOME_DRUID_PAGE_STANDARD( self ))->vbox ),
			GTK_WIDGET( table ), TRUE, TRUE, 8 );
		gtk_widget_show_all( GTK_WIDGET( table ) );
	
#line 161 "balsa-druid-page-user.c"
 }
}


#line 50 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
GtkObject *
balsa_druid_page_user_new (BalsaInitDruid *druid)
{
#line 50 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_val_if_fail (!(druid) || BALSA_IS_INITDRUID (druid), (GtkObject *)0);
#line 50 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_val_if_fail (druid != NULL, (GtkObject *)0);
#line 174 "balsa-druid-page-user.c"
{
#line 51 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	 
		GtkObject *self = GTK_OBJECT( GET_NEW );
		(BALSA_DRUID_PAGE( self ))->druid = GNOME_DRUID( druid );
		balsa_druid_page_user_construct( BALSA_DRUID_PAGE( self ) );
		return self;
	}}
#line 183 "balsa-druid-page-user.c"


#line 101 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
static void 
balsa_druid_page_user_construct (BalsaDruidPage *self)
#define PARENT_HANDLER(___self) \
	{ if(BALSA_DRUID_PAGE_CLASS(parent_class)->construct) \
		(* BALSA_DRUID_PAGE_CLASS(parent_class)->construct)(___self); }
{
#line 193 "balsa-druid-page-user.c"
{
#line 102 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	
		(GNOME_DRUID_PAGE_STANDARD( self ))->title = g_strdup( _("User Settings" ) );

		g_return_if_fail( (BALSA_DRUID_PAGE( self ))->druid != NULL );
		(GNOME_DRUID_PAGE_STANDARD( self ))->logo_image = (BALSA_INITDRUID( (BALSA_DRUID_PAGE( self ))->druid ))->default_logo;

		PARENT_HANDLER( self );
	}}
#line 204 "balsa-druid-page-user.c"
#undef PARENT_HANDLER

#line 111 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
static void 
balsa_druid_page_user_prepare (GnomeDruidPage *_self, GtkWidget *druid)
#define PARENT_HANDLER(____self,___druid) \
	{ if(GNOME_DRUID_PAGE_CLASS(parent_class)->prepare) \
		(* GNOME_DRUID_PAGE_CLASS(parent_class)->prepare)(____self,___druid); }
{
#line 111 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_if_fail (!(druid) || GTK_IS_WIDGET (druid));
#line 111 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_if_fail (druid != NULL);
#line 218 "balsa-druid-page-user.c"
{
#line 112 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	
		BalsaDruidPageUser *self = BALSA_DRUID_PAGE_USER( _self );

		/* Don't let them continue unless all entries have something. */
		/* FIXME: unify this with code above */

		if( ENTRY_MASTER_DONE( self->_priv->emaster ) ) {
			gnome_druid_set_buttons_sensitive( GNOME_DRUID( druid ), TRUE, TRUE, TRUE );
		} else {
			gnome_druid_set_buttons_sensitive( GNOME_DRUID( druid ), TRUE, FALSE, TRUE );
		}

		gnome_druid_set_show_finish( GNOME_DRUID( druid ), FALSE );
	}}
#line 235 "balsa-druid-page-user.c"
#undef PARENT_HANDLER

#line 127 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
static gboolean 
balsa_druid_page_user_next (GnomeDruidPage *_self, GtkWidget *druid)
#define PARENT_HANDLER(____self,___druid) \
	((GNOME_DRUID_PAGE_CLASS(parent_class)->next)? \
		(* GNOME_DRUID_PAGE_CLASS(parent_class)->next)(____self,___druid): \
		((gboolean )0))
{
#line 127 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_val_if_fail (!(druid) || GTK_IS_WIDGET (druid), (gboolean )0);
#line 127 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	g_return_val_if_fail (druid != NULL, (gboolean )0);
#line 250 "balsa-druid-page-user.c"
{
#line 128 "../../balsa/libinit_balsa/balsa-druid-page-user.gob"
	
		gchar *uhoh;
		BalsaDruidPageUser *self = BALSA_DRUID_PAGE_USER( _self );

		if( balsa_app.address->personal )
			g_free( balsa_app.address->personal );
		balsa_app.address->personal = g_strdup( gtk_entry_get_text( GTK_ENTRY( self->_priv->name ) ) );

		if( balsa_app.address->mailbox )
			g_free( balsa_app.address->mailbox );
		balsa_app.address->mailbox = g_strdup( gtk_entry_get_text( GTK_ENTRY( self->_priv->email ) ) );

		if( balsa_app.smtp_server );
			g_free( balsa_app.smtp_server );
		balsa_app.smtp_server = g_strdup( gtk_entry_get_text( GTK_ENTRY( self->_priv->smtp ) ) );

		if( balsa_app.local_mail_directory );
			g_free( balsa_app.local_mail_directory );
		balsa_app.local_mail_directory = g_strdup( gtk_entry_get_text( GTK_ENTRY( self->_priv->localmaildir ) ) );

		if( balsa_init_create_to_directory( balsa_app.local_mail_directory, &uhoh ) ) {
			GtkObject *page;

			page = balsa_druid_page_error_new_after( BALSA_DRUID_PAGE( self ), _("Local Mail Problem"), uhoh );
			g_free( uhoh );
			balsa_druid_page_error_goto_me( BALSA_DRUID_PAGE_ERROR( page ) );
		} else {
			PARENT_HANDLER( _self, druid );
		}

		return TRUE;
	}}
#line 285 "balsa-druid-page-user.c"
#undef PARENT_HANDLER

static void 
balsa_druid_page_user_finalize (GtkObject *o)
#define PARENT_HANDLER(___o) \
	{ if(GTK_OBJECT_CLASS(parent_class)->finalize) \
		(* GTK_OBJECT_CLASS(parent_class)->finalize)(___o); }
{
	BalsaDruidPageUser *___self = BALSA_DRUID_PAGE_USER (o);
	g_free (___self->_priv);
	___self->_priv = NULL;
{
	PARENT_HANDLER (o);
}}
#undef PARENT_HANDLER


#ifndef __GNUC__
/*REALLY BAD HACK
  This is to avoid unused warnings if you don't call
  some method.  I need to find a better way to do
  this, not needed in GCC since we use some gcc
  extentions to make saner, faster code */
static void
___balsa_druid_page_user_really_bad_hack_to_avoid_warnings(void)
{
	((void (*)(void))new)();
	___balsa_druid_page_user_really_bad_hack_to_avoid_warnings();
}
#endif /* __GNUC__ */

