3 import sys
, dbus
, gobject
, dbus
.glib
10 notebook
= sys
.argv
[5]
11 appendnote
= sys
.argv
[6]
15 if len(url
) > 0: url
= "<italic><size:small>Source: <link:url>" + url
+ "</link:url></size:small></italic>\n\n"
18 # Connect to Tomboy DBUS
19 bus
= dbus
.SessionBus()
20 obj
= bus
.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
21 tomboy
= dbus
.Interface(obj
, "org.gnome.Tomboy.RemoteControl")
25 if tomboy
.NoteExists(tomboy
.FindNote(title
)) == 1 and appendnote
== "true":
26 uri
= tomboy
.FindNote(title
)
27 currentcontents
= tomboy
.GetNoteContentsXml(uri
)
28 currentcontents
= currentcontents
.encode('utf-8')
29 separator
= "<strikethrough>"
30 for i
in range(1, 70): separator
+= " "
31 separator
+= "</strikethrough>"
32 tomboy
.SetNoteContentsXml(uri
, "<note-content>" + currentcontents
+ separator
+ "\n\n" + note
+ url
+ "</note-content>")
34 # Check if title exists, append #1, #2, #3... to the end of the note title
35 if tomboy
.NoteExists(tomboy
.FindNote(title
)) == 1:
37 while tomboy
.NoteExists(tomboy
.FindNote(title
+ " #" + str(notedupe
))) == 1:
38 notedupe
= notedupe
+ 1
39 if notedupe
> 0: title
= title
+ " #" + str(notedupe
)
41 # Create the note and set the contents
42 uri
= tomboy
.CreateNamedNote(title
)
43 tomboy
.SetNoteContentsXml(uri
, "<note-content>" + title
+ "\n\n" + note
+ url
+ "</note-content>")
45 # Assign note to the default notebook
46 if len(notebook
) > 0: tomboy
.AddTagToNote(uri
, "system:notebook:" + notebook
)
49 # Display Note if enabled
50 if display
== "true": tomboy
.DisplayNote(uri
)