merge gtk3 branch into master
[claws.git] / src / plugins / python / examples / main / Open-Tomboy-Notes
1 # -*- Mode: python -*-
2
3 import re
4 import dbus
5
6 # collect message ids of all selected messages
7 msgids = set()
8 for msg in clawsmail.get_summaryview_selected_message_list():
9     msgid = msg.MessageID.replace("<", "&lt;").replace(">", "&gt;")
10     msgids.add(msgid)
11
12 # setup D-Bus interface object
13 bus = dbus.SessionBus()
14 rc = bus.get_object('org.gnome.Tomboy', '/org/gnome/Tomboy/RemoteControl')
15 rc_iface = dbus.Interface(rc, dbus_interface='org.gnome.Tomboy.RemoteControl')
16
17 # iterate over all Tomboy notes
18 for uri in rc_iface.ListAllNotes():
19     contents = rc_iface.GetNoteContentsXml(uri)
20     # Check if message id is in a link to claws mail
21     for msgid in msgids:
22         if re.search(r'<link:cm-mail uri=".*?%s.*?">' % msgid, contents) != None:
23             rc_iface.DisplayNote(uri)