[kupfer] notes: AppendToNote using only Text Content
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] notes: AppendToNote using only Text Content
- Date: Fri, 28 Aug 2009 09:31:54 +0000 (UTC)
commit 33409426c02c44f6e75d1b76232c4dbd5013f49a
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Aug 27 16:53:51 2009 +0200
notes: AppendToNote using only Text Content
This will kill some text formatting, but it does not have the horrible
(Gnote) failure modes of the Xml methods.
kupfer/plugin/notes.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/notes.py b/kupfer/plugin/notes.py
index 2d27889..6c54b26 100644
--- a/kupfer/plugin/notes.py
+++ b/kupfer/plugin/notes.py
@@ -59,6 +59,31 @@ class Open (Action):
app_icon = icons.get_gicon_with_fallbacks(None, PROGRAM_IDS)
return icons.ComposedIcon(self.get_icon_name(), app_icon)
+class AppendToNote (Action):
+ def __init__(self):
+ Action.__init__(self, _("Append to Note..."))
+
+ def activate(self, leaf, iobj):
+ notes = _get_notes_interface()
+ noteuri = iobj.object
+ text = leaf.object
+ # NOTE: We could append using the Note's XML content, but
+ # it does not always work
+ contents = notes.GetNoteContents(noteuri)
+ contents += u"\n%s" % text
+ notes.SetNoteContents(noteuri, contents)
+
+ def item_types(self):
+ yield TextLeaf
+ def requires_object(self):
+ return True
+ def object_types(self):
+ yield Note
+ def get_description(self):
+ return _("Append text (note may lose formatting)")
+ def get_icon_name(self):
+ return "gtk-add"
+
class Note (Leaf):
"""The Note Leaf's represented object is the Note URI"""
def get_actions(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]