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