1 # -*- coding: utf-8 -*-
3 # Define the function to deal with each folder
4 def deal_with_folder(folder):
5 if folder.num_unread_messages > 0:
6 # Get actions for selecting all messages, and marking the selection as read
7 action_group = clawsmail.get_mainwindow_action_group();
8 select_all_action = action_group.get_action("Edit/SelectAll")
9 mark_read_action = action_group.get_action("Message/Mark/MarkRead")
12 clawsmail.folderview_select_folder(folder)
14 # Search for messages with age greater than 28 days
15 clawsmail.quicksearch_search("ag 28", clawsmail.QUICK_SEARCH_EXTENDED)
17 # Mark all messages in the search result as read
18 select_all_action.activate()
19 mark_read_action.activate()
23 root = clawsmail.get_folderview_selected_folder()
25 root = clawsmail.get_folderview_selected_mailbox()
28 # Get a tree of subfolders. The argument could also be a string of a mailbox name,
29 # or left out for a list of mailbox trees.
30 tree = clawsmail.get_folder_tree(root)
32 # Call above function for all folders.
33 tree.traverse(deal_with_folder)
35 # Clear the quicksearch widget again
36 clawsmail.quicksearch_clear()
38 # Change back to original folder
39 clawsmail.folderview_select(root)