Statistics
| Revision:

root / src / prefs_folder_item.c @ 1

History | View | Annotate | Download (17.1 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2003 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

    
30
#include "intl.h"
31
#include "folder.h"
32
#include "prefs.h"
33
#include "prefs_folder_item.h"
34
#include "prefs_account.h"
35
#include "account.h"
36
#include "manage_window.h"
37
#include "folderview.h"
38
#include "inc.h"
39
#include "menu.h"
40

    
41
typedef struct _PrefsFolderItemDialog        PrefsFolderItemDialog;
42

    
43
struct _PrefsFolderItemDialog
44
{
45
        PrefsDialog *dialog;
46
        FolderItem *item;
47

    
48
        /* General */
49
        GtkWidget *name_entry;
50
        GtkWidget *path_entry;
51
        GtkWidget *type_optmenu;
52

    
53
        GtkWidget *trim_summary_subj_chkbtn;
54
        GtkWidget *trim_compose_subj_chkbtn;
55

    
56
        /* Compose */
57
        GtkWidget *account_optmenu;
58
        GtkWidget *ac_apply_sub_chkbtn;
59
        GtkWidget *to_entry;
60
        GtkWidget *on_reply_chkbtn;
61
        GtkWidget *cc_entry;
62
        GtkWidget *bcc_entry;
63
        GtkWidget *replyto_entry;
64
};
65

    
66
static PrefsFolderItemDialog *prefs_folder_item_create
67
                                        (FolderItem                *item);
68
static void prefs_folder_item_general_create
69
                                        (PrefsFolderItemDialog        *dialog);
70
static void prefs_folder_item_compose_create
71
                                        (PrefsFolderItemDialog        *dialog);
72
static void prefs_folder_item_set_dialog(PrefsFolderItemDialog        *dialog);
73

    
74
static void prefs_folder_item_ok_cb        (GtkWidget                *widget, 
75
                                         PrefsFolderItemDialog        *dialog);
76
static void prefs_folder_item_apply_cb        (GtkWidget                *widget, 
77
                                         PrefsFolderItemDialog        *dialog);
78
static void prefs_folder_item_cancel_cb        (GtkWidget                *widget, 
79
                                         PrefsFolderItemDialog        *dialog);
80
static gint prefs_folder_item_delete_cb        (GtkWidget                *widget,
81
                                         GdkEventAny                *event, 
82
                                         PrefsFolderItemDialog        *dialog);
83
static gboolean prefs_folder_item_key_press_cb
84
                                        (GtkWidget                *widget,
85
                                         GdkEventKey                *event,
86
                                         PrefsFolderItemDialog        *dialog);
87

    
88
void prefs_folder_item_open(FolderItem *item)
89
{
90
        PrefsFolderItemDialog *dialog;
91

    
92
        g_return_if_fail(item != NULL);
93

    
94
        inc_lock();
95

    
96
        dialog = prefs_folder_item_create(item);
97

    
98
        manage_window_set_transient(GTK_WINDOW(dialog->dialog->window));
99

    
100
        prefs_folder_item_set_dialog(dialog);
101

    
102
        gtk_widget_show_all(dialog->dialog->window);
103
}
104

    
105
PrefsFolderItemDialog *prefs_folder_item_create(FolderItem *item)
106
{
107
        PrefsFolderItemDialog *new_dialog;
108
        PrefsDialog *dialog;
109

    
110
        new_dialog = g_new0(PrefsFolderItemDialog, 1);
111

    
112
        dialog = g_new0(PrefsDialog, 1);
113
        prefs_dialog_create(dialog);
114

    
115
        gtk_window_set_title(GTK_WINDOW(dialog->window), _("Folder properties"));
116
        gtk_widget_realize(dialog->window);
117
        g_signal_connect(G_OBJECT(dialog->window), "delete_event",
118
                         G_CALLBACK(prefs_folder_item_delete_cb), new_dialog);
119
        g_signal_connect(G_OBJECT(dialog->window), "key_press_event",
120
                         G_CALLBACK(prefs_folder_item_key_press_cb), new_dialog);
121
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog->window);
122

    
123
        g_signal_connect(G_OBJECT(dialog->ok_btn), "clicked",
124
                         G_CALLBACK(prefs_folder_item_ok_cb), new_dialog);
125
        g_signal_connect(G_OBJECT(dialog->apply_btn), "clicked",
126
                         G_CALLBACK(prefs_folder_item_apply_cb), new_dialog);
127
        g_signal_connect(G_OBJECT(dialog->cancel_btn), "clicked",
128
                         G_CALLBACK(prefs_folder_item_cancel_cb), new_dialog);
129

    
130
        new_dialog->dialog = dialog;
131
        new_dialog->item = item;
132

    
133
        prefs_folder_item_general_create(new_dialog);
134
        prefs_folder_item_compose_create(new_dialog);
135

    
136
        SET_NOTEBOOK_LABEL(dialog->notebook, _("General"), 0);
137
        SET_NOTEBOOK_LABEL(dialog->notebook, _("Compose"), 1);
138

    
139
        return new_dialog;
140
}
141

    
142
static void prefs_folder_item_general_create(PrefsFolderItemDialog *dialog)
143
{
144
        GtkWidget *vbox;
145
        GtkWidget *table;
146
        GtkWidget *hbox;
147
        GtkWidget *label;
148
        GtkWidget *name_entry;
149
        GtkWidget *path_entry;
150
        GtkWidget *optmenu;
151
        GtkWidget *optmenu_menu;
152
        GtkWidget *menuitem;
153
        GtkWidget *vbox2;
154
        GtkWidget *trim_summary_subj_chkbtn;
155
        GtkWidget *trim_compose_subj_chkbtn;
156
        GtkStyle *style;
157

    
158
        style = gtk_style_copy(gtk_widget_get_style(dialog->dialog->window));
159
        style->base[GTK_STATE_NORMAL] = style->bg[GTK_STATE_NORMAL];
160

    
161
        vbox = gtk_vbox_new(FALSE, VSPACING);
162
        gtk_container_add(GTK_CONTAINER(dialog->dialog->notebook), vbox);
163
        gtk_container_set_border_width(GTK_CONTAINER (vbox), VBOX_BORDER);
164

    
165
        table = gtk_table_new(3, 2, FALSE);
166
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
167
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
168
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
169

    
170
        label = gtk_label_new(_("Name"));
171
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
172
                         GTK_FILL, 0, 0, 0);
173
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
174

    
175
        name_entry = gtk_entry_new();
176
        gtk_editable_set_editable(GTK_EDITABLE(name_entry), FALSE);
177
        gtk_widget_set_size_request(name_entry, 200, -1);
178
        gtk_widget_set_style(name_entry, style);
179
        gtk_table_attach(GTK_TABLE(table), name_entry, 1, 2, 0, 1,
180
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
181
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
182

    
183
        label = gtk_label_new(_("Path"));
184
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
185
                         GTK_FILL, 0, 0, 0);
186
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
187

    
188
        path_entry = gtk_entry_new();
189
        gtk_editable_set_editable(GTK_EDITABLE(path_entry), FALSE);
190
        gtk_widget_set_size_request(path_entry, 200, -1);
191
        gtk_widget_set_style(path_entry, style);
192
        gtk_table_attach(GTK_TABLE(table), path_entry, 1, 2, 1, 2,
193
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
194
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
195

    
196
        label = gtk_label_new(_("Type"));
197
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
198
                         GTK_FILL, 0, 0, 0);
199

    
200
        hbox = gtk_hbox_new(FALSE, 8);
201
        gtk_widget_show(hbox);
202
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3,
203
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
204
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
205

    
206
        optmenu = gtk_option_menu_new();
207
        gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
208

    
209
        optmenu_menu = gtk_menu_new();
210

    
211
        MENUITEM_ADD(optmenu_menu, menuitem, _("Normal"), F_NORMAL);
212
        MENUITEM_ADD(optmenu_menu, menuitem, _("Inbox") , F_INBOX);
213
        MENUITEM_ADD(optmenu_menu, menuitem, _("Sent")  , F_OUTBOX);
214
        MENUITEM_ADD(optmenu_menu, menuitem, _("Drafts"), F_DRAFT);
215
        MENUITEM_ADD(optmenu_menu, menuitem, _("Queue") , F_QUEUE);
216
        MENUITEM_ADD(optmenu_menu, menuitem, _("Trash") , F_TRASH);
217

    
218
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
219

    
220
        vbox2 = gtk_vbox_new(FALSE, 0);
221
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0);
222

    
223
        PACK_CHECK_BUTTON(vbox2, trim_summary_subj_chkbtn,
224
                          _("Don't display [...] or (...) at the beginning of subject in summary"));
225
        PACK_CHECK_BUTTON(vbox2, trim_compose_subj_chkbtn,
226
                          _("Delete [...] or (...) at the beginning of subject on reply"));
227

    
228
        dialog->name_entry = name_entry;
229
        dialog->path_entry = path_entry;
230
        dialog->type_optmenu = optmenu;
231
        dialog->trim_summary_subj_chkbtn = trim_summary_subj_chkbtn;
232
        dialog->trim_compose_subj_chkbtn = trim_compose_subj_chkbtn;
233
}
234

    
235
static void prefs_folder_item_compose_create(PrefsFolderItemDialog *dialog)
236
{
237
        GtkWidget *vbox;
238
        GtkWidget *frame;
239
        GtkWidget *account_vbox;
240
        GtkWidget *table;
241
        GtkWidget *hbox;
242
        GtkWidget *label;
243
        GtkWidget *optmenu;
244
        GtkWidget *optmenu_menu;
245
        GtkWidget *menuitem;
246
        GtkWidget *ac_apply_sub_chkbtn;
247
        GtkWidget *to_entry;
248
        GtkWidget *on_reply_chkbtn;
249
        GtkWidget *cc_entry;
250
        GtkWidget *bcc_entry;
251
        GtkWidget *replyto_entry;
252
        GList *list;
253

    
254
        vbox = gtk_vbox_new(FALSE, VSPACING);
255
        gtk_container_add(GTK_CONTAINER(dialog->dialog->notebook), vbox);
256
        gtk_container_set_border_width(GTK_CONTAINER (vbox), VBOX_BORDER);
257

    
258
        PACK_FRAME(vbox, frame, _("Account"));
259

    
260
        account_vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
261
        gtk_container_add(GTK_CONTAINER(frame), account_vbox);
262
        gtk_container_set_border_width (GTK_CONTAINER (account_vbox), 8);
263

    
264
        table = gtk_table_new(1, 2, FALSE);
265
        gtk_box_pack_start(GTK_BOX(account_vbox), table, FALSE, FALSE, 0);
266
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
267
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
268

    
269
        label = gtk_label_new(_("Account"));
270
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
271
                         GTK_FILL, 0, 0, 0);
272
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
273

    
274
        hbox = gtk_hbox_new(FALSE, 8);
275
        gtk_widget_show(hbox);
276
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1,
277
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
278
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
279

    
280
        optmenu = gtk_option_menu_new();
281
        gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
282

    
283
        optmenu_menu = gtk_menu_new();
284

    
285
        MENUITEM_ADD(optmenu_menu, menuitem, _("None"), -1);
286

    
287
        for (list = account_get_list(); list != NULL; list = list->next) {
288
                gchar *text;
289
                PrefsAccount *ac = list->data;
290

    
291
                text = g_strdup_printf("%s: %s", ac->account_name, ac->address);
292
                MENUITEM_ADD(optmenu_menu, menuitem, text, ac->account_id);
293
        }
294

    
295
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
296

    
297
        PACK_CHECK_BUTTON(account_vbox, ac_apply_sub_chkbtn,
298
                          _("Apply to subfolders"));
299

    
300
        PACK_FRAME(vbox, frame, _("Automatically set the following addresses"));
301

    
302
        table = gtk_table_new(4, 2, FALSE);
303
        gtk_container_add(GTK_CONTAINER(frame), table);
304
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
305
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
306
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
307

    
308
        label = gtk_label_new(_("To:"));
309
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
310
                         GTK_FILL, 0, 0, 0);
311
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
312

    
313
        hbox = gtk_hbox_new(FALSE, 8);
314
        gtk_widget_show(hbox);
315
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1,
316
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
317
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
318

    
319
        to_entry = gtk_entry_new();
320
        gtk_widget_set_size_request(to_entry, 200, -1);
321
        gtk_box_pack_start(GTK_BOX(hbox), to_entry, TRUE, TRUE, 0);
322

    
323
        PACK_CHECK_BUTTON(hbox, on_reply_chkbtn, _("use also on reply"));
324

    
325
        label = gtk_label_new(_("Cc:"));
326
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
327
                         GTK_FILL, 0, 0, 0);
328
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
329

    
330
        cc_entry = gtk_entry_new();
331
        gtk_widget_set_size_request(cc_entry, 200, -1);
332
        gtk_table_attach(GTK_TABLE(table), cc_entry, 1, 2, 1, 2,
333
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
334
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
335

    
336
        label = gtk_label_new(_("Bcc:"));
337
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
338
                         GTK_FILL, 0, 0, 0);
339
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
340

    
341
        bcc_entry = gtk_entry_new();
342
        gtk_widget_set_size_request(bcc_entry, 200, -1);
343
        gtk_table_attach(GTK_TABLE(table), bcc_entry, 1, 2, 2, 3,
344
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
345
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
346

    
347
        label = gtk_label_new(_("Reply-To:"));
348
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
349
                         GTK_FILL, 0, 0, 0);
350
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
351

    
352
        replyto_entry = gtk_entry_new();
353
        gtk_widget_set_size_request(replyto_entry, 200, -1);
354
        gtk_table_attach(GTK_TABLE(table), replyto_entry, 1, 2, 3, 4,
355
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
356
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
357

    
358
        dialog->account_optmenu     = optmenu;
359
        dialog->ac_apply_sub_chkbtn = ac_apply_sub_chkbtn;
360
        dialog->to_entry            = to_entry;
361
        dialog->on_reply_chkbtn     = on_reply_chkbtn;
362
        dialog->cc_entry            = cc_entry;
363
        dialog->bcc_entry           = bcc_entry;
364
        dialog->replyto_entry       = replyto_entry;
365
}
366

    
367
#define SET_ENTRY(entry, str) \
368
        gtk_entry_set_text(GTK_ENTRY(dialog->entry), \
369
                           dialog->item->str ? dialog->item->str : "")
370

    
371
static void prefs_folder_item_set_dialog(PrefsFolderItemDialog *dialog)
372
{
373
        GtkWidget *menu;
374
        GtkWidget *menuitem;
375
        GtkOptionMenu *optmenu;
376
        gchar *id;
377
        GList *cur;
378
        SpecialFolderItemType type;
379
        gint n;
380
        guint index = 0;
381

    
382
        /* General */
383

    
384
        SET_ENTRY(name_entry, name);
385

    
386
        id = folder_item_get_identifier(dialog->item);
387
        gtk_entry_set_text(GTK_ENTRY(dialog->path_entry), id);
388
        g_free(id);
389

    
390
        optmenu = GTK_OPTION_MENU(dialog->type_optmenu);
391
        menu = gtk_option_menu_get_menu(optmenu);
392
        for (cur = GTK_MENU_SHELL(menu)->children, n = 0;
393
             cur != NULL; cur = cur->next, n++) {
394
                menuitem = GTK_WIDGET(cur->data);
395
                type = (SpecialFolderItemType)
396
                        g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
397
                if (type != F_NORMAL &&
398
                    FOLDER_TYPE(dialog->item->folder) == F_NEWS)
399
                        gtk_widget_set_sensitive(menuitem, FALSE);
400
                if (dialog->item->stype == type)
401
                        index = n;
402
        }
403

    
404
        gtk_option_menu_set_history(optmenu, index);
405

    
406
        gtk_toggle_button_set_active
407
                (GTK_TOGGLE_BUTTON(dialog->trim_summary_subj_chkbtn),
408
                 dialog->item->trim_summary_subject);
409
        gtk_toggle_button_set_active
410
                (GTK_TOGGLE_BUTTON(dialog->trim_compose_subj_chkbtn),
411
                 dialog->item->trim_compose_subject);
412

    
413
        /* Compose */
414

    
415
        index = 0;
416
        optmenu = GTK_OPTION_MENU(dialog->account_optmenu);
417
        if (dialog->item->account) {
418
                index = menu_find_option_menu_index
419
                        (optmenu,
420
                         GINT_TO_POINTER(dialog->item->account->account_id),
421
                         NULL);
422
                if (index < 0)
423
                        index = 0;
424
        }
425

    
426
        gtk_option_menu_set_history(optmenu, index);
427

    
428
        gtk_toggle_button_set_active
429
                (GTK_TOGGLE_BUTTON(dialog->ac_apply_sub_chkbtn),
430
                 dialog->item->ac_apply_sub);
431

    
432
        SET_ENTRY(to_entry, auto_to);
433
        gtk_toggle_button_set_active
434
                (GTK_TOGGLE_BUTTON(dialog->on_reply_chkbtn),
435
                 dialog->item->use_auto_to_on_reply);
436

    
437
        SET_ENTRY(cc_entry, auto_cc);
438
        SET_ENTRY(bcc_entry, auto_bcc);
439
        SET_ENTRY(replyto_entry, auto_replyto);
440
}
441

    
442
#undef SET_ENTRY
443

    
444
void prefs_folder_item_destroy(PrefsFolderItemDialog *dialog) 
445
{
446
        prefs_dialog_destroy(dialog->dialog);
447
        g_free(dialog->dialog);
448
        g_free(dialog);
449

    
450
        inc_unlock();
451
}
452

    
453
static void prefs_folder_item_ok_cb(GtkWidget *widget,
454
                                    PrefsFolderItemDialog *dialog)
455
{
456
        prefs_folder_item_apply_cb(widget, dialog);
457
        prefs_folder_item_destroy(dialog);
458
}
459

    
460
#define SET_DATA_FROM_ENTRY(entry, str) \
461
{ \
462
        entry_str = gtk_entry_get_text(GTK_ENTRY(dialog->entry)); \
463
        g_free(item->str); \
464
        item->str = (entry_str && *entry_str) ? g_strdup(entry_str) : NULL; \
465
}
466

    
467
static void prefs_folder_item_apply_cb(GtkWidget *widget,
468
                                       PrefsFolderItemDialog *dialog)
469
{
470
        GtkWidget *menu;
471
        GtkWidget *menuitem;
472
        GtkOptionMenu *optmenu;
473
        SpecialFolderItemType type;
474
        FolderItem *item = dialog->item;
475
        Folder *folder = item->folder;
476
        FolderItem *prev_item = NULL;
477
        gint account_id;
478
        const gchar *entry_str;
479

    
480
        optmenu = GTK_OPTION_MENU(dialog->type_optmenu);
481
        menu = gtk_option_menu_get_menu(optmenu);
482
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
483
        type = (SpecialFolderItemType)
484
                g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
485

    
486
        if (item->stype != type) {
487
                switch (type) {
488
                case F_NORMAL:
489
                        break;
490
                case F_INBOX:
491
                        if (folder->inbox)
492
                                folder->inbox->stype = F_NORMAL;
493
                        prev_item = folder->inbox;
494
                        folder->inbox = item;
495
                        break;
496
                case F_OUTBOX:
497
                        if (folder->outbox)
498
                                folder->outbox->stype = F_NORMAL;
499
                        prev_item = folder->outbox;
500
                        folder->outbox = item;
501
                        break;
502
                case F_DRAFT:
503
                        if (folder->draft)
504
                                folder->draft->stype = F_NORMAL;
505
                        prev_item = folder->draft;
506
                        folder->draft = item;
507
                        break;
508
                case F_QUEUE:
509
                        if (folder->queue)
510
                                folder->queue->stype = F_NORMAL;
511
                        prev_item = folder->queue;
512
                        folder->queue = item;
513
                        break;
514
                case F_TRASH:
515
                        if (folder->trash)
516
                                folder->trash->stype = F_NORMAL;
517
                        prev_item = folder->trash;
518
                        folder->trash = item;
519
                        break;
520
                }
521

    
522
                item->stype = type;
523

    
524
                if (prev_item)
525
                        folderview_update_item(prev_item, FALSE);
526
                folderview_update_item(item, FALSE);
527
        }
528

    
529
        item->trim_summary_subject = gtk_toggle_button_get_active
530
                (GTK_TOGGLE_BUTTON(dialog->trim_summary_subj_chkbtn));
531
        item->trim_compose_subject = gtk_toggle_button_get_active
532
                (GTK_TOGGLE_BUTTON(dialog->trim_compose_subj_chkbtn));
533

    
534
        /* account menu */
535
        optmenu = GTK_OPTION_MENU(dialog->account_optmenu);
536
        menu = gtk_option_menu_get_menu(optmenu);
537
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
538
        account_id = GPOINTER_TO_INT
539
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
540
        if (account_id >= 0)
541
                item->account = account_find_from_id(account_id);
542
        else
543
                item->account = NULL;
544

    
545
        item->ac_apply_sub = gtk_toggle_button_get_active
546
                (GTK_TOGGLE_BUTTON(dialog->ac_apply_sub_chkbtn));
547

    
548
        SET_DATA_FROM_ENTRY(to_entry, auto_to);
549
        item->use_auto_to_on_reply = gtk_toggle_button_get_active
550
                (GTK_TOGGLE_BUTTON(dialog->on_reply_chkbtn));
551

    
552
        SET_DATA_FROM_ENTRY(cc_entry, auto_cc);
553
        SET_DATA_FROM_ENTRY(bcc_entry, auto_bcc);
554
        SET_DATA_FROM_ENTRY(replyto_entry, auto_replyto);
555
}
556

    
557
#undef SET_DATA_FROM_ENTRY
558

    
559
static void prefs_folder_item_cancel_cb(GtkWidget *widget,
560
                                        PrefsFolderItemDialog *dialog)
561
{
562
        prefs_folder_item_destroy(dialog);
563
}
564

    
565
static gint prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event,
566
                                        PrefsFolderItemDialog *dialog)
567
{
568
        prefs_folder_item_destroy(dialog);
569
        return TRUE;
570
}
571

    
572
static gboolean prefs_folder_item_key_press_cb(GtkWidget *widget,
573
                                           GdkEventKey *event,
574
                                           PrefsFolderItemDialog *dialog)
575
{
576
        if (event && event->keyval == GDK_Escape)
577
                prefs_folder_item_cancel_cb(widget, dialog);
578
        return FALSE;
579
}