/* gcc `pkg-config --cflags --libs webkit-1.0` main.c -o jamendo-player */
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#define URL_FORMAT "http://widgets.jamendo.com/fr/playlist/?playertype=2008&playlist_id=%s"
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *webview;
gchar *url;
gchar *playlist_id = argv[1];
if (argc < 2)
{
playlist_id = g_strdup ("65196");
g_message ("Loading the default playlist %s", playlist_id);
}
url = g_strdup_printf (URL_FORMAT, playlist_id);
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_icon_name (GTK_WINDOW (window), "multimedia-player");
gtk_window_set_title (GTK_WINDOW (window), "Jamendo Player");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
webview = webkit_web_view_new ();
gtk_widget_set_size_request (webview, 200, 300);
gtk_container_add (GTK_CONTAINER (window), webview);
webkit_web_view_open (WEBKIT_WEB_VIEW (webview), url);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
The result is pleasing, the flash application has nice colors, and is something I would never be able to do with GTK+ :-)
If you like the code, feel free to extend it and send patches, I will enjoy any contribution. For now I will just leave a desktop file inside my applications directory to open it when I am bored again of my music :-p
Update: I hacked a little on the program to handle the links inside the Flash application. This means it is possible to change the playlist, which was one the thing that started to annoy me very much.
However, this update requires WebKit 1.0.3 and GLib 2.16.
This time I'm making the code available here instead of pasting it as it has grown up to 120 lines.