evolution-3.6.4/widgets/misc/e-send-options.c

No issues found

  1 /*
  2  * Evolution calendar - Main page of the Groupwise send options Dialog
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Authors:
 19  *		Chenthill Palanisamy <pchenthill@novell.com>
 20  *
 21  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 22  *
 23  */
 24 
 25 #ifdef HAVE_CONFIG_H
 26 #include <config.h>
 27 #endif
 28 
 29 #include <string.h>
 30 #include <glib/gi18n.h>
 31 #include <time.h>
 32 
 33 #include "e-util/e-util.h"
 34 #include "e-util/e-util-private.h"
 35 
 36 #include "e-dateedit.h"
 37 #include "e-send-options.h"
 38 
 39 #define E_SEND_OPTIONS_DIALOG_GET_PRIVATE(obj) \
 40 	(G_TYPE_INSTANCE_GET_PRIVATE \
 41 	((obj), E_TYPE_SEND_OPTIONS_DIALOG, ESendOptionsDialogPrivate))
 42 
 43 struct _ESendOptionsDialogPrivate {
 44 	GtkBuilder *builder;
 45 
 46 	gboolean gopts_needed;
 47 	gboolean global;
 48 
 49 	/* Widgets */
 50 
 51 	GtkWidget *main;
 52 
 53 	/* Noteboook to add options page and status tracking page*/
 54 	GtkNotebook *notebook;
 55 
 56 	GtkWidget *status;
 57 
 58 	/* priority */
 59 	GtkWidget *priority;
 60 
 61 	/* Security */
 62 	GtkWidget *security;
 63 
 64 	/* Widgets for Reply Requestion options */
 65 	GtkWidget *reply_request;
 66 	GtkWidget *reply_convenient;
 67 	GtkWidget *reply_within;
 68 	GtkWidget *within_days;
 69 
 70 	/* Widgets for delay delivery Option */
 71 	GtkWidget *delay_delivery;
 72 	GtkWidget *delay_until;
 73 
 74 	/* Widgets for Choosing expiration date */
 75 	GtkWidget *expiration;
 76 	GtkWidget *expire_after;
 77 
 78 	/* Widgets to for tracking information through sent Item */
 79 	GtkWidget *create_sent;
 80 	GtkWidget *delivered;
 81 	GtkWidget *delivered_opened;
 82 	GtkWidget *all_info;
 83 	GtkWidget *autodelete;
 84 
 85 	/* Widgets for setting the Return Notification */
 86 	GtkWidget *when_opened;
 87 	GtkWidget *when_declined;
 88 	GtkWidget *when_accepted;
 89 	GtkWidget *when_completed;
 90 
 91 	/* label widgets */
 92 	GtkWidget *security_label;
 93 	GtkWidget *priority_label;
 94 	GtkWidget *gopts_label;
 95 	GtkWidget *opened_label;
 96 	GtkWidget *declined_label;
 97 	GtkWidget *accepted_label;
 98 	GtkWidget *completed_label;
 99 	GtkWidget *until_label;
100         gchar *help_section;
101 };
102 
103 static void e_send_options_dialog_finalize (GObject *object);
104 static void e_send_options_cb (GtkDialog *dialog, gint state, gpointer func_data);
105 
106 enum {
107 	SOD_RESPONSE,
108 	LAST_SIGNAL
109 };
110 
111 static guint signals[LAST_SIGNAL] = {0};
112 
113 G_DEFINE_TYPE (
114 	ESendOptionsDialog,
115 	e_send_options_dialog,
116 	G_TYPE_OBJECT)
117 
118 static void
119 e_send_options_get_widgets_data (ESendOptionsDialog *sod)
120 {
121 	ESendOptionsDialogPrivate *priv;
122 	ESendOptionsGeneral *gopts;
123 	ESendOptionsStatusTracking *sopts;
124 
125 	priv = sod->priv;
126 	gopts = sod->data->gopts;
127 	sopts = sod->data->sopts;
128 
129 	gopts->priority = gtk_combo_box_get_active ((GtkComboBox *) priv->priority);
130 	gopts->security = gtk_combo_box_get_active ((GtkComboBox *) priv->security);
131 
132 	gopts->reply_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reply_request));
133 	gopts->reply_convenient = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->reply_convenient));
134 	gopts->reply_within = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->within_days));
135 
136 	gopts->expiration_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->expiration));
137 	gopts->expire_after = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (priv->expire_after));
138 	gopts->delay_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delay_delivery));
139 
140 	if (e_date_edit_date_is_valid (E_DATE_EDIT (priv->delay_until)) &&
141 								e_date_edit_time_is_valid (E_DATE_EDIT (priv->delay_until)))
142 		gopts->delay_until = e_date_edit_get_time (E_DATE_EDIT (priv->delay_until));
143 
144 	sopts->tracking_enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->create_sent));
145 
146 	sopts->autodelete = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->autodelete));
147 
148 	if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivered)))
149 		sopts->track_when = E_DELIVERED;
150 	else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->delivered_opened)))
151 		sopts->track_when = E_DELIVERED_OPENED;
152 	else
153 		sopts->track_when = E_ALL;
154 
155 	sopts->opened = gtk_combo_box_get_active ((GtkComboBox *) priv->when_opened);
156 	sopts->accepted = gtk_combo_box_get_active ((GtkComboBox *) priv->when_accepted);
157 	sopts->declined = gtk_combo_box_get_active ((GtkComboBox *) priv->when_declined);
158 	sopts->completed = gtk_combo_box_get_active ((GtkComboBox *) priv->when_completed);
159 }
160 
161 static void
162 e_send_options_fill_widgets_with_data (ESendOptionsDialog *sod)
163 {
164 	ESendOptionsDialogPrivate *priv;
165 	ESendOptionsGeneral *gopts;
166 	ESendOptionsStatusTracking *sopts;
167 	time_t tmp;
168 
169 	priv = sod->priv;
170 	gopts = sod->data->gopts;
171 	sopts = sod->data->sopts;
172 	tmp = time (NULL);
173 
174 	gtk_combo_box_set_active ((GtkComboBox *) priv->priority, gopts->priority);
175 	gtk_combo_box_set_active ((GtkComboBox *) priv->security, gopts->security);
176 
177 	if (gopts->reply_enabled)
178 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_request), TRUE);
179 	else
180 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_request), FALSE);
181 
182 	if (gopts->reply_convenient)
183 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_convenient), TRUE);
184 	else
185 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->reply_within), TRUE);
186 
187 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->within_days), (gdouble) gopts->reply_within);
188 
189 	if (gopts->expiration_enabled)
190 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->expiration), TRUE);
191 	else
192 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->expiration), FALSE);
193 
194 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->expire_after), (gdouble) gopts->expire_after);
195 
196 	if (gopts->delay_enabled)
197 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delay_delivery), TRUE);
198 	else
199 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delay_delivery), FALSE);
200 
201 	if (!gopts->delay_until || (!difftime (gopts->delay_until, tmp) < 0))
202 		e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), 0);
203 	else
204 		e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), gopts->delay_until);
205 
206 	if (sopts->tracking_enabled)
207 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->create_sent), TRUE);
208 	else
209 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->create_sent), FALSE);
210 
211 	if (sopts->autodelete)
212 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autodelete), TRUE);
213 	else
214 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autodelete), FALSE);
215 
216 	switch (sopts->track_when) {
217 		case E_DELIVERED:
218 			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivered), TRUE);
219 			break;
220 		case E_DELIVERED_OPENED:
221 			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->delivered_opened), TRUE);
222 			break;
223 		case E_ALL:
224 			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_info), TRUE);
225 	}
226 
227 	gtk_combo_box_set_active ((GtkComboBox *) priv->when_opened, sopts->opened);
228 	gtk_combo_box_set_active ((GtkComboBox *) priv->when_declined, sopts->declined);
229 	gtk_combo_box_set_active ((GtkComboBox *) priv->when_accepted, sopts->accepted);
230 	gtk_combo_box_set_active ((GtkComboBox *) priv->when_completed, sopts->completed);
231 }
232 
233 static void
234 sensitize_widgets (ESendOptionsDialog *sod)
235 {
236 	ESendOptionsDialogPrivate *priv;
237 	ESendOptionsGeneral *gopts;
238 	ESendOptionsStatusTracking *sopts;
239 
240 	priv = sod->priv;
241 	gopts = sod->data->gopts;
242 	sopts = sod->data->sopts;
243 
244 	if (!gopts->reply_enabled) {
245 		gtk_widget_set_sensitive (priv->reply_convenient, FALSE);
246 		gtk_widget_set_sensitive (priv->reply_within, FALSE);
247 		gtk_widget_set_sensitive (priv->within_days, FALSE);
248 	}
249 
250 	if (!gopts->expiration_enabled)
251 		gtk_widget_set_sensitive (priv->expire_after, FALSE);
252 
253 	if (!gopts->delay_enabled) {
254 		gtk_widget_set_sensitive (priv->delay_until, FALSE);
255 	}
256 
257 	if (!sopts->tracking_enabled) {
258 		gtk_widget_set_sensitive (priv->delivered, FALSE);
259 		gtk_widget_set_sensitive (priv->delivered_opened, FALSE);
260 		gtk_widget_set_sensitive (priv->all_info, FALSE);
261 		gtk_widget_set_sensitive (priv->autodelete, FALSE);
262 	}
263 }
264 
265 static void
266 expiration_toggled_cb (GtkToggleButton *toggle,
267                        gpointer data)
268 {
269 	gboolean active;
270 	ESendOptionsDialog *sod;
271 	ESendOptionsDialogPrivate *priv;
272 
273 	sod = data;
274 	priv = sod->priv;
275 
276 	active = gtk_toggle_button_get_active (toggle);
277 
278 	gtk_widget_set_sensitive (priv->expire_after, active);
279 }
280 
281 static void
282 reply_request_toggled_cb (GtkToggleButton *toggle,
283                           gpointer data)
284 {
285 	gboolean active;
286 	ESendOptionsDialog *sod;
287 	ESendOptionsDialogPrivate *priv;
288 
289 	sod = data;
290 	priv = sod->priv;
291 	active = gtk_toggle_button_get_active (toggle);
292 
293 	gtk_widget_set_sensitive (priv->reply_convenient, active);
294 	gtk_widget_set_sensitive (priv->reply_within, active);
295 	gtk_widget_set_sensitive (priv->within_days, active);
296 
297 }
298 
299 static void
300 delay_delivery_toggled_cb (GtkToggleButton *toggle,
301                            gpointer data)
302 {
303 	gboolean active;
304 	ESendOptionsDialog *sod;
305 	ESendOptionsDialogPrivate *priv;
306 
307 	sod = data;
308 	priv = sod->priv;
309 	active = gtk_toggle_button_get_active (toggle);
310 
311 	gtk_widget_set_sensitive (priv->delay_until, active);
312 }
313 
314 static void
315 sent_item_toggled_cb (GtkToggleButton *toggle,
316                       gpointer data)
317 {
318 	gboolean active;
319 	ESendOptionsDialog *sod;
320 	ESendOptionsDialogPrivate *priv;
321 
322 	sod = data;
323 	priv = sod->priv;
324 	active = gtk_toggle_button_get_active (toggle);
325 
326 	gtk_widget_set_sensitive (priv->delivered, active);
327 	gtk_widget_set_sensitive (priv->delivered_opened, active);
328 	gtk_widget_set_sensitive (priv->all_info, active);
329 	gtk_widget_set_sensitive (priv->autodelete, active);
330 }
331 
332 static void
333 delay_until_date_changed_cb (GtkWidget *dedit,
334                              gpointer data)
335 {
336 	ESendOptionsDialog *sod;
337 	ESendOptionsDialogPrivate *priv;
338 	time_t tmp, current;
339 
340 	sod = data;
341 	priv = sod->priv;
342 
343 	current = time (NULL);
344 	tmp = e_date_edit_get_time (E_DATE_EDIT (priv->delay_until));
345 
346 	if ((difftime (tmp, current) < 0) || !e_date_edit_time_is_valid (E_DATE_EDIT (priv->delay_until))
347 					  || !e_date_edit_date_is_valid (E_DATE_EDIT (priv->delay_until)))
348 		e_date_edit_set_time (E_DATE_EDIT (priv->delay_until), 0);
349 
350 }
351 static void
352 page_changed_cb (GtkNotebook *notebook,
353                  GtkWidget *page,
354                  gint num,
355                  gpointer data)
356 {
357 	ESendOptionsDialog *sod = data;
358 	ESendOptionsDialogPrivate *priv = sod->priv;
359 
360 	e_send_options_get_widgets_data (sod);
361 	if (num > 0) {
362 		GtkWidget *child;
363 
364 		if (num == 1) {
365 			gtk_widget_hide (priv->accepted_label);
366 			gtk_widget_hide (priv->when_accepted);
367 			gtk_widget_hide (priv->completed_label);
368 			gtk_widget_hide (priv->when_completed);
369 			gtk_widget_set_sensitive (priv->autodelete, TRUE);
370 			sod->data->sopts = sod->data->mopts;
371 
372 			child = gtk_notebook_get_nth_page (notebook, 1);
373 			if (child != priv->status && (!GTK_IS_BIN (child) || gtk_bin_get_child (GTK_BIN (child)) != priv->status))
374 				gtk_widget_reparent (priv->status, child);
375 		} else if (num == 2) {
376 			gtk_widget_hide (priv->completed_label);
377 			gtk_widget_hide (priv->when_completed);
378 			gtk_widget_set_sensitive (priv->autodelete, FALSE);
379 
380 			gtk_widget_show (priv->accepted_label);
381 			gtk_widget_show (priv->when_accepted);
382 			sod->data->sopts = sod->data->copts;
383 
384 			child = gtk_notebook_get_nth_page (notebook, 2);
385 			if (gtk_bin_get_child (GTK_BIN (child)) != priv->status)
386 				gtk_widget_reparent (priv->status, child);
387 		} else {
388 			gtk_widget_set_sensitive (priv->autodelete, FALSE);
389 
390 			gtk_widget_show (priv->completed_label);
391 			gtk_widget_show (priv->when_completed);
392 			gtk_widget_show (priv->accepted_label);
393 			gtk_widget_show (priv->when_accepted);
394 			sod->data->sopts = sod->data->topts;
395 
396 			child = gtk_notebook_get_nth_page (notebook, 3);
397 			if (gtk_bin_get_child (GTK_BIN (child)) != priv->status)
398 				gtk_widget_reparent (priv->status, child);
399 		}
400 	}
401 	e_send_options_fill_widgets_with_data (sod);
402 }
403 
404 static void
405 init_widgets (ESendOptionsDialog *sod)
406 {
407 	ESendOptionsDialogPrivate *priv;
408 
409 	priv = sod->priv;
410 
411 	g_signal_connect (
412 		priv->expiration, "toggled",
413 		G_CALLBACK (expiration_toggled_cb), sod);
414 	g_signal_connect (
415 		priv->reply_request, "toggled",
416 		G_CALLBACK (reply_request_toggled_cb), sod);
417 	g_signal_connect (
418 		priv->delay_delivery, "toggled",
419 		G_CALLBACK (delay_delivery_toggled_cb), sod);
420 	g_signal_connect (
421 		priv->create_sent, "toggled",
422 		G_CALLBACK (sent_item_toggled_cb), sod);
423 
424 	g_signal_connect (
425 		priv->main, "response",
426 		G_CALLBACK (e_send_options_cb), sod);
427 	g_signal_connect (
428 		priv->delay_until, "changed",
429 		G_CALLBACK (delay_until_date_changed_cb), sod);
430 
431 	if (priv->global)
432 		g_signal_connect (
433 			priv->notebook, "switch-page",
434 			G_CALLBACK (page_changed_cb), sod);
435 
436 }
437 
438 static gboolean
439 get_widgets (ESendOptionsDialog *sod)
440 {
441 	ESendOptionsDialogPrivate *priv;
442 	GtkBuilder *builder;
443 
444 	priv = sod->priv;
445 	builder = sod->priv->builder;
446 
447 	priv->main = e_builder_get_widget (builder, "send-options-dialog");
448 	if (!priv->main)
449 		return FALSE;
450 
451 	priv->priority = e_builder_get_widget (builder, "combo-priority");
452 	priv->status = e_builder_get_widget (builder, "status-tracking");
453 	priv->security = e_builder_get_widget (builder, "security-combo");
454 	priv->notebook = (GtkNotebook *) e_builder_get_widget (builder, "notebook");
455 	priv->reply_request = e_builder_get_widget (builder, "reply-request-button");
456 	priv->reply_convenient = e_builder_get_widget (builder, "reply-convinient");
457 	priv->reply_within = e_builder_get_widget (builder, "reply-within");
458 	priv->within_days = e_builder_get_widget (builder, "within-days");
459 	priv->delay_delivery = e_builder_get_widget (builder, "delay-delivery-button");
460 	priv->delay_until = e_builder_get_widget (builder, "until-date");
461 	gtk_widget_show (priv->delay_until);
462 	priv->expiration = e_builder_get_widget (builder, "expiration-button");
463 	priv->expire_after = e_builder_get_widget (builder, "expire-after");
464 	priv->create_sent = e_builder_get_widget (builder, "create-sent-button");
465 	priv->delivered = e_builder_get_widget (builder, "delivered");
466 	priv->delivered_opened = e_builder_get_widget (builder, "delivered-opened");
467 	priv->all_info = e_builder_get_widget (builder, "all-info");
468 	priv->autodelete = e_builder_get_widget (builder, "autodelete");
469 	priv->when_opened = e_builder_get_widget (builder, "open-combo");
470 	priv->when_declined = e_builder_get_widget (builder, "delete-combo");
471 	priv->when_accepted = e_builder_get_widget (builder, "accept-combo");
472 	priv->when_completed = e_builder_get_widget (builder, "complete-combo");
473 	priv->security_label = e_builder_get_widget (builder, "security-label");
474 	priv->gopts_label = e_builder_get_widget (builder, "gopts-label");
475 	priv->priority_label = e_builder_get_widget (builder, "priority-label");
476 	priv->until_label = e_builder_get_widget (builder, "until-label");
477 	priv->opened_label = e_builder_get_widget (builder, "opened-label");
478 	priv->declined_label = e_builder_get_widget (builder, "declined-label");
479 	priv->accepted_label = e_builder_get_widget (builder, "accepted-label");
480 	priv->completed_label = e_builder_get_widget (builder, "completed-label");
481 
482 	return (priv->priority
483 		&& priv->security
484 		&& priv->status
485 		&& priv->reply_request
486 		&& priv->reply_convenient
487 		&& priv->reply_within
488 		&& priv->within_days
489 		&& priv->delay_delivery
490 		&& priv->delay_until
491 		&& priv->expiration
492 		&& priv->expire_after
493 		&& priv->create_sent
494 		&& priv->delivered
495 		&& priv->delivered_opened
496 		&& priv->autodelete
497 		&& priv->all_info
498 		&& priv->when_opened
499 		&& priv->when_declined
500 		&& priv->when_accepted
501 		&& priv->when_completed
502 		&& priv->security_label
503 		&& priv->priority_label
504 		&& priv->opened_label
505 		&& priv->gopts_label
506 		&& priv->declined_label
507 		&& priv->accepted_label
508 		&& priv->completed_label);
509 
510 }
511 
512 static void
513 setup_widgets (ESendOptionsDialog *sod,
514                Item_type type)
515 {
516 	ESendOptionsDialogPrivate *priv;
517 
518 	priv = sod->priv;
519 
520 	if (!priv->gopts_needed) {
521 		gtk_notebook_set_show_tabs (priv->notebook, FALSE);
522 		gtk_notebook_set_current_page (priv->notebook, 1);
523 		gtk_widget_hide (priv->delay_until);
524 	} else
525 		gtk_notebook_set_show_tabs (priv->notebook, TRUE);
526 
527 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->priority_label), priv->priority);
528 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->security_label), priv->security);
529 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->accepted_label), priv->when_accepted);
530 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->declined_label), priv->when_declined);
531 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->opened_label), priv->when_opened);
532 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->completed_label), priv->when_completed);
533 	gtk_label_set_mnemonic_widget (GTK_LABEL (priv->until_label), priv->delay_until);
534 
535 	if (priv->global) {
536 		GtkWidget *widget, *page;
537 
538 		widget = gtk_label_new (_("Mail"));
539 		page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
540 		gtk_widget_reparent (priv->status, page);
541 		gtk_notebook_append_page (priv->notebook, page, widget);
542 		gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
543 		gtk_widget_show (page);
544 		gtk_widget_show (widget);
545 
546 		widget = gtk_label_new (_("Calendar"));
547 		page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
548 		gtk_notebook_append_page (priv->notebook, page, widget);
549 		gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
550 		gtk_widget_show (page);
551 		gtk_widget_show (widget);
552 
553 		widget = gtk_label_new (_("Task"));
554 		page = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
555 		gtk_notebook_append_page (priv->notebook, page, widget);
556 		gtk_container_child_set (GTK_CONTAINER (priv->notebook), page, "tab-fill", FALSE, "tab-expand", FALSE, NULL);
557 		gtk_widget_show (page);
558 		gtk_widget_show (widget);
559 
560 		gtk_notebook_set_show_tabs (priv->notebook, TRUE);
561 	}
562 
563 	switch (type) {
564 		case E_ITEM_MAIL:
565 			priv->help_section = g_strdup ("groupwise-placeholder");
566 			gtk_widget_hide (priv->accepted_label);
567 			gtk_widget_hide (priv->when_accepted);
568 			gtk_widget_hide (priv->completed_label);
569 			gtk_widget_hide (priv->when_completed);
570 			gtk_label_set_text_with_mnemonic (GTK_LABEL (priv->declined_label), (_("When de_leted:")));
571 			break;
572 		case E_ITEM_CALENDAR:
573 			priv->help_section = g_strdup ("groupwise-placeholder");
574 			gtk_widget_hide (priv->completed_label);
575 			gtk_widget_hide (priv->when_completed);
576 		case E_ITEM_TASK:
577 			priv->help_section = g_strdup ("groupwise-placeholder");
578 			gtk_widget_hide (priv->security_label);
579 			gtk_widget_hide (priv->security);
580 			gtk_widget_set_sensitive (priv->autodelete, FALSE);
581 			break;
582 		default:
583 			break;
584 	}
585 }
586 
587 ESendOptionsDialog *
588 e_send_options_dialog_new (void)
589 {
590 	ESendOptionsDialog *sod;
591 
592 	sod = g_object_new (E_TYPE_SEND_OPTIONS_DIALOG, NULL);
593 
594 	return sod;
595 }
596 
597 void
598 e_send_options_set_need_general_options (ESendOptionsDialog *sod,
599                                          gboolean needed)
600 {
601 	g_return_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod));
602 
603 	sod->priv->gopts_needed = needed;
604 }
605 
606 gboolean
607 e_send_options_get_need_general_options (ESendOptionsDialog *sod)
608 {
609 	g_return_val_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
610 
611 	return sod->priv->gopts_needed;
612 }
613 
614 gboolean
615 e_send_options_set_global (ESendOptionsDialog *sod,
616                            gboolean set)
617 {
618 	g_return_val_if_fail (E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
619 
620 	sod->priv->global = set;
621 
622 	return TRUE;
623 }
624 
625 static void
626 e_send_options_cb (GtkDialog *dialog,
627                    gint state,
628                    gpointer func_data)
629 {
630 	ESendOptionsDialogPrivate *priv;
631 	ESendOptionsDialog *sod;
632 
633 	sod = func_data;
634 	priv = sod->priv;
635 
636 	switch (state) {
637 		case GTK_RESPONSE_OK:
638 			e_send_options_get_widgets_data (sod);
639 		case GTK_RESPONSE_CANCEL:
640 			gtk_widget_hide (priv->main);
641 			gtk_widget_destroy (priv->main);
642 			g_object_unref (priv->builder);
643 			break;
644 		case GTK_RESPONSE_HELP:
645 			e_display_help (
646 				GTK_WINDOW (priv->main),
647 				priv->help_section);
648 			break;
649 	}
650 
651 	g_signal_emit (func_data, signals[SOD_RESPONSE], 0, state);
652 }
653 
654 gboolean
655 e_send_options_dialog_run (ESendOptionsDialog *sod,
656                            GtkWidget *parent,
657                            Item_type type)
658 {
659 	ESendOptionsDialogPrivate *priv;
660 	GtkWidget *toplevel;
661 
662 	g_return_val_if_fail (sod != NULL || E_IS_SEND_OPTIONS_DIALOG (sod), FALSE);
663 
664 	priv = sod->priv;
665 
666 	/* Make sure our custom widget classes are registered with
667 	 * GType before we load the GtkBuilder definition file. */
668 	E_TYPE_DATE_EDIT;
669 
670 	priv->builder = gtk_builder_new ();
671 	e_load_ui_builder_definition (priv->builder, "e-send-options.ui");
672 
673 	if (!get_widgets (sod)) {
674 		g_object_unref (priv->builder);
675 		g_message (G_STRLOC ": Could not get the Widgets \n");
676 		return FALSE;
677 	}
678 
679 	if (priv->global) {
680 		g_free (sod->data->sopts);
681 		sod->data->sopts = sod->data->mopts;
682 	}
683 
684 	setup_widgets (sod, type);
685 
686 	toplevel =  gtk_widget_get_toplevel (priv->main);
687 	if (parent)
688 		gtk_window_set_transient_for (GTK_WINDOW (toplevel),
689 				      GTK_WINDOW (parent));
690 
691 	e_send_options_fill_widgets_with_data (sod);
692 	sensitize_widgets (sod);
693 	init_widgets (sod);
694 	gtk_window_set_modal ((GtkWindow *) priv->main, TRUE);
695 
696 	gtk_widget_show (priv->main);
697 
698 	return TRUE;
699 }
700 
701 static void
702 e_send_options_dialog_finalize (GObject *object)
703 {
704 	ESendOptionsDialog *sod;
705 
706 	sod = E_SEND_OPTIONS_DIALOG (object);
707 
708 	g_free (sod->priv->help_section);
709 
710 	g_free (sod->data->gopts);
711 
712 	if (!sod->priv->global)
713 		g_free (sod->data->sopts);
714 
715 	g_free (sod->data->mopts);
716 	g_free (sod->data->copts);
717 	g_free (sod->data->topts);
718 	g_free (sod->data);
719 
720 	/* Chain up to parent's finalize() method. */
721 	G_OBJECT_CLASS (e_send_options_dialog_parent_class)->finalize (object);
722 }
723 
724 /* Object initialization function for the task page */
725 static void
726 e_send_options_dialog_init (ESendOptionsDialog *sod)
727 {
728 	ESendOptionsData *new;
729 
730 	new = g_new0 (ESendOptionsData, 1);
731 	new->gopts = g_new0 (ESendOptionsGeneral, 1);
732 	new->sopts = g_new0 (ESendOptionsStatusTracking, 1);
733 	new->mopts = g_new0 (ESendOptionsStatusTracking, 1);
734 	new->copts = g_new0 (ESendOptionsStatusTracking, 1);
735 	new->topts = g_new0 (ESendOptionsStatusTracking, 1);
736 
737 	sod->priv = E_SEND_OPTIONS_DIALOG_GET_PRIVATE (sod);
738 
739 	sod->data = new;
740 	sod->data->initialized = FALSE;
741 	sod->data->gopts->security = 0;
742 
743 	sod->priv->gopts_needed = TRUE;
744 }
745 
746 /* Class initialization function for the Send Options */
747 static void
748 e_send_options_dialog_class_init (ESendOptionsDialogClass *class)
749 {
750 	GObjectClass *object_class;
751 
752 	g_type_class_add_private (class, sizeof (ESendOptionsDialogPrivate));
753 
754 	object_class = G_OBJECT_CLASS (class);
755 	object_class->finalize = e_send_options_dialog_finalize;
756 
757 	signals[SOD_RESPONSE] = g_signal_new (
758 		"sod_response",
759 		G_TYPE_FROM_CLASS (class),
760 		G_SIGNAL_RUN_FIRST,
761 		G_STRUCT_OFFSET (ESendOptionsDialogClass, sod_response),
762 		NULL, NULL,
763 		g_cclosure_marshal_VOID__INT,
764 		G_TYPE_NONE, 1,
765 		G_TYPE_INT);
766 
767 }