Movie list store: remove insert call and switch back to integer rating string
authorPhilipp Zabel <philipp.zabel@gmail.com>
Fri, 6 Aug 2010 16:19:53 +0000 (18:19 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Fri, 6 Aug 2010 16:38:59 +0000 (18:38 +0200)
Fixes up commit 02f8ac68a39fdf534e5ff7d99a1051c880e9c60f. Avoids
getting empty lines and localized floating point strings from "%.1f".

src/movie-list-store.vala

index c87d1da..52a3c3d 100644 (file)
@@ -81,18 +81,25 @@ public class MovieListStore : ListStore, TreeModel {
                        markup.append_printf (year_markup, movie.year);
                }
 
-               append (out iter1);
-
                base.insert_with_values (out iter1, -1,
                                         0, movie,
                                         1, markup.str,
-                                        2, (movie.rating >= 0) ? "%.1f".printf (movie.rating / 10.0) : null);
+                                        2, rating_string (movie.rating));
 
                movie.notify.connect (this.on_movie_changed);
 
                iter = iter1;
        }
 
+       private string? rating_string (int rating) {
+               if (rating >= 0) {
+                       return "%d.%d".printf (rating / 10,
+                                              rating % 10);
+               } else {
+                       return null;
+               }
+       }
+
        public new bool remove (Movie movie) {
                TreeIter iter;