Skip to content

Instantly share code, notes, and snippets.

@rpl
Created October 11, 2008 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpl/16263 to your computer and use it in GitHub Desktop.
Save rpl/16263 to your computer and use it in GitHub Desktop.
Tomboy Ubiquity Commands (require mozjs_dbus extension)
Components.utils.import("resource://mozjs_dbus/DBUS.jsm");
const bus = DBUS.sessionBus;
const tb = bus.getObject("org.gnome.Tomboy",
"/org/gnome/Tomboy/RemoteControl",
"org.gnome.Tomboy.RemoteControl");
CmdUtils.CreateCommand({
name: "tomboy-list",
homepage: "http://rplcodeline.blogspot.com",
author: { name: "Luca Greco", email: "luca.greco@alca.le.it"},
license: "GPL3",
preview: function(pvdata, text) {
var notes = tb.ListAllNotes();
var data = "<ul>";
notes.forEach(function(item) {
data += "<li>"+tb.GetNoteTitle(item)+"</li>";
});
data += "</ul>";
pvdata.innerHTML = data;
}
});
CmdUtils.CreateCommand({
name: "tomboy-view",
homepage: "http://rplcodeline.blogspot.com",
author: { name: "Luca Greco", email: "luca.greco@alca.le.it"},
license: "GPL3",
takes: {status: noun_arb_text},
preview: function(pvdata, input) {
var data = "<ul>";
this._foreach(input,function(item) {
data += "<li>"+tb.GetNoteTitle(item)+": "+tb.GetNoteContents(item)+"</li>";
},function() { data += "<li>NOCONTENT</li>";});
data += "</ul>";
pvdata.innerHTML = data;
},
execute: function(input) {
this._foreach(input,function(item) {
tb.DisplayNote(item)
});
},
_foreach: function(input, item_handler, noitem_handler) {
if (input.length < 1) return;
var notes = tb.SearchNotes(input.text,false);
if (notes == null) {
noitem_handler.call();
}
else notes.forEach(item_handler);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment