Skip to content

Instantly share code, notes, and snippets.

@yurenju
Created September 14, 2010 11:57
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 yurenju/578922 to your computer and use it in GitHub Desktop.
Save yurenju/578922 to your computer and use it in GitHub Desktop.
Seed.include("./dbus-rhythmbox.js");
function sendNotification(summary, body, timeOut) {
var notification = new Notify.Notification({summary:summary, body:body});
notification.set_timeout(timeOut);
notification.show();
}
function getWindows () {
Wnck = imports.gi.Wnck;
Gtk = imports.gi.Gtk
Gtk.init(Seed.argv);
var screen = Wnck.Screen.get_default();
while (Gtk.events_pending())
Gtk.main_iteration();
return screen.get_windows();
}
$(document).ready(function(){
var shell = new RhythmboxShell();
var player = new RhythmboxPlayer();
Notify = imports.gi.Notify;
$("#wins-button").click( function() {
var wins = getWindows();
Seed.print (wins.length);
for (var i = 0; i < wins.length; i++) {
Seed.print (wins[i].get_name());
$("#windows-list").append("<li>" + wins[i].get_name() + "</li>");
}
});
$("#min-button").click( function() {
var wins = getWindows();
for (var i = 0; i < wins.length; i++) {
wins[i].minimize();
}
});
Notify.init("Webview");
$("#notify-button").click( function() {
sendNotification("Raised from a WebView","Raised from a WebView", 500);
Seed.print("clicked");
});
//playeplayer.getVolumeRemote(function (volume) {print("oi")});
$("#next-button").click(function(){
player.nextRemote();
});
$("#prev-button").click(function(){
player.previousRemote();
});
player.connect("playingUriChanged",
function(emitter, uri){
//var song = shell.getSongPropertiesRemoteSync(uri);
//print(song);
});
player.connect("playingSongPropertyChanged",
function(emitter, title, property_name, old_value, new_value){
if (property_name == "rb:coverArt-uri")
$("#cover-art").attr('src', new_value);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment