[kupfer: 4/6] zim: add quick note action
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 4/6] zim: add quick note action
- Date: Tue, 13 Dec 2011 17:56:30 +0000 (UTC)
commit 1a047d76f4b1282d00bed040b2f005760eedca5f
Author: Karol BÄdkowski <karol bedkowski gmail com>
Date: Sat Dec 3 20:52:06 2011 +0100
zim: add quick note action
New action 'Insert QuickNote into Zim' allow to create note with
selected text as content and configured name and namespace.
kupfer/plugin/zim.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/kupfer/plugin/zim.py b/kupfer/plugin/zim.py
index d840c34..52ce3cc 100644
--- a/kupfer/plugin/zim.py
+++ b/kupfer/plugin/zim.py
@@ -6,13 +6,15 @@ __kupfer_sources__ = ("ZimPagesSource", )
__kupfer_actions__ = (
"CreateZimPage",
"CreateZimPageInNotebook",
+ "CreateZimQuickNote",
)
__description__ = _("Access to Pages stored in Zim - "
"A Desktop Wiki and Outliner")
-__version__ = "2011-12-02"
+__version__ = "2011-12-03"
__author__ = "Karol BÄdkowski <karol bedkowski gmail com>"
import os
+import time
import gio
import glib
@@ -29,18 +31,34 @@ __kupfer_settings__ = plugin_support.PluginSettings(
"type": bool,
"value": False,
},
+ {
+ "key": "quicknote_basename",
+ "label": _("Default page name for quick notes"),
+ "type": str,
+ "value": _("Note %x %X"),
+ "tooltip": _("Strftime tags can be used: %H - hour, %M - minutes, etc\n"
+ "Please check python documentation for details.\n"
+ "NOTE: comma will be replaced by _"),
+ },
+ {
+ "key": "quicknote_namespace",
+ "label": _("Default namespace for quick notes"),
+ "type": str,
+ "value": "",
+ },
)
'''
Changes:
2011-12-02 Karol BÄdkowski
fix loading notebook list from zim 0.53
+ 2011-12-03 Karol BÄdkowski
+ add CreateZimQuickNote action
TODO:
use FilesystemWatchMixin (?)
'''
-
def _start_zim(notebook, page):
''' Start zim and open given notebook and page. '''
utils.spawn_async(("zim", notebook, page.replace("'", "_")))
@@ -108,6 +126,48 @@ class CreateZimPageInNotebook(Action):
return ZimNotebooksSource()
+class CreateZimQuickNote(Action):
+ """ Create new page using quicknote plugin """
+ def __init__(self):
+ Action.__init__(self, _('Insert QuickNote into Zim'))
+
+ def activate(self, leaf):
+ self._create_note(leaf.object)
+
+ def activate_multiple(self, objects):
+ text = '\n'.join(str(leaf.object) for leaf in objects)
+ self._create_note(text)
+
+ def get_description(self):
+ return _("Quick note selected text into Zim notebook")
+
+ def get_icon_name(self):
+ return 'document-new'
+
+ def item_types(self):
+ yield TextLeaf
+
+ def _create_note(self, text):
+ argv = ['zim', '--plugin', 'quicknote', 'input=stdin']
+ basename = __kupfer_settings__['quicknote_basename']
+ if basename:
+ try:
+ basename = time.strftime(basename, time.localtime())
+ basename = basename.replace(':', '_')
+ except:
+ pass
+ argv.append("basename=" + basename)
+ namespace = __kupfer_settings__['quicknote_namespace']
+ if namespace:
+ argv.append("namespace=" + namespace)
+
+ def finish_callback(acommand, stdout, stderr):
+ pretty.print_debug(__name__, "CreateZimQuickNote.finish_callback", acommand,
+ stdout, stderr)
+
+ utils.AsyncCommand(argv, finish_callback, None, stdin=text)
+
+
class OpenZimPage(Action):
""" Open Zim page """
rank_adjust = 10
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]