File: balsa-druid-page-user.gob

package info (click to toggle)
balsa 0.6.0-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 4,044 kB
  • ctags: 3,648
  • sloc: ansic: 36,750; sh: 7,458; makefile: 518; sed: 93
file content (160 lines) | stat: -rw-r--r-- 5,434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%h{
/*
 * Balsa E-Mail Client
 * Copyright (C) 1997-1999 Jay Painter and Stuart Parmenter
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option) 
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
 * 02111-1307, USA.
 */

#include "config.h"
#include <gnome.h>
#include "helper.h"
#include "balsa-initdruid.h"
#include "balsa-druid-page.h"

%}

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

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

class Balsa:Druid:Page:User from Balsa:Druid:Page {
	private GtkWidget *name;
	private GtkWidget *email;
	private GtkWidget *smtp;
	private GtkWidget *localmaildir;
	private EntryMaster emaster;
	/* Gob can't handle arrays. Sigh. */
	private EntryData ed0;
	private EntryData ed1;
	private EntryData ed2;
	private EntryData ed3;

	public GtkObject *new( Balsa:InitDruid *druid (check type null ) ) 
	{ 
		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;
	}

	init( self ) {
		GtkTable *table;
		GtkLabel *label;
		gchar *preset;
		char hostbuf[512];

		self->emaster.setbits = 0;
		self->emaster.numentries = 0;
		self->emaster.donemask = 0;
		self->ed0.master = &( self->emaster );
		self->ed1.master = &( self->emaster );
		self->ed2.master = &( self->emaster );
		self->ed3.master = &( self->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->ed0 ), GTK_WIDGET( self ), &( self->name ) );
		
		gethostname( hostbuf, 511 );
		preset = g_strconcat( g_get_user_name(), "@", hostbuf, NULL );
		balsa_init_add_table_entry( table, 1, _("Email address:"), preset, &( self->ed1 ), GTK_WIDGET( self ), &( self->email ) );
		g_free( preset );

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

		preset = g_strconcat( g_get_home_dir(), "/mail", NULL );
		balsa_init_add_table_entry( table, 3, _("Local Mail Directory:"), preset, &( self->ed3 ), GTK_WIDGET( self ), &( self->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 ) );
	}

	override (Balsa:Druid:Page) void
	construct( Balsa:Druid:Page *self ) {
		(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 );
	}

	override (Gnome:Druid:Page) void
	prepare( Gnome:Druid:Page *_self, Gtk:Widget *druid (check type null) ) {
		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->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 );
	}

	override (Gnome:Druid:Page) gboolean
	next( Gnome:Druid:Page *_self, Gtk:Widget *druid (check type null) ) {
		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->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->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->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->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;
	}
}