#include "gtkshruler.h"
#include "folder.h"
#include "addr_compl.h"
+#include "headers.h"
#if USE_GPGME
# include "rfc2015.h"
fprintf(fp, "\n--%s--\n", compose->boundary);
}
+static gint is_in_custom_headers(Compose *compose, gchar * header)
+{
+ GSList * cur;
+
+ if (compose->account->add_customhdr) {
+ for (cur = compose->account->customhdr_list;
+ cur != NULL; cur = cur->next) {
+ CustomHeader * ch = (CustomHeader *) cur->data;
+ if (strcasecmp(ch->name, header) == 0)
+ return 1;
+ }
+ }
+ return 0;
+}
+
static gint compose_write_headers(Compose *compose, FILE *fp,
const gchar *charset, EncodingType encoding,
gboolean is_draft)
gchar buf[BUFFSIZE];
gchar *str;
/* struct utsname utsbuf; */
+ GSList * cur;
g_return_val_if_fail(fp != NULL, -1);
g_return_val_if_fail(charset != NULL, -1);
g_return_val_if_fail(compose->account->address != NULL, -1);
/* Date */
- if (compose->account->add_date) {
- get_rfc822_date(buf, sizeof(buf));
- fprintf(fp, "Date: %s\n", buf);
+ if (!is_in_custom_headers(compose, "Date")) {
+ if (compose->account->add_date) {
+ get_rfc822_date(buf, sizeof(buf));
+ fprintf(fp, "Date: %s\n", buf);
+ }
}
/* From */
- if (compose->account->name && *compose->account->name) {
- compose_convert_header
- (buf, sizeof(buf), compose->account->name,
- strlen("From: "));
- fprintf(fp, "From: %s <%s>\n", buf, compose->account->address);
- } else
- fprintf(fp, "From: %s\n", compose->account->address);
+ if (!is_in_custom_headers(compose, "From")) {
+ if (compose->account->name && *compose->account->name) {
+ compose_convert_header
+ (buf, sizeof(buf), compose->account->name,
+ strlen("From: "));
+ fprintf(fp, "From: %s <%s>\n", buf, compose->account->address);
+ } else
+ fprintf(fp, "From: %s\n", compose->account->address);
+ }
slist_free_strings(compose->to_list);
g_slist_free(compose->to_list);
(compose->to_list, str);
compose_convert_header(buf, sizeof(buf), str,
strlen("To: "));
- fprintf(fp, "To: %s\n", buf);
+ if (!is_in_custom_headers(compose, "To")) {
+ fprintf(fp, "To: %s\n", buf);
+ }
}
}
}
str);
compose_convert_header(buf, sizeof(buf), str,
strlen("Newsgroups: "));
- fprintf(fp, "Newsgroups: %s\n", buf);
+ if (!is_in_custom_headers(compose, "Newsgroups")) {
+ fprintf(fp, "Newsgroups: %s\n", buf);
+ }
}
}
(compose->to_list, str);
compose_convert_header(buf, sizeof(buf), str,
strlen("Cc: "));
- fprintf(fp, "Cc: %s\n", buf);
+ if (!is_in_custom_headers(compose, "Cc")) {
+ fprintf(fp, "Cc: %s\n", buf);
+ }
}
}
}
compose_convert_header
(buf, sizeof(buf), str,
strlen("Bcc: "));
- fprintf(fp, "Bcc: %s\n", buf);
+ if (!is_in_custom_headers(compose,
+ "Bcc")) {
+ fprintf(fp, "Bcc: %s\n", buf);
+ }
}
}
}
}
/* Subject */
- str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
+ if (!is_in_custom_headers(compose, "Subject")) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Subject: "));
- fprintf(fp, "Subject: %s\n", buf);
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ if (*str != '\0') {
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Subject: "));
+ fprintf(fp, "Subject: %s\n", buf);
+ }
}
}
/* Message-ID */
- if (compose->account->gen_msgid) {
- compose_generate_msgid(compose, buf, sizeof(buf));
- fprintf(fp, "Message-Id: <%s>\n", buf);
- compose->msgid = g_strdup(buf);
+ if (!is_in_custom_headers(compose, "Message-Id")) {
+ if (compose->account->gen_msgid) {
+ compose_generate_msgid(compose, buf, sizeof(buf));
+ fprintf(fp, "Message-Id: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
+ }
}
/* In-Reply-To */
- if (compose->inreplyto && compose->to_list)
- fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
+ if (!is_in_custom_headers(compose, "In-Reply-To")) {
+ if (compose->inreplyto && compose->to_list)
+ fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
+ }
/* References */
- if (compose->references)
- fprintf(fp, "References: %s\n", compose->references);
+ if (!is_in_custom_headers(compose, "References")) {
+ if (compose->references)
+ fprintf(fp, "References: %s\n", compose->references);
+ }
/* Followup-To */
- if (compose->use_followupto) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- remove_space(str);
+ if (!is_in_custom_headers(compose, "Followup-To")) {
+ if (compose->use_followupto) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Followup-To: "));
- fprintf(fp, "Followup-To: %s\n", buf);
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ remove_space(str);
+ if (*str != '\0') {
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Followup-To: "));
+ fprintf(fp, "Followup-To: %s\n", buf);
+ }
}
}
}
/* Reply-To */
- if (compose->use_replyto) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
- if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
+ if (!is_in_custom_headers(compose, "Reply-To")) {
+ if (compose->use_replyto) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Reply-To: "));
- fprintf(fp, "Reply-To: %s\n", buf);
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ if (*str != '\0') {
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Reply-To: "));
+ fprintf(fp, "Reply-To: %s\n", buf);
+ }
}
}
}
/* Program version and system info */
/* uname(&utsbuf); */
- str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
- if (*str != '\0') {
- fprintf(fp, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
- prog_version,
- gtk_major_version, gtk_minor_version, gtk_micro_version,
- HOST_ALIAS);
+ if (!is_in_custom_headers(compose, "X-Mailer")) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
+ if (*str != '\0') {
+ fprintf(fp, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
+ prog_version,
+ gtk_major_version, gtk_minor_version, gtk_micro_version,
+ HOST_ALIAS);
/* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
+ }
}
- str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
- if (*str != '\0') {
+
+ if (!is_in_custom_headers(compose, "X-Newsreader")) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
+ if (*str != '\0') {
fprintf(fp, "X-Newsreader: %s (GTK+ %d.%d.%d; %s)\n",
prog_version,
gtk_major_version, gtk_minor_version, gtk_micro_version,
HOST_ALIAS);
/* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
+ }
}
/* Organization */
- if (compose->account->organization) {
- compose_convert_header(buf, sizeof(buf),
- compose->account->organization,
- strlen("Organization: "));
- fprintf(fp, "Organization: %s\n", buf);
+ if (!is_in_custom_headers(compose, "Organization")) {
+ if (compose->account->organization) {
+ compose_convert_header(buf, sizeof(buf),
+ compose->account->organization,
+ strlen("Organization: "));
+ fprintf(fp, "Organization: %s\n", buf);
+ }
}
/* MIME */
- fprintf(fp, "Mime-Version: 1.0\n");
+ if (!is_in_custom_headers(compose, "Mime-Version")) {
+ fprintf(fp, "Mime-Version: 1.0\n");
+ }
+
if (compose->use_attach) {
get_rfc822_date(buf, sizeof(buf));
subst_char(buf, ' ', '_');
subst_char(buf, ',', '_');
compose->boundary = g_strdup_printf("Multipart_%s_%08x",
buf, (guint)compose);
- fprintf(fp,
- "Content-Type: multipart/mixed;\n"
- " boundary=\"%s\"\n", compose->boundary);
+ if (!is_in_custom_headers(compose, "Content-Type")) {
+ fprintf(fp,
+ "Content-Type: multipart/mixed;\n"
+ " boundary=\"%s\"\n", compose->boundary);
+ }
} else {
- fprintf(fp, "Content-Type: text/plain; charset=%s\n", charset);
- fprintf(fp, "Content-Transfer-Encoding: %s\n",
- procmime_get_encoding_str(encoding));
+ if (!is_in_custom_headers(compose, "Content-Type")) {
+ fprintf(fp, "Content-Type: text/plain; charset=%s\n", charset);
+ }
+ if (!is_in_custom_headers(compose,
+ "Content-Transfer-Encoding")) {
+ fprintf(fp, "Content-Transfer-Encoding: %s\n",
+ procmime_get_encoding_str(encoding));
+ }
+ }
+
+ /* Custom Headers */
+ if (compose->account->add_customhdr) {
+ for (cur = compose->account->customhdr_list; cur != NULL;
+ cur = cur->next) {
+ CustomHeader * ch = (CustomHeader *) cur->data;
+ fprintf(fp, "%s: %s\n", ch->name, ch->value);
+ }
}
/* separator between header and body */
--- /dev/null
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "intl.h"
+#include "main.h"
+#include "prefs.h"
+#include "prefs_headers.h"
+#include "prefs_common.h"
+#include "prefs_account.h"
+#include "mainwindow.h"
+#include "foldersel.h"
+#include "manage_window.h"
+#include "headers.h"
+#include "utils.h"
+#include "gtkutils.h"
+#include "alertpanel.h"
+#include "folder.h"
+
+static struct Headers {
+ GtkWidget *window;
+
+ GtkWidget *close_btn;
+
+ GtkWidget *hdr_combo;
+ GtkWidget *hdr_entry;
+ GtkWidget *key_entry;
+ GtkWidget *headers_clist;
+
+ /*
+ GtkWidget *hdr_combo1;
+ GtkWidget *hdr_combo2;
+ GtkWidget *hdr_entry1;
+ GtkWidget *hdr_entry2;
+ GtkWidget *key_entry1;
+ GtkWidget *key_entry2;
+ GtkWidget *pred_combo1;
+ GtkWidget *pred_combo2;
+ GtkWidget *pred_entry1;
+ GtkWidget *pred_entry2;
+ GtkWidget *op_combo;
+ GtkWidget *op_entry;
+
+ GtkWidget *dest_entry;
+ GtkWidget *regex_chkbtn;
+
+ GtkWidget *destsel_btn;
+ GtkWidget *dest_radiobtn;
+ GtkWidget *notrecv_radiobtn;
+
+ GtkWidget *cond_clist;
+ */
+} headers;
+
+/*
+ parameter name, default value, pointer to the prefs variable, data type,
+ pointer to the widget pointer,
+ pointer to the function for data setting,
+ pointer to the function for widget setting
+ */
+
+#define VSPACING 12
+#define VSPACING_NARROW 4
+#define DEFAULT_ENTRY_WIDTH 80
+#define PREFSBUFSIZE 1024
+
+/* widget creating functions */
+static void prefs_headers_create (void);
+
+static void prefs_headers_set_dialog (PrefsAccount * ac);
+static void prefs_headers_set_list (PrefsAccount * ac);
+static gint prefs_headers_clist_set_row (PrefsAccount * ac,
+ gint row);
+
+/* callback functions */
+static void prefs_headers_select_dest_cb (void);
+static void prefs_headers_register_cb (void);
+static void prefs_headers_substitute_cb (void);
+static void prefs_headers_delete_cb (void);
+static void prefs_headers_up (void);
+static void prefs_headers_down (void);
+static void prefs_headers_select (GtkCList *clist,
+ gint row,
+ gint column,
+ GdkEvent *event);
+
+static void prefs_headers_dest_radio_button_toggled (void);
+static void prefs_headers_notrecv_radio_button_toggled (void);
+
+static void prefs_headers_key_pressed (GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data);
+static void prefs_headers_close (GtkButton *button);
+
+static PrefsAccount * cur_ac = NULL;
+
+void prefs_headers_open(PrefsAccount * ac)
+{
+ if (!headers.window) {
+ prefs_headers_create();
+ }
+
+ manage_window_set_transient(GTK_WINDOW(headers.window));
+ gtk_widget_grab_focus(headers.close_btn);
+
+ prefs_headers_set_dialog(ac);
+
+ cur_ac = ac;
+
+ gtk_widget_show(headers.window);
+}
+
+static void prefs_headers_create(void)
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *close_btn;
+ GtkWidget *confirm_area;
+
+ GtkWidget *vbox1;
+
+ GtkWidget *table1;
+ GtkWidget *hdr_label;
+ GtkWidget *hdr_combo;
+ GtkWidget *key_label;
+ GtkWidget *key_entry;
+
+ GtkWidget *reg_hbox;
+ GtkWidget *btn_hbox;
+ GtkWidget *arrow;
+ GtkWidget *reg_btn;
+ GtkWidget *subst_btn;
+ GtkWidget *del_btn;
+
+ GtkWidget *ch_hbox;
+ GtkWidget *ch_scrolledwin;
+ GtkWidget *headers_clist;
+
+ GtkWidget *btn_vbox;
+ GtkWidget *up_btn;
+ GtkWidget *down_btn;
+ /*
+
+ GtkWidget *table1;
+ GtkWidget *op_label;
+ GtkWidget *op_combo;
+ GtkWidget *op_entry;
+ GtkWidget *hdr_label;
+ GtkWidget *hdr_combo1;
+ GtkWidget *hdr_combo2;
+ GtkWidget *key_label;
+ GtkWidget *key_entry1;
+ GtkWidget *key_entry2;
+ GtkWidget *pred_label;
+ GtkWidget *pred_combo1;
+ GtkWidget *pred_entry1;
+ GtkWidget *pred_combo2;
+ GtkWidget *pred_entry2;
+
+ GtkWidget *vbox2;
+ GtkWidget *dest_hbox;
+ GtkWidget *dest_entry;
+ GtkWidget *destsel_btn;
+ GtkWidget *dest_radiobtn;
+ GtkWidget *notrecv_radiobtn;
+ GSList *recv_group = NULL;
+
+ GtkWidget *regex_chkbtn;
+
+ GtkWidget *reg_hbox;
+ GtkWidget *btn_hbox;
+ GtkWidget *arrow;
+ GtkWidget *reg_btn;
+ GtkWidget *subst_btn;
+ GtkWidget *del_btn;
+
+ GtkWidget *cond_hbox;
+ GtkWidget *cond_scrolledwin;
+ GtkWidget *cond_clist;
+
+ GtkWidget *btn_vbox;
+ GtkWidget *up_btn;
+ GtkWidget *down_btn;
+ */
+
+ gchar *title[] = {_("Custom headers")};
+
+ debug_print(_("Creating headers setting window...\n"));
+
+ window = gtk_window_new (GTK_WINDOW_DIALOG);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 8);
+ gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
+ gtk_window_set_modal (GTK_WINDOW (window), TRUE);
+ gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ gtkut_button_set_create (&confirm_area, &close_btn, _("Close"),
+ NULL, NULL, NULL, NULL);
+ gtk_widget_show (confirm_area);
+ gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
+ gtk_widget_grab_default (close_btn);
+
+ gtk_window_set_title (GTK_WINDOW(window),
+ _("Headers setting"));
+ gtk_signal_connect (GTK_OBJECT(window), "delete_event",
+ GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
+ GTK_SIGNAL_FUNC(prefs_headers_key_pressed), NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "focus_in_event",
+ GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
+ gtk_signal_connect (GTK_OBJECT(window), "focus_out_event",
+ GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
+ gtk_signal_connect (GTK_OBJECT(close_btn), "clicked",
+ GTK_SIGNAL_FUNC(prefs_headers_close), NULL);
+
+ vbox1 = gtk_vbox_new (FALSE, VSPACING);
+ gtk_widget_show (vbox1);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox1, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
+
+ table1 = gtk_table_new (2, 2, FALSE);
+ gtk_widget_show (table1);
+ gtk_box_pack_start (GTK_BOX (vbox1), table1,
+ FALSE, FALSE, 0);
+ gtk_table_set_row_spacings (GTK_TABLE (table1), 8);
+ gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
+
+ /*
+ op_label = gtk_label_new (_("Operator"));
+ gtk_widget_show (op_label);
+ gtk_table_attach (GTK_TABLE (table1), op_label, 0, 1, 0, 1,
+ GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (op_label), 0, 0.5);
+
+ op_combo = gtk_combo_new ();
+ gtk_widget_show (op_combo);
+ gtk_table_attach (GTK_TABLE (table1), op_combo, 0, 1, 2, 3,
+ 0, 0, 0, 0);
+ gtk_widget_set_usize (op_combo, 52, -1);
+ gtkut_combo_set_items (GTK_COMBO (op_combo), "and", "or", NULL);
+
+ op_entry = GTK_COMBO (op_combo)->entry;
+ gtk_entry_set_editable (GTK_ENTRY (op_entry), FALSE);
+
+ hdr_label = gtk_label_new (_("Header"));
+ gtk_widget_show (hdr_label);
+ gtk_table_attach (GTK_TABLE (table1), hdr_label, 1, 2, 0, 1,
+ GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (hdr_label), 0, 0.5);
+
+ hdr_combo1 = gtk_combo_new ();
+ gtk_widget_show (hdr_combo1);
+ gtk_table_attach (GTK_TABLE (table1), hdr_combo1, 1, 2, 1, 2,
+ 0, 0, 0, 0);
+ gtk_widget_set_usize (hdr_combo1, 96, -1);
+ gtkut_combo_set_items (GTK_COMBO (hdr_combo1),
+ "Subject", "From", "To", "Cc", "Reply-To",
+ "Sender", "X-ML-Name", "X-List", "X-Sequence",
+ "X-Mailer",
+ NULL);
+
+ hdr_combo2 = gtk_combo_new ();
+ gtk_widget_show (hdr_combo2);
+ gtk_table_attach (GTK_TABLE (table1), hdr_combo2, 1, 2, 2, 3,
+ 0, 0, 0, 0);
+ gtk_widget_set_usize (hdr_combo2, 96, -1);
+ gtkut_combo_set_items (GTK_COMBO (hdr_combo2), _("(none)"),
+ "Subject", "From", "To", "Cc", "Reply-To",
+ "Sender", "X-ML-Name", "X-List", "X-Sequence",
+ "X-Mailer",
+ NULL);
+
+ key_label = gtk_label_new (_("Keyword"));
+ gtk_widget_show (key_label);
+ gtk_table_attach (GTK_TABLE (table1), key_label, 2, 3, 0, 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (key_label), 0, 0.5);
+
+ key_entry1 = gtk_entry_new ();
+ gtk_widget_show (key_entry1);
+ gtk_widget_set_usize (key_entry1, 128, -1);
+ gtk_table_attach (GTK_TABLE (table1), key_entry1, 2, 3, 1, 2,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+
+ key_entry2 = gtk_entry_new ();
+ gtk_widget_show (key_entry2);
+ gtk_widget_set_usize (key_entry2, 128, -1);
+ gtk_table_attach (GTK_TABLE (table1), key_entry2, 2, 3, 2, 3,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+
+ pred_label = gtk_label_new (_("Predicate"));
+ gtk_widget_show (pred_label);
+ gtk_table_attach (GTK_TABLE (table1), pred_label, 3, 4, 0, 1,
+ GTK_FILL, 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (pred_label), 0, 0.5);
+
+ pred_combo1 = gtk_combo_new ();
+ gtk_widget_show (pred_combo1);
+ gtk_table_attach (GTK_TABLE (table1), pred_combo1, 3, 4, 1, 2,
+ 0, 0, 0, 0);
+ gtk_widget_set_usize (pred_combo1, 92, -1);
+ gtkut_combo_set_items (GTK_COMBO (pred_combo1),
+ _("contains"), _("not contain"), NULL);
+
+ pred_entry1 = GTK_COMBO (pred_combo1)->entry;
+ gtk_entry_set_editable (GTK_ENTRY (pred_entry1), FALSE);
+
+ pred_combo2 = gtk_combo_new ();
+ gtk_widget_show (pred_combo2);
+ gtk_table_attach (GTK_TABLE (table1), pred_combo2, 3, 4, 2, 3,
+ 0, 0, 0, 0);
+ gtk_widget_set_usize (pred_combo2, 92, -1);
+ gtkut_combo_set_items (GTK_COMBO (pred_combo2),
+ _("contains"), _("not contain"), NULL);
+
+ pred_entry2 = GTK_COMBO (pred_combo2)->entry;
+ gtk_entry_set_editable (GTK_ENTRY (pred_entry2), FALSE);
+ */
+
+ /* destination */
+
+ /*
+ vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
+ gtk_widget_show (vbox2);
+ gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
+
+ dest_hbox = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (dest_hbox);
+ gtk_box_pack_start (GTK_BOX (vbox2), dest_hbox, FALSE, TRUE, 0);
+
+ dest_radiobtn =
+ gtk_radio_button_new_with_label (recv_group, _("Destination"));
+ recv_group = gtk_radio_button_group (GTK_RADIO_BUTTON (dest_radiobtn));
+ gtk_widget_show (dest_radiobtn);
+ gtk_box_pack_start (GTK_BOX (dest_hbox), dest_radiobtn,
+ FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dest_radiobtn), TRUE);
+ gtk_signal_connect
+ (GTK_OBJECT (dest_radiobtn), "toggled",
+ GTK_SIGNAL_FUNC (prefs_headers_dest_radio_button_toggled),
+ NULL);
+
+ dest_entry = gtk_entry_new ();
+ gtk_widget_show (dest_entry);
+ gtk_widget_set_usize (dest_entry, DEFAULT_ENTRY_WIDTH, -1);
+ gtk_box_pack_start (GTK_BOX (dest_hbox), dest_entry, TRUE, TRUE, 0);
+ gtk_entry_set_editable (GTK_ENTRY (dest_entry), FALSE);
+
+ destsel_btn = gtk_button_new_with_label (_(" Select... "));
+ gtk_widget_show (destsel_btn);
+ gtk_box_pack_start (GTK_BOX (dest_hbox), destsel_btn, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (destsel_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_select_dest_cb),
+ NULL);
+
+ PACK_CHECK_BUTTON (dest_hbox, regex_chkbtn, _("Use regex"));
+ gtk_widget_set_sensitive(regex_chkbtn, FALSE);
+
+ notrecv_radiobtn = gtk_radio_button_new_with_label
+ (recv_group, _("Don't receive"));
+ recv_group = gtk_radio_button_group
+ (GTK_RADIO_BUTTON (notrecv_radiobtn));
+ gtk_widget_show (notrecv_radiobtn);
+ gtk_box_pack_start (GTK_BOX (vbox2), notrecv_radiobtn, FALSE, FALSE, 0);
+ gtk_signal_connect
+ (GTK_OBJECT (notrecv_radiobtn), "toggled",
+ GTK_SIGNAL_FUNC (prefs_headers_notrecv_radio_button_toggled),
+ NULL);
+ */
+
+ /* register / substitute / delete */
+
+ /*
+ reg_hbox = gtk_hbox_new (FALSE, 4);
+ gtk_widget_show (reg_hbox);
+ gtk_box_pack_start (GTK_BOX (vbox1), reg_hbox, FALSE, FALSE, 0);
+
+ arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+ gtk_widget_show (arrow);
+ gtk_box_pack_start (GTK_BOX (reg_hbox), arrow, FALSE, FALSE, 0);
+ gtk_widget_set_usize (arrow, -1, 16);
+
+ btn_hbox = gtk_hbox_new (TRUE, 4);
+ gtk_widget_show (btn_hbox);
+ gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
+
+ reg_btn = gtk_button_new_with_label (_("Register"));
+ gtk_widget_show (reg_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), reg_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (reg_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_register_cb), NULL);
+
+ subst_btn = gtk_button_new_with_label (_(" Substitute "));
+ gtk_widget_show (subst_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), subst_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (subst_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_substitute_cb),
+ NULL);
+
+ del_btn = gtk_button_new_with_label (_("Delete"));
+ gtk_widget_show (del_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), del_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (del_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_delete_cb), NULL);
+
+ cond_hbox = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (cond_hbox);
+ gtk_box_pack_start (GTK_BOX (vbox1), cond_hbox, TRUE, TRUE, 0);
+
+ cond_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (cond_scrolledwin);
+ gtk_widget_set_usize (cond_scrolledwin, -1, 150);
+ gtk_box_pack_start (GTK_BOX (cond_hbox), cond_scrolledwin,
+ TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (cond_scrolledwin),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ cond_clist = gtk_clist_new_with_titles(1, title);
+ gtk_widget_show (cond_clist);
+ gtk_container_add (GTK_CONTAINER (cond_scrolledwin), cond_clist);
+ gtk_clist_set_column_width (GTK_CLIST (cond_clist), 0, 80);
+ gtk_clist_set_selection_mode (GTK_CLIST (cond_clist),
+ GTK_SELECTION_BROWSE);
+ GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (cond_clist)->column[0].button,
+ GTK_CAN_FOCUS);
+ gtk_signal_connect (GTK_OBJECT (cond_clist), "select_row",
+ GTK_SIGNAL_FUNC (prefs_headers_select), NULL);
+
+ btn_vbox = gtk_vbox_new (FALSE, 8);
+ gtk_widget_show (btn_vbox);
+ gtk_box_pack_start (GTK_BOX (cond_hbox), btn_vbox, FALSE, FALSE, 0);
+
+ up_btn = gtk_button_new_with_label (_("Up"));
+ gtk_widget_show (up_btn);
+ gtk_box_pack_start (GTK_BOX (btn_vbox), up_btn, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (up_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_up), NULL);
+
+ down_btn = gtk_button_new_with_label (_("Down"));
+ gtk_widget_show (down_btn);
+ gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (down_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_down), NULL);
+ */
+
+ hdr_label = gtk_label_new (_("Header"));
+ gtk_widget_show (hdr_label);
+ gtk_table_attach (GTK_TABLE (table1), hdr_label, 0, 1, 0, 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (hdr_label), 0, 0.5);
+
+ hdr_combo = gtk_combo_new ();
+ gtk_widget_show (hdr_combo);
+ gtk_table_attach (GTK_TABLE (table1), hdr_combo, 0, 1, 1, 2,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+ gtk_widget_set_usize (hdr_combo, 150 /* 96 */, -1);
+ gtkut_combo_set_items (GTK_COMBO (hdr_combo),
+ "User-Agent", "X-Operating-System", NULL);
+
+ key_label = gtk_label_new (_("Value"));
+ gtk_widget_show (key_label);
+ gtk_table_attach (GTK_TABLE (table1), key_label, 1, 2, 0, 1,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (key_label), 0, 0.5);
+
+ key_entry = gtk_entry_new ();
+ gtk_widget_show (key_entry);
+ gtk_table_attach (GTK_TABLE (table1), key_entry, 1, 2, 1, 2,
+ GTK_EXPAND | GTK_SHRINK | GTK_FILL,
+ 0, 0, 0);
+
+ /* register / substitute / delete */
+
+ reg_hbox = gtk_hbox_new (FALSE, 4);
+ gtk_widget_show (reg_hbox);
+ gtk_box_pack_start (GTK_BOX (vbox1), reg_hbox,
+ FALSE, FALSE, 0);
+
+ arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
+ gtk_widget_show (arrow);
+ gtk_box_pack_start (GTK_BOX (reg_hbox), arrow, FALSE, FALSE, 0);
+ gtk_widget_set_usize (arrow, -1, 16);
+
+ btn_hbox = gtk_hbox_new (TRUE, 4);
+ gtk_widget_show (btn_hbox);
+ gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
+
+ reg_btn = gtk_button_new_with_label (_("Add"));
+ gtk_widget_show (reg_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), reg_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (reg_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_register_cb), NULL);
+
+ subst_btn = gtk_button_new_with_label (_(" Substitute "));
+ gtk_widget_show (subst_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), subst_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (subst_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_substitute_cb),
+ NULL);
+
+ del_btn = gtk_button_new_with_label (_("Delete"));
+ gtk_widget_show (del_btn);
+ gtk_box_pack_start (GTK_BOX (btn_hbox), del_btn, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT (del_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_delete_cb), NULL);
+
+
+ ch_hbox = gtk_hbox_new (FALSE, 8);
+ gtk_widget_show (ch_hbox);
+ gtk_box_pack_start (GTK_BOX (vbox1), ch_hbox,
+ TRUE, TRUE, 0);
+
+ ch_scrolledwin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_usize (ch_scrolledwin, -1, 100);
+ gtk_widget_show (ch_scrolledwin);
+ gtk_box_pack_start (GTK_BOX (ch_hbox), ch_scrolledwin,
+ TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ch_scrolledwin),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+
+ headers_clist = gtk_clist_new_with_titles(1, title);
+ gtk_widget_show (headers_clist);
+ gtk_container_add (GTK_CONTAINER (ch_scrolledwin), headers_clist);
+ gtk_clist_set_column_width (GTK_CLIST (headers_clist), 0, 80);
+ gtk_clist_set_selection_mode (GTK_CLIST (headers_clist),
+ GTK_SELECTION_BROWSE);
+ GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (headers_clist)->column[0].button,
+ GTK_CAN_FOCUS);
+ gtk_signal_connect (GTK_OBJECT (headers_clist), "select_row",
+ GTK_SIGNAL_FUNC (prefs_headers_select),
+ NULL);
+
+
+ btn_vbox = gtk_vbox_new (FALSE, 8);
+ gtk_widget_show (btn_vbox);
+ gtk_box_pack_start (GTK_BOX (ch_hbox), btn_vbox, FALSE, FALSE, 0);
+
+ up_btn = gtk_button_new_with_label (_("Up"));
+ gtk_widget_show (up_btn);
+ gtk_box_pack_start (GTK_BOX (btn_vbox), up_btn, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (up_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_up), NULL);
+
+ down_btn = gtk_button_new_with_label (_("Down"));
+ gtk_widget_show (down_btn);
+ gtk_box_pack_start (GTK_BOX (btn_vbox), down_btn, FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (down_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_headers_down), NULL);
+
+
+ gtk_widget_show_all(window);
+
+ headers.window = window;
+ headers.close_btn = close_btn;
+
+ headers.hdr_combo = hdr_combo;
+ headers.hdr_entry = GTK_COMBO (hdr_combo)->entry;
+ headers.key_entry = key_entry;
+ headers.headers_clist = headers_clist;
+
+ /*
+ headers.hdr_combo1 = hdr_combo1;
+ headers.hdr_combo2 = hdr_combo2;
+ headers.hdr_entry1 = GTK_COMBO (hdr_combo1)->entry;
+ headers.hdr_entry2 = GTK_COMBO (hdr_combo2)->entry;
+ headers.key_entry1 = key_entry1;
+ headers.key_entry2 = key_entry2;
+ headers.pred_combo1 = pred_combo1;
+ headers.pred_combo2 = pred_combo2;
+ headers.pred_entry1 = pred_entry1;
+ headers.pred_entry2 = pred_entry2;
+ headers.op_combo = op_combo;
+ headers.op_entry = op_entry;
+
+ headers.dest_entry = dest_entry;
+ headers.destsel_btn = destsel_btn;
+ headers.dest_radiobtn = dest_radiobtn;
+ headers.notrecv_radiobtn = notrecv_radiobtn;
+ headers.regex_chkbtn = regex_chkbtn;
+
+ headers.headers_clist = headers_clist;
+ */
+}
+
+void prefs_headers_read_config(PrefsAccount * ac)
+{
+ gchar *rcpath;
+ FILE *fp;
+ gchar buf[PREFSBUFSIZE];
+ CustomHeader *ch;
+
+ debug_print(_("Reading headers configuration...\n"));
+
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, HEADERS_RC, NULL);
+ if ((fp = fopen(rcpath, "r")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
+ g_free(rcpath);
+ ac->customhdr_list = NULL;
+ return;
+ }
+ g_free(rcpath);
+
+ /* remove all previous headers list */
+ while (ac->customhdr_list != NULL) {
+ ch = (CustomHeader *)ac->customhdr_list->data;
+ custom_header_free(ch);
+ ac->customhdr_list = g_slist_remove(ac->customhdr_list, ch);
+ }
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ g_strchomp(buf);
+ ch = custom_header_read_str(buf);
+ if (ch) {
+ if (strcmp(ch->account_name, ac->account_name) == 0)
+ ac->customhdr_list =
+ g_slist_append(ac->customhdr_list, ch);
+ else
+ custom_header_free(ch);
+ }
+ }
+
+ fclose(fp);
+}
+
+void prefs_headers_write_config(PrefsAccount * ac)
+{
+ gchar *rcpath;
+ PrefFile *pfile;
+ GSList *cur;
+ gchar buf[PREFSBUFSIZE];
+ FILE * fp;
+ CustomHeader *ch;
+
+ GSList *all_hdrs = NULL;
+
+ debug_print(_("Writing headers configuration...\n"));
+
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, HEADERS_RC, NULL);
+
+ if ((fp = fopen(rcpath, "r")) == NULL) {
+ if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
+ }
+ else {
+ all_hdrs = NULL;
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ g_strchomp(buf);
+ ch = custom_header_read_str(buf);
+ if (ch) {
+ if (strcmp(ch->account_name, ac->account_name) != 0)
+ all_hdrs =
+ g_slist_append(all_hdrs, ch);
+ else
+ custom_header_free(ch);
+ }
+ }
+
+ fclose(fp);
+ }
+
+ if ((pfile = prefs_write_open(rcpath)) == NULL) {
+ g_warning(_("failed to write configuration to file\n"));
+ g_free(rcpath);
+ return;
+ }
+
+ for (cur = all_hdrs; cur != NULL; cur = cur->next) {
+ CustomHeader *hdr = (CustomHeader *)cur->data;
+ gchar *chstr;
+
+ chstr = custom_header_get_str(hdr);
+ if (fputs(chstr, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
+ prefs_write_close_revert(pfile);
+ g_free(rcpath);
+ g_free(chstr);
+ return;
+ }
+ g_free(chstr);
+ }
+
+ for (cur = ac->customhdr_list; cur != NULL; cur = cur->next) {
+ CustomHeader *hdr = (CustomHeader *)cur->data;
+ gchar *chstr;
+
+ chstr = custom_header_get_str(hdr);
+ if (fputs(chstr, pfile->fp) == EOF ||
+ fputc('\n', pfile->fp) == EOF) {
+ FILE_OP_ERROR(rcpath, "fputs || fputc");
+ prefs_write_close_revert(pfile);
+ g_free(rcpath);
+ g_free(chstr);
+ return;
+ }
+ g_free(chstr);
+ }
+
+ g_free(rcpath);
+
+ while (all_hdrs != NULL) {
+ ch = (CustomHeader *)all_hdrs->data;
+ custom_header_free(ch);
+ all_hdrs = g_slist_remove(all_hdrs, ch);
+ }
+
+ if (prefs_write_close(pfile) < 0) {
+ g_warning(_("failed to write configuration to file\n"));
+ return;
+ }
+}
+
+static void prefs_headers_set_dialog(PrefsAccount * ac)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ GSList *cur;
+ gchar *ch_str[1];
+ gint row;
+
+ gtk_clist_freeze(clist);
+ gtk_clist_clear(clist);
+
+ ch_str[0] = _("(New)");
+ row = gtk_clist_append(clist, ch_str);
+ gtk_clist_set_row_data(clist, row, NULL);
+
+ for (cur = ac->customhdr_list; cur != NULL; cur = cur->next) {
+ CustomHeader *ch = (CustomHeader *)cur->data;
+
+ ch_str[0] = g_strdup_printf("%s: %s", ch->name, ch->value);
+ row = gtk_clist_append(clist, ch_str);
+ gtk_clist_set_row_data(clist, row, ch);
+
+ g_free(ch_str[0]);
+ }
+
+ gtk_clist_thaw(clist);
+}
+
+static void prefs_headers_set_list(PrefsAccount * ac)
+{
+ gint row = 1;
+ CustomHeader *ch;
+
+ g_slist_free(ac->customhdr_list);
+ ac->customhdr_list = NULL;
+
+ while ((ch = gtk_clist_get_row_data(GTK_CLIST(headers.headers_clist),
+ row)) != NULL) {
+ ac->customhdr_list = g_slist_append(ac->customhdr_list,
+ ch);
+ row++;
+ }
+}
+
+#define GET_ENTRY(entry) \
+ entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
+
+static gint prefs_headers_clist_set_row(PrefsAccount * ac, gint row)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ CustomHeader *ch;
+ gchar *entry_text;
+ gchar *ch_str[1];
+
+ g_return_val_if_fail(row != 0, -1);
+
+ GET_ENTRY(headers.hdr_entry);
+ if (entry_text[0] == '\0') {
+ alertpanel_error(_("Header name is not set."));
+ return -1;
+ }
+
+ ch = g_new0(CustomHeader, 1);
+
+ ch->account_name = g_strdup(ac->account_name);
+
+ ch->name = g_strdup(entry_text);
+
+ GET_ENTRY(headers.key_entry);
+ if (entry_text[0] != '\0')
+ ch->value = g_strdup(entry_text);
+
+ ch_str[0] = g_strdup_printf("%s: %s", ch->name, ch->value);
+
+ if (row < 0)
+ row = gtk_clist_append(clist, ch_str);
+ else {
+ CustomHeader *tmpch;
+
+ gtk_clist_set_text(clist, row, 0, ch_str[0]);
+ tmpch = gtk_clist_get_row_data(clist, row);
+ if (tmpch)
+ custom_header_free(tmpch);
+ }
+
+ gtk_clist_set_row_data(clist, row, ch);
+
+ g_free(ch_str[0]);
+
+ prefs_headers_set_list(cur_ac);
+
+ return row;
+}
+
+static void prefs_headers_register_cb(void)
+{
+ prefs_headers_clist_set_row(cur_ac, -1);
+}
+
+static void prefs_headers_substitute_cb(void)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ CustomHeader *ch;
+ gint row;
+
+ if (!clist->selection) return;
+
+ row = GPOINTER_TO_INT(clist->selection->data);
+ if (row == 0) return;
+
+ ch = gtk_clist_get_row_data(clist, row);
+ if (!ch) return;
+
+ prefs_headers_clist_set_row(cur_ac, row);
+}
+
+static void prefs_headers_delete_cb(void)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ CustomHeader *ch;
+ gint row;
+
+ if (!clist->selection) return;
+ row = GPOINTER_TO_INT(clist->selection->data);
+ if (row == 0) return;
+
+ if (alertpanel(_("Delete header"),
+ _("Do you really want to delete this header?"),
+ _("Yes"), _("No"), NULL) == G_ALERTALTERNATE)
+ return;
+
+ ch = gtk_clist_get_row_data(clist, row);
+ custom_header_free(ch);
+ gtk_clist_remove(clist, row);
+ cur_ac->customhdr_list = g_slist_remove(cur_ac->customhdr_list, ch);
+}
+
+static void prefs_headers_up(void)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ gint row;
+
+ if (!clist->selection) return;
+
+ row = GPOINTER_TO_INT(clist->selection->data);
+ if (row > 1) {
+ gtk_clist_row_move(clist, row, row - 1);
+ prefs_headers_set_list(cur_ac);
+ }
+}
+
+static void prefs_headers_down(void)
+{
+ GtkCList *clist = GTK_CLIST(headers.headers_clist);
+ gint row;
+
+ if (!clist->selection) return;
+
+ row = GPOINTER_TO_INT(clist->selection->data);
+ if (row > 0 && row < clist->rows - 1) {
+ gtk_clist_row_move(clist, row, row + 1);
+ prefs_headers_set_list(cur_ac);
+ }
+}
+
+#define ENTRY_SET_TEXT(entry, str) \
+ gtk_entry_set_text(GTK_ENTRY(entry), str ? str : "")
+
+static void prefs_headers_select(GtkCList *clist, gint row, gint column,
+ GdkEvent *event)
+{
+ CustomHeader *ch;
+ CustomHeader default_ch = { "", NULL };
+
+ ch = gtk_clist_get_row_data(clist, row);
+ if (!ch)
+ ch = &default_ch;
+
+ ENTRY_SET_TEXT(headers.hdr_entry, ch->name);
+ ENTRY_SET_TEXT(headers.key_entry, ch->value);
+}
+
+static void prefs_headers_key_pressed(GtkWidget *widget, GdkEventKey *event,
+ gpointer data)
+{
+ if (event && event->keyval == GDK_Escape)
+ gtk_widget_hide(headers.window);
+}
+
+static void prefs_headers_close(GtkButton *button)
+{
+ prefs_headers_write_config(cur_ac);
+ gtk_widget_hide(headers.window);
+}