2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 Hiroyuki Yamamoto & the Claws Mail Team
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 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
35 #include "folder_item_prefs.h"
36 #include "folderview.h"
39 #include "alertpanel.h"
40 #include "foldersel.h"
41 #include "inputdialog.h"
44 #include "prefs_common.h"
45 #include "statusbar.h"
46 #include "summaryview.h"
47 #include "prefs_actions.h"
49 static void new_folder_cb(GtkAction
*action
, gpointer data
);
50 static void rename_folder_cb(GtkAction
*action
, gpointer data
);
51 static void move_folder_cb(GtkAction
*action
, gpointer data
);
52 static void copy_folder_cb(GtkAction
*action
, gpointer data
);
53 static void delete_folder_cb(GtkAction
*action
, gpointer data
);
54 static void update_tree_cb(GtkAction
*action
, gpointer data
);
55 static void download_cb(GtkAction
*action
, gpointer data
);
56 static void sync_cb(GtkAction
*action
, gpointer data
);
57 static void subscribed_cb(GtkAction
*action
, gpointer data
);
58 static void subscribe_cb(GtkAction
*action
, gpointer data
);
59 static void unsubscribe_cb(GtkAction
*action
, gpointer data
);
61 static GtkActionEntry imap_popup_entries
[] =
63 {"FolderViewPopup/CreateNewFolder", NULL
, N_("Create _new folder..."), NULL
, NULL
, G_CALLBACK(new_folder_cb
) },
65 {"FolderViewPopup/RenameFolder", NULL
, N_("_Rename folder..."), NULL
, NULL
, G_CALLBACK(rename_folder_cb
) },
66 {"FolderViewPopup/MoveFolder", NULL
, N_("M_ove folder..."), NULL
, NULL
, G_CALLBACK(move_folder_cb
) },
67 {"FolderViewPopup/CopyFolder", NULL
, N_("Cop_y folder..."), NULL
, NULL
, G_CALLBACK(copy_folder_cb
) },
69 {"FolderViewPopup/DeleteFolder", NULL
, N_("_Delete folder..."), NULL
, NULL
, G_CALLBACK(delete_folder_cb
) },
71 {"FolderViewPopup/Synchronise", NULL
, N_("Synchronise"), NULL
, NULL
, G_CALLBACK(sync_cb
) },
72 {"FolderViewPopup/DownloadMessages", NULL
, N_("Down_load messages"), NULL
, NULL
, G_CALLBACK(download_cb
) },
75 {"FolderViewPopup/Subscriptions", NULL
, N_("S_ubscriptions") },
76 {"FolderViewPopup/Subscriptions/---", NULL
, "---", NULL
, NULL
, NULL
},
77 {"FolderViewPopup/Subscriptions/Subscribe", NULL
, N_("_Subscribe..."), NULL
, NULL
, G_CALLBACK(subscribe_cb
) },
78 {"FolderViewPopup/Subscriptions/Unsubscribe", NULL
, N_("_Unsubscribe..."), NULL
, NULL
, G_CALLBACK(unsubscribe_cb
) },
80 {"FolderViewPopup/CheckNewMessages", NULL
, N_("_Check for new messages"), NULL
, NULL
, G_CALLBACK(update_tree_cb
) }, /*0*/
81 {"FolderViewPopup/CheckNewFolders", NULL
, N_("C_heck for new folders"), NULL
, NULL
, G_CALLBACK(update_tree_cb
) }, /*1*/
82 {"FolderViewPopup/RebuildTree", NULL
, N_("R_ebuild folder tree"), NULL
, NULL
, G_CALLBACK(update_tree_cb
) }, /*2*/
85 static GtkToggleActionEntry imap_toggle_popup_entries
[] =
87 {"FolderViewPopup/Subscriptions/ShowOnlySubs", NULL
, N_("Show only subscribed _folders"), NULL
, NULL
, G_CALLBACK(subscribed_cb
) },
90 static void set_sensitivity(GtkUIManager
*ui_manager
, FolderItem
*item
);
91 static void add_menuitems(GtkUIManager
*ui_manager
, FolderItem
*item
);
93 static FolderViewPopup imap_popup
=
98 G_N_ELEMENTS(imap_popup_entries
),
99 imap_toggle_popup_entries
,
100 G_N_ELEMENTS(imap_toggle_popup_entries
),
106 void imap_gtk_init(void)
108 folderview_register_popup(&imap_popup
);
111 static void add_menuitems(GtkUIManager
*ui_manager
, FolderItem
*item
)
113 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "CreateNewFolder", "FolderViewPopup/CreateNewFolder", GTK_UI_MANAGER_MENUITEM
)
114 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "SeparatorIMAP1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR
)
115 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "RenameFolder", "FolderViewPopup/RenameFolder", GTK_UI_MANAGER_MENUITEM
)
116 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "MoveFolder", "FolderViewPopup/MoveFolder", GTK_UI_MANAGER_MENUITEM
)
117 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "CopyFolder", "FolderViewPopup/CopyFolder", GTK_UI_MANAGER_MENUITEM
)
118 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "SeparatorIMAP2", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR
)
119 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "DeleteFolder", "FolderViewPopup/DeleteFolder", GTK_UI_MANAGER_MENUITEM
)
120 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "SeparatorIMAP3", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR
)
121 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "Synchronise", "FolderViewPopup/Synchronise", GTK_UI_MANAGER_MENUITEM
)
122 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "DownloadMessages", "FolderViewPopup/DownloadMessages", GTK_UI_MANAGER_MENUITEM
)
123 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "SeparatorIMAP4", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR
)
124 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "Subscriptions", "FolderViewPopup/Subscriptions", GTK_UI_MANAGER_MENU
)
125 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup/Subscriptions", "ShowOnlySubs", "FolderViewPopup/Subscriptions/ShowOnlySubs", GTK_UI_MANAGER_MENUITEM
)
126 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup/Subscriptions", "SeparatorIMAP5", "FolderViewPopup/Subscriptions/---", GTK_UI_MANAGER_SEPARATOR
)
127 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup/Subscriptions", "Subscribe", "FolderViewPopup/Subscriptions/Subscribe", GTK_UI_MANAGER_MENUITEM
)
128 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup/Subscriptions", "Unsubscribe", "FolderViewPopup/Subscriptions/Unsubscribe", GTK_UI_MANAGER_MENUITEM
)
129 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "CheckNewMessages", "FolderViewPopup/CheckNewMessages", GTK_UI_MANAGER_MENUITEM
)
130 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "CheckNewFolders", "FolderViewPopup/CheckNewFolders", GTK_UI_MANAGER_MENUITEM
)
131 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "RebuildTree", "FolderViewPopup/RebuildTree", GTK_UI_MANAGER_MENUITEM
)
132 MENUITEM_ADDUI_MANAGER(ui_manager
, "/Popup/FolderViewPopup", "SeparatorIMAP6", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR
)
135 static void set_sensitivity(GtkUIManager
*ui_manager
, FolderItem
*item
)
137 gboolean folder_is_normal
=
139 item
->stype
== F_NORMAL
&&
140 !folder_has_parent_of_type(item
, F_OUTBOX
) &&
141 !folder_has_parent_of_type(item
, F_DRAFT
) &&
142 !folder_has_parent_of_type(item
, F_QUEUE
) &&
143 !folder_has_parent_of_type(item
, F_TRASH
);
145 #define SET_SENS(name, sens) \
146 cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens)
148 SET_SENS("FolderViewPopup/CreateNewFolder", item
&& item
->no_sub
== FALSE
);
149 SET_SENS("FolderViewPopup/RenameFolder", item
&& item
->stype
== F_NORMAL
&& folder_item_parent(item
) != NULL
);
150 SET_SENS("FolderViewPopup/MoveFolder", item
&& folder_is_normal
&& folder_item_parent(item
) != NULL
);
151 SET_SENS("FolderViewPopup/DeleteFolder", item
&& item
->stype
== F_NORMAL
&& folder_item_parent(item
) != NULL
);
153 SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item
) == NULL
);
154 SET_SENS("FolderViewPopup/CheckNewFolders", folder_item_parent(item
) == NULL
);
155 SET_SENS("FolderViewPopup/RebuildTree", folder_item_parent(item
) == NULL
);
157 SET_SENS("FolderViewPopup/Synchronise",
158 item
? (folder_item_parent(item
) != NULL
159 && folder_want_synchronise(item
->folder
))
161 SET_SENS("FolderViewPopup/DownloadMessages", item
&& !item
->no_select
);
163 SET_SENS("FolderViewPopup/CheckNewMessages", folder_item_parent(item
) == NULL
);
164 SET_SENS("FolderViewPopup/CheckNewFolders", folder_item_parent(item
) == NULL
);
165 SET_SENS("FolderViewPopup/RebuildTree", folder_item_parent(item
) == NULL
);
167 SET_SENS("FolderViewPopup/Subscriptions/Unsubscribe", item
&& item
->stype
== F_NORMAL
&& folder_item_parent(item
) != NULL
);
168 SET_SENS("FolderViewPopup/Subscriptions/Subscribe", TRUE
);
169 if (item
&& item
->folder
&& item
->folder
->account
)
170 cm_toggle_menu_set_active_full(ui_manager
, "Popup/FolderViewPopup/Subscriptions/ShowOnlySubs",
171 item
->folder
->account
->imap_subsonly
);
176 static void new_folder_cb(GtkAction
*action
, gpointer data
)
178 FolderView
*folderview
= (FolderView
*)data
;
180 FolderItem
*new_item
;
184 gchar separator
= '/';
186 if ((item
= folderview_get_selected_item(folderview
)) == NULL
) return;
188 cm_return_if_fail(item
!= NULL
);
189 cm_return_if_fail(item
->folder
!= NULL
);
190 cm_return_if_fail(item
->folder
->account
!= NULL
);
192 new_folder
= input_dialog_with_checkbtn
194 _("Input the name of new folder:\n"
195 "(if you want to create a folder to store subfolders\n"
196 "only and no mail, append '/' to the folder name)"),
198 _("Inherit properties from parent folder"),
199 &(prefs_common
.inherit_folder_props
));
201 if (!new_folder
) return;
202 AUTORELEASE_STR(new_folder
, {g_free(new_folder
); return;});
204 separator
= imap_get_path_separator_for_item(item
);
206 p
= strchr(new_folder
, separator
);
207 if (p
&& *(p
+ 1) != '\0') {
208 alertpanel_error(_("'%c' can't be included in folder name."),
212 p
= strchr(new_folder
, '/');
213 if (p
&& *(p
+ 1) != '\0') {
214 alertpanel_error(_("'%c' can't be included in folder name."),
219 name
= trim_string(new_folder
, 32);
220 AUTORELEASE_STR(name
, {g_free(name
); return;});
222 /* find whether the directory already exists */
223 if (folder_find_child_item_by_name(item
, new_folder
)) {
224 alertpanel_error(_("The folder '%s' already exists."), name
);
228 new_item
= folder_create_folder(item
, new_folder
);
230 alertpanel_error(_("Can't create the folder '%s'."), name
);
234 if (prefs_common
.inherit_folder_props
) {
235 folder_item_prefs_copy_prefs(item
, new_item
);
241 static void rename_folder_cb(GtkAction
*action
, gpointer data
)
243 FolderView
*folderview
= (FolderView
*)data
;
251 gchar separator
= '/';
253 item
= folderview_get_selected_item(folderview
);
254 cm_return_if_fail(item
!= NULL
);
255 cm_return_if_fail(item
->path
!= NULL
);
256 cm_return_if_fail(item
->folder
!= NULL
);
258 name
= trim_string(item
->name
, 32);
259 message
= g_strdup_printf(_("Input new name for '%s':"), name
);
260 base
= g_path_get_basename(item
->path
);
261 new_folder
= input_dialog(_("Rename folder"), message
, base
);
265 if (!new_folder
) return;
266 AUTORELEASE_STR(new_folder
, {g_free(new_folder
); return;});
268 separator
= imap_get_path_separator_for_item(item
);
269 if (strchr(new_folder
, separator
) != NULL
) {
270 alertpanel_error(_("'%c' can't be included in folder name."),
274 if (strchr(new_folder
, '/') != NULL
) {
275 alertpanel_error(_("'%c' can't be included in folder name."),
280 if (folder_find_child_item_by_name(folder_item_parent(item
), new_folder
)) {
281 name
= trim_string(new_folder
, 32);
282 alertpanel_error(_("The folder '%s' already exists."), name
);
287 old_id
= folder_item_get_identifier(item
);
289 if (folder_item_rename(item
, new_folder
) < 0) {
290 alertpanel_error(_("The folder could not be renamed.\n"
291 "The new folder name is not allowed."));
296 new_id
= folder_item_get_identifier(item
);
297 prefs_filtering_rename_path(old_id
, new_id
);
298 account_rename_path(old_id
, new_id
);
299 prefs_actions_rename_path(old_id
, new_id
);
303 folder_item_prefs_save_config_recursive(item
);
307 static void move_folder_cb(GtkAction
*action
, gpointer data
)
309 FolderView
*folderview
= (FolderView
*)data
;
310 FolderItem
*from_folder
= NULL
, *to_folder
= NULL
;
312 from_folder
= folderview_get_selected_item(folderview
);
313 if (!from_folder
|| from_folder
->folder
->klass
!= imap_get_class())
316 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, TRUE
);
320 folderview_move_folder(folderview
, from_folder
, to_folder
, 0);
323 static void copy_folder_cb(GtkAction
*action
, gpointer data
)
325 FolderView
*folderview
= (FolderView
*)data
;
326 FolderItem
*from_folder
= NULL
, *to_folder
= NULL
;
328 from_folder
= folderview_get_selected_item(folderview
);
329 if (!from_folder
|| from_folder
->folder
->klass
!= imap_get_class())
332 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, TRUE
);
336 folderview_move_folder(folderview
, from_folder
, to_folder
, 1);
339 static void delete_folder_cb(GtkAction
*action
, gpointer data
)
341 FolderView
*folderview
= (FolderView
*)data
;
342 FolderItem
*item
, *opened
;
343 gchar
*message
, *name
;
347 if ((item
= folderview_get_selected_item(folderview
)) == NULL
) return;
348 opened
= folderview_get_opened_item(folderview
);
350 cm_return_if_fail(item
!= NULL
);
351 cm_return_if_fail(item
->path
!= NULL
);
352 cm_return_if_fail(item
->folder
!= NULL
);
354 name
= trim_string(item
->name
, 32);
355 AUTORELEASE_STR(name
, {g_free(name
); return;});
356 message
= g_markup_printf_escaped
357 (_("All folders and messages under '%s' will be permanently deleted. "
358 "Recovery will not be possible.\n\n"
359 "Do you really want to delete?"), name
);
360 avalue
= alertpanel_full(_("Delete folder"), message
,
361 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
, FALSE
,
362 NULL
, ALERT_WARNING
, G_ALERTDEFAULT
);
364 if (avalue
!= G_ALERTALTERNATE
) return;
366 old_id
= folder_item_get_identifier(item
);
368 if (item
== opened
||
369 folder_is_child_of(item
, opened
)) {
370 summary_clear_all(folderview
->summaryview
);
371 folderview_close_opened(folderview
, TRUE
);
374 if (item
->folder
->klass
->remove_folder(item
->folder
, item
) < 0) {
375 folder_item_scan(item
);
376 alertpanel_error(_("Can't remove the folder '%s'."), name
);
383 prefs_filtering_delete_path(old_id
);
388 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) act; }
390 static void update_tree_cb(GtkAction
*action
, gpointer data
)
392 FolderView
*folderview
= (FolderView
*)data
;
394 const gchar
*a_name
= gtk_action_get_name(action
);
396 item
= folderview_get_selected_item(folderview
);
397 cm_return_if_fail(item
!= NULL
);
399 summary_show(folderview
->summaryview
, NULL
);
401 cm_return_if_fail(item
->folder
!= NULL
);
403 DO_ACTION("FolderViewPopup/CheckNewMessages", folderview_check_new(item
->folder
));
404 DO_ACTION("FolderViewPopup/CheckNewFolders", folderview_rescan_tree(item
->folder
, FALSE
));
405 DO_ACTION("FolderViewPopup/RebuildTree", folderview_rescan_tree(item
->folder
, TRUE
));
408 static void sync_cb(GtkAction
*action
, gpointer data
)
410 FolderView
*folderview
= (FolderView
*)data
;
413 item
= folderview_get_selected_item(folderview
);
414 cm_return_if_fail(item
!= NULL
);
415 folder_synchronise(item
->folder
);
418 void imap_gtk_synchronise(FolderItem
*item
, gint days
)
420 MainWindow
*mainwin
= mainwindow_get_mainwindow();
421 FolderView
*folderview
= mainwin
->folderview
;
423 cm_return_if_fail(item
!= NULL
);
424 cm_return_if_fail(item
->folder
!= NULL
);
426 main_window_cursor_wait(mainwin
);
428 main_window_lock(mainwin
);
429 gtk_widget_set_sensitive(folderview
->ctree
, FALSE
);
430 main_window_progress_on(mainwin
);
432 if (item
->no_select
== FALSE
) {
436 gint total
= item
->total_msgs
;
437 time_t t
= time(NULL
);
439 mlist
= folder_item_get_msg_list(item
);
440 for (cur
= mlist
; cur
!= NULL
; cur
= cur
->next
) {
441 MsgInfo
*msginfo
= (MsgInfo
*)cur
->data
;
442 gint age
= (t
- msginfo
->date_t
) / (60*60*24);
443 if (days
== 0 || age
<= days
)
444 imap_cache_msg(msginfo
->folder
, msginfo
->msgnum
);
445 statusbar_progress_all(num
++,total
, 100);
450 statusbar_progress_all(0,0,0);
451 procmsg_msg_list_free(mlist
);
454 folder_set_ui_func(item
->folder
, NULL
, NULL
);
455 main_window_progress_off(mainwin
);
456 gtk_widget_set_sensitive(folderview
->ctree
, TRUE
);
457 main_window_unlock(mainwin
);
459 main_window_cursor_normal(mainwin
);
462 static void chk_update_val(GtkWidget
*widget
, gpointer data
)
464 gboolean
*val
= (gboolean
*)data
;
465 *val
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
468 static gboolean
imap_gtk_subscribe_func(GNode
*node
, gpointer data
)
470 FolderItem
*item
= node
->data
;
471 gboolean action
= GPOINTER_TO_INT(data
);
474 imap_subscribe(item
->folder
, item
, NULL
, action
);
479 static void subscribe_cb_full(FolderView
*folderview
, guint action
)
482 gchar
*message
, *name
;
485 gboolean recurse
= FALSE
;
487 if ((item
= folderview_get_selected_item(folderview
)) == NULL
) return;
488 cm_return_if_fail(item
->folder
!= NULL
);
490 name
= trim_string(item
->name
, 32);
491 AUTORELEASE_STR(name
, {g_free(name
); return;});
493 if (action
&& item
->folder
->account
->imap_subsonly
) {
494 GList
*child_list
= NULL
;
495 GList
*transc_list
= NULL
;
497 message
= g_markup_printf_escaped
498 (_("Do you want to search for unsubscribed subfolders of '%s'?"),
501 rec_chk
= gtk_check_button_new_with_label(_("Search recursively"));
503 g_signal_connect(G_OBJECT(rec_chk
), "toggled",
504 G_CALLBACK(chk_update_val
), &recurse
);
506 avalue
= alertpanel_full(_("Subscriptions"), message
,
507 GTK_STOCK_CANCEL
, g_strconcat("+", _("_Search"), NULL
),
508 NULL
, FALSE
, rec_chk
, ALERT_QUESTION
, G_ALERTDEFAULT
);
510 if (avalue
!= G_ALERTALTERNATE
) return;
512 child_list
= imap_scan_subtree(item
->folder
, item
, TRUE
, recurse
);
517 gchar
*msg
= g_strdup_printf(_("Choose a subfolder of %s to subscribe to: "),
519 gchar
*child_folder
= NULL
;
521 for (cur
= child_list
; cur
; cur
= cur
->next
) {
522 transc_list
= g_list_append(transc_list
,
523 imap_modified_utf7_to_utf8(cur
->data
, FALSE
));
526 transc_list
= g_list_sort(transc_list
, g_str_equal
);
528 child_folder
= input_dialog_combo(_("Subscribe"),
530 transc_list
->next
?_("All of them"):transc_list
->data
, transc_list
);
532 if (child_folder
&& strcmp(child_folder
, _("All of them"))) {
533 gchar
*transc_folder
= imap_utf8_to_modified_utf7(child_folder
, FALSE
);
534 r
= imap_subscribe(item
->folder
, NULL
, transc_folder
, TRUE
);
535 g_free(transc_folder
);
536 } else if (child_folder
) {
537 for (cur
= child_list
; cur
; cur
= cur
->next
)
538 r
= imap_subscribe(item
->folder
, NULL
, (gchar
*)cur
->data
, TRUE
);
540 g_free(child_folder
);
541 for (cur
= child_list
; cur
; cur
= cur
->next
)
542 g_free((gchar
*)cur
->data
);
543 for (cur
= transc_list
; cur
; cur
= cur
->next
)
544 g_free((gchar
*)cur
->data
);
546 folderview_rescan_tree(item
->folder
, FALSE
);
548 alertpanel_notice(_("This folder is already subscribed and "
549 "has no unsubscribed subfolders.\n\nIf there are new folders, "
550 "created and subscribed to from another client, use \"Check "
551 "for new folders\" at the mailbox's root folder."));
553 g_list_free(child_list
);
556 message
= g_markup_printf_escaped
557 (_("Do you want to %s the '%s' folder?"),
558 action
?_("subscribe"):_("unsubscribe"), name
);
560 rec_chk
= gtk_check_button_new_with_label(_("Apply to subfolders"));
562 g_signal_connect(G_OBJECT(rec_chk
), "toggled",
563 G_CALLBACK(chk_update_val
), &recurse
);
565 avalue
= alertpanel_full(_("Subscriptions"), message
,
566 GTK_STOCK_CANCEL
, action
?g_strconcat("+", _("_Subscribe"), NULL
):
567 g_strconcat("+", _("_Unsubscribe"), NULL
), NULL
, FALSE
,
568 rec_chk
, ALERT_QUESTION
, G_ALERTDEFAULT
);
570 if (avalue
!= G_ALERTALTERNATE
) return;
572 FolderItem
*opened
= folderview_get_opened_item(folderview
);
573 FolderItem
*selected
= folderview_get_selected_item(folderview
);
575 if (opened
== selected
||
576 folder_is_child_of(selected
, opened
)) {
577 summary_clear_all(folderview
->summaryview
);
578 folderview_close_opened(folderview
, TRUE
);
583 g_node_traverse(item
->node
, G_PRE_ORDER
,
584 G_TRAVERSE_ALL
, -1, imap_gtk_subscribe_func
, GINT_TO_POINTER(action
));
586 imap_subscribe(item
->folder
, item
, NULL
, action
);
589 if (!action
&& item
->folder
->account
->imap_subsonly
)
590 folderview_rescan_tree(item
->folder
, FALSE
);
593 static void subscribe_cb(GtkAction
*action
, gpointer data
)
595 subscribe_cb_full((FolderView
*)data
, 1);
598 static void unsubscribe_cb(GtkAction
*action
, gpointer data
)
600 subscribe_cb_full((FolderView
*)data
, 0);
603 static void subscribed_cb(GtkAction
*action
, gpointer data
)
605 FolderView
*folderview
= (FolderView
*)data
;
606 FolderItem
*item
= folderview_get_selected_item(folderview
);
607 FolderItem
*opened
= folderview_get_opened_item(folderview
);
609 if (!item
|| !item
->folder
|| !item
->folder
->account
)
611 if (item
->folder
->account
->imap_subsonly
== gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
)))
614 if (opened
== item
||
615 folder_is_child_of(item
, opened
)) {
616 summary_clear_all(folderview
->summaryview
);
617 folderview_close_opened(folderview
, TRUE
);
620 item
->folder
->account
->imap_subsonly
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
));
621 folderview_rescan_tree(item
->folder
, FALSE
);
624 static void download_cb(GtkAction
*action
, gpointer data
)
626 FolderView
*folderview
= (FolderView
*)data
;
629 if ((item
= folderview_get_selected_item(folderview
)) == NULL
)
631 imap_gtk_synchronise(item
, 0);