2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2022 the Claws Mail Team and Hiroyuki Yamamoto
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"), NULL
, NULL
, NULL
},
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
), FALSE
},
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 and processing rules 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
;
313 from_folder
= folderview_get_selected_item(folderview
);
314 if (!from_folder
|| from_folder
->folder
->klass
!= imap_get_class())
317 msg
= g_strdup_printf(_("Select folder to move folder '%s' to"),
319 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, TRUE
, msg
);
324 folderview_move_folder(folderview
, from_folder
, to_folder
, 0);
327 static void copy_folder_cb(GtkAction
*action
, gpointer data
)
329 FolderView
*folderview
= (FolderView
*)data
;
330 FolderItem
*from_folder
= NULL
, *to_folder
= NULL
;
333 from_folder
= folderview_get_selected_item(folderview
);
334 if (!from_folder
|| from_folder
->folder
->klass
!= imap_get_class())
337 msg
= g_strdup_printf(_("Select folder to copy folder '%s' to"),
339 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, TRUE
, msg
);
344 folderview_move_folder(folderview
, from_folder
, to_folder
, 1);
347 static void delete_folder_cb(GtkAction
*action
, gpointer data
)
349 FolderView
*folderview
= (FolderView
*)data
;
350 FolderItem
*item
, *opened
;
351 gchar
*message
, *name
;
355 if ((item
= folderview_get_selected_item(folderview
)) == NULL
) return;
356 opened
= folderview_get_opened_item(folderview
);
358 cm_return_if_fail(item
!= NULL
);
359 cm_return_if_fail(item
->path
!= NULL
);
360 cm_return_if_fail(item
->folder
!= NULL
);
362 name
= trim_string(item
->name
, 32);
363 AUTORELEASE_STR(name
, {g_free(name
); return;});
364 message
= g_markup_printf_escaped
365 (_("All folders and messages under '%s' will be permanently deleted.\n"
366 "Recovery will not be possible.\n\n"
367 "Do you really want to delete?"), name
);
368 avalue
= alertpanel_full(_("Delete folder"), message
,
369 NULL
, _("_Cancel"), "edit-delete", _("_Delete"),
370 NULL
, NULL
, ALERTFOCUS_FIRST
, FALSE
,
371 NULL
, ALERT_WARNING
);
373 if (avalue
!= G_ALERTALTERNATE
) return;
375 old_id
= folder_item_get_identifier(item
);
377 if (item
== opened
||
378 folder_is_child_of(item
, opened
)) {
379 summary_clear_all(folderview
->summaryview
);
380 folderview_close_opened(folderview
, TRUE
);
383 if (item
->folder
->klass
->remove_folder(item
->folder
, item
) < 0) {
384 folder_item_scan(item
);
385 alertpanel_error(_("Can't remove the folder '%s'."), name
);
392 prefs_filtering_delete_path(old_id
);
397 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) act; }
399 static void update_tree_cb(GtkAction
*action
, gpointer data
)
401 FolderView
*folderview
= (FolderView
*)data
;
403 const gchar
*a_name
= gtk_action_get_name(action
);
405 item
= folderview_get_selected_item(folderview
);
406 cm_return_if_fail(item
!= NULL
);
408 summary_show(folderview
->summaryview
, NULL
, FALSE
);
410 cm_return_if_fail(item
->folder
!= NULL
);
412 DO_ACTION("FolderViewPopup/CheckNewMessages", folderview_check_new(item
->folder
));
413 DO_ACTION("FolderViewPopup/CheckNewFolders", folderview_rescan_tree(item
->folder
, FALSE
));
414 DO_ACTION("FolderViewPopup/RebuildTree", folderview_rescan_tree(item
->folder
, TRUE
));
417 static void sync_cb(GtkAction
*action
, gpointer data
)
419 FolderView
*folderview
= (FolderView
*)data
;
422 item
= folderview_get_selected_item(folderview
);
423 cm_return_if_fail(item
!= NULL
);
424 folder_synchronise(item
->folder
);
427 void imap_gtk_synchronise(FolderItem
*item
, gint days
)
429 MainWindow
*mainwin
= mainwindow_get_mainwindow();
430 FolderView
*folderview
= mainwin
->folderview
;
432 cm_return_if_fail(item
!= NULL
);
433 cm_return_if_fail(item
->folder
!= NULL
);
435 main_window_cursor_wait(mainwin
);
437 main_window_lock(mainwin
);
438 gtk_widget_set_sensitive(folderview
->ctree
, FALSE
);
439 main_window_progress_on(mainwin
);
441 if (item
->no_select
== FALSE
) {
445 gint total
= item
->total_msgs
;
446 time_t t
= time(NULL
);
448 mlist
= folder_item_get_msg_list(item
);
449 for (cur
= mlist
; cur
!= NULL
; cur
= cur
->next
) {
450 MsgInfo
*msginfo
= (MsgInfo
*)cur
->data
;
451 gint age
= (t
- msginfo
->date_t
) / (60*60*24);
452 if (days
== 0 || age
<= days
)
453 imap_cache_msg(msginfo
->folder
, msginfo
->msgnum
);
454 statusbar_progress_all(num
++,total
, 100);
459 statusbar_progress_all(0,0,0);
460 procmsg_msg_list_free(mlist
);
463 folder_set_ui_func(item
->folder
, NULL
, NULL
);
464 main_window_progress_off(mainwin
);
465 gtk_widget_set_sensitive(folderview
->ctree
, TRUE
);
466 main_window_unlock(mainwin
);
468 main_window_cursor_normal(mainwin
);
471 static void chk_update_val(GtkWidget
*widget
, gpointer data
)
473 gboolean
*val
= (gboolean
*)data
;
474 *val
= gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
477 static gboolean
imap_gtk_subscribe_func(GNode
*node
, gpointer data
)
479 FolderItem
*item
= node
->data
;
480 gboolean action
= GPOINTER_TO_INT(data
);
483 imap_subscribe(item
->folder
, item
, NULL
, action
);
488 static void subscribe_cb_full(FolderView
*folderview
, guint action
)
491 gchar
*message
, *name
;
494 gboolean recurse
= FALSE
;
496 if ((item
= folderview_get_selected_item(folderview
)) == NULL
) return;
497 cm_return_if_fail(item
->folder
!= NULL
);
499 name
= trim_string(item
->name
, 32);
500 AUTORELEASE_STR(name
, {g_free(name
); return;});
502 if (action
&& item
->folder
->account
->imap_subsonly
) {
503 GList
*child_list
= NULL
;
504 GList
*transc_list
= NULL
;
506 message
= g_markup_printf_escaped
507 (_("Do you want to search for unsubscribed subfolders of '%s'?"),
510 rec_chk
= gtk_check_button_new_with_label(_("Search recursively"));
512 g_signal_connect(G_OBJECT(rec_chk
), "toggled",
513 G_CALLBACK(chk_update_val
), &recurse
);
515 avalue
= alertpanel_full(_("Subscriptions"), message
,
516 NULL
, _("_Cancel"), "edit-find", _("_Search"),
517 NULL
, NULL
, ALERTFOCUS_SECOND
,
518 FALSE
, rec_chk
, ALERT_QUESTION
);
520 if (avalue
!= G_ALERTALTERNATE
) return;
522 child_list
= imap_scan_subtree(item
->folder
, item
, TRUE
, recurse
);
527 gchar
*msg
= g_strdup_printf(_("Choose a subfolder of %s to subscribe to: "),
529 gchar
*child_folder
= NULL
;
531 for (cur
= child_list
; cur
; cur
= cur
->next
) {
532 transc_list
= g_list_append(transc_list
,
533 imap_modified_utf7_to_utf8(cur
->data
, FALSE
));
536 transc_list
= g_list_sort(transc_list
, g_str_equal
);
538 child_folder
= input_dialog_combo(_("Subscribe"),
540 transc_list
->next
?_("All of them"):transc_list
->data
, transc_list
);
542 if (child_folder
&& strcmp(child_folder
, _("All of them"))) {
543 gchar
*transc_folder
= imap_utf8_to_modified_utf7(child_folder
, FALSE
);
544 r
= imap_subscribe(item
->folder
, NULL
, transc_folder
, TRUE
);
545 g_free(transc_folder
);
546 } else if (child_folder
) {
547 for (cur
= child_list
; cur
; cur
= cur
->next
)
548 r
= imap_subscribe(item
->folder
, NULL
, (gchar
*)cur
->data
, TRUE
);
550 g_free(child_folder
);
551 for (cur
= child_list
; cur
; cur
= cur
->next
)
552 g_free((gchar
*)cur
->data
);
553 for (cur
= transc_list
; cur
; cur
= cur
->next
)
554 g_free((gchar
*)cur
->data
);
556 folderview_rescan_tree(item
->folder
, FALSE
);
558 alertpanel_notice(_("This folder is already subscribed and "
559 "has no unsubscribed subfolders.\n\nIf there are new folders, "
560 "created and subscribed to from another client, use \"Check "
561 "for new folders\" at the mailbox's root folder."));
563 g_list_free(child_list
);
566 message
= g_markup_printf_escaped
567 (_("Do you want to %s the '%s' folder?"),
568 action
?_("subscribe"):_("unsubscribe"), name
);
570 rec_chk
= gtk_check_button_new_with_label(_("Apply to subfolders"));
572 g_signal_connect(G_OBJECT(rec_chk
), "toggled",
573 G_CALLBACK(chk_update_val
), &recurse
);
575 avalue
= alertpanel_full(_("Subscriptions"), message
,
576 NULL
, _("_Cancel"), NULL
, action
?_("_Subscribe"):_("_Unsubscribe"),
577 NULL
, NULL
, ALERTFOCUS_SECOND
, FALSE
, rec_chk
, ALERT_QUESTION
);
579 if (avalue
!= G_ALERTALTERNATE
) return;
581 FolderItem
*opened
= folderview_get_opened_item(folderview
);
582 FolderItem
*selected
= folderview_get_selected_item(folderview
);
584 if (opened
== selected
||
585 folder_is_child_of(selected
, opened
)) {
586 summary_clear_all(folderview
->summaryview
);
587 folderview_close_opened(folderview
, TRUE
);
592 g_node_traverse(item
->node
, G_PRE_ORDER
,
593 G_TRAVERSE_ALL
, -1, imap_gtk_subscribe_func
, GINT_TO_POINTER(action
));
595 imap_subscribe(item
->folder
, item
, NULL
, action
);
598 if (!action
&& item
->folder
->account
->imap_subsonly
)
599 folderview_rescan_tree(item
->folder
, FALSE
);
602 static void subscribe_cb(GtkAction
*action
, gpointer data
)
604 subscribe_cb_full((FolderView
*)data
, 1);
607 static void unsubscribe_cb(GtkAction
*action
, gpointer data
)
609 subscribe_cb_full((FolderView
*)data
, 0);
612 static void subscribed_cb(GtkAction
*action
, gpointer data
)
614 FolderView
*folderview
= (FolderView
*)data
;
615 FolderItem
*item
= folderview_get_selected_item(folderview
);
616 FolderItem
*opened
= folderview_get_opened_item(folderview
);
618 if (!item
|| !item
->folder
|| !item
->folder
->account
)
620 if (item
->folder
->account
->imap_subsonly
== gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
)))
623 if (opened
== item
||
624 folder_is_child_of(item
, opened
)) {
625 summary_clear_all(folderview
->summaryview
);
626 folderview_close_opened(folderview
, TRUE
);
629 item
->folder
->account
->imap_subsonly
= gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action
));
630 folderview_rescan_tree(item
->folder
, FALSE
);
633 static void download_cb(GtkAction
*action
, gpointer data
)
635 FolderView
*folderview
= (FolderView
*)data
;
638 if ((item
= folderview_get_selected_item(folderview
)) == NULL
)
640 imap_gtk_synchronise(item
, 0);