Statistics
| Revision:

root / src / prefs_display_header.c @ 1

History | View | Annotate | Download (17.2 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2004 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 "prefs.h"
36
#include "prefs_display_header.h"
37
#include "prefs_common.h"
38
#include "manage_window.h"
39
#include "alertpanel.h"
40
#include "displayheader.h"
41
#include "utils.h"
42
#include "gtkutils.h"
43

    
44
static struct DisplayHeader {
45
        GtkWidget *window;
46

    
47
        GtkWidget *ok_btn;
48
        GtkWidget *cancel_btn;
49

    
50
        GtkWidget *hdr_combo;
51
        GtkWidget *hdr_entry;
52
        GtkWidget *key_check;
53
        GtkWidget *headers_clist;
54
        GtkWidget *hidden_headers_clist;
55

    
56
        GtkWidget *other_headers;
57
} dispheader;
58

    
59
/* widget creating functions */
60
static void prefs_display_header_create        (void);
61

    
62
static void prefs_display_header_set_dialog        (void);
63
static void prefs_display_header_set_list        (void);
64
static gint prefs_display_header_clist_set_row        (gboolean hidden);
65

    
66
/* callback functions */
67
static void prefs_display_header_register_cb        (GtkButton        *btn,
68
                                                 gpointer         hidden_data);
69
static void prefs_display_header_delete_cb        (GtkButton        *btn,
70
                                                 gpointer         clist_data);
71
static void prefs_display_header_up                (void);
72
static void prefs_display_header_down                (void);
73

    
74
static void prefs_display_header_row_moved        (GtkCList        *clist,
75
                                                 gint                 source_row,
76
                                                 gint                 dest_row,
77
                                                 gpointer         data);
78

    
79
static gboolean prefs_display_header_key_pressed(GtkWidget        *widget,
80
                                                 GdkEventKey        *event,
81
                                                 gpointer         data);
82
static void prefs_display_header_ok                (void);
83
static void prefs_display_header_cancel                (void);
84
static gint prefs_display_header_deleted        (GtkWidget        *widget,
85
                                                 GdkEventAny        *event,
86
                                                 gpointer         data);
87

    
88
static gchar *defaults[] =
89
{
90
        "From",
91
        "To",
92
        "Cc",
93
        "Reply-To",
94
        "Newsgroups",
95
        "Followup-To",
96
        "Subject",
97
        "Date",
98
        "Sender",
99
        "Organization",
100
        "X-Mailer",
101
        "X-Newsreader",
102
        "User-Agent",
103
        "-Received",
104
        "-Message-Id",
105
        "-In-Reply-To",
106
        "-References",
107
        "-Mime-Version",
108
        "-Content-Type",
109
        "-Content-Transfer-Encoding",
110
        "-X-UIDL",
111
        "-Precedence",
112
        "-Status",
113
        "-Priority",
114
        "-X-Face"
115
};
116

    
117
static void prefs_display_header_set_default(void)
118
{
119
        gint i;
120
        DisplayHeaderProp *dp;
121

    
122
        for(i = 0; i < sizeof(defaults) / sizeof(defaults[0]); i++) {
123
                dp = display_header_prop_read_str(defaults[i]);
124
                prefs_common.disphdr_list =
125
                        g_slist_append(prefs_common.disphdr_list, dp);
126
        }
127
}
128

    
129
void prefs_display_header_open(void)
130
{
131
        if (!dispheader.window) {
132
                prefs_display_header_create();
133
        }
134

    
135
        manage_window_set_transient(GTK_WINDOW(dispheader.window));
136
        gtk_widget_grab_focus(dispheader.ok_btn);
137

    
138
        prefs_display_header_set_dialog();
139

    
140
        gtk_widget_show(dispheader.window);
141
}
142

    
143
static void prefs_display_header_create(void)
144
{
145
        GtkWidget *window;
146
        GtkWidget *vbox;
147
        GtkWidget *btn_hbox;
148
        GtkWidget *ok_btn;
149
        GtkWidget *cancel_btn;
150
        GtkWidget *confirm_area;
151

    
152
        GtkWidget *vbox1;
153

    
154
        GtkWidget *hbox1;
155
        GtkWidget *hdr_label;
156
        GtkWidget *hdr_combo;
157

    
158
        GtkWidget *btn_vbox;
159
        GtkWidget *reg_btn;
160
        GtkWidget *del_btn;
161
        GtkWidget *up_btn;
162
        GtkWidget *down_btn;
163

    
164
        GtkWidget *clist_hbox;
165
        GtkWidget *clist_hbox1;
166
        GtkWidget *clist_hbox2;
167
        GtkWidget *clist_scrolledwin;
168
        GtkWidget *headers_clist;
169
        GtkWidget *hidden_headers_clist;
170

    
171
        GtkWidget *checkbtn_other_headers;
172

    
173
        gchar *title[1];
174

    
175
        debug_print(_("Creating display header setting window...\n"));
176

    
177
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
178
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
179
        gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
180
        gtk_window_set_modal (GTK_WINDOW (window), TRUE);
181
        gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
182

    
183
        vbox = gtk_vbox_new (FALSE, 6);
184
        gtk_widget_show (vbox);
185
        gtk_container_add (GTK_CONTAINER (window), vbox);
186

    
187
        btn_hbox = gtk_hbox_new (FALSE, 8);
188
        gtk_widget_show (btn_hbox);
189
        gtk_box_pack_end (GTK_BOX (vbox), btn_hbox, FALSE, FALSE, 0);
190

    
191
        gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
192
                                &cancel_btn, _("Cancel"), NULL, NULL);
193
        gtk_widget_show (confirm_area);
194
        gtk_box_pack_end (GTK_BOX(btn_hbox), confirm_area, FALSE, FALSE, 0);
195
        gtk_widget_grab_default (ok_btn);
196

    
197
        gtk_window_set_title (GTK_WINDOW(window),
198
                              _("Display header setting"));
199
        MANAGE_WINDOW_SIGNALS_CONNECT(window);
200
        g_signal_connect (G_OBJECT(window), "delete_event",
201
                          G_CALLBACK(prefs_display_header_deleted), NULL);
202
        g_signal_connect (G_OBJECT(window), "key_press_event",
203
                          G_CALLBACK(prefs_display_header_key_pressed), NULL);
204
        g_signal_connect (G_OBJECT(ok_btn), "clicked",
205
                          G_CALLBACK(prefs_display_header_ok), NULL);
206
        g_signal_connect (G_OBJECT(cancel_btn), "clicked",
207
                          G_CALLBACK(prefs_display_header_cancel), NULL);
208

    
209
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
210
        gtk_widget_show (vbox1);
211
        gtk_box_pack_start (GTK_BOX (vbox), vbox1, TRUE, TRUE, 0);
212
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
213

    
214
        hbox1 = gtk_hbox_new (FALSE, 8);
215
        gtk_widget_show (hbox1);
216
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, TRUE, 0);
217

    
218
        hdr_label = gtk_label_new (_("Header name"));
219
        gtk_widget_show (hdr_label);
220
        gtk_box_pack_start (GTK_BOX (hbox1), hdr_label, FALSE, FALSE, 0);
221

    
222
        hdr_combo = gtk_combo_new ();
223
        gtk_widget_show (hdr_combo);
224
        gtk_box_pack_start (GTK_BOX (hbox1), hdr_combo, TRUE, TRUE, 0);
225
        gtk_widget_set_size_request (hdr_combo, 150, -1);
226
        gtkut_combo_set_items (GTK_COMBO (hdr_combo),
227
                               "From", "To", "Cc", "Subject", "Date",
228
                               "Reply-To", "Sender", "User-Agent", "X-Mailer",
229
                               NULL);
230

    
231
        clist_hbox = gtk_hbox_new (FALSE, 10);
232
        gtk_widget_show (clist_hbox);
233
        gtk_box_pack_start (GTK_BOX (vbox1), clist_hbox, TRUE, TRUE, 0);
234

    
235
        /* display headers list */
236

    
237
        clist_hbox1 = gtk_hbox_new (FALSE, 8);
238
        gtk_widget_show (clist_hbox1);
239
        gtk_box_pack_start (GTK_BOX (clist_hbox), clist_hbox1, TRUE, TRUE, 0);
240

    
241
        clist_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
242
        gtk_widget_set_size_request (clist_scrolledwin, 200, 210);
243
        gtk_widget_show (clist_scrolledwin);
244
        gtk_box_pack_start (GTK_BOX (clist_hbox1), clist_scrolledwin,
245
                            TRUE, TRUE, 0);
246
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (clist_scrolledwin),
247
                                        GTK_POLICY_AUTOMATIC,
248
                                        GTK_POLICY_AUTOMATIC);
249

    
250
        title[0] = _("Displayed Headers");
251
        headers_clist = gtk_clist_new_with_titles(1, title);
252
        gtk_widget_show (headers_clist);
253
        gtk_container_add (GTK_CONTAINER (clist_scrolledwin), headers_clist);
254
        gtk_clist_set_selection_mode (GTK_CLIST (headers_clist),
255
                                      GTK_SELECTION_BROWSE);
256
        gtk_clist_set_reorderable (GTK_CLIST (headers_clist), TRUE);
257
        gtk_clist_set_use_drag_icons (GTK_CLIST (headers_clist), FALSE);
258
        GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (headers_clist)->column[0].button,
259
                                GTK_CAN_FOCUS);
260
        g_signal_connect_after
261
                (G_OBJECT (headers_clist), "row_move",
262
                 G_CALLBACK (prefs_display_header_row_moved), NULL);
263

    
264
        btn_vbox = gtk_vbox_new (FALSE, 8);
265
        gtk_widget_show (btn_vbox);
266
        gtk_box_pack_start (GTK_BOX (clist_hbox1), btn_vbox, FALSE, FALSE, 0);
267

    
268
        reg_btn = gtk_button_new_with_label (_("Add"));
269
        gtk_widget_show (reg_btn);
270
        gtk_box_pack_start (GTK_BOX (btn_vbox), reg_btn, FALSE, TRUE, 0);
271
        g_signal_connect (G_OBJECT (reg_btn), "clicked",
272
                          G_CALLBACK (prefs_display_header_register_cb),
273
                          GINT_TO_POINTER(FALSE));
274
        del_btn = gtk_button_new_with_label (_("Delete"));
275
        gtk_widget_show (del_btn);
276
        gtk_box_pack_start (GTK_BOX (btn_vbox), del_btn, FALSE, TRUE, 0);
277
        g_signal_connect (G_OBJECT (del_btn), "clicked",
278
                          G_CALLBACK (prefs_display_header_delete_cb),
279
                          headers_clist);
280

    
281
        up_btn = gtk_button_new_with_label (_("Up"));
282
        gtk_widget_show (up_btn);
283
        gtk_box_pack_start (GTK_BOX (btn_vbox), up_btn, FALSE, FALSE, 0);
284
        g_signal_connect (G_OBJECT (up_btn), "clicked",
285
                          G_CALLBACK (prefs_display_header_up), NULL);
286

    
287
        down_btn = gtk_button_new_with_label (_("Down"));
288
        gtk_widget_show (down_btn);
289
        gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
290
        g_signal_connect (G_OBJECT (down_btn), "clicked",
291
                          G_CALLBACK (prefs_display_header_down), NULL);
292

    
293
        /* hidden headers list */
294

    
295
        clist_hbox2 = gtk_hbox_new (FALSE, 8);
296
        gtk_widget_show (clist_hbox2);
297
        gtk_box_pack_start (GTK_BOX (clist_hbox), clist_hbox2, TRUE, TRUE, 0);
298

    
299
        clist_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
300
        gtk_widget_set_size_request (clist_scrolledwin, 200, 210);
301
        gtk_widget_show (clist_scrolledwin);
302
        gtk_box_pack_start (GTK_BOX (clist_hbox2), clist_scrolledwin,
303
                            TRUE, TRUE, 0);
304
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (clist_scrolledwin),
305
                                        GTK_POLICY_AUTOMATIC,
306
                                        GTK_POLICY_AUTOMATIC);
307

    
308
        title[0] = _("Hidden headers");
309
        hidden_headers_clist = gtk_clist_new_with_titles(1, title);
310
        gtk_widget_show (hidden_headers_clist);
311
        gtk_container_add (GTK_CONTAINER (clist_scrolledwin),
312
                           hidden_headers_clist);
313
        gtk_clist_set_selection_mode (GTK_CLIST (hidden_headers_clist),
314
                                      GTK_SELECTION_BROWSE);
315
        gtk_clist_set_auto_sort(GTK_CLIST (hidden_headers_clist), TRUE);
316
        GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (hidden_headers_clist)->
317
                                column[0].button, GTK_CAN_FOCUS);
318

    
319
        btn_vbox = gtk_vbox_new (FALSE, 8);
320
        gtk_widget_show (btn_vbox);
321
        gtk_box_pack_start (GTK_BOX (clist_hbox2), btn_vbox, FALSE, FALSE, 0);
322

    
323
        reg_btn = gtk_button_new_with_label (_("Add"));
324
        gtk_widget_show (reg_btn);
325
        gtk_box_pack_start (GTK_BOX (btn_vbox), reg_btn, FALSE, TRUE, 0);
326
        g_signal_connect (G_OBJECT (reg_btn), "clicked",
327
                          G_CALLBACK (prefs_display_header_register_cb),
328
                          GINT_TO_POINTER (TRUE));
329
        del_btn = gtk_button_new_with_label (_("Delete"));
330
        gtk_widget_show (del_btn);
331
        gtk_box_pack_start (GTK_BOX (btn_vbox), del_btn, FALSE, TRUE, 0);
332
        g_signal_connect (G_OBJECT (del_btn), "clicked",
333
                          G_CALLBACK (prefs_display_header_delete_cb),
334
                          hidden_headers_clist);
335

    
336
        PACK_CHECK_BUTTON (btn_hbox, checkbtn_other_headers,
337
                           _("Show all unspecified headers"));
338
        SET_TOGGLE_SENSITIVITY (checkbtn_other_headers, clist_hbox2);
339

    
340
        gtk_widget_show_all(window);
341

    
342
        dispheader.window        = window;
343
        dispheader.ok_btn        = ok_btn;
344
        dispheader.cancel_btn    = cancel_btn;
345

    
346
        dispheader.hdr_combo     = hdr_combo;
347
        dispheader.hdr_entry     = GTK_COMBO (hdr_combo)->entry;
348

    
349
        dispheader.headers_clist        = headers_clist;
350
        dispheader.hidden_headers_clist = hidden_headers_clist;
351

    
352
        dispheader.other_headers = checkbtn_other_headers;
353
}
354

    
355
void prefs_display_header_read_config(void)
356
{
357
        gchar *rcpath;
358
        FILE *fp;
359
        gchar buf[PREFSBUFSIZE];
360
        DisplayHeaderProp *dp;
361

    
362
        debug_print(_("Reading configuration for displaying headers...\n"));
363

    
364
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
365
                             DISPLAY_HEADER_RC, NULL);
366
        if ((fp = fopen(rcpath, "rb")) == NULL) {
367
                if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
368
                g_free(rcpath);
369
                prefs_common.disphdr_list = NULL;
370
                prefs_display_header_set_default();
371
                return;
372
        }
373
        g_free(rcpath);
374

    
375
        /* remove all previous headers list */
376
        while (prefs_common.disphdr_list != NULL) {
377
                dp = (DisplayHeaderProp *)prefs_common.disphdr_list->data;
378
                display_header_prop_free(dp);
379
                prefs_common.disphdr_list =
380
                        g_slist_remove(prefs_common.disphdr_list, dp);
381
        }
382

    
383
        while (fgets(buf, sizeof(buf), fp) != NULL) {
384
                g_strchomp(buf);
385
                dp = display_header_prop_read_str(buf);
386
                if (dp)
387
                        prefs_common.disphdr_list =
388
                                g_slist_append(prefs_common.disphdr_list, dp);
389
        }
390

    
391
        fclose(fp);
392
}
393

    
394
void prefs_display_header_write_config(void)
395
{
396
        gchar *rcpath;
397
        PrefFile *pfile;
398
        GSList *cur;
399

    
400
        debug_print(_("Writing configuration for displaying headers...\n"));
401

    
402
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
403
                             DISPLAY_HEADER_RC, NULL);
404

    
405
        if ((pfile = prefs_file_open(rcpath)) == NULL) {
406
                g_warning(_("failed to write configuration to file\n"));
407
                g_free(rcpath);
408
                return;
409
        }
410

    
411
        for (cur = prefs_common.disphdr_list; cur != NULL;
412
             cur = cur->next) {
413
                DisplayHeaderProp *dp = (DisplayHeaderProp *)cur->data;
414
                gchar *dpstr;
415

    
416
                dpstr = display_header_prop_get_str(dp);
417
                if (fputs(dpstr, pfile->fp) == EOF ||
418
                    fputc('\n', pfile->fp) == EOF) {
419
                        FILE_OP_ERROR(rcpath, "fputs || fputc");
420
                        prefs_file_close_revert(pfile);
421
                        g_free(rcpath);
422
                        g_free(dpstr);
423
                        return;
424
                }
425
                g_free(dpstr);
426
        }
427

    
428
        g_free(rcpath);
429

    
430
        if (prefs_file_close(pfile) < 0) {
431
                g_warning(_("failed to write configuration to file\n"));
432
                return;
433
        }
434
}
435

    
436
static void prefs_display_header_set_dialog(void)
437
{
438
        GtkCList *clist = GTK_CLIST(dispheader.headers_clist);
439
        GtkCList *hidden_clist = GTK_CLIST(dispheader.hidden_headers_clist);
440
        GSList *cur;
441
        gchar *dp_str[1];
442
        gint row;
443

    
444
        gtk_clist_freeze(clist);
445
        gtk_clist_freeze(hidden_clist);
446

    
447
        gtk_clist_clear(clist);
448
        gtk_clist_clear(hidden_clist);
449

    
450
        for (cur = prefs_common.disphdr_list; cur != NULL;
451
             cur = cur->next) {
452
                DisplayHeaderProp *dp = (DisplayHeaderProp *)cur->data;
453

    
454
                dp_str[0] = dp->name;
455

    
456
                if (dp->hidden) {
457
                        row = gtk_clist_append(hidden_clist, dp_str);
458
                        gtk_clist_set_row_data(hidden_clist, row, dp);
459
                } else {
460
                        row = gtk_clist_append(clist, dp_str);
461
                        gtk_clist_set_row_data(clist, row, dp);
462
                }
463
        }
464

    
465
        gtk_clist_thaw(hidden_clist);
466
        gtk_clist_thaw(clist);
467

    
468
        gtk_toggle_button_set_active
469
                (GTK_TOGGLE_BUTTON(dispheader.other_headers),
470
                 prefs_common.show_other_header);
471
}
472

    
473
static void prefs_display_header_set_list()
474
{
475
        gint row = 0;
476
        DisplayHeaderProp *dp;
477

    
478
        g_slist_free(prefs_common.disphdr_list);
479
        prefs_common.disphdr_list = NULL;
480

    
481
        while ((dp = gtk_clist_get_row_data
482
                (GTK_CLIST(dispheader.headers_clist), row)) != NULL) {
483
                prefs_common.disphdr_list =
484
                        g_slist_append(prefs_common.disphdr_list, dp);
485
                row++;
486
        }
487

    
488
        row = 0;
489
        while ((dp = gtk_clist_get_row_data
490
                (GTK_CLIST(dispheader.hidden_headers_clist), row)) != NULL) {
491
                prefs_common.disphdr_list =
492
                        g_slist_append(prefs_common.disphdr_list, dp);
493
                row++;
494
        }
495
}
496

    
497
static gint prefs_display_header_find_header(GtkCList *clist,
498
                                             const gchar *header)
499
{
500
        gint row = 0;
501
        DisplayHeaderProp *dp;
502

    
503
        while ((dp = gtk_clist_get_row_data(clist, row)) != NULL) {
504
                if (g_strcasecmp(dp->name, header) == 0)
505
                        return row;
506
                row++;
507
        }
508

    
509
        return -1;
510
}
511

    
512
static gint prefs_display_header_clist_set_row(gboolean hidden)
513
{
514
        GtkCList *clist;
515
        DisplayHeaderProp *dp;
516
        const gchar *entry_text;
517
        gchar *dp_str[1];
518
        gint row;
519

    
520
        entry_text = gtk_entry_get_text(GTK_ENTRY(dispheader.hdr_entry));
521
        if (entry_text[0] == '\0') {
522
                alertpanel_error(_("Header name is not set."));
523
                return -1;
524
        }
525

    
526
        if (hidden)
527
                clist = GTK_CLIST(dispheader.hidden_headers_clist);
528
        else
529
                clist = GTK_CLIST(dispheader.headers_clist);
530

    
531
        if (prefs_display_header_find_header(clist, entry_text) != -1) {
532
                alertpanel_error(_("This header is already in the list."));
533
                return -1;
534
        }
535

    
536
        dp = g_new0(DisplayHeaderProp, 1);
537

    
538
        dp->name = g_strdup(entry_text);
539
        dp->hidden = hidden;
540

    
541
        dp_str[0] = dp->name;
542
        row = gtk_clist_append(clist, dp_str);
543
        gtk_clist_set_row_data(clist, row, dp);
544

    
545
        prefs_display_header_set_list();
546

    
547
        return row;
548
}
549

    
550
static void prefs_display_header_register_cb(GtkButton *btn,
551
                                             gpointer hidden_data)
552
{
553
        prefs_display_header_clist_set_row(GPOINTER_TO_INT(hidden_data));
554
}
555

    
556
static void prefs_display_header_delete_cb(GtkButton *btn, gpointer clist_data)
557
{
558
        GtkCList *clist = GTK_CLIST(clist_data);
559
        DisplayHeaderProp *dp;
560
        gint row;
561

    
562
        if (!clist->selection) return;
563
        row = GPOINTER_TO_INT(clist->selection->data);
564

    
565
        dp = gtk_clist_get_row_data(clist, row);
566
        display_header_prop_free(dp);
567
        gtk_clist_remove(clist, row);
568
        prefs_common.disphdr_list =
569
                g_slist_remove(prefs_common.disphdr_list, dp);
570
}
571

    
572
static void prefs_display_header_up(void)
573
{
574
        GtkCList *clist = GTK_CLIST(dispheader.headers_clist);
575
        gint row;
576

    
577
        if (!clist->selection) return;
578

    
579
        row = GPOINTER_TO_INT(clist->selection->data);
580
        if (row > 0)
581
                gtk_clist_row_move(clist, row, row - 1);
582
}
583

    
584
static void prefs_display_header_down(void)
585
{
586
        GtkCList *clist = GTK_CLIST(dispheader.headers_clist);
587
        gint row;
588

    
589
        if (!clist->selection) return;
590

    
591
        row = GPOINTER_TO_INT(clist->selection->data);
592
        if (row >= 0 && row < clist->rows - 1)
593
                gtk_clist_row_move(clist, row, row + 1);
594
}
595

    
596
static void prefs_display_header_row_moved(GtkCList *clist, gint source_row,
597
                                           gint dest_row, gpointer data)
598
{
599
        prefs_display_header_set_list();
600
}
601

    
602
static gboolean prefs_display_header_key_pressed(GtkWidget *widget,
603
                                             GdkEventKey *event,
604
                                             gpointer data)
605
{
606
        if (event && event->keyval == GDK_Escape)
607
                prefs_display_header_cancel();
608
        return FALSE;
609
}
610

    
611
static void prefs_display_header_ok(void)
612
{
613
        prefs_common.show_other_header =
614
                gtk_toggle_button_get_active
615
                        (GTK_TOGGLE_BUTTON(dispheader.other_headers));
616
        prefs_display_header_write_config();
617
        gtk_widget_hide(dispheader.window);
618
}
619

    
620
static void prefs_display_header_cancel(void)
621
{
622
        prefs_display_header_read_config();
623
        gtk_widget_hide(dispheader.window);
624
}
625

    
626
static gint prefs_display_header_deleted(GtkWidget *widget, GdkEventAny *event,
627
                                         gpointer data)
628
{
629
        prefs_display_header_cancel();
630
        return TRUE;
631
}