further merging: 0.4.67cvs6
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 13 May 2001 13:53:50 +0000 (13:53 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sun, 13 May 2001 13:53:50 +0000 (13:53 +0000)
ChangeLog
ChangeLog.claws
ChangeLog.jp
src/compose.c
src/customheader.c
src/prefs_account.c
src/prefs_customheader.c
src/prefs_customheader.h
src/prefs_display_header.c

index 0af6415..b729c06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2001-05-13
+
+       * src/prefs_customheader.[ch]: renamed prefs_headers_* to
+         prefs_custom_header_*. Removed `(New)' row and `Substitute'
+         button. Supported empty value.
+         prefs_custom_header_row_moved(): new. Connected "row_move" signal
+         to the function, and made it set header list.
+       * src/customheader.c: custom_header_get_str()
+         src/compose.c: compose_write_headers(): supported empty value.
+       * src/prefs_display_header.c: prefs_display_header_row_moved(): new.
+         Connected "row_move" signal to the function, and made it set
+         header list.
+       * src/compose.c: compose_write_headers(): modified the order of
+         headers, and made it encode the custom headers.
+
 2001-05-13
 
        * merged the custom header stuff from claws branch:
index 1402d89..42423c0 100644 (file)
@@ -2,7 +2,7 @@
 
        0.4.67claws3
        
-       * sync with sylpheed 0.4.67cvs5
+       * sync with sylpheed 0.4.67cvs5-6
 
 2001-05-13 [paul]
 
index 863af4f..e91da63 100644 (file)
@@ -1,3 +1,18 @@
+2001-05-13
+
+       * src/prefs_customheader.[ch]: prefs_headers_* ¤ò
+         prefs_custom_header_* ¤Ë̾¾ÎÊѹ¹¡£ `(New)' ¹Ô¤È `ÃÖ´¹' ¥Ü¥¿¥ó¤ò
+         ºï½ü¡£¶õ¤ÎÆâÍƤËÂбþ¡£
+         prefs_custom_header_row_moved(): ¿·µ¬¡£ "row_move" ¥·¥°¥Ê¥ë¤ò
+         ¤½¤ì¤ËÀܳ¤·¡¢¥Ø¥Ã¥À¥ê¥¹¥È¤ò¥»¥Ã¥È¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+       * src/customheader.c: custom_header_get_str()
+         src/compose.c: compose_write_headers(): ¶õ¤ÎÆâÍƤËÂбþ¡£
+       * src/prefs_display_header.c: prefs_display_header_row_moved(): ¿·µ¬¡£
+         "row_move" ¥·¥°¥Ê¥ë¤ò¤½¤ì¤ËÀܳ¤·¡¢¥Ø¥Ã¥À¥ê¥¹¥È¤ò¥»¥Ã¥È¤¹¤ë¤è¤¦¤Ë
+         ¤·¤¿¡£
+       * src/compose.c: compose_write_headers(): ¥Ø¥Ã¥À¤Î½ç½ø¤ò½¤Àµ¤·¡¢
+         ¥«¥¹¥¿¥à¥Ø¥Ã¥À¤ò¥¨¥ó¥³¡¼¥É¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+
 2001-05-13
 
        * claws ¥Ö¥é¥ó¥Á¤«¤é¥«¥¹¥¿¥à¥Ø¥Ã¥À´ØÏ¢¤ò¥Þ¡¼¥¸:
index c7b8fc6..73bacae 100644 (file)
@@ -2043,6 +2043,15 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                }
        }
 
+       /* Organization */
+       if (compose->account->organization &&
+           !IS_IN_CUSTOM_HEADER("Organization")) {
+               compose_convert_header(buf, sizeof(buf),
+                                      compose->account->organization,
+                                      strlen("Organization: "));
+               fprintf(fp, "Organization: %s\n", buf);
+       }
+
        /* Program version and system info */
        /* uname(&utsbuf); */
        str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
@@ -2062,15 +2071,30 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                        /* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
        }
 
-       /* Organization */
-       if (compose->account->organization &&
-           !IS_IN_CUSTOM_HEADER("Organization")) {
-               compose_convert_header(buf, sizeof(buf),
-                                      compose->account->organization,
-                                      strlen("Organization: "));
-               fprintf(fp, "Organization: %s\n", buf);
-       }
+       /* custom headers */
+       if (compose->account->add_customhdr) {
+               GSList *cur;
+
+               for (cur = compose->account->customhdr_list; cur != NULL;
+                    cur = cur->next) {
+                       CustomHeader *chdr = (CustomHeader *)cur->data;
 
+                       if (strcasecmp(chdr->name, "Date")         != 0 &&
+                           strcasecmp(chdr->name, "Message-Id")   != 0 &&
+                           strcasecmp(chdr->name, "In-Reply-To")  != 0 &&
+                           strcasecmp(chdr->name, "References")   != 0 &&
+                           strcasecmp(chdr->name, "Mime-Version") != 0 &&
+                           strcasecmp(chdr->name, "Content-Type") != 0 &&
+                           strcasecmp(chdr->name, "Content-Transfer-Encoding")
+                           != 0)
+                               compose_convert_header
+                                       (buf, sizeof(buf),
+                                        chdr->value ? chdr->value : "",
+                                        strlen(chdr->name) + 2);
+                               fprintf(fp, "%s: %s\n", chdr->name, buf);
+               }
+       }
+       
        /* MIME */
        fprintf(fp, "Mime-Version: 1.0\n");
        if (compose->use_attach) {
@@ -2088,26 +2112,6 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                        procmime_get_encoding_str(encoding));
        }
 
-       /* custom headers */
-       if (compose->account->add_customhdr) {
-               GSList *cur;
-
-               for (cur = compose->account->customhdr_list; cur != NULL;
-                    cur = cur->next) {
-                       CustomHeader *chdr = (CustomHeader *)cur->data;
-
-                       if (strcasecmp(chdr->name, "Date") != 0 &&
-                           strcasecmp(chdr->name, "Message-Id") != 0 &&
-                           strcasecmp(chdr->name, "In-Reply-To") != 0 &&
-                           strcasecmp(chdr->name, "References") != 0 &&
-                           strcasecmp(chdr->name, "Mime-Version") != 0 &&
-                           strcasecmp(chdr->name, "Content-Type") != 0 &&
-                           strcasecmp(chdr->name, "Content-Transfer-Encoding") != 0)
-                               fprintf(fp, "%s: %s\n",
-                                       chdr->name, chdr->value);
-               }
-       }
-
        /* Request Return Receipt */
        if (!IS_IN_CUSTOM_HEADER("Disposition-Notification-To")) {
                if (compose->return_receipt) {
index add563a..7d8560a 100644 (file)
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "intl.h"
 #include "customheader.h"
 #include "utils.h"
 
@@ -33,7 +32,8 @@
 gchar *custom_header_get_str(CustomHeader *ch)
 {
        return g_strdup_printf("%i:%s: %s",
-                              ch->account_id, ch->name, ch->value);
+                              ch->account_id, ch->name,
+                              ch->value ? ch->value : "");
 }
 
 CustomHeader *custom_header_read_str(const gchar *buf)
@@ -63,16 +63,13 @@ CustomHeader *custom_header_read_str(const gchar *buf)
 
        while (*name == ' ') name++;
 
-       ch = g_new0(CustomHeader, 1);
-       ch->account_id = id;
-
        value = strchr(name, ':');
-       if (!value) {
-               g_free(ch);
-               return NULL;
-       } else
-               *value++ = '\0';
+       if (!value) return NULL;
 
+       *value++ = '\0';
+
+       ch = g_new0(CustomHeader, 1);
+       ch->account_id = id;
        ch->name = *name ? g_strdup(name) : NULL;
        while (*value == ' ') value++;
        ch->value = *value ? g_strdup(value) : NULL;
@@ -98,10 +95,7 @@ void custom_header_free(CustomHeader *ch)
 {
        if (!ch) return;
 
-       if (ch->name)
-               g_free(ch->name);
-       if (ch->value)
-               g_free(ch->value);
-
+       g_free(ch->name);
+       g_free(ch->value);
        g_free(ch);
 }
index 648baf6..d743534 100644 (file)
@@ -349,7 +349,7 @@ void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
        if (id < 0) g_warning("wrong account id: %d\n", id);
        ac_prefs->account_id = id;
 
-       prefs_headers_read_config(ac_prefs);
+       prefs_custom_header_read_config(ac_prefs);
 }
 
 void prefs_account_save_config(PrefsAccount *ac_prefs)
@@ -1291,7 +1291,7 @@ static void prefs_account_cancel(void)
 
 static void prefs_account_edit_custom_header(void)
 {
-       prefs_headers_open(&tmp_ac_prefs);
+       prefs_custom_header_open(&tmp_ac_prefs);
 }
 
 #if USE_GPGME
index fcea198..029b345 100644 (file)
@@ -46,7 +46,7 @@
 #include "gtkutils.h"
 #include "alertpanel.h"
 
-static struct Headers {
+static struct CustomHdr {
        GtkWidget *window;
 
        GtkWidget *ok_btn;
@@ -55,8 +55,8 @@ static struct Headers {
        GtkWidget *hdr_combo;
        GtkWidget *hdr_entry;
        GtkWidget *key_entry;
-       GtkWidget *headers_clist;
-} headers;
+       GtkWidget *customhdr_clist;
+} customhdr;
 
 #define VSPACING               12
 #define VSPACING_NARROW                4
@@ -64,52 +64,56 @@ static struct Headers {
 #define PREFSBUFSIZE           1024
 
 /* widget creating functions */
-static void prefs_headers_create       (void);
+static void prefs_custom_header_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);
+static void prefs_custom_header_set_dialog     (PrefsAccount *ac);
+static void prefs_custom_header_set_list       (PrefsAccount *ac);
+static gint prefs_custom_header_clist_set_row  (PrefsAccount *ac,
+                                                gint          row);
 
 /* callback functions */
-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_key_pressed  (GtkWidget      *widget,
-                                        GdkEventKey    *event,
-                                        gpointer        data);
-static void prefs_headers_ok           (GtkButton      *button);
-static void prefs_headers_cancel       (GtkButton      *button);
-static gint prefs_headers_deleted      (GtkWidget      *widget,
-                                        GdkEventAny    *event,
-                                        gpointer        data);
+static void prefs_custom_header_add_cb         (void);
+static void prefs_custom_header_delete_cb      (void);
+static void prefs_custom_header_up             (void);
+static void prefs_custom_header_down           (void);
+static void prefs_custom_header_select         (GtkCList       *clist,
+                                                gint            row,
+                                                gint            column,
+                                                GdkEvent       *event);
+
+static void prefs_custom_header_row_moved      (GtkCList       *clist,
+                                                gint            source_row,
+                                                gint            dest_row,
+                                                gpointer        data);
+
+static void prefs_custom_header_key_pressed    (GtkWidget      *widget,
+                                                GdkEventKey    *event,
+                                                gpointer        data);
+static void prefs_custom_header_ok             (void);
+static void prefs_custom_header_cancel         (void);
+static gint prefs_custom_header_deleted                (GtkWidget      *widget,
+                                                GdkEventAny    *event,
+                                                gpointer        data);
 
 static PrefsAccount *cur_ac = NULL;
 
-void prefs_headers_open(PrefsAccount *ac)
+void prefs_custom_header_open(PrefsAccount *ac)
 {
-       if (!headers.window) {
-               prefs_headers_create();
+       if (!customhdr.window) {
+               prefs_custom_header_create();
        }
 
-       manage_window_set_transient(GTK_WINDOW(headers.window));
-       gtk_widget_grab_focus(headers.ok_btn);
+       manage_window_set_transient(GTK_WINDOW(customhdr.window));
+       gtk_widget_grab_focus(customhdr.ok_btn);
 
-       prefs_headers_set_dialog(ac);
+       prefs_custom_header_set_dialog(ac);
 
        cur_ac = ac;
 
-       gtk_widget_show(headers.window);
+       gtk_widget_show(customhdr.window);
 }
 
-static void prefs_headers_create(void)
+static void prefs_custom_header_create(void)
 {
        GtkWidget *window;
        GtkWidget *vbox;
@@ -130,13 +134,12 @@ static void prefs_headers_create(void)
        GtkWidget *reg_hbox;
        GtkWidget *btn_hbox;
        GtkWidget *arrow;
-       GtkWidget *reg_btn;
-       GtkWidget *subst_btn;
+       GtkWidget *add_btn;
        GtkWidget *del_btn;
 
        GtkWidget *ch_hbox;
        GtkWidget *ch_scrolledwin;
-       GtkWidget *headers_clist;
+       GtkWidget *customhdr_clist;
 
        GtkWidget *btn_vbox;
        GtkWidget *up_btn;
@@ -144,7 +147,7 @@ static void prefs_headers_create(void)
 
        gchar *title[] = {_("Custom headers")};
 
-       debug_print(_("Creating headers setting window...\n"));
+       debug_print(_("Creating custom header setting window...\n"));
 
        window = gtk_window_new (GTK_WINDOW_DIALOG);
        gtk_container_set_border_width (GTK_CONTAINER (window), 8);
@@ -162,20 +165,21 @@ static void prefs_headers_create(void)
        gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
        gtk_widget_grab_default (ok_btn);
 
-       gtk_window_set_title (GTK_WINDOW(window),
-                             _("Headers setting"));
-       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                           GTK_SIGNAL_FUNC(prefs_headers_deleted), NULL);
-       gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
-                           GTK_SIGNAL_FUNC(prefs_headers_key_pressed), NULL);
+       gtk_window_set_title (GTK_WINDOW(window), _("Custom header setting"));
        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(window), "delete_event",
+                           GTK_SIGNAL_FUNC(prefs_custom_header_deleted),
+                           NULL);
+       gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
+                           GTK_SIGNAL_FUNC(prefs_custom_header_key_pressed),
+                           NULL);
        gtk_signal_connect (GTK_OBJECT(ok_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_headers_ok), NULL);
+                           GTK_SIGNAL_FUNC(prefs_custom_header_ok), NULL);
        gtk_signal_connect (GTK_OBJECT(cancel_btn), "clicked",
-                           GTK_SIGNAL_FUNC(prefs_headers_cancel), NULL);
+                           GTK_SIGNAL_FUNC(prefs_custom_header_cancel), NULL);
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -201,7 +205,7 @@ static void prefs_headers_create(void)
        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);
+       gtk_widget_set_usize (hdr_combo, 150, -1);
        gtkut_combo_set_items (GTK_COMBO (hdr_combo),
                               "User-Agent", "X-Operating-System", NULL);
 
@@ -218,12 +222,11 @@ static void prefs_headers_create(void)
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
                          0, 0, 0);
 
-       /* register / substitute / delete */
+       /* add / 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);
+       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);
@@ -234,52 +237,49 @@ static void prefs_headers_create(void)
        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),
+       add_btn = gtk_button_new_with_label (_("Add"));
+       gtk_widget_show (add_btn);
+       gtk_box_pack_start (GTK_BOX (btn_hbox), add_btn, FALSE, TRUE, 0);
+       gtk_signal_connect (GTK_OBJECT (add_btn), "clicked",
+                           GTK_SIGNAL_FUNC (prefs_custom_header_add_cb),
                            NULL);
 
-       del_btn = gtk_button_new_with_label (_("Delete"));
+       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);
+                           GTK_SIGNAL_FUNC (prefs_custom_header_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);
+       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_set_usize (ch_scrolledwin, -1, 150);
        gtk_widget_show (ch_scrolledwin);
-       gtk_box_pack_start (GTK_BOX (ch_hbox), ch_scrolledwin,
-                           TRUE, TRUE, 0);
+       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),
+       customhdr_clist = gtk_clist_new_with_titles(1, title);
+       gtk_widget_show (customhdr_clist);
+       gtk_container_add (GTK_CONTAINER (ch_scrolledwin), customhdr_clist);
+       gtk_clist_set_column_width (GTK_CLIST (customhdr_clist), 0, 80);
+       gtk_clist_set_selection_mode (GTK_CLIST (customhdr_clist),
                                      GTK_SELECTION_BROWSE);
-       GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (headers_clist)->column[0].button,
+       gtk_clist_set_reorderable (GTK_CLIST (customhdr_clist), TRUE);
+       gtk_clist_set_use_drag_icons (GTK_CLIST (customhdr_clist), FALSE);
+       GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (customhdr_clist)->column[0].button,
                                GTK_CAN_FOCUS);
-       gtk_signal_connect (GTK_OBJECT (headers_clist), "select_row",
-                           GTK_SIGNAL_FUNC (prefs_headers_select),
+       gtk_signal_connect (GTK_OBJECT (customhdr_clist), "select_row",
+                           GTK_SIGNAL_FUNC (prefs_custom_header_select),
                            NULL);
-
+       gtk_signal_connect_after
+               (GTK_OBJECT (customhdr_clist), "row_move",
+                GTK_SIGNAL_FUNC (prefs_custom_header_row_moved), NULL);
 
        btn_vbox = gtk_vbox_new (FALSE, 8);
        gtk_widget_show (btn_vbox);
@@ -289,35 +289,35 @@ static void prefs_headers_create(void)
        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);
+                           GTK_SIGNAL_FUNC (prefs_custom_header_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_SIGNAL_FUNC (prefs_custom_header_down), NULL);
 
        gtk_widget_show_all(window);
 
-       headers.window     = window;
-       headers.ok_btn     = ok_btn;
-       headers.cancel_btn = cancel_btn;
+       customhdr.window     = window;
+       customhdr.ok_btn     = ok_btn;
+       customhdr.cancel_btn = cancel_btn;
 
-       headers.hdr_combo  = hdr_combo;
-       headers.hdr_entry  = GTK_COMBO (hdr_combo)->entry;
-       headers.key_entry  = key_entry;
+       customhdr.hdr_combo  = hdr_combo;
+       customhdr.hdr_entry  = GTK_COMBO (hdr_combo)->entry;
+       customhdr.key_entry  = key_entry;
 
-       headers.headers_clist   = headers_clist;
+       customhdr.customhdr_clist   = customhdr_clist;
 }
 
-void prefs_headers_read_config(PrefsAccount *ac)
+void prefs_custom_header_read_config(PrefsAccount *ac)
 {
        gchar *rcpath;
        FILE *fp;
        gchar buf[PREFSBUFSIZE];
        CustomHeader *ch;
 
-       debug_print(_("Reading headers configuration...\n"));
+       debug_print(_("Reading custom header configuration...\n"));
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                             CUSTOM_HEADER_RC, NULL);
@@ -351,7 +351,7 @@ void prefs_headers_read_config(PrefsAccount *ac)
        fclose(fp);
 }
 
-void prefs_headers_write_config(PrefsAccount *ac)
+void prefs_custom_header_write_config(PrefsAccount *ac)
 {
        gchar *rcpath;
        PrefFile *pfile;
@@ -362,7 +362,7 @@ void prefs_headers_write_config(PrefsAccount *ac)
 
        GSList *all_hdrs = NULL;
 
-       debug_print(_("Writing headers configuration...\n"));
+       debug_print(_("Writing custom header configuration...\n"));
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
                             CUSTOM_HEADER_RC, NULL);
@@ -439,9 +439,9 @@ void prefs_headers_write_config(PrefsAccount *ac)
        }
 }
 
-static void prefs_headers_set_dialog(PrefsAccount *ac)
+static void prefs_custom_header_set_dialog(PrefsAccount *ac)
 {
-       GtkCList *clist = GTK_CLIST(headers.headers_clist);
+       GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
        GSList *cur;
        gchar *ch_str[1];
        gint row;
@@ -449,14 +449,11 @@ static void prefs_headers_set_dialog(PrefsAccount *ac)
        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);
+               ch_str[0] = g_strdup_printf("%s: %s", ch->name,
+                                           ch->value ? ch->value : "");
                row = gtk_clist_append(clist, ch_str);
                gtk_clist_set_row_data(clist, row, ch);
 
@@ -466,32 +463,29 @@ static void prefs_headers_set_dialog(PrefsAccount *ac)
        gtk_clist_thaw(clist);
 }
 
-static void prefs_headers_set_list(PrefsAccount *ac)
+static void prefs_custom_header_set_list(PrefsAccount *ac)
 {
-       gint row = 1;
+       gint row = 0;
        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);
+       while ((ch = gtk_clist_get_row_data
+               (GTK_CLIST(customhdr.customhdr_clist), row)) != NULL) {
+               ac->customhdr_list = g_slist_append(ac->customhdr_list, ch);
                row++;
        }
 }
 
-static gint prefs_headers_clist_set_row(PrefsAccount *ac, gint row)
+static gint prefs_custom_header_clist_set_row(PrefsAccount *ac, gint row)
 {
-       GtkCList *clist = GTK_CLIST(headers.headers_clist);
+       GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
        CustomHeader *ch;
        gchar *entry_text;
        gchar *ch_str[1];
 
-       g_return_val_if_fail(row != 0, -1);
-
-       entry_text = gtk_entry_get_text(GTK_ENTRY(headers.hdr_entry));
+       entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.hdr_entry));
        if (entry_text[0] == '\0') {
                alertpanel_error(_("Header name is not set."));
                return -1;
@@ -503,63 +497,46 @@ static gint prefs_headers_clist_set_row(PrefsAccount *ac, gint row)
 
        ch->name = g_strdup(entry_text);
 
-       entry_text = gtk_entry_get_text(GTK_ENTRY(headers.key_entry));
+       entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.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);
+       ch_str[0] = g_strdup_printf("%s: %s", ch->name,
+                                   ch->value ? ch->value : "");
 
        if (row < 0)
                row = gtk_clist_append(clist, ch_str);
        else {
-               CustomHeader *tmpch;
+               CustomHeader *tmp_ch;
 
                gtk_clist_set_text(clist, row, 0, ch_str[0]);
-               tmpch = gtk_clist_get_row_data(clist, row);
-               if (tmpch)
-                       custom_header_free(tmpch);
+               tmp_ch = gtk_clist_get_row_data(clist, row);
+               if (tmp_ch)
+                       custom_header_free(tmp_ch);
        }
 
        gtk_clist_set_row_data(clist, row, ch);
 
        g_free(ch_str[0]);
 
-       prefs_headers_set_list(cur_ac);
+       prefs_custom_header_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)
+static void prefs_custom_header_add_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);
+       prefs_custom_header_clist_set_row(cur_ac, -1);
 }
 
-static void prefs_headers_delete_cb(void)
+static void prefs_custom_header_delete_cb(void)
 {
-       GtkCList *clist = GTK_CLIST(headers.headers_clist);
+       GtkCList *clist = GTK_CLIST(customhdr.customhdr_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?"),
@@ -572,75 +549,77 @@ static void prefs_headers_delete_cb(void)
        cur_ac->customhdr_list = g_slist_remove(cur_ac->customhdr_list, ch);
 }
 
-static void prefs_headers_up(void)
+static void prefs_custom_header_up(void)
 {
-       GtkCList *clist = GTK_CLIST(headers.headers_clist);
+       GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
        gint row;
 
        if (!clist->selection) return;
 
        row = GPOINTER_TO_INT(clist->selection->data);
-       if (row > 1) {
+       if (row > 0)
                gtk_clist_row_move(clist, row, row - 1);
-               prefs_headers_set_list(cur_ac);
-       }
 }
 
-static void prefs_headers_down(void)
+static void prefs_custom_header_down(void)
 {
-       GtkCList *clist = GTK_CLIST(headers.headers_clist);
+       GtkCList *clist = GTK_CLIST(customhdr.customhdr_clist);
        gint row;
 
        if (!clist->selection) return;
 
        row = GPOINTER_TO_INT(clist->selection->data);
-       if (row > 0 && row < clist->rows - 1) {
+       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)
+static void prefs_custom_header_select(GtkCList *clist, gint row, gint column,
+                                      GdkEvent *event)
 {
-       CustomHeader *ch;
-       CustomHeader default_ch = { 0, "", 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);
+       CustomHeader *ch;
+       CustomHeader default_ch = { 0, "", NULL };
+
+       ch = gtk_clist_get_row_data(clist, row);
+       if (!ch) ch = &default_ch;
+
+       ENTRY_SET_TEXT(customhdr.hdr_entry, ch->name);
+       ENTRY_SET_TEXT(customhdr.key_entry, ch->value);
 }
 
 #undef ENTRY_SET_TEXT
 
-static void prefs_headers_key_pressed(GtkWidget *widget, GdkEventKey *event,
-                                    gpointer data)
+static void prefs_custom_header_row_moved(GtkCList *clist, gint source_row,
+                                         gint dest_row, gpointer data)
+{
+       prefs_custom_header_set_list(cur_ac);
+}
+
+static void prefs_custom_header_key_pressed(GtkWidget *widget,
+                                           GdkEventKey *event,
+                                           gpointer data)
 {
        if (event && event->keyval == GDK_Escape)
-               gtk_widget_hide(headers.window);
+               prefs_custom_header_cancel();
 }
 
-static void prefs_headers_ok(GtkButton *button)
+static void prefs_custom_header_ok(void)
 {
-       prefs_headers_write_config(cur_ac);
-       gtk_widget_hide(headers.window);
+       prefs_custom_header_write_config(cur_ac);
+       gtk_widget_hide(customhdr.window);
 }
 
-static void prefs_headers_cancel(GtkButton *button)
+static void prefs_custom_header_cancel(void)
 {
-       prefs_headers_read_config(cur_ac); 
-       gtk_widget_hide(headers.window);
+       prefs_custom_header_read_config(cur_ac); 
+       gtk_widget_hide(customhdr.window);
 }
 
-static gint prefs_headers_deleted(GtkWidget *widget, GdkEventAny *event,
-                                 gpointer data)
+static gint prefs_custom_header_deleted(GtkWidget *widget, GdkEventAny *event,
+                                       gpointer data)
 {
-       prefs_headers_cancel(GTK_BUTTON(widget));
+       prefs_custom_header_cancel();
        return TRUE;
 }
index e81d7d9..c72e29d 100644 (file)
 #ifndef __PREFS_CUSTOMHEADER_H__
 #define __PREFS_CUSTOMHEADER_H__
 
-void prefs_headers_read_config (PrefsAccount *ac);
-void prefs_headers_write_config        (PrefsAccount *ac);
-void prefs_headers_open                (PrefsAccount *ac);
+#include "prefs_account.h"
+
+void prefs_custom_header_read_config   (PrefsAccount *ac);
+void prefs_custom_header_write_config  (PrefsAccount *ac);
+void prefs_custom_header_open          (PrefsAccount *ac);
 
 #endif /* __PREFS_CUSTOMHEADER_H__ */
index 3a7dde2..86883d4 100644 (file)
@@ -83,13 +83,19 @@ static void prefs_display_header_delete_cb  (GtkButton      *btn,
 static void prefs_display_header_up            (void);
 static void prefs_display_header_down          (void);
 
+static void prefs_display_header_row_moved     (GtkCList       *clist,
+                                                gint            source_row,
+                                                gint            dest_row,
+                                                gpointer        data);
+
 static void prefs_display_header_key_pressed   (GtkWidget      *widget,
                                                 GdkEventKey    *event,
                                                 gpointer        data);
 static void prefs_display_header_ok            (void);
 static void prefs_display_header_cancel                (void);
-static gint prefs_display_header_deleted(GtkWidget *widget, GdkEventAny *event,
-                                        gpointer data);
+static gint prefs_display_header_deleted       (GtkWidget      *widget,
+                                                GdkEventAny    *event,
+                                                gpointer        data);
 
 static gchar *defaults[] =
 {
@@ -125,7 +131,7 @@ static void prefs_display_header_set_default(void)
        gint i;
        DisplayHeaderProp *dp;
 
-       for(i = 0; i < (gint) (sizeof(defaults) / sizeof(defaults[0])); i++) {
+       for(i = 0; i < sizeof(defaults) / sizeof(defaults[0]); i++) {
                dp = display_header_prop_read_str(defaults[i]);
                prefs_common.disphdr_list =
                        g_slist_append(prefs_common.disphdr_list, dp);
@@ -202,16 +208,16 @@ static void prefs_display_header_create(void)
 
        gtk_window_set_title (GTK_WINDOW(window),
                              _("Display header setting"));
+       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(window), "delete_event",
                            GTK_SIGNAL_FUNC(prefs_display_header_deleted),
                            NULL);
        gtk_signal_connect (GTK_OBJECT(window), "key_press_event",
                            GTK_SIGNAL_FUNC(prefs_display_header_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(ok_btn), "clicked",
                            GTK_SIGNAL_FUNC(prefs_display_header_ok),
                            NULL);
@@ -270,6 +276,9 @@ static void prefs_display_header_create(void)
        gtk_clist_set_use_drag_icons (GTK_CLIST (headers_clist), FALSE);
        GTK_WIDGET_UNSET_FLAGS (GTK_CLIST (headers_clist)->column[0].button,
                                GTK_CAN_FOCUS);
+       gtk_signal_connect_after
+               (GTK_OBJECT (headers_clist), "row_move",
+                GTK_SIGNAL_FUNC (prefs_display_header_row_moved), NULL);
 
        btn_vbox = gtk_vbox_new (FALSE, 8);
        gtk_widget_show (btn_vbox);
@@ -590,10 +599,8 @@ static void prefs_display_header_up(void)
        if (!clist->selection) return;
 
        row = GPOINTER_TO_INT(clist->selection->data);
-       if (row > 0) {
+       if (row > 0)
                gtk_clist_row_move(clist, row, row - 1);
-               prefs_display_header_set_list();
-       }
 }
 
 static void prefs_display_header_down(void)
@@ -604,10 +611,14 @@ static void prefs_display_header_down(void)
        if (!clist->selection) return;
 
        row = GPOINTER_TO_INT(clist->selection->data);
-       if (row >= 0 && row < clist->rows - 1) {
+       if (row >= 0 && row < clist->rows - 1)
                gtk_clist_row_move(clist, row, row + 1);
-               prefs_display_header_set_list();
-       }
+}
+
+static void prefs_display_header_row_moved(GtkCList *clist, gint source_row,
+                                          gint dest_row, gpointer data)
+{
+       prefs_display_header_set_list();
 }
 
 static void prefs_display_header_key_pressed(GtkWidget *widget,