[kupfer] notes: Add CreateNote action



commit 5f59c69a8f98e76ae1a235bf12a39090baccda27
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Aug 28 00:29:09 2009 +0200

    notes: Add CreateNote action
    
    This action will create a note from a TextLeaf; manually typed in
    text, a clipboard or the current selection.

 kupfer/plugin/notes.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/notes.py b/kupfer/plugin/notes.py
index ab6ed7b..9d816fb 100644
--- a/kupfer/plugin/notes.py
+++ b/kupfer/plugin/notes.py
@@ -13,6 +13,7 @@ __kupfer_sources__ = ("NotesSource", )
 __kupfer_contents__ = ("NotesSource", )
 __kupfer_actions__ = (
 		"AppendToNote",
+		"CreateNote",
 	)
 __description__ = _("Gnote or Tomboy notes")
 __version__ = ""
@@ -84,6 +85,26 @@ class AppendToNote (Action):
 	def get_icon_name(self):
 		return "gtk-add"
 
+class CreateNote (Action):
+	def __init__(self):
+		Action.__init__(self, _("Create Note"))
+
+	def activate(self, leaf):
+		notes = _get_notes_interface()
+		text = leaf.object
+		# FIXME: For Gnote we have to call DisplayNote
+		# else we can't change its contents
+		noteuri = notes.CreateNote()
+		notes.DisplayNote(noteuri)
+		notes.SetNoteContents(noteuri, text)
+
+	def item_types(self):
+		yield TextLeaf
+	def get_description(self):
+		return _("Create a new note from this text")
+	def get_icon_name(self):
+		return "gtk-new"
+
 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]