X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmovie-list-view.vala;h=385eeead9c26df071b005071f1ff3cec24d3eaa7;hb=ded1a5bcb7f68a3366d0aa9ed7cee3a4560d4812;hp=4f2c95695d6ac6a4f11cd0093f6f27a0c42adbaf;hpb=8d64edafb7b3b59ad97e557e9db0d901d42755a6;p=cinaest diff --git a/src/movie-list-view.vala b/src/movie-list-view.vala index 4f2c956..385eeea 100644 --- a/src/movie-list-view.vala +++ b/src/movie-list-view.vala @@ -20,29 +20,22 @@ using Gtk; using Hildon; public class MovieListView : PannableArea { - private enum Columns { - TITLE, - YEAR, - RATING, - N_COLUMNS - } - - ListStore store; + MovieListStore store; TreeView tree; public TreeSortable sorted_store; construct { - store = new ListStore (3, typeof (string), typeof (int), typeof (int)); + store = new MovieListStore (); // FIXME - fill store with test data int i; for (i = 0; i < 10; i++) { + var m = new Movie (); + m.title = "Test %d".printf (i); + m.year = 2000 - i; + m.rating = 10 * (i % 5) + i; TreeIter iter; - - store.append (out iter); - store.set_value (iter, Columns.TITLE, "Test %d".printf (i)); - store.set_value (iter, Columns.YEAR, 2000 - i); - store.set_value (iter, Columns.RATING, 10 * (i % 5) + i); + store.add (m, out iter); } // Add filter wrapper @@ -63,36 +56,41 @@ public class MovieListView : PannableArea { var selection = tree.get_selection (); selection.set_mode (SelectionMode.SINGLE); - // Title column + // Title column with poster var title_column = new TreeViewColumn (); title_column.set_title ("Movie"); - title_column.set_sort_column_id (Columns.TITLE); + title_column.set_sort_column_id (MovieListStore.Columns.TITLE); title_column.set_reorderable (false); title_column.set_sizing (TreeViewColumnSizing.AUTOSIZE); title_column.set_expand (true); + // Add poster icon to column + var pixbuf_renderer = new CellRendererPixbuf (); + title_column.pack_start (pixbuf_renderer, false); + title_column.add_attribute (pixbuf_renderer, "pixbuf", MovieListStore.Columns.POSTER); + // Add text to column var renderer = new CellRendererText (); renderer.set ("ellipsize", Pango.EllipsizeMode.END); title_column.pack_start (renderer, true); - title_column.add_attribute (renderer, "text", Columns.TITLE); + title_column.add_attribute (renderer, "text", MovieListStore.Columns.TITLE); tree.append_column (title_column); // Sort by title - sorted_store.set_sort_column_id (Columns.TITLE, SortType.ASCENDING); + sorted_store.set_sort_column_id (MovieListStore.Columns.TITLE, SortType.ASCENDING); // Year column renderer = new CellRendererText (); - var year_column = new TreeViewColumn.with_attributes ("Year", renderer, "text", Columns.YEAR); - year_column.set_sort_column_id (Columns.YEAR); + var year_column = new TreeViewColumn.with_attributes ("Year", renderer, "text", MovieListStore.Columns.YEAR); + year_column.set_sort_column_id (MovieListStore.Columns.YEAR); year_column.set_reorderable (false); year_column.set_sort_order (SortType.DESCENDING); tree.append_column (year_column); // Rating column renderer = new CellRendererText (); - var rating_column = new TreeViewColumn.with_attributes ("Rating", renderer, "text", Columns.RATING); - rating_column.set_sort_column_id (Columns.RATING); + var rating_column = new TreeViewColumn.with_attributes ("Rating", renderer, "text", MovieListStore.Columns.RATING); + rating_column.set_sort_column_id (MovieListStore.Columns.RATING); rating_column.set_reorderable (false); rating_column.set_sort_order (SortType.DESCENDING); rating_column.set_cell_data_func (renderer, rating_data_func);