85c108ee3218c70b9f6de93572c5ca6e4748ffcf
[claws.git] / src / plugins / python / examples / main / Recusively-mark-messages-as-read
1 # -*- coding: utf-8 -*-
2
3 # Define the function to deal with each folder
4 def deal_with_folder(folder):
5     # Get actions for selecting all messages, and marking the selection as read
6     action_group = clawsmail.get_mainwindow_action_group();
7     select_all_action = action_group.get_action("Edit/SelectAll")
8     mark_read_action = action_group.get_action("Message/Mark/MarkRead")
9     
10     # Select given folder
11     clawsmail.folderview_select_folder(folder)
12     
13     # Search for messages with age greater than 28 days
14     clawsmail.quicksearch_search("ag 28", clawsmail.QUICK_SEARCH_EXTENDED)
15     
16     # Mark all messages in the search result as read
17     select_all_action.activate()
18     mark_read_action.activate()
19
20
21 # Get selected folder
22 root = clawsmail.get_folderview_selected_folder()
23
24 # Get a tree of subfolders. The argument could also be a string of a mailbox name,
25 # or left out for a list of mailbox trees.
26 tree = clawsmail.get_folder_tree(root)
27
28 # Call above function for all folders.
29 tree.traverse(deal_with_folder)
30
31 # Clear the quicksearch widget again
32 clawsmail.quicksearch_clear()
33
34 # Change back to original folder
35 clawsmail.folderview_select_folder(root)