add gtkspell source files from stuphead + GtkText compatibility header
[claws.git] / src / prefs_customheader.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2001 Hiroyuki Yamamoto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include <gdk/gdkkeysyms.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <errno.h>
33
34 #include "intl.h"
35 #include "main.h"
36 #include "prefs.h"
37 #include "prefs_customheader.h"
38 #include "prefs_common.h"
39 #include "prefs_account.h"
40 #include "mainwindow.h"
41 #include "foldersel.h"
42 #include "manage_window.h"
43 #include "customheader.h"
44 #include "folder.h"
45 #include "utils.h"
46 #include "gtkutils.h"
47 #include "alertpanel.h"
48
49 static struct CustomHdr {
50         GtkWidget *window;
51
52         GtkWidget *ok_btn;
53         GtkWidget *cancel_btn;
54
55         GtkWidget *hdr_combo;
56         GtkWidget *hdr_entry;
57         GtkWidget *val_entry;
58         GtkWidget *customhdr_clist;
59 } customhdr;
60
61 #define VSPACING                12
62 #define VSPACING_NARROW         4
63 #define DEFAULT_ENTRY_WIDTH     80
64 #define PREFSBUFSIZE            1024
65
66 /* widget creating functions */
67 static void prefs_custom_header_create  (void);
68
69 static void prefs_custom_header_set_dialog      (PrefsAccount *ac);
70 static void prefs_custom_header_set_list        (PrefsAccount *ac);
71 static gint prefs_custom_header_clist_set_row   (PrefsAccount *ac,
72                                                  gint          row);
73
74 /* callback functions */
75 static void prefs_custom_header_add_cb          (void);
76 static void prefs_custom_header_delete_cb       (void);
77 static void prefs_custom_header_up              (void);
78 static void prefs_custom_header_down            (void);
79 static void prefs_custom_header_select          (GtkCList       *clist,
80                                                  gint            row,
81                                                  gint            column,
82                                                  GdkEvent       *event);
83
84 static void prefs_custom_header_row_moved       (GtkCList       *clist,
85                                                  gint            source_row,
86                                                  gint            dest_row,
87                                                  gpointer        data);
88
89 static void prefs_custom_header_key_pressed     (GtkWidget      *widget,
90                                                  GdkEventKey    *event,
91                                                  gpointer        data);
92 static void prefs_custom_header_ok              (void);
93 static void prefs_custom_header_cancel          (void);
94 static gint prefs_custom_header_deleted         (GtkWidget      *widget,
95                                                  GdkEventAny    *event,
96                                                  gpointer        data);
97
98 static PrefsAccount *cur_ac = NULL;
99
100 void prefs_custom_header_open(PrefsAccount *ac)
101 {
102         if (!customhdr.window) {
103                 prefs_custom_header_create();
104         }
105
106         manage_window_set_transient(GTK_WINDOW(customhdr.window));
107         gtk_widget_grab_focus(customhdr.ok_btn);
108
109         prefs_custom_header_set_dialog(ac);
110
111         cur_ac = ac;
112
113         gtk_widget_show(customhdr.window);
114 }
115
116 static void prefs_custom_header_create(void)
117 {
118         GtkWidget *window;
119         GtkWidget *vbox;
120
121         GtkWidget *ok_btn;
122         GtkWidget *cancel_btn;
123
124         GtkWidget *confirm_area;
125
126         GtkWidget *vbox1;
127
128         GtkWidget *table1;
129         GtkWidget *hdr_label;
130         GtkWidget *hdr_combo;
131         GtkWidget *val_label;
132         GtkWidget *val_entry;
133
134         GtkWidget *reg_hbox;
135         GtkWidget *btn_hbox;
136         GtkWidget *arrow;
137         GtkWidget *add_btn;
138         GtkWidget *del_btn;
139
140         GtkWidget *ch_hbox;
141         GtkWidget *ch_scrolledwin;
142         GtkWidget *customhdr_clist;
143
144         GtkWidget *btn_vbox;
145         GtkWidget *up_btn;
146         GtkWidget *down_btn;
147
148         gchar *title[] = {_("Custom headers")};
149
150         debug_print(_("Creating custom header setting window...\n"));
151
152         window = gtk_window_new (GTK_WINDOW_DIALOG);
153         gtk_container_set_border_width (GTK_CONTAINER (window), 8);
154         gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
155         gtk_window_set_modal (GTK_WINDOW (window), TRUE);
156         gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
157
158         vbox = gtk_vbox_new (FALSE, 6);
159         gtk_widget_show (vbox);
160         gtk_container_add (GTK_CONTAINER (window), vbox);
161
162         gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
163                                 &cancel_btn, _("Cancel"), NULL, NULL);
164         gtk_widget_show (confirm_area);
165         gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
166         gtk_widget_grab_default (ok_btn);
167
168         gtk_window_set_title (GTK_WINDOW(window), _("Custom header setting"));
169         gtk_signal_connect (GTK_OBJECT(window), "focus_in_event",
170                             GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
171         gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
172                             GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
173         gtk_signal_connect (GTK_OBJECT(window), "delete_event",
174                             GTK_SIGNAL_FUNC(prefs_custom_header_deleted),
175                             NULL);
176         gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
177                             GTK_SIGNAL_FUNC(prefs_custom_header_key_pressed),
178                             NULL);
179         gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
180                             GTK_SIGNAL_FUNC(prefs_custom_header_ok), NULL);
181         gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
182                             GTK_SIGNAL_FUNC(prefs_custom_header_cancel), NULL);
183
184         vbox1 = gtk_vbox_new (FALSE, VSPACING);
185         gtk_widget_show (vbox1);
186         gtk_box_pack_start (GTK_BOX (vbox), vbox1, TRUE, TRUE, 0);
187         gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
188
189         table1 = gtk_table_new (2, 2, FALSE);
190         gtk_widget_show (table1);
191         gtk_box_pack_start (GTK_BOX (vbox1), table1,
192                             FALSE, FALSE, 0);
193         gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
194         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
195
196         hdr_label = gtk_label_new (_("Header"));
197         gtk_widget_show (hdr_label);
198         gtk_table_attach (GTK_TABLE (table1), hdr_label, 0, 1, 0, 1,
199                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
200                           0, 0, 0);
201         gtk_misc_set_alignment (GTK_MISC (hdr_label), 0, 0.5);
202         
203         hdr_combo = gtk_combo_new ();
204         gtk_widget_show (hdr_combo);
205         gtk_table_attach (GTK_TABLE (table1), hdr_combo, 0, 1, 1, 2,
206                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
207                           0, 0, 0);
208         gtk_widget_set_usize (hdr_combo, 150, -1);
209         gtkut_combo_set_items (GTK_COMBO (hdr_combo),
210                                "User-Agent", "X-Face", "X-Operating-System",
211                                NULL);
212
213         val_label = gtk_label_new (_("Value"));
214         gtk_widget_show (val_label);
215         gtk_table_attach (GTK_TABLE (table1), val_label, 1, 2, 0, 1,
216                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
217                           0, 0, 0);
218         gtk_misc_set_alignment (GTK_MISC (val_label), 0, 0.5);
219         
220         val_entry = gtk_entry_new ();
221         gtk_widget_show (val_entry);
222         gtk_table_attach (GTK_TABLE (table1), val_entry, 1, 2, 1, 2,
223                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
224                           0, 0, 0);
225         gtk_widget_set_usize (val_entry, 200, -1);
226
227         /* add / delete */
228
229         reg_hbox = gtk_hbox_new (FALSE, 4);
230         gtk_widget_show (reg_hbox);
231         gtk_box_pack_start (GTK_BOX (vbox1), reg_hbox, FALSE, FALSE, 0);
232
233         arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
234         gtk_widget_show (arrow);
235         gtk_box_pack_start (GTK_BOX (reg_hbox), arrow, FALSE, FALSE, 0);
236         gtk_widget_set_usize (arrow, -1, 16);
237
238         btn_hbox = gtk_hbox_new (TRUE, 4);
239         gtk_widget_show (btn_hbox);
240         gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
241
242         add_btn = gtk_button_new_with_label (_("Add"));
243         gtk_widget_show (add_btn);
244         gtk_box_pack_start (GTK_BOX (btn_hbox), add_btn, FALSE, TRUE, 0);
245         gtk_signal_connect (GTK_OBJECT (add_btn), "clicked",
246                             GTK_SIGNAL_FUNC (prefs_custom_header_add_cb),
247                             NULL);
248
249         del_btn = gtk_button_new_with_label (_(" Delete "));
250         gtk_widget_show (del_btn);
251         gtk_box_pack_start (GTK_BOX (btn_hbox), del_btn, FALSE, TRUE, 0);
252         gtk_signal_connect (GTK_OBJECT (del_btn), "clicked",
253                             GTK_SIGNAL_FUNC (prefs_custom_header_delete_cb),
254                             NULL);
255
256
257         ch_hbox = gtk_hbox_new (FALSE, 8);
258         gtk_widget_show (ch_hbox);
259         gtk_box_pack_start (GTK_BOX (vbox1), ch_hbox, TRUE, TRUE, 0);
260
261         ch_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
262         gtk_widget_set_usize (ch_scrolledwin, -1, 200);
263         gtk_widget_show (ch_scrolledwin);
264         gtk_box_pack_start (GTK_BOX (ch_hbox), ch_scrolledwin, TRUE, TRUE, 0);
265         gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ch_scrolledwin),
266                                         GTK_POLICY_AUTOMATIC,
267                                         GTK_POLICY_AUTOMATIC);
268
269         customhdr_clist = gtk_clist_new_with_titles(1, title);
270         gtk_widget_show (customhdr_clist);
271         gtk_container_add (GTK_CONTAINER (ch_scrolledwin), customhdr_clist);
272         gtk_clist_set_column_width (GTK_CLIST (customhdr_clist), 0, 80);
273         gtk_clist_set_selection_mode (GTK_CLIST (customhdr_clist),
274                                       GTK_SELECTION_BROWSE);
275         gtk_clist_set_reorderable (GTK_CLIST (customhdr_clist), TRUE);
276         gtk_clist_set_use_drag_icons (GTK_CLIST (customhdr_clist), FALSE);
277         GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (customhdr_clist)->column[0].button,
278                                 GTK_CAN_FOCUS);
279         gtk_signal_connect (GTK_OBJECT (customhdr_clist), "select_row",
280                             GTK_SIGNAL_FUNC (prefs_custom_header_select),
281                             NULL);
282         gtk_signal_connect_after
283                 (GTK_OBJECT (customhdr_clist), "row_move",
284                  GTK_SIGNAL_FUNC (prefs_custom_header_row_moved), NULL);
285
286         btn_vbox = gtk_vbox_new (FALSE, 8);
287         gtk_widget_show (btn_vbox);
288         gtk_box_pack_start (GTK_BOX (ch_hbox), btn_vbox, FALSE, FALSE, 0);
289
290         up_btn = gtk_button_new_with_label (_("Up"));
291         gtk_widget_show (up_btn);
292         gtk_box_pack_start (GTK_BOX (btn_vbox), up_btn, FALSE, FALSE, 0);
293         gtk_signal_connect (GTK_OBJECT (up_btn), "clicked",
294                             GTK_SIGNAL_FUNC (prefs_custom_header_up), NULL);
295
296         down_btn = gtk_button_new_with_label (_("Down"));
297         gtk_widget_show (down_btn);
298         gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
299         gtk_signal_connect (GTK_OBJECT (down_btn), "clicked",
300                             GTK_SIGNAL_FUNC (prefs_custom_header_down), NULL);
301
302         gtk_widget_show_all(window);
303
304         customhdr.window     = window;
305         customhdr.ok_btn     = ok_btn;
306         customhdr.cancel_btn = cancel_btn;
307
308         customhdr.hdr_combo  = hdr_combo;
309         customhdr.hdr_entry  = GTK_COMBO (hdr_combo)->entry;
310         customhdr.val_entry  = val_entry;
311
312         customhdr.customhdr_clist   = customhdr_clist;
313 }
314
315 void prefs_custom_header_read_config(PrefsAccount *ac)
316 {
317         gchar *rcpath;
318         FILE *fp;
319         gchar buf[PREFSBUFSIZE];
320         CustomHeader *ch;
321
322         debug_print(_("Reading custom header configuration...\n"));
323
324         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
325                              CUSTOM_HEADER_RC, NULL);
326         if ((fp = fopen(rcpath, "r")) == NULL) {
327                 if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
328                 g_free(rcpath);
329                 ac->customhdr_list = NULL;
330                 return;
331         }
332         g_free(rcpath);
333
334         /* remove all previous headers list */
335         while (ac->customhdr_list != NULL) {
336                 ch = (CustomHeader *)ac->customhdr_list->data;
337                 custom_header_free(ch);
338                 ac->customhdr_list = g_slist_remove(ac->customhdr_list, ch);
339         }
340
341         while (fgets(buf, sizeof(buf), fp) != NULL) {
342                 g_strchomp(buf);
343                 ch = custom_header_read_str(buf);
344                 if (ch) {
345                         if (ch->account_id == ac->account_id) {
346                                 ac->customhdr_list =
347                                         g_slist_append(ac->customhdr_list, ch);
348                         } else
349                                 custom_header_free(ch);
350                 }
351         }
352
353         fclose(fp);
354 }
355
356 void prefs_custom_header_write_config(PrefsAccount *ac)
357 {
358         gchar *rcpath;
359         PrefFile *pfile;
360         GSList *cur;
361         gchar buf[PREFSBUFSIZE];
362         FILE * fp;
363         CustomHeader *ch;
364
365         GSList *all_hdrs = NULL;
366
367         debug_print(_("Writing custom header configuration...\n"));
368
369         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
370                              CUSTOM_HEADER_RC, NULL);
371
372         if ((fp = fopen(rcpath, "r")) == NULL) {
373                 if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
374         } else {
375                 all_hdrs = NULL;
376
377                 while (fgets(buf, sizeof(buf), fp) != NULL) {
378                         g_strchomp(buf);
379                         ch = custom_header_read_str(buf);
380                         if (ch) {
381                                 if (ch->account_id != ac->account_id)
382                                         all_hdrs =
383                                                 g_slist_append(all_hdrs, ch);
384                                 else
385                                         custom_header_free(ch);
386                         }
387                 }
388
389                 fclose(fp);
390         }
391
392         if ((pfile = prefs_write_open(rcpath)) == NULL) {
393                 g_warning(_("failed to write configuration to file\n"));
394                 g_free(rcpath);
395                 return;
396         }
397
398         for (cur = all_hdrs; cur != NULL; cur = cur->next) {
399                 CustomHeader *hdr = (CustomHeader *)cur->data;
400                 gchar *chstr;
401
402                 chstr = custom_header_get_str(hdr);
403                 if (fputs(chstr, pfile->fp) == EOF ||
404                     fputc('\n', pfile->fp) == EOF) {
405                         FILE_OP_ERROR(rcpath, "fputs || fputc");
406                         prefs_write_close_revert(pfile);
407                         g_free(rcpath);
408                         g_free(chstr);
409                         return;
410                 }
411                 g_free(chstr);
412         }
413
414         for (cur = ac->customhdr_list; cur != NULL; cur = cur->next) {
415                 CustomHeader *hdr = (CustomHeader *)cur->data;
416                 gchar *chstr;
417
418                 chstr = custom_header_get_str(hdr);
419                 if (fputs(chstr, pfile->fp) == EOF ||
420                     fputc('\n', pfile->fp) == EOF) {
421                         FILE_OP_ERROR(rcpath, "fputs || fputc");
422                         prefs_write_close_revert(pfile);
423                         g_free(rcpath);
424                         g_free(chstr);
425                         return;
426                 }
427                 g_free(chstr);
428         }
429
430         g_free(rcpath);
431
432         while (all_hdrs != NULL) {
433                 ch = (CustomHeader *)all_hdrs->data;
434                 custom_header_free(ch);
435                 all_hdrs = g_slist_remove(all_hdrs, ch);
436         }
437
438         if (prefs_write_close(pfile) < 0) {
439                 g_warning(_("failed to write configuration to file\n"));
440                 return;
441         }
442 }
443
444 static void prefs_custom_header_set_dialog(PrefsAccount *ac)
445 {
446         GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
447         GSList *cur;
448         gchar *ch_str[1];
449         gint row;
450
451         gtk_clist_freeze(clist);
452         gtk_clist_clear(clist);
453
454         for (cur = ac->customhdr_list; cur != NULL; cur = cur->next) {
455                 CustomHeader *ch = (CustomHeader *)cur->data;
456
457                 ch_str[0] = g_strdup_printf("%s: %s", ch->name,
458                                             ch->value ? ch->value : "");
459                 row = gtk_clist_append(clist, ch_str);
460                 gtk_clist_set_row_data(clist, row, ch);
461
462                 g_free(ch_str[0]);
463         }
464
465         gtk_clist_thaw(clist);
466 }
467
468 static void prefs_custom_header_set_list(PrefsAccount *ac)
469 {
470         gint row = 0;
471         CustomHeader *ch;
472
473         g_slist_free(ac->customhdr_list);
474         ac->customhdr_list = NULL;
475
476         while ((ch = gtk_clist_get_row_data
477                 (GTK_CLIST(customhdr.customhdr_clist), row)) != NULL) {
478                 ac->customhdr_list = g_slist_append(ac->customhdr_list, ch);
479                 row++;
480         }
481 }
482
483 static gint prefs_custom_header_clist_set_row(PrefsAccount *ac, gint row)
484 {
485         GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
486         CustomHeader *ch;
487         gchar *entry_text;
488         gchar *ch_str[1];
489
490         entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.hdr_entry));
491         if (entry_text[0] == '\0') {
492                 alertpanel_error(_("Header name is not set."));
493                 return -1;
494         }
495
496         ch = g_new0(CustomHeader, 1);
497
498         ch->account_id = ac->account_id;
499
500         ch->name = g_strdup(entry_text);
501         unfold_line(ch->name);
502
503         entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.val_entry));
504         if (entry_text[0] != '\0') {
505                 ch->value = g_strdup(entry_text);
506                 unfold_line(ch->value);
507         }
508
509         ch_str[0] = g_strdup_printf("%s: %s", ch->name,
510                                     ch->value ? ch->value : "");
511
512         if (row < 0)
513                 row = gtk_clist_append(clist, ch_str);
514         else {
515                 CustomHeader *tmp_ch;
516
517                 gtk_clist_set_text(clist, row, 0, ch_str[0]);
518                 tmp_ch = gtk_clist_get_row_data(clist, row);
519                 if (tmp_ch)
520                         custom_header_free(tmp_ch);
521         }
522
523         gtk_clist_set_row_data(clist, row, ch);
524
525         g_free(ch_str[0]);
526
527         prefs_custom_header_set_list(cur_ac);
528
529         return row;
530 }
531
532 static void prefs_custom_header_add_cb(void)
533 {
534         prefs_custom_header_clist_set_row(cur_ac, -1);
535 }
536
537 static void prefs_custom_header_delete_cb(void)
538 {
539         GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
540         CustomHeader *ch;
541         gint row;
542
543         if (!clist->selection) return;
544         row = GPOINTER_TO_INT(clist->selection->data);
545
546         if (alertpanel(_("Delete header"),
547                        _("Do you really want to delete this header?"),
548                        _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
549                 return;
550
551         ch = gtk_clist_get_row_data(clist, row);
552         custom_header_free(ch);
553         gtk_clist_remove(clist, row);
554         cur_ac->customhdr_list = g_slist_remove(cur_ac->customhdr_list, ch);
555 }
556
557 static void prefs_custom_header_up(void)
558 {
559         GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
560         gint row;
561
562         if (!clist->selection) return;
563
564         row = GPOINTER_TO_INT(clist->selection->data);
565         if (row > 0)
566                 gtk_clist_row_move(clist, row, row - 1);
567 }
568
569 static void prefs_custom_header_down(void)
570 {
571         GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
572         gint row;
573
574         if (!clist->selection) return;
575
576         row = GPOINTER_TO_INT(clist->selection->data);
577         if (row >= 0 && row < clist->rows - 1)
578                 gtk_clist_row_move(clist, row, row + 1);
579 }
580
581 #define ENTRY_SET_TEXT(entry, str) \
582         gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
583
584 static void prefs_custom_header_select(GtkCList *clist, gint row, gint column,
585                                        GdkEvent *event)
586 {
587         CustomHeader *ch;
588         CustomHeader default_ch = { 0, "", NULL };
589
590         ch = gtk_clist_get_row_data(clist, row);
591         if (!ch) ch = &default_ch;
592
593         ENTRY_SET_TEXT(customhdr.hdr_entry, ch->name);
594         ENTRY_SET_TEXT(customhdr.val_entry, ch->value);
595 }
596
597 #undef ENTRY_SET_TEXT
598
599 static void prefs_custom_header_row_moved(GtkCList *clist, gint source_row,
600                                           gint dest_row, gpointer data)
601 {
602         prefs_custom_header_set_list(cur_ac);
603 }
604
605 static void prefs_custom_header_key_pressed(GtkWidget *widget,
606                                             GdkEventKey *event,
607                                             gpointer data)
608 {
609         if (event && event->keyval == GDK_Escape)
610                 prefs_custom_header_cancel();
611 }
612
613 static void prefs_custom_header_ok(void)
614 {
615         prefs_custom_header_write_config(cur_ac);
616         gtk_widget_hide(customhdr.window);
617 }
618
619 static void prefs_custom_header_cancel(void)
620 {
621         prefs_custom_header_read_config(cur_ac); 
622         gtk_widget_hide(customhdr.window);
623 }
624
625 static gint prefs_custom_header_deleted(GtkWidget *widget, GdkEventAny *event,
626                                         gpointer data)
627 {
628         prefs_custom_header_cancel();
629         return TRUE;
630 }