2009-01-19

Fix bitmap^Whorrible fonts

You have horrible fonts in Firefox and don't know how to fix it? It is fairy simple:
cd /etc/fonts/conf.d
cp ../conf.avail/70-no-bitmaps.conf .
And this is it. Restart X.

2009-01-09

./jamendo-player

I was enough bored from my (small) music collection that I wanted to listen to something new, without actually caring what it is. I know Jamendo has a big load of music with artists uploading music under creative commons licence. So I went on their website to have a look, and they have "widgets". They are a small flash application not bigger than 200x300, but I actually didn't find any link to open such a widget inside an external window, except some lost links on some pages. In conclusion it was enough annoying to get an external player that I fired up vim and wrote a 20 lines C program.

/* 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.