[Pioneers-commits] r23 - trunk/client/gtk

kemm at garage.maemo.org kemm at garage.maemo.org
Mon Mar 10 18:19:20 EET 2008


Author: kemm
Date: 2008-03-10 18:19:20 +0200 (Mon, 10 Mar 2008)
New Revision: 23

Modified:
   trunk/client/gtk/player.c
Log:
Draw current scores on the statusbar

Modified: trunk/client/gtk/player.c
===================================================================
--- trunk/client/gtk/player.c	2008-03-10 13:32:23 UTC (rev 22)
+++ trunk/client/gtk/player.c	2008-03-10 16:19:20 UTC (rev 23)
@@ -630,48 +630,59 @@
 				G_GNUC_UNUSED GdkEventExpose * event,
 				G_GNUC_UNUSED gpointer user_data)
 {
-	static GdkGC *turn_gc;
-	gint offset;
-	gint idx;
+    static GdkGC *turn_gc;
+    PangoLayout *lay;
+    gint offset;
+    gint idx;
+    gchar score[3];
+    gint w, h;
 
-	if (area->window == NULL)
-		return FALSE;
+    if (area->window == NULL)
+        return FALSE;
 
-	if (turn_gc == NULL)
-		turn_gc = gdk_gc_new(area->window);
+    if (turn_gc == NULL)
+        turn_gc = gdk_gc_new(area->window);
 
-	offset = 0;
-	for (idx = 0; idx < num_players(); idx++) {
-		gdk_gc_set_foreground(turn_gc, player_color(idx));
-		gdk_draw_rectangle(area->window, turn_gc, TRUE,
-				   offset + 2, 2,
-				   turn_area_icon_width - 4,
-				   area->allocation.height - 4);
-		gdk_gc_set_foreground(turn_gc, &black);
-		if (idx == current_player()) {
-			gdk_gc_set_line_attributes(turn_gc, 3,
-						   GDK_LINE_SOLID,
-						   GDK_CAP_BUTT,
-						   GDK_JOIN_MITER);
-			gdk_draw_rectangle(area->window, turn_gc, FALSE,
-					   offset + 3, 3,
-					   turn_area_icon_width - 6,
-					   area->allocation.height - 6);
-		} else {
-			gdk_gc_set_line_attributes(turn_gc, 1,
-						   GDK_LINE_SOLID,
-						   GDK_CAP_BUTT,
-						   GDK_JOIN_MITER);
-			gdk_draw_rectangle(area->window, turn_gc, FALSE,
-					   offset + 2, 2,
-					   turn_area_icon_width - 4,
-					   area->allocation.height - 4);
-		}
+    offset = 0;
+    for (idx = 0; idx < num_players(); idx++) {
+        gdk_gc_set_foreground(turn_gc, player_color(idx));
+        gdk_draw_rectangle(area->window, turn_gc, TRUE,
+                           offset + 2, 2,
+                           turn_area_icon_width - 4,
+                           area->allocation.height - 4);
+        gdk_gc_set_foreground(turn_gc, &black);
+        if (idx == current_player()) {
+            gdk_gc_set_line_attributes(turn_gc, 3,
+                                       GDK_LINE_SOLID,
+                                       GDK_CAP_BUTT,
+                                       GDK_JOIN_MITER);
+            gdk_draw_rectangle(area->window, turn_gc, FALSE,
+                               offset + 3, 3,
+                               turn_area_icon_width - 6,
+                               area->allocation.height - 6);
+        } else {
+            gdk_gc_set_line_attributes(turn_gc, 1,
+                                       GDK_LINE_SOLID,
+                                       GDK_CAP_BUTT,
+                                       GDK_JOIN_MITER);
+            gdk_draw_rectangle(area->window, turn_gc, FALSE,
+                               offset + 2, 2,
+                               turn_area_icon_width - 4,
+                               area->allocation.height - 4);
+        }
 
-		offset += turn_area_icon_width;
-	}
+        snprintf(score, sizeof(score), "%d", player_get_score(idx));
+        lay = gtk_widget_create_pango_layout(area, score);
+        pango_layout_get_pixel_size(lay, &w, &h);
+        gdk_draw_layout(area->window, turn_gc,
+                        offset + (turn_area_icon_width - w) / 2 + 1,
+                        (area->allocation.height - h) / 2 + 1,
+                        lay);
 
-	return FALSE;
+        offset += turn_area_icon_width;
+    }
+
+    return FALSE;
 }
 
 GtkWidget *player_build_turn_area(void)



More information about the Pioneers-commits mailing list