Statistics
| Revision:

root / src / prefs_folder_item.c @ 56

History | View | Annotate | Download (17.1 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1 hiro
 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifdef HAVE_CONFIG_H
21 1 hiro
#  include "config.h"
22 1 hiro
#endif
23 1 hiro
24 1 hiro
#include "defs.h"
25 1 hiro
26 1 hiro
#include <glib.h>
27 1 hiro
#include <gtk/gtk.h>
28 1 hiro
#include <gdk/gdkkeysyms.h>
29 1 hiro
30 1 hiro
#include "intl.h"
31 1 hiro
#include "folder.h"
32 1 hiro
#include "prefs.h"
33 1 hiro
#include "prefs_folder_item.h"
34 1 hiro
#include "prefs_account.h"
35 1 hiro
#include "account.h"
36 1 hiro
#include "manage_window.h"
37 1 hiro
#include "folderview.h"
38 1 hiro
#include "inc.h"
39 1 hiro
#include "menu.h"
40 1 hiro
41 1 hiro
typedef struct _PrefsFolderItemDialog        PrefsFolderItemDialog;
42 1 hiro
43 1 hiro
struct _PrefsFolderItemDialog
44 1 hiro
{
45 1 hiro
        PrefsDialog *dialog;
46 1 hiro
        FolderItem *item;
47 1 hiro
48 1 hiro
        /* General */
49 1 hiro
        GtkWidget *name_entry;
50 1 hiro
        GtkWidget *path_entry;
51 1 hiro
        GtkWidget *type_optmenu;
52 1 hiro
53 1 hiro
        GtkWidget *trim_summary_subj_chkbtn;
54 1 hiro
        GtkWidget *trim_compose_subj_chkbtn;
55 1 hiro
56 1 hiro
        /* Compose */
57 1 hiro
        GtkWidget *account_optmenu;
58 1 hiro
        GtkWidget *ac_apply_sub_chkbtn;
59 1 hiro
        GtkWidget *to_entry;
60 1 hiro
        GtkWidget *on_reply_chkbtn;
61 1 hiro
        GtkWidget *cc_entry;
62 1 hiro
        GtkWidget *bcc_entry;
63 1 hiro
        GtkWidget *replyto_entry;
64 1 hiro
};
65 1 hiro
66 1 hiro
static PrefsFolderItemDialog *prefs_folder_item_create
67 1 hiro
                                        (FolderItem                *item);
68 1 hiro
static void prefs_folder_item_general_create
69 1 hiro
                                        (PrefsFolderItemDialog        *dialog);
70 1 hiro
static void prefs_folder_item_compose_create
71 1 hiro
                                        (PrefsFolderItemDialog        *dialog);
72 1 hiro
static void prefs_folder_item_set_dialog(PrefsFolderItemDialog        *dialog);
73 1 hiro
74 1 hiro
static void prefs_folder_item_ok_cb        (GtkWidget                *widget,
75 1 hiro
                                         PrefsFolderItemDialog        *dialog);
76 1 hiro
static void prefs_folder_item_apply_cb        (GtkWidget                *widget,
77 1 hiro
                                         PrefsFolderItemDialog        *dialog);
78 1 hiro
static void prefs_folder_item_cancel_cb        (GtkWidget                *widget,
79 1 hiro
                                         PrefsFolderItemDialog        *dialog);
80 1 hiro
static gint prefs_folder_item_delete_cb        (GtkWidget                *widget,
81 1 hiro
                                         GdkEventAny                *event,
82 1 hiro
                                         PrefsFolderItemDialog        *dialog);
83 1 hiro
static gboolean prefs_folder_item_key_press_cb
84 1 hiro
                                        (GtkWidget                *widget,
85 1 hiro
                                         GdkEventKey                *event,
86 1 hiro
                                         PrefsFolderItemDialog        *dialog);
87 1 hiro
88 1 hiro
void prefs_folder_item_open(FolderItem *item)
89 1 hiro
{
90 1 hiro
        PrefsFolderItemDialog *dialog;
91 1 hiro
92 1 hiro
        g_return_if_fail(item != NULL);
93 1 hiro
94 1 hiro
        inc_lock();
95 1 hiro
96 1 hiro
        dialog = prefs_folder_item_create(item);
97 1 hiro
98 1 hiro
        manage_window_set_transient(GTK_WINDOW(dialog->dialog->window));
99 1 hiro
100 1 hiro
        prefs_folder_item_set_dialog(dialog);
101 1 hiro
102 1 hiro
        gtk_widget_show_all(dialog->dialog->window);
103 1 hiro
}
104 1 hiro
105 1 hiro
PrefsFolderItemDialog *prefs_folder_item_create(FolderItem *item)
106 1 hiro
{
107 1 hiro
        PrefsFolderItemDialog *new_dialog;
108 1 hiro
        PrefsDialog *dialog;
109 1 hiro
110 1 hiro
        new_dialog = g_new0(PrefsFolderItemDialog, 1);
111 1 hiro
112 1 hiro
        dialog = g_new0(PrefsDialog, 1);
113 1 hiro
        prefs_dialog_create(dialog);
114 1 hiro
115 1 hiro
        gtk_window_set_title(GTK_WINDOW(dialog->window), _("Folder properties"));
116 1 hiro
        gtk_widget_realize(dialog->window);
117 1 hiro
        g_signal_connect(G_OBJECT(dialog->window), "delete_event",
118 1 hiro
                         G_CALLBACK(prefs_folder_item_delete_cb), new_dialog);
119 1 hiro
        g_signal_connect(G_OBJECT(dialog->window), "key_press_event",
120 1 hiro
                         G_CALLBACK(prefs_folder_item_key_press_cb), new_dialog);
121 1 hiro
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog->window);
122 1 hiro
123 1 hiro
        g_signal_connect(G_OBJECT(dialog->ok_btn), "clicked",
124 1 hiro
                         G_CALLBACK(prefs_folder_item_ok_cb), new_dialog);
125 1 hiro
        g_signal_connect(G_OBJECT(dialog->apply_btn), "clicked",
126 1 hiro
                         G_CALLBACK(prefs_folder_item_apply_cb), new_dialog);
127 1 hiro
        g_signal_connect(G_OBJECT(dialog->cancel_btn), "clicked",
128 1 hiro
                         G_CALLBACK(prefs_folder_item_cancel_cb), new_dialog);
129 1 hiro
130 1 hiro
        new_dialog->dialog = dialog;
131 1 hiro
        new_dialog->item = item;
132 1 hiro
133 1 hiro
        prefs_folder_item_general_create(new_dialog);
134 1 hiro
        prefs_folder_item_compose_create(new_dialog);
135 1 hiro
136 1 hiro
        SET_NOTEBOOK_LABEL(dialog->notebook, _("General"), 0);
137 1 hiro
        SET_NOTEBOOK_LABEL(dialog->notebook, _("Compose"), 1);
138 1 hiro
139 1 hiro
        return new_dialog;
140 1 hiro
}
141 1 hiro
142 1 hiro
static void prefs_folder_item_general_create(PrefsFolderItemDialog *dialog)
143 1 hiro
{
144 1 hiro
        GtkWidget *vbox;
145 1 hiro
        GtkWidget *table;
146 1 hiro
        GtkWidget *hbox;
147 1 hiro
        GtkWidget *label;
148 1 hiro
        GtkWidget *name_entry;
149 1 hiro
        GtkWidget *path_entry;
150 1 hiro
        GtkWidget *optmenu;
151 1 hiro
        GtkWidget *optmenu_menu;
152 1 hiro
        GtkWidget *menuitem;
153 1 hiro
        GtkWidget *vbox2;
154 1 hiro
        GtkWidget *trim_summary_subj_chkbtn;
155 1 hiro
        GtkWidget *trim_compose_subj_chkbtn;
156 1 hiro
        GtkStyle *style;
157 1 hiro
158 1 hiro
        style = gtk_style_copy(gtk_widget_get_style(dialog->dialog->window));
159 1 hiro
        style->base[GTK_STATE_NORMAL] = style->bg[GTK_STATE_NORMAL];
160 1 hiro
161 1 hiro
        vbox = gtk_vbox_new(FALSE, VSPACING);
162 1 hiro
        gtk_container_add(GTK_CONTAINER(dialog->dialog->notebook), vbox);
163 1 hiro
        gtk_container_set_border_width(GTK_CONTAINER (vbox), VBOX_BORDER);
164 1 hiro
165 1 hiro
        table = gtk_table_new(3, 2, FALSE);
166 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
167 1 hiro
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
168 1 hiro
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
169 1 hiro
170 1 hiro
        label = gtk_label_new(_("Name"));
171 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
172 1 hiro
                         GTK_FILL, 0, 0, 0);
173 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
174 1 hiro
175 1 hiro
        name_entry = gtk_entry_new();
176 1 hiro
        gtk_editable_set_editable(GTK_EDITABLE(name_entry), FALSE);
177 1 hiro
        gtk_widget_set_size_request(name_entry, 200, -1);
178 1 hiro
        gtk_widget_set_style(name_entry, style);
179 1 hiro
        gtk_table_attach(GTK_TABLE(table), name_entry, 1, 2, 0, 1,
180 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
181 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
182 1 hiro
183 1 hiro
        label = gtk_label_new(_("Path"));
184 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
185 1 hiro
                         GTK_FILL, 0, 0, 0);
186 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
187 1 hiro
188 1 hiro
        path_entry = gtk_entry_new();
189 1 hiro
        gtk_editable_set_editable(GTK_EDITABLE(path_entry), FALSE);
190 1 hiro
        gtk_widget_set_size_request(path_entry, 200, -1);
191 1 hiro
        gtk_widget_set_style(path_entry, style);
192 1 hiro
        gtk_table_attach(GTK_TABLE(table), path_entry, 1, 2, 1, 2,
193 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
194 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
195 1 hiro
196 1 hiro
        label = gtk_label_new(_("Type"));
197 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
198 1 hiro
                         GTK_FILL, 0, 0, 0);
199 1 hiro
200 1 hiro
        hbox = gtk_hbox_new(FALSE, 8);
201 1 hiro
        gtk_widget_show(hbox);
202 1 hiro
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3,
203 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
204 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
205 1 hiro
206 1 hiro
        optmenu = gtk_option_menu_new();
207 1 hiro
        gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
208 1 hiro
209 1 hiro
        optmenu_menu = gtk_menu_new();
210 1 hiro
211 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Normal"), F_NORMAL);
212 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Inbox") , F_INBOX);
213 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Sent")  , F_OUTBOX);
214 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Drafts"), F_DRAFT);
215 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Queue") , F_QUEUE);
216 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("Trash") , F_TRASH);
217 1 hiro
218 1 hiro
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
219 1 hiro
220 1 hiro
        vbox2 = gtk_vbox_new(FALSE, 0);
221 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0);
222 1 hiro
223 1 hiro
        PACK_CHECK_BUTTON(vbox2, trim_summary_subj_chkbtn,
224 1 hiro
                          _("Don't display [...] or (...) at the beginning of subject in summary"));
225 1 hiro
        PACK_CHECK_BUTTON(vbox2, trim_compose_subj_chkbtn,
226 1 hiro
                          _("Delete [...] or (...) at the beginning of subject on reply"));
227 1 hiro
228 1 hiro
        dialog->name_entry = name_entry;
229 1 hiro
        dialog->path_entry = path_entry;
230 1 hiro
        dialog->type_optmenu = optmenu;
231 1 hiro
        dialog->trim_summary_subj_chkbtn = trim_summary_subj_chkbtn;
232 1 hiro
        dialog->trim_compose_subj_chkbtn = trim_compose_subj_chkbtn;
233 1 hiro
}
234 1 hiro
235 1 hiro
static void prefs_folder_item_compose_create(PrefsFolderItemDialog *dialog)
236 1 hiro
{
237 1 hiro
        GtkWidget *vbox;
238 1 hiro
        GtkWidget *frame;
239 1 hiro
        GtkWidget *account_vbox;
240 1 hiro
        GtkWidget *table;
241 1 hiro
        GtkWidget *hbox;
242 1 hiro
        GtkWidget *label;
243 1 hiro
        GtkWidget *optmenu;
244 1 hiro
        GtkWidget *optmenu_menu;
245 1 hiro
        GtkWidget *menuitem;
246 1 hiro
        GtkWidget *ac_apply_sub_chkbtn;
247 1 hiro
        GtkWidget *to_entry;
248 1 hiro
        GtkWidget *on_reply_chkbtn;
249 1 hiro
        GtkWidget *cc_entry;
250 1 hiro
        GtkWidget *bcc_entry;
251 1 hiro
        GtkWidget *replyto_entry;
252 1 hiro
        GList *list;
253 1 hiro
254 1 hiro
        vbox = gtk_vbox_new(FALSE, VSPACING);
255 1 hiro
        gtk_container_add(GTK_CONTAINER(dialog->dialog->notebook), vbox);
256 1 hiro
        gtk_container_set_border_width(GTK_CONTAINER (vbox), VBOX_BORDER);
257 1 hiro
258 1 hiro
        PACK_FRAME(vbox, frame, _("Account"));
259 1 hiro
260 1 hiro
        account_vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
261 1 hiro
        gtk_container_add(GTK_CONTAINER(frame), account_vbox);
262 1 hiro
        gtk_container_set_border_width (GTK_CONTAINER (account_vbox), 8);
263 1 hiro
264 1 hiro
        table = gtk_table_new(1, 2, FALSE);
265 1 hiro
        gtk_box_pack_start(GTK_BOX(account_vbox), table, FALSE, FALSE, 0);
266 1 hiro
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
267 1 hiro
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
268 1 hiro
269 1 hiro
        label = gtk_label_new(_("Account"));
270 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
271 1 hiro
                         GTK_FILL, 0, 0, 0);
272 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
273 1 hiro
274 1 hiro
        hbox = gtk_hbox_new(FALSE, 8);
275 1 hiro
        gtk_widget_show(hbox);
276 1 hiro
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1,
277 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
278 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
279 1 hiro
280 1 hiro
        optmenu = gtk_option_menu_new();
281 1 hiro
        gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0);
282 1 hiro
283 1 hiro
        optmenu_menu = gtk_menu_new();
284 1 hiro
285 1 hiro
        MENUITEM_ADD(optmenu_menu, menuitem, _("None"), -1);
286 1 hiro
287 1 hiro
        for (list = account_get_list(); list != NULL; list = list->next) {
288 1 hiro
                gchar *text;
289 1 hiro
                PrefsAccount *ac = list->data;
290 1 hiro
291 1 hiro
                text = g_strdup_printf("%s: %s", ac->account_name, ac->address);
292 1 hiro
                MENUITEM_ADD(optmenu_menu, menuitem, text, ac->account_id);
293 1 hiro
        }
294 1 hiro
295 1 hiro
        gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), optmenu_menu);
296 1 hiro
297 1 hiro
        PACK_CHECK_BUTTON(account_vbox, ac_apply_sub_chkbtn,
298 1 hiro
                          _("Apply to subfolders"));
299 1 hiro
300 1 hiro
        PACK_FRAME(vbox, frame, _("Automatically set the following addresses"));
301 1 hiro
302 1 hiro
        table = gtk_table_new(4, 2, FALSE);
303 1 hiro
        gtk_container_add(GTK_CONTAINER(frame), table);
304 1 hiro
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
305 1 hiro
        gtk_table_set_row_spacings(GTK_TABLE(table), VSPACING_NARROW);
306 1 hiro
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
307 1 hiro
308 1 hiro
        label = gtk_label_new(_("To:"));
309 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
310 1 hiro
                         GTK_FILL, 0, 0, 0);
311 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
312 1 hiro
313 1 hiro
        hbox = gtk_hbox_new(FALSE, 8);
314 1 hiro
        gtk_widget_show(hbox);
315 1 hiro
        gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1,
316 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
317 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
318 1 hiro
319 1 hiro
        to_entry = gtk_entry_new();
320 1 hiro
        gtk_widget_set_size_request(to_entry, 200, -1);
321 1 hiro
        gtk_box_pack_start(GTK_BOX(hbox), to_entry, TRUE, TRUE, 0);
322 1 hiro
323 1 hiro
        PACK_CHECK_BUTTON(hbox, on_reply_chkbtn, _("use also on reply"));
324 1 hiro
325 1 hiro
        label = gtk_label_new(_("Cc:"));
326 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
327 1 hiro
                         GTK_FILL, 0, 0, 0);
328 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
329 1 hiro
330 1 hiro
        cc_entry = gtk_entry_new();
331 1 hiro
        gtk_widget_set_size_request(cc_entry, 200, -1);
332 1 hiro
        gtk_table_attach(GTK_TABLE(table), cc_entry, 1, 2, 1, 2,
333 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
334 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
335 1 hiro
336 1 hiro
        label = gtk_label_new(_("Bcc:"));
337 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
338 1 hiro
                         GTK_FILL, 0, 0, 0);
339 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
340 1 hiro
341 1 hiro
        bcc_entry = gtk_entry_new();
342 1 hiro
        gtk_widget_set_size_request(bcc_entry, 200, -1);
343 1 hiro
        gtk_table_attach(GTK_TABLE(table), bcc_entry, 1, 2, 2, 3,
344 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
345 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
346 1 hiro
347 1 hiro
        label = gtk_label_new(_("Reply-To:"));
348 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
349 1 hiro
                         GTK_FILL, 0, 0, 0);
350 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
351 1 hiro
352 1 hiro
        replyto_entry = gtk_entry_new();
353 1 hiro
        gtk_widget_set_size_request(replyto_entry, 200, -1);
354 1 hiro
        gtk_table_attach(GTK_TABLE(table), replyto_entry, 1, 2, 3, 4,
355 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL,
356 1 hiro
                         GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
357 1 hiro
358 1 hiro
        dialog->account_optmenu     = optmenu;
359 1 hiro
        dialog->ac_apply_sub_chkbtn = ac_apply_sub_chkbtn;
360 1 hiro
        dialog->to_entry            = to_entry;
361 1 hiro
        dialog->on_reply_chkbtn     = on_reply_chkbtn;
362 1 hiro
        dialog->cc_entry            = cc_entry;
363 1 hiro
        dialog->bcc_entry           = bcc_entry;
364 1 hiro
        dialog->replyto_entry       = replyto_entry;
365 1 hiro
}
366 1 hiro
367 1 hiro
#define SET_ENTRY(entry, str) \
368 1 hiro
        gtk_entry_set_text(GTK_ENTRY(dialog->entry), \
369 1 hiro
                           dialog->item->str ? dialog->item->str : "")
370 1 hiro
371 1 hiro
static void prefs_folder_item_set_dialog(PrefsFolderItemDialog *dialog)
372 1 hiro
{
373 1 hiro
        GtkWidget *menu;
374 1 hiro
        GtkWidget *menuitem;
375 1 hiro
        GtkOptionMenu *optmenu;
376 1 hiro
        gchar *id;
377 1 hiro
        GList *cur;
378 1 hiro
        SpecialFolderItemType type;
379 1 hiro
        gint n;
380 1 hiro
        guint index = 0;
381 1 hiro
382 1 hiro
        /* General */
383 1 hiro
384 1 hiro
        SET_ENTRY(name_entry, name);
385 1 hiro
386 1 hiro
        id = folder_item_get_identifier(dialog->item);
387 1 hiro
        gtk_entry_set_text(GTK_ENTRY(dialog->path_entry), id);
388 1 hiro
        g_free(id);
389 1 hiro
390 1 hiro
        optmenu = GTK_OPTION_MENU(dialog->type_optmenu);
391 1 hiro
        menu = gtk_option_menu_get_menu(optmenu);
392 1 hiro
        for (cur = GTK_MENU_SHELL(menu)->children, n = 0;
393 1 hiro
             cur != NULL; cur = cur->next, n++) {
394 1 hiro
                menuitem = GTK_WIDGET(cur->data);
395 1 hiro
                type = (SpecialFolderItemType)
396 1 hiro
                        g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
397 1 hiro
                if (type != F_NORMAL &&
398 1 hiro
                    FOLDER_TYPE(dialog->item->folder) == F_NEWS)
399 1 hiro
                        gtk_widget_set_sensitive(menuitem, FALSE);
400 1 hiro
                if (dialog->item->stype == type)
401 1 hiro
                        index = n;
402 1 hiro
        }
403 1 hiro
404 1 hiro
        gtk_option_menu_set_history(optmenu, index);
405 1 hiro
406 1 hiro
        gtk_toggle_button_set_active
407 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->trim_summary_subj_chkbtn),
408 1 hiro
                 dialog->item->trim_summary_subject);
409 1 hiro
        gtk_toggle_button_set_active
410 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->trim_compose_subj_chkbtn),
411 1 hiro
                 dialog->item->trim_compose_subject);
412 1 hiro
413 1 hiro
        /* Compose */
414 1 hiro
415 1 hiro
        index = 0;
416 1 hiro
        optmenu = GTK_OPTION_MENU(dialog->account_optmenu);
417 1 hiro
        if (dialog->item->account) {
418 1 hiro
                index = menu_find_option_menu_index
419 1 hiro
                        (optmenu,
420 1 hiro
                         GINT_TO_POINTER(dialog->item->account->account_id),
421 1 hiro
                         NULL);
422 1 hiro
                if (index < 0)
423 1 hiro
                        index = 0;
424 1 hiro
        }
425 1 hiro
426 1 hiro
        gtk_option_menu_set_history(optmenu, index);
427 1 hiro
428 1 hiro
        gtk_toggle_button_set_active
429 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->ac_apply_sub_chkbtn),
430 1 hiro
                 dialog->item->ac_apply_sub);
431 1 hiro
432 1 hiro
        SET_ENTRY(to_entry, auto_to);
433 1 hiro
        gtk_toggle_button_set_active
434 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->on_reply_chkbtn),
435 1 hiro
                 dialog->item->use_auto_to_on_reply);
436 1 hiro
437 1 hiro
        SET_ENTRY(cc_entry, auto_cc);
438 1 hiro
        SET_ENTRY(bcc_entry, auto_bcc);
439 1 hiro
        SET_ENTRY(replyto_entry, auto_replyto);
440 1 hiro
}
441 1 hiro
442 1 hiro
#undef SET_ENTRY
443 1 hiro
444 1 hiro
void prefs_folder_item_destroy(PrefsFolderItemDialog *dialog)
445 1 hiro
{
446 1 hiro
        prefs_dialog_destroy(dialog->dialog);
447 1 hiro
        g_free(dialog->dialog);
448 1 hiro
        g_free(dialog);
449 1 hiro
450 1 hiro
        inc_unlock();
451 1 hiro
}
452 1 hiro
453 1 hiro
static void prefs_folder_item_ok_cb(GtkWidget *widget,
454 1 hiro
                                    PrefsFolderItemDialog *dialog)
455 1 hiro
{
456 1 hiro
        prefs_folder_item_apply_cb(widget, dialog);
457 1 hiro
        prefs_folder_item_destroy(dialog);
458 1 hiro
}
459 1 hiro
460 1 hiro
#define SET_DATA_FROM_ENTRY(entry, str) \
461 1 hiro
{ \
462 1 hiro
        entry_str = gtk_entry_get_text(GTK_ENTRY(dialog->entry)); \
463 1 hiro
        g_free(item->str); \
464 1 hiro
        item->str = (entry_str && *entry_str) ? g_strdup(entry_str) : NULL; \
465 1 hiro
}
466 1 hiro
467 1 hiro
static void prefs_folder_item_apply_cb(GtkWidget *widget,
468 1 hiro
                                       PrefsFolderItemDialog *dialog)
469 1 hiro
{
470 1 hiro
        GtkWidget *menu;
471 1 hiro
        GtkWidget *menuitem;
472 1 hiro
        GtkOptionMenu *optmenu;
473 1 hiro
        SpecialFolderItemType type;
474 1 hiro
        FolderItem *item = dialog->item;
475 1 hiro
        Folder *folder = item->folder;
476 1 hiro
        FolderItem *prev_item = NULL;
477 1 hiro
        gint account_id;
478 1 hiro
        const gchar *entry_str;
479 1 hiro
480 1 hiro
        optmenu = GTK_OPTION_MENU(dialog->type_optmenu);
481 1 hiro
        menu = gtk_option_menu_get_menu(optmenu);
482 1 hiro
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
483 1 hiro
        type = (SpecialFolderItemType)
484 1 hiro
                g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID);
485 1 hiro
486 1 hiro
        if (item->stype != type) {
487 1 hiro
                switch (type) {
488 1 hiro
                case F_NORMAL:
489 1 hiro
                        break;
490 1 hiro
                case F_INBOX:
491 1 hiro
                        if (folder->inbox)
492 1 hiro
                                folder->inbox->stype = F_NORMAL;
493 1 hiro
                        prev_item = folder->inbox;
494 1 hiro
                        folder->inbox = item;
495 1 hiro
                        break;
496 1 hiro
                case F_OUTBOX:
497 1 hiro
                        if (folder->outbox)
498 1 hiro
                                folder->outbox->stype = F_NORMAL;
499 1 hiro
                        prev_item = folder->outbox;
500 1 hiro
                        folder->outbox = item;
501 1 hiro
                        break;
502 1 hiro
                case F_DRAFT:
503 1 hiro
                        if (folder->draft)
504 1 hiro
                                folder->draft->stype = F_NORMAL;
505 1 hiro
                        prev_item = folder->draft;
506 1 hiro
                        folder->draft = item;
507 1 hiro
                        break;
508 1 hiro
                case F_QUEUE:
509 1 hiro
                        if (folder->queue)
510 1 hiro
                                folder->queue->stype = F_NORMAL;
511 1 hiro
                        prev_item = folder->queue;
512 1 hiro
                        folder->queue = item;
513 1 hiro
                        break;
514 1 hiro
                case F_TRASH:
515 1 hiro
                        if (folder->trash)
516 1 hiro
                                folder->trash->stype = F_NORMAL;
517 1 hiro
                        prev_item = folder->trash;
518 1 hiro
                        folder->trash = item;
519 1 hiro
                        break;
520 1 hiro
                }
521 1 hiro
522 1 hiro
                item->stype = type;
523 1 hiro
524 1 hiro
                if (prev_item)
525 1 hiro
                        folderview_update_item(prev_item, FALSE);
526 1 hiro
                folderview_update_item(item, FALSE);
527 1 hiro
        }
528 1 hiro
529 1 hiro
        item->trim_summary_subject = gtk_toggle_button_get_active
530 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->trim_summary_subj_chkbtn));
531 1 hiro
        item->trim_compose_subject = gtk_toggle_button_get_active
532 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->trim_compose_subj_chkbtn));
533 1 hiro
534 1 hiro
        /* account menu */
535 1 hiro
        optmenu = GTK_OPTION_MENU(dialog->account_optmenu);
536 1 hiro
        menu = gtk_option_menu_get_menu(optmenu);
537 1 hiro
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
538 1 hiro
        account_id = GPOINTER_TO_INT
539 1 hiro
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
540 1 hiro
        if (account_id >= 0)
541 1 hiro
                item->account = account_find_from_id(account_id);
542 1 hiro
        else
543 1 hiro
                item->account = NULL;
544 1 hiro
545 1 hiro
        item->ac_apply_sub = gtk_toggle_button_get_active
546 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->ac_apply_sub_chkbtn));
547 1 hiro
548 1 hiro
        SET_DATA_FROM_ENTRY(to_entry, auto_to);
549 1 hiro
        item->use_auto_to_on_reply = gtk_toggle_button_get_active
550 1 hiro
                (GTK_TOGGLE_BUTTON(dialog->on_reply_chkbtn));
551 1 hiro
552 1 hiro
        SET_DATA_FROM_ENTRY(cc_entry, auto_cc);
553 1 hiro
        SET_DATA_FROM_ENTRY(bcc_entry, auto_bcc);
554 1 hiro
        SET_DATA_FROM_ENTRY(replyto_entry, auto_replyto);
555 1 hiro
}
556 1 hiro
557 1 hiro
#undef SET_DATA_FROM_ENTRY
558 1 hiro
559 1 hiro
static void prefs_folder_item_cancel_cb(GtkWidget *widget,
560 1 hiro
                                        PrefsFolderItemDialog *dialog)
561 1 hiro
{
562 1 hiro
        prefs_folder_item_destroy(dialog);
563 1 hiro
}
564 1 hiro
565 1 hiro
static gint prefs_folder_item_delete_cb(GtkWidget *widget, GdkEventAny *event,
566 1 hiro
                                        PrefsFolderItemDialog *dialog)
567 1 hiro
{
568 1 hiro
        prefs_folder_item_destroy(dialog);
569 1 hiro
        return TRUE;
570 1 hiro
}
571 1 hiro
572 1 hiro
static gboolean prefs_folder_item_key_press_cb(GtkWidget *widget,
573 1 hiro
                                           GdkEventKey *event,
574 1 hiro
                                           PrefsFolderItemDialog *dialog)
575 1 hiro
{
576 1 hiro
        if (event && event->keyval == GDK_Escape)
577 1 hiro
                prefs_folder_item_cancel_cb(widget, dialog);
578 1 hiro
        return FALSE;
579 1 hiro
}