Created
October 11, 2008 12:56
-
-
Save rpl/16263 to your computer and use it in GitHub Desktop.
Tomboy Ubiquity Commands (require mozjs_dbus extension)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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