Statistics
| Revision:

root / src / prefs_folder_item.c @ 540

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