aboutsummaryrefslogtreecommitdiffstats
path: root/my-evolution/e-summary-preferences.c
blob: a13804abdae7e80ab2b4a420aabd682996fb103d (plain) (blame)
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
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* e-summary-preferences.c
 *
 * Copyright (C) 2001 Ximian, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * 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.
 *
 * Author: Iain Holmes
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <gtk/gtk.h>

#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-config.h>

#include <libgnomeui/gnome-propertybox.h>
#include <libgnomeui/gnome-stock.h>

#include <glade/glade.h>
#include <stdio.h>

#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
#include <bonobo-conf/bonobo-config-database.h>

#include "e-summary.h"
#include "e-summary-preferences.h"
#include "e-summary-table.h"

static void
make_initial_mail_list (ESummaryPrefs *prefs)
{
    char *evolution_dir;
    GList *folders;

    evolution_dir = gnome_util_prepend_user_home ("evolution/local");

    folders = g_list_append (NULL, g_strconcat (evolution_dir, "/Inbox", NULL));
    folders = g_list_append (folders, g_strconcat (evolution_dir, "/Outbox", NULL));

    g_free (evolution_dir);
    prefs->display_folders = folders;
}

static void
make_initial_rdf_list (ESummaryPrefs *prefs)
{
    GList *rdfs;

    rdfs = g_list_prepend (NULL, g_strdup ("http://linuxtoday.com/backend/my-netscape.rdf"));
    rdfs = g_list_append (rdfs, g_strdup ("http://www.salon.com/feed/RDF/salon_use.rdf"));
    
    prefs->rdf_urls = rdfs;
}

static void
make_initial_weather_list (ESummaryPrefs *prefs)
{
    /* translators: Put a list of codes for locations you want to see in
       My Evolution by default here. You can find the list of all
       stations and their codes in Evolution sources.
       (evolution/my-evolution/Locations)
       Codes are seperated with : eg. "KBOS:EGAA"*/
    char *default_stations = _("KBOS"), **stations_v, **p;
    GList *stations = NULL;

    stations_v = g_strsplit (default_stations, ":", 0);
    g_assert (stations_v != NULL);
    for (p = stations_v; *p != NULL; p++) {
        stations = g_list_prepend (stations, *p);
    }
    g_free (stations_v);

    prefs->stations = g_list_reverse (stations);
}

/* Load the prefs off disk */

static char *
vector_from_str_list (GList *strlist)
{
    char *vector;
    GString *str;

    if (strlist == NULL) {
        return g_strdup ("");
    }

    str = g_string_new ("");
    for (; strlist; strlist = strlist->next) {
        g_string_append (str, strlist->data);

        /* No space at end */
        if (strlist->next) {
            g_string_append (str, " !<-->! ");
        }
    }

    vector = str->str;
    g_string_free (str, FALSE);

    return vector;
}

static GList *
str_list_from_vector (const char *vector)
{
    GList *strlist = NULL;
    char **tokens, **t;

    t = tokens = g_strsplit (vector, " !<-->! ", 8196);

    if (tokens == NULL) {
        return NULL;
    }

    for (; *tokens; tokens++) {
        strlist = g_list_prepend (strlist, g_strdup (*tokens));
    }

    g_strfreev (t);

    strlist = g_list_reverse (strlist);
    return strlist;
}

gboolean
e_summary_preferences_restore (ESummaryPrefs *prefs)
{
    Bonobo_ConfigDatabase db;
    CORBA_Environment ev;
    char *vector;

    g_return_val_if_fail (prefs != NULL, FALSE);

    CORBA_exception_init (&ev);
    db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Wombat. Using defaults");
        CORBA_exception_free (&ev);
        return FALSE;
    }

    CORBA_exception_free (&ev);
    vector = bonobo_config_get_string (db, "My-Evolution/Mail/display_folders", &ev);
    if (BONOBO_EX (&ev)) {
        g_warning ("Error getting Mail/display_folders");
        CORBA_exception_free (&ev);
        bonobo_object_release_unref (db, NULL);
        return FALSE;
    }
    prefs->display_folders = str_list_from_vector (vector);
    g_free (vector);

    prefs->show_full_path = bonobo_config_get_boolean (db, "My-Evolution/Mail/show_full_path", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Mail/show_full_path. Using defaults");
        bonobo_object_release_unref (db, NULL);
        CORBA_exception_free (&ev);
        return FALSE;
    }


    vector = bonobo_config_get_string (db, "My-Evolution/RDF/rdf_urls", &ev);
    if (BONOBO_EX (&ev)) {
        g_warning ("Error getting RDF/rdf_urls");
        CORBA_exception_free (&ev);
        bonobo_object_release_unref (db, NULL);
        return FALSE;
    }
    prefs->rdf_urls = str_list_from_vector (vector);
    g_free (vector);

    prefs->rdf_refresh_time = bonobo_config_get_long_with_default (db, "My-Evolution/RDF/rdf_refresh_time", 600, NULL);

    prefs->limit = bonobo_config_get_long_with_default (db, "My-Evolution/RDF/limit", 10, NULL);

    vector = bonobo_config_get_string (db, "My-Evolution/Weather/stations", &ev);
    if (BONOBO_EX (&ev)) {
        g_warning ("Error getting Weather/stations");
        CORBA_exception_free (&ev);
        bonobo_object_release_unref (db, NULL);
        return FALSE;
    }
    prefs->stations = str_list_from_vector (vector);
    g_free (vector);

    prefs->units = bonobo_config_get_long (db, "My-Evolution/Weather/units", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Weather/units. Using defaults");
        bonobo_object_release_unref (db, NULL);
        CORBA_exception_free (&ev);
        return FALSE;
    }

    prefs->weather_refresh_time = bonobo_config_get_long (db, "My-Evolution/Weather/weather_refresh_time", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Weather/weather_refresh_time. Using defaults");
        bonobo_object_release_unref (db, NULL);
        CORBA_exception_free (&ev);
        return FALSE;
    }

    
    prefs->days = bonobo_config_get_long (db, "My-Evolution/Schedule/days", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Schedule/days. Using defaults");
        bonobo_object_release_unref (db, NULL);
        CORBA_exception_free (&ev);
        return FALSE;
    }

    prefs->show_tasks = bonobo_config_get_long (db, "My-Evolution/Schedule/show_tasks", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Error getting Schedule/show_tasks. Using defaults");
        bonobo_object_release_unref (db, NULL);
        CORBA_exception_free (&ev);
        return FALSE;
    }

    bonobo_object_release_unref (db, NULL);
    return TRUE;
}

/* Write prefs to disk */
void
e_summary_preferences_save (ESummaryPrefs *prefs)
{
    Bonobo_ConfigDatabase db;
    CORBA_Environment ev;
    char *vector;

    g_return_if_fail (prefs != NULL);

    CORBA_exception_init (&ev);
    db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
    if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
        g_warning ("Cannot save preferences");
        CORBA_exception_free (&ev);
        return;
    }
    CORBA_exception_free (&ev);

    vector = vector_from_str_list (prefs->display_folders);
    bonobo_config_set_string (db, "My-Evolution/Mail/display_folders", vector, NULL);
    g_free (vector); 

    bonobo_config_set_boolean (db, "My-Evolution/Mail/show_full_path", prefs->show_full_path, NULL);

    vector = vector_from_str_list (prefs->rdf_urls);
    bonobo_config_set_string (db, "My-Evolution/RDF/rdf_urls", vector, NULL);
    g_free (vector); 

    bonobo_config_set_long (db, "My-Evolution/RDF/rdf_refresh_time", prefs->rdf_refresh_time, NULL);
    bonobo_config_set_long (db, "My-Evolution/RDF/limit", prefs->limit, NULL);

    vector = vector_from_str_list (prefs->stations);
    bonobo_config_set_string (db, "My-Evolution/Weather/stations", vector, NULL);
    g_free (vector); 

    bonobo_config_set_long (db, "My-Evolution/Weather/units", prefs->units, NULL);
    bonobo_config_set_long (db, "My-Evolution/Weather/weather_refresh_time", prefs->weather_refresh_time, NULL);

    bonobo_config_set_long (db, "My-Evolution/Schedule/days", prefs->days, NULL);
    bonobo_config_set_long (db, "My-Evolution/Schedule/show_tasks", prefs->show_tasks, NULL);

    CORBA_exception_init (&ev);
    Bonobo_ConfigDatabase_sync (db, &ev);
    CORBA_exception_free (&ev);

    bonobo_object_release_unref (db, NULL);
}

static void
free_str_list (GList *list)
{
    for (; list; list = list->next) {
        g_free (list->data);
    }
}

void
e_summary_preferences_free (ESummaryPrefs *prefs)
{
    if (prefs->display_folders) {
        free_str_list (prefs->display_folders);
        g_list_free (prefs->display_folders);
    }

    if (prefs->rdf_urls) {
        free_str_list (prefs->rdf_urls);
        g_list_free (prefs->rdf_urls);
    }

    if (prefs->stations) {
        free_str_list (prefs->stations);
        g_list_free (prefs->stations);
    }

    g_free (prefs);
}

static GList *
copy_str_list (GList *list)
{
    GList *list_copy = NULL;

    for (; list; list = list->next) {
        list_copy = g_list_prepend (list_copy, g_strdup (list->data));
    }

    list_copy = g_list_reverse (list_copy);
    return list_copy;
}

ESummaryPrefs *
e_summary_preferences_copy (ESummaryPrefs *prefs)
{
    ESummaryPrefs *prefs_copy;

    prefs_copy = g_new (ESummaryPrefs, 1);

    prefs_copy->display_folders = copy_str_list (prefs->display_folders);
    prefs_copy->show_full_path = prefs->show_full_path;

    prefs_copy->rdf_urls = copy_str_list (prefs->rdf_urls);
    prefs_copy->rdf_refresh_time = prefs->rdf_refresh_time;
    prefs_copy->limit = prefs->limit;

    prefs_copy->stations = copy_str_list (prefs->stations);
    prefs_copy->units = prefs->units;
    prefs_copy->weather_refresh_time = prefs->weather_refresh_time;

    prefs_copy->days = prefs->days;
    prefs_copy->show_tasks = prefs->show_tasks;

    return prefs_copy;
}

void
e_summary_preferences_init (ESummary *summary)
{
    ESummaryPrefs *prefs;

    g_return_if_fail (summary != NULL);
    g_return_if_fail (IS_E_SUMMARY (summary));

    summary->preferences = g_new0 (ESummaryPrefs, 1);
    summary->old_prefs = NULL;

    if (e_summary_preferences_restore (summary->preferences) == TRUE) {
        return;
    }

    prefs = summary->preferences;
    /* Defaults */
    
    /* Mail */
    make_initial_mail_list (prefs);

    /* RDF */
    make_initial_rdf_list (prefs);
    prefs->rdf_refresh_time = 600;
    prefs->limit = 10;

    /* Weather */
    make_initial_weather_list (prefs);
    prefs->units = UNITS_METRIC;
    prefs->weather_refresh_time = 600;

    prefs->days = E_SUMMARY_CALENDAR_ONE_DAY;
    prefs->show_tasks = E_SUMMARY_CALENDAR_ALL_TASKS;
}

struct _MailPage {
    GtkWidget *etable;
    GtkWidget *all, *shown;
    GtkWidget *fullpath;
    GtkWidget *add, *remove;

    GHashTable *model;
    GList *tmp_list;
};

struct _RDFPage {
    GtkWidget *etable;
    GtkWidget *refresh, *limit;
    GtkWidget *new_url, *delete_url;

    GHashTable *default_hash, *model;
    GList *known, *tmp_list;
};

struct _WeatherPage {
    GtkWidget *etable;
    GtkWidget *refresh, *imperial, *metric;
    GtkWidget *add, *remove;

    GHashTable *model;
    GList *tmp_list;
};

struct _CalendarPage {
    GtkWidget *one, *five, *week, *month;
    GtkWidget *all, *today;
};

typedef struct _PropertyData {
    ESummary *summary;
    GnomePropertyBox *box;
    GtkWidget *new_url_entry, *new_name_entry;
    GladeXML *xml;

    struct _MailPage *mail;
    struct _RDFPage *rdf;
    struct _WeatherPage *weather;
    struct _CalendarPage *calendar;
} PropertyData;

struct _RDFInfo {
    char *url;
    char *name;

    gboolean custom;
};

static struct _RDFInfo rdfs[] = {
    {"http://advogato.org/rss/articles.xml", "Advogato", FALSE},
    {"http://barrapunto.com/barrapunto.rdf", "Barrapunto", FALSE},
    {"http://barrapunto.com/gnome.rdf", "Barrapunto GNOME", FALSE,},
    {"http://www.bsdtoday.com/backend/bt.rdf", "BSD Today", FALSE},
    {"http://beyond2000.com/b2k.rdf", "Beyond 2000", FALSE},
    {"http://www.cnn.com/cnn.rss", "CNN", FALSE},
        {"http://www.debianplanet.org/debianplanet/backend.php", "Debian Planet", FALSE},
    {"http://www.dictionary.com/wordoftheday/wotd.rss", N_("Dictionary.com Word of the Day"), FALSE},
    {"http://www.dvdreview.com/rss/newschannel.rss", "DVD Review", FALSE},
    {"http://freshmeat.net/backend/fm.rdf", "Freshmeat", FALSE},
    {"http://news.gnome.org/gnome-news/rdf", "GNotices", FALSE},
    {"http://headlines.internet.com/internetnews/prod-news/news.rss", "Internet.com", FALSE},
    {"http://www.hispalinux.es/backend.php", "HispaLinux", FALSE},
    {"http://dot.kde.org/rdf", "KDE Dot News", FALSE},
    {"http://www.kuro5hin.org/backend.rdf", "Kuro5hin", FALSE},
    {"http://linuxgames.com/bin/mynetscape.pl", "Linux Games", FALSE},
    {"http://linux.com/mrn/jobs/latest_jobs.rss", "Linux Jobs", FALSE},
    {"http://linuxtoday.com/backend/my-netscape.rdf", "Linux Today", FALSE},
    {"http://lwn.net/headlines/rss", "Linux Weekly News", FALSE},
    {"http://www.linux.com/mrn/front_page.rss", "Linux.com", FALSE},
    {"http://memepool.com/memepool.rss", "Memepool", FALSE},
    {"http://www.mozilla.org/news.rdf", "Mozilla", FALSE},
    {"http://www.mozillazine.org/contents.rdf", "Mozillazine", FALSE},
    {"http://www.fool.com/about/headlines/rss_headlines.asp", "The Motley Fool", FALSE},
    {"http://www.newsforge.com/newsforge.rss", "Newsforge", FALSE},
    {"http://www.nanotechnews.com/nano/rdf", "Nanotech News", FALSE},
    {"http://www.pigdog.org/pigdog.rdf", "Pigdog", FALSE},
    {"http://www.python.org/channews.rdf", "Python.org", FALSE},
    {"http://www.quotationspage.com/data/mqotd.rss", N_("Quotes of the Day"), FALSE},
    {"http://www.salon.com/feed/RDF/salon_use.rdf", "Salon", FALSE},
    {"http://slashdot.org/slashdot.rdf", "Slashdot", FALSE},
    {"http://www.theregister.co.uk/tonys/slashdot.rdf", "The Register", FALSE},
    {"http://www.thinkgeek.com/thinkgeek.rdf", "Think Geek", FALSE},
    {"http://www.webreference.com/webreference.rdf", "Web Reference", FALSE},
    {"http://redcarpet.ximian.com/red-carpet.rdf", "Ximian Red Carpet New", FALSE},
    {NULL, NULL, FALSE}
};

static void
free_rdf_info (struct _RDFInfo *info)
{
    g_free (info->url);
    g_free (info->name);
    g_free (info);
}

static const char *
find_name_for_url (PropertyData *pd,
           const char *url)
{
    GList *p;

    for (p = pd->rdf->known; p; p = p->next) {
        struct _RDFInfo *info = p->data;
        
        if (info == NULL || info->url == NULL) {
            continue;
        }

        if (strcmp (url, info->url) == 0) {
            return info->name;
        }
    }

    return url;
}

static void
save_known_rdfs (GList *rdfs)
{
    FILE *handle;
    char *rdf_file;

    rdf_file = gnome_util_prepend_user_home ("evolution/RDF-urls.txt");
    handle = fopen (rdf_file, "w");
    g_free (rdf_file);

    if (handle == NULL) {
        g_warning ("Error opening RDF-urls.txt");
        return;
    }

    for (; rdfs; rdfs = rdfs->next) {
        struct _RDFInfo *info;
        char *line;
        
        info = rdfs->data;
        if (info->custom == FALSE) {
            continue;
        }
        
        line = g_strconcat (info->url, ",", info->name, "\n", NULL);
        fputs (line, handle);
        g_free (line);
    }

    fclose (handle);
}

/* Yeah a silly loop, but p should be short enough that it doesn't matter much */
static gboolean
rdf_is_shown (PropertyData *pd,
          const char *url)
{
    GList *p;

    for (p = pd->summary->preferences->rdf_urls; p; p = p->next) {
        if (strcmp (p->data, url) == 0) {
            return TRUE;
        }
    }

    return FALSE;
}

static void
fill_rdf_etable (GtkWidget *widget,
         PropertyData *pd)
{
    ESummaryTableModelEntry *entry;
    ESummaryTable *est;
    FILE *handle;
    int i, total;
    char *rdf_file, line[4096];

    if (pd->rdf->default_hash == NULL) {
        pd->rdf->default_hash = g_hash_table_new (g_str_hash, g_str_equal);
    }

    est = E_SUMMARY_TABLE (widget);

    /* Fill the defaults first */
    for (i = 0; rdfs[i].url; i++) {
        ETreePath path;

        path = e_summary_table_add_node (est, NULL, i, NULL);

        entry = g_new (ESummaryTableModelEntry, 1);
        entry->path = path;
        entry->location = g_strdup (rdfs[i].url);
        entry->name = g_strdup (rdfs[i].name);
        entry->editable = TRUE;
        entry->removable = FALSE;
        entry->shown = rdf_is_shown (pd, entry->location);
        g_hash_table_insert (est->model, entry->path, entry);

        pd->rdf->known = g_list_append (pd->rdf->known, &rdfs[i]);

        g_hash_table_insert (pd->rdf->default_hash, rdfs[i].url, &rdfs[i]);
    }

    total = i;

    rdf_file = gnome_util_prepend_user_home ("evolution/RDF-urls.txt");
    handle = fopen (rdf_file, "r");
    g_free (rdf_file);
    if (handle == NULL) {
        /* Open the old location just so that users data isn't lost */
        rdf_file = gnome_util_prepend_user_home ("evolution/config/RDF-urls.txt");
        handle = fopen (rdf_file, "r");
        g_free (rdf_file);
    }

    if (handle == NULL) {
        return;
    }

    while (fgets (line, 4095, handle)) {
        ETreePath path;
        char **tokens;
        struct _RDFInfo *info;
        int len;

        len = strlen (line);
        if (line[len - 1] == '\n') {
            line[len - 1] = 0;
        }

        tokens = g_strsplit (line, ",", 2);
        if (tokens == NULL) {
            continue;
        }

        if (g_hash_table_lookup (pd->rdf->default_hash, tokens[0]) != NULL) {
            g_strfreev (tokens);
            continue;
        }
        
        info = g_new (struct _RDFInfo, 1);
        info->url = g_strdup (tokens[0]);
        info->name = g_strdup (tokens[1]);
        info->custom = TRUE;
        
        pd->rdf->known = g_list_append (pd->rdf->known, info);

        path = e_summary_table_add_node (est, NULL, total++, NULL);
        entry = g_new (ESummaryTableModelEntry, 1);
        entry->path = path;
        entry->location = g_strdup (info->url);
        entry->name = g_strdup (info->name);
        entry->editable = TRUE;
        entry->removable = TRUE;
        entry->shown = rdf_is_shown (pd, entry->location);
        g_hash_table_insert (est->model, entry->path, entry);
                
        g_strfreev (tokens);
    }

    fclose (handle);
}

static void
fill_weather_etable (ESummaryTable *est,
             PropertyData *pd)
{
    e_summary_weather_fill_etable (est, pd->summary);
}

static void
fill_mail_etable (ESummaryTable *est,
          PropertyData *pd)
{
    e_summary_mail_fill_list (est, pd->summary);
}

static void
mail_show_full_path_toggled_cb (GtkToggleButton *tb,
                PropertyData *pd)
{
    pd->summary->preferences->show_full_path = gtk_toggle_button_get_active (tb);
    gnome_property_box_changed (pd->box);
}

#if 0
static void
add_dialog_clicked_cb (GnomeDialog *dialog,
               int button,
               PropertyData *pd)
{
    struct _RDFInfo *info;
    char *url, *name;
    char *text[1];
    int row;

    if (button == 1) {
        gnome_dialog_close (dialog);
        return;
    }

    url = gtk_entry_get_text (GTK_ENTRY (pd->new_url_entry));
    if (url == NULL || *text == 0) {
        gnome_dialog_close (dialog);
        return;
    }
    name = gtk_entry_get_text (GTK_ENTRY (pd->new_name_entry));
    info = g_new (struct _RDFInfo, 1);
    info->url = g_strdup (url);
    info->name = name ? g_strdup (name) : g_strdup (url);

    text[0] = info->name;
    row = gtk_clist_append (GTK_CLIST (pd->rdf->all), text);
    gtk_clist_set_row_data_full (GTK_CLIST (pd->rdf->all), row, info,
                     (GdkDestroyNotify) free_rdf_info);
    pd->rdf->known = g_list_append (pd->rdf->known, info);

    save_known_rdfs (pd->rdf->known);
    pd->summary->preferences->rdf_urls = g_list_prepend (pd->summary->preferences->rdf_urls, g_strdup (info->url));
    row = gtk_clist_prepend (GTK_CLIST (pd->rdf->shown), text);
    gtk_clist_set_row_data (GTK_CLIST (pd->rdf->shown), row,
                pd->summary->preferences->rdf_urls);


    gnome_property_box_changed (pd->box);
    gnome_dialog_close (dialog);
}

static void
rdf_new_url_clicked_cb (GtkButton *button,
            PropertyData *pd)
{
    static GtkWidget *add_dialog = NULL;
    GtkWidget *label, *hbox;

    if (add_dialog != NULL) {
        gdk_window_raise (add_dialog->window);
        gdk_window_show (add_dialog->window);
        return;
    } 

    add_dialog = gnome_dialog_new (_("Add a news feed"),
                       GNOME_STOCK_BUTTON_OK,
                       GNOME_STOCK_BUTTON_CANCEL, NULL);
    gtk_signal_connect (GTK_OBJECT (add_dialog), "clicked",
                GTK_SIGNAL_FUNC (add_dialog_clicked_cb), pd);
    gtk_signal_connect (GTK_OBJECT (add_dialog), "destroy",
                GTK_SIGNAL_FUNC (gtk_widget_destroyed), &add_dialog);

    label = gtk_label_new (_("Enter the URL of the news feed you wish to add"));
    gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), label,
                TRUE, TRUE, 0);
    hbox = gtk_hbox_new (FALSE, 2);
    label = gtk_label_new (_("Name:"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    pd->new_name_entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (hbox), pd->new_name_entry, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), hbox,
                TRUE, TRUE, 0);

    hbox = gtk_hbox_new (FALSE, 2);
    label = gtk_label_new (_("URL:"));
    pd->new_url_entry = gtk_entry_new ();
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), pd->new_url_entry, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), 
                hbox, TRUE, TRUE, 0);
    gtk_widget_show_all (add_dialog);
}
#endif

static void
rdf_refresh_value_changed_cb (GtkAdjustment *adj,
                  PropertyData *pd)
{
    pd->summary->preferences->rdf_refresh_time = (int) adj->value;
    gnome_property_box_changed (pd->box);
}

static void
rdf_limit_value_changed_cb (GtkAdjustment *adj,
                PropertyData *pd)
{
    pd->summary->preferences->limit = (int) adj->value;
    gnome_property_box_changed (pd->box);
}

static void
mail_etable_item_changed_cb (ESummaryTable *est,
                 ETreePath path,
                 PropertyData *pd)
{
    gnome_property_box_changed (pd->box);
}

static void
rdf_etable_item_changed_cb (ESummaryTable *est,
                ETreePath path,
                PropertyData *pd)
{
    gnome_property_box_changed (pd->box);
}

static void
weather_etable_item_changed_cb (ESummaryTable *est,
                ETreePath path,
                PropertyData *pd)
{
    gnome_property_box_changed (pd->box);
}

static void
weather_refresh_value_changed_cb (GtkAdjustment *adj,
                  PropertyData *pd)
{
    pd->summary->preferences->weather_refresh_time = (int) adj->value;
    gnome_property_box_changed (pd->box);
}

static void
weather_metric_toggled_cb (GtkToggleButton *tb,
               PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->units = UNITS_METRIC;
    gnome_property_box_changed (pd->box);
}

static void
weather_imperial_toggled_cb (GtkToggleButton *tb,
                 PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->units = UNITS_IMPERIAL;
    gnome_property_box_changed (pd->box);
}


static void
calendar_one_toggled_cb (GtkToggleButton *tb,
             PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->days = E_SUMMARY_CALENDAR_ONE_DAY;
    gnome_property_box_changed (pd->box);
}

static void
calendar_five_toggled_cb (GtkToggleButton *tb,
              PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->days = E_SUMMARY_CALENDAR_FIVE_DAYS;
    gnome_property_box_changed (pd->box);
}

static void
calendar_week_toggled_cb (GtkToggleButton *tb,
              PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->days = E_SUMMARY_CALENDAR_ONE_WEEK;
    gnome_property_box_changed (pd->box);
}

static void
calendar_month_toggled_cb (GtkToggleButton *tb,
               PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->days = E_SUMMARY_CALENDAR_ONE_MONTH;
    gnome_property_box_changed (pd->box);
}

static void
calendar_all_toggled_cb (GtkToggleButton *tb,
             PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->show_tasks = E_SUMMARY_CALENDAR_ALL_TASKS;
    gnome_property_box_changed (pd->box);
}

static void
calendar_today_toggled_cb (GtkToggleButton *tb,
               PropertyData *pd)
{
    if (gtk_toggle_button_get_active (tb) == FALSE) {
        return;
    }

    pd->summary->preferences->show_tasks = E_SUMMARY_CALENDAR_TODAYS_TASKS;
    gnome_property_box_changed (pd->box);
}

static gboolean
make_property_dialog (PropertyData *pd)
{
    struct _MailPage *mail;
    struct _RDFPage *rdf;
    struct _WeatherPage *weather;
    struct _CalendarPage *calendar;

    /* Mail */
    mail = pd->mail = g_new (struct _MailPage, 1);
    mail->tmp_list = NULL;
    
    mail->etable = glade_xml_get_widget (pd->xml, "mail-custom");
    g_return_val_if_fail (mail->etable != NULL, FALSE);

    gtk_signal_connect (GTK_OBJECT (mail->etable), "item-changed",
                GTK_SIGNAL_FUNC (mail_etable_item_changed_cb), pd);
    
    mail->model = E_SUMMARY_TABLE (mail->etable)->model;
    fill_mail_etable (E_SUMMARY_TABLE (mail->etable), pd);
    
    mail->fullpath = glade_xml_get_widget (pd->xml, "checkbutton1");
    g_return_val_if_fail (mail->fullpath != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mail->fullpath),
                      pd->summary->preferences->show_full_path);
    gtk_signal_connect (GTK_OBJECT (mail->fullpath), "toggled",
                GTK_SIGNAL_FUNC (mail_show_full_path_toggled_cb), pd);

    /* RDF */
    rdf = pd->rdf = g_new (struct _RDFPage, 1);
    rdf->known = NULL;
    rdf->tmp_list = NULL;
    rdf->default_hash = NULL;
    
    rdf->etable = glade_xml_get_widget (pd->xml, "rdf-custom");
    g_return_val_if_fail (rdf->etable != NULL, FALSE);

    gtk_signal_connect (GTK_OBJECT (rdf->etable), "item-changed",
                GTK_SIGNAL_FUNC (rdf_etable_item_changed_cb), pd);

    rdf->model = E_SUMMARY_TABLE (rdf->etable)->model;

    fill_rdf_etable (rdf->etable, pd);
    
    rdf->refresh = glade_xml_get_widget (pd->xml, "spinbutton1");
    g_return_val_if_fail (rdf->refresh != NULL, FALSE);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (rdf->refresh),
                   (float) pd->summary->preferences->rdf_refresh_time);
    gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (rdf->refresh)->adjustment), "value_changed",
                GTK_SIGNAL_FUNC (rdf_refresh_value_changed_cb), pd);

    rdf->limit = glade_xml_get_widget (pd->xml, "spinbutton4");
    g_return_val_if_fail (rdf->limit != NULL, FALSE);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (rdf->limit), 
                   (float) pd->summary->preferences->limit);
    gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (rdf->limit)->adjustment), "value_changed",
                GTK_SIGNAL_FUNC (rdf_limit_value_changed_cb), pd);

    /* Weather */
    weather = pd->weather = g_new (struct _WeatherPage, 1);
    weather->tmp_list = NULL;
    
    weather->etable = glade_xml_get_widget (pd->xml, "weather-custom");
    g_return_val_if_fail (weather->etable != NULL, FALSE);

    gtk_signal_connect (GTK_OBJECT (weather->etable), "item-changed",
                GTK_SIGNAL_FUNC (weather_etable_item_changed_cb),
                pd);
    weather->model = E_SUMMARY_TABLE (weather->etable)->model;

    fill_weather_etable (E_SUMMARY_TABLE (weather->etable), pd);

    weather->refresh = glade_xml_get_widget (pd->xml, "spinbutton5");
    g_return_val_if_fail (weather->refresh != NULL, FALSE);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (weather->refresh),
                   (float) pd->summary->preferences->weather_refresh_time);
    gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (weather->refresh)->adjustment),
                    "value-changed",
                    GTK_SIGNAL_FUNC (weather_refresh_value_changed_cb),
                    pd);

    weather->metric = glade_xml_get_widget (pd->xml, "radiobutton7");
    g_return_val_if_fail (weather->metric != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (weather->metric), (pd->summary->preferences->units == UNITS_METRIC));
    gtk_signal_connect (GTK_OBJECT (weather->metric), "toggled",
                GTK_SIGNAL_FUNC (weather_metric_toggled_cb), pd);

    weather->imperial = glade_xml_get_widget (pd->xml, "radiobutton8");
    g_return_val_if_fail (weather->imperial != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (weather->imperial), (pd->summary->preferences->units == UNITS_IMPERIAL));
    gtk_signal_connect (GTK_OBJECT (weather->imperial), "toggled",
                GTK_SIGNAL_FUNC (weather_imperial_toggled_cb), pd);

    /* Calendar */
    calendar = pd->calendar = g_new (struct _CalendarPage, 1);
    calendar->one = glade_xml_get_widget (pd->xml, "radiobutton3");
    g_return_val_if_fail (calendar->one != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->one),
                      (pd->summary->preferences->days == E_SUMMARY_CALENDAR_ONE_DAY));
    gtk_signal_connect (GTK_OBJECT (calendar->one), "toggled",
                GTK_SIGNAL_FUNC (calendar_one_toggled_cb), pd);

    calendar->five = glade_xml_get_widget (pd->xml, "radiobutton4");
    g_return_val_if_fail (calendar->five != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->five),
                      (pd->summary->preferences->days == E_SUMMARY_CALENDAR_FIVE_DAYS));
    gtk_signal_connect (GTK_OBJECT (calendar->five), "toggled",
                GTK_SIGNAL_FUNC (calendar_five_toggled_cb), pd);

    calendar->week = glade_xml_get_widget (pd->xml, "radiobutton5");
    g_return_val_if_fail (calendar->week != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->week),
                      (pd->summary->preferences->days == E_SUMMARY_CALENDAR_ONE_WEEK));
    gtk_signal_connect (GTK_OBJECT (calendar->week), "toggled",
                GTK_SIGNAL_FUNC (calendar_week_toggled_cb), pd);

    calendar->month = glade_xml_get_widget (pd->xml, "radiobutton6");
    g_return_val_if_fail (calendar->month != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->month),
                      (pd->summary->preferences->days == E_SUMMARY_CALENDAR_ONE_MONTH));
    gtk_signal_connect (GTK_OBJECT (calendar->month), "toggled",
                GTK_SIGNAL_FUNC (calendar_month_toggled_cb), pd);

    calendar->all = glade_xml_get_widget (pd->xml, "radiobutton1");
    g_return_val_if_fail (calendar->all != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->all),
                      (pd->summary->preferences->show_tasks == E_SUMMARY_CALENDAR_ALL_TASKS));
    gtk_signal_connect (GTK_OBJECT (calendar->all), "toggled",
                GTK_SIGNAL_FUNC (calendar_all_toggled_cb), pd);

    calendar->today = glade_xml_get_widget (pd->xml, "radiobutton2");
    g_return_val_if_fail (calendar->today != NULL, FALSE);
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (calendar->today),
                      (pd->summary->preferences->show_tasks == E_SUMMARY_CALENDAR_TODAYS_TASKS));
    gtk_signal_connect (GTK_OBJECT(calendar->today), "toggled",
                GTK_SIGNAL_FUNC (calendar_today_toggled_cb), pd);

    return TRUE;
}

static void
free_property_dialog (PropertyData *pd)
{
    if (pd->rdf) {
        g_list_free (pd->rdf->known);

        free_str_list (pd->rdf->tmp_list);
        g_list_free (pd->rdf->tmp_list);
        g_free (pd->rdf);
    }
    if (pd->mail) {
        free_str_list (pd->mail->tmp_list);
        g_list_free (pd->mail->tmp_list);
        g_free (pd->mail);
    }
    if (pd->weather) {
        free_str_list (pd->weather->tmp_list);
        g_list_free (pd->weather->tmp_list);
        g_free (pd->weather);
    }
    if (pd->calendar) {
        g_free (pd->calendar);
    }

    if (pd->xml) {
        gtk_object_unref (GTK_OBJECT (pd->xml));
    }
    if (pd->summary) {
        gtk_object_unref (GTK_OBJECT (pd->summary));
    }

    g_free (pd);
}

static void
maybe_add_to_shown (gpointer key,
            gpointer value,
            gpointer data)
{
    ESummaryTableModelEntry *item;
    GList **list;

    item = (ESummaryTableModelEntry *) value;
    list = (GList **) data;

    if (item->shown == TRUE) {
        *list = g_list_prepend (*list, g_strdup (item->location));
    }
}

static void
property_box_clicked_cb (GnomeDialog *dialog,
             int page_num,
             PropertyData *pd)
{
    if (page_num == -1) {

        /* RDFs */
        if (pd->rdf->tmp_list) {
            free_str_list (pd->rdf->tmp_list);
            g_list_free (pd->rdf->tmp_list);
            pd->rdf->tmp_list = NULL;
        }

        /* Take each news feed which is on and add it
           to the shown list */
        g_hash_table_foreach (pd->rdf->model, maybe_add_to_shown, &pd->rdf->tmp_list);

        if (pd->summary->preferences->rdf_urls) {
            free_str_list (pd->summary->preferences->rdf_urls);
            g_list_free (pd->summary->preferences->rdf_urls);
        }

        pd->summary->preferences->rdf_urls = copy_str_list (pd->rdf->tmp_list);

        /* Weather */
        if (pd->weather->tmp_list) {
            free_str_list (pd->weather->tmp_list);
            g_list_free (pd->weather->tmp_list);
            pd->weather->tmp_list = NULL;
        }
        g_hash_table_foreach (pd->weather->model, maybe_add_to_shown, &pd->weather->tmp_list);
        
        if (pd->summary->preferences->stations) {
            free_str_list (pd->summary->preferences->stations);
            g_list_free (pd->summary->preferences->stations);
        }
        pd->summary->preferences->stations = copy_str_list (pd->weather->tmp_list);
        
        /* Folders */
        if (pd->mail->tmp_list) {
            free_str_list (pd->mail->tmp_list);
            g_list_free (pd->mail->tmp_list);
            pd->mail->tmp_list = NULL;
        }
        g_hash_table_foreach (pd->mail->model, maybe_add_to_shown, &pd->mail->tmp_list);

        if (pd->summary->preferences->display_folders) {
            free_str_list (pd->summary->preferences->display_folders);
            g_list_free (pd->summary->preferences->display_folders);
        }
        pd->summary->preferences->display_folders = copy_str_list (pd->mail->tmp_list);
        
        e_summary_reconfigure (pd->summary);
    }
}

static void
property_box_destroy_cb (GtkObject *object,
             PropertyData *pd)
{
    if (pd->summary->old_prefs != NULL) {
        e_summary_preferences_free (pd->summary->old_prefs);
        pd->summary->old_prefs = NULL;
    }

    e_summary_preferences_save (pd->summary->preferences);
    pd->summary->prefs_window = NULL;
    free_property_dialog (pd);
}

/* Prototypes to shut gcc up */
GtkWidget *e_summary_preferences_make_mail_table (PropertyData *pd);
GtkWidget *e_summary_preferences_make_rdf_table (PropertyData *pd);
GtkWidget *e_summary_preferences_make_weather_table (PropertyData *pd);
GtkWidget *
e_summary_preferences_make_mail_table (PropertyData *pd)
{
    return e_summary_table_new (g_hash_table_new (NULL, NULL));
}

GtkWidget *
e_summary_preferences_make_rdf_table (PropertyData *pd)
{
    return e_summary_table_new (g_hash_table_new (NULL, NULL));
}

GtkWidget *
e_summary_preferences_make_weather_table (PropertyData *pd)
{
    return e_summary_table_new (g_hash_table_new (NULL, NULL));
}
    
void
e_summary_configure (BonoboUIComponent *component,
             gpointer userdata,
             const char *cname)
{
    ESummary *summary = userdata;
    PropertyData *pd;

    if (summary->prefs_window != NULL) {
        gdk_window_raise (summary->prefs_window->window);
        gdk_window_show (summary->prefs_window->window);
        return;
    }

    pd = g_new0 (PropertyData, 1);

    gtk_object_ref (GTK_OBJECT (summary));
    pd->summary = summary;

    if (summary->old_prefs != NULL) {
        e_summary_preferences_free (summary->old_prefs);
    }

    summary->old_prefs = e_summary_preferences_copy (summary->preferences);

    pd->xml = glade_xml_new (EVOLUTION_GLADEDIR "/my-evolution.glade", NULL);
    g_return_if_fail (pd->xml != NULL);

    pd->box = GNOME_PROPERTY_BOX (glade_xml_get_widget (pd->xml, "dialog1"));
    gtk_widget_hide (pd->box->help_button);
    summary->prefs_window = GTK_WIDGET (pd->box);

    gtk_window_set_title (GTK_WINDOW (pd->box), _("Summary Settings"));
    if (make_property_dialog (pd) == FALSE) {
        g_warning ("Missing some part of XML file");
        free_property_dialog (pd);
        return;
    }

    gtk_signal_connect (GTK_OBJECT (pd->box), "apply",
                GTK_SIGNAL_FUNC (property_box_clicked_cb), pd);
    gtk_signal_connect (GTK_OBJECT (pd->box), "destroy",
                GTK_SIGNAL_FUNC (property_box_destroy_cb), pd);
    gtk_widget_show (GTK_WIDGET (pd->box));
}