5 gi.require_version("Gtk", "3.0")
6 from gi.repository import Gtk
11 def get_reminder(desc):
12 get_reminder.reminder = None
14 # callback functions for the GUI
15 def no_reminder(button, ww):
16 get_reminder.reminder = ""
19 def date_time_cb(button, ww, cal, cb, hours, minutes):
20 ymd = list(cal.get_date())
22 get_reminder.reminder = "/".join([str(v) for v in ymd])
24 get_reminder.reminder += "".join([" at ", "%02d" % hours.get_value_as_int(), ":", "%02d" % minutes.get_value_as_int()])
27 def day_selected(cal, exp):
28 ymd = list(cal.get_date())
30 exp.set_label("/".join(str(vv) for vv in ymd))
32 def custom(button, ww, entry):
33 get_reminder.reminder = entry.get_text()
37 # Check if the user wants a reminder in a dialog box
39 win.set_title("Reminder")
40 win.connect("destroy", Gtk.main_quit)
41 win.set_position(Gtk.WindowPosition.CENTER)
42 table = Gtk.Table(n_rows=2, n_columns=7)
44 table.attach(Gtk.Label(label=desc), 0, 2, 0, 1)
46 button = Gtk.Button(label="No reminder")
47 button.connect("clicked", no_reminder, win)
48 table.attach(button, 0, 1, 1, 2,
49 xoptions=Gtk.AttachOptions.FILL, yoptions=0, ypadding=4)
50 table.attach(Gtk.HSeparator(), 0, 2, 2, 3)
51 # date / time reminder
52 button = Gtk.Button(label="Date/Time")
53 table.attach(button, 0, 1, 3, 4,
54 xoptions=Gtk.AttachOptions.FILL,
55 yoptions=Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, ypadding=4)
57 table.attach(hbox, 1, 2, 3, 4)
60 day_selected(cal, exp)
61 cal.connect("day-selected", day_selected, exp)
63 hbox.pack_start(exp, False, False, 5)
64 cb = Gtk.CheckButton(label="at")
65 hbox.pack_start(cb, False, False, 5)
66 hours = Gtk.SpinButton.new(Gtk.Adjustment(
67 value=12.0, lower=0.0, upper=24.0, step_increment=1.0,
68 page_increment=5.0, page_size=0.0), 1.0, 0)
69 hours.set_numeric(True)
71 hbox.pack_start(hours, False, False, 5)
72 hbox.pack_start(Gtk.Label(label=":"), False, False, 5)
73 minutes = Gtk.SpinButton.new(Gtk.Adjustment(
74 value=0.0, lower=0.0, upper=59.0, step_increment=1.0,
75 page_increment=5.0, page_size=0.0), 1.0, 0)
76 minutes.set_numeric(True)
77 minutes.set_wrap(True)
78 hbox.pack_start(minutes, False, False, 5)
79 button.connect("clicked", date_time_cb, win, cal, cb, hours, minutes)
81 button = Gtk.Button(label="custom")
82 table.attach(button, 0, 1, 4, 5,
83 xoptions=Gtk.AttachOptions.FILL, yoptions=0, ypadding=4)
85 button.connect("clicked", custom, win, entry)
86 table.attach(entry, 1, 2, 4, 5)
88 # "Show note" toggle option
89 table.attach(Gtk.HSeparator(), 0, 2, 5, 6)
90 cb = Gtk.CheckButton(label="Show note")
91 table.attach(cb, 0, 2, 6, 7)
96 return (get_reminder.reminder, cb.get_active())
99 # set up contents: opening tag
100 content = ["<note-content>"]
102 content.append(title)
103 content.append("\n\n")
105 (reminder, show_note) = get_reminder("\n".join([msg.From, msg.Subject]))
109 content.extend(["!", reminder, "\n"])
111 msgid = msg.MessageID
117 msgid = msgid.replace("<", "<").replace(">", ">")
118 link = '<link:cm-mail uri="%s/%s">%s</link:cm-mail>' % (clawsmail.get_folderview_selected_folder().get_identifier(), msgid, msg.Subject)
121 content.append("</note-content>")
123 # create a tomboy note
124 bus = dbus.SessionBus()
125 rc = bus.get_object('org.gnome.Tomboy', '/org/gnome/Tomboy/RemoteControl')
126 rc_iface = dbus.Interface(rc, dbus_interface='org.gnome.Tomboy.RemoteControl')
127 uri = rc_iface.CreateNamedNote(title)
128 rc_iface.SetNoteContentsXml(uri, "".join(content))
129 rc_iface.DisplayNote(uri)
131 rc_iface.HideNote(uri)
134 # iterate over all notes
135 for msg in clawsmail.get_summaryview_selected_message_list():