Index: widgets/rb-header.c
===================================================================
--- widgets/rb-header.c	(revision 5467)
+++ widgets/rb-header.c	(working copy)
@@ -37,6 +37,7 @@
 #include "eel-gconf-extensions.h"
 #include "rb-util.h"
 #include "rhythmdb.h"
+#include "rb-rating.h"
 
 static void rb_header_class_init (RBHeaderClass *klass);
 static void rb_header_init (RBHeader *header);
@@ -59,6 +60,11 @@
 
 static void rb_header_elapsed_changed_cb (RBShellPlayer *player, guint elapsed, RBHeader *header);
 
+static void rb_header_update_rating (RBRating *rating, double score, RBHeader *header);
+
+static void rb_header_rated_cb (RBShellPlayer *player, const char *file, const char *type,
+				GValue *old, GValue *new, RBHeader *header);
+
 struct RBHeaderPrivate
 {
 	RhythmDB *db;
@@ -69,6 +75,8 @@
 	GtkWidget *image;
 	GtkWidget *song;
 
+	GtkWidget *rating;
+
 	GtkWidget *timeline;
 	GtkWidget *scaleline;
 	gboolean scaleline_shown;
@@ -183,6 +191,15 @@
 	gtk_box_pack_start (GTK_BOX (hbox), header->priv->song, TRUE, TRUE, 0);
 	gtk_widget_show (header->priv->song);
 
+	header->priv->rating = GTK_WIDGET (rb_rating_new ());
+
+	g_signal_connect_object (header->priv->rating, "rated",
+				 G_CALLBACK (rb_header_update_rating),
+				 G_OBJECT (header), 0);
+
+	gtk_box_pack_start (GTK_BOX (hbox), header->priv->rating, FALSE, FALSE, 0);
+	gtk_widget_show (GTK_WIDGET (header->priv->rating));
+
 	/* construct the time display */
 	header->priv->timeline = gtk_hbox_new (FALSE, 3);
 	header->priv->elapsed = gtk_label_new ("");
@@ -221,6 +238,53 @@
 }
 
 static void
+rb_header_rated_cb (RBShellPlayer *player,
+		    const char *file,
+		    const char *type,
+		    GValue *old,
+		    GValue *new_rating,
+		    RBHeader *header)
+{
+	g_return_if_fail (RB_IS_HEADER (header));
+	
+	RhythmDBEntry *entry;
+	entry = rb_shell_player_get_playing_entry (player);
+
+	if(entry != NULL) {
+		double score = rhythmdb_entry_get_double (entry, RHYTHMDB_PROP_RATING);
+		g_object_set (G_OBJECT (header->priv->rating), "rating", score, NULL);
+	}
+}
+
+
+static void
+rb_header_update_rating (RBRating *rating,
+			 double score,
+			 RBHeader *header)
+{
+	g_return_if_fail (RB_IS_RATING (rating));
+	g_return_if_fail (RB_IS_HEADER (header));
+	g_return_if_fail (score >= 0 && score <= 5 );
+
+	GValue value = {0, };
+	g_value_init(&value, G_TYPE_DOUBLE);
+	g_value_set_double (&value, score);
+
+	RhythmDBEntry *playing_entry;
+	playing_entry = rb_shell_player_get_playing_entry (header->priv->shell_player);
+
+	if (playing_entry != NULL) {
+		rhythmdb_entry_set (header->priv->db,
+				    playing_entry,
+				    RHYTHMDB_PROP_RATING,
+				    &value);
+		rhythmdb_commit (header->priv->db);	
+	}
+
+	g_value_unset (&value);
+}
+
+static void
 rb_header_finalize (GObject *object)
 {
 	RBHeader *header;
@@ -261,6 +325,11 @@
 				  "elapsed-changed",
 				  (GCallback) rb_header_elapsed_changed_cb,
 				  header);
+		
+		g_signal_connect (G_OBJECT (header->priv->shell_player),
+				  "playing-song-property-changed",
+				  G_CALLBACK (rb_header_rated_cb),
+				  header);
 		break;
 	case PROP_SEEKABLE:
 		header->priv->seekable = g_value_get_boolean (value);
@@ -322,6 +391,14 @@
 		      "entry", entry,
 		      "seekable", seekable,
 		      NULL);
+
+	if(entry != NULL) {
+		double score = rhythmdb_entry_get_double (entry, RHYTHMDB_PROP_RATING);
+
+		g_object_set (G_OBJECT (header->priv->rating),
+			      "rating", score,
+			      NULL);
+	}
 }
 
 static void
@@ -649,7 +726,6 @@
 	} else {
 		gtk_label_set_text (GTK_LABEL (header->priv->elapsed), "");
 	}
-
 }
 
 static void
