X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmovie-window.vala;h=5d751b649694e0724fdeb8205356bbfe3f535244;hb=b8f57dcda33952d6f249e581553756686d2550e9;hp=82a2511eb9a0eb5b1de8feec7f1d6d8a5924c334;hpb=93f3b57e52dadc83c5751a66c5fd616aa06eefdd;p=cinaest
diff --git a/src/movie-window.vala b/src/movie-window.vala
index 82a2511..5d751b6 100644
--- a/src/movie-window.vala
+++ b/src/movie-window.vala
@@ -27,11 +27,13 @@ public class MovieWindow : StackableWindow {
private Image image;
private VBox details;
private PannableArea pannable;
+ private Label title_label;
+ private Label rating_label;
private Label plot;
private bool portrait_mode;
public MovieWindow.with_movie (Movie movie, MovieListStore store) {
- set_title (movie.title);
+ update_title (movie);
// View menu
menu = new MovieMenu (movie, store, this);
@@ -44,7 +46,6 @@ public class MovieWindow : StackableWindow {
if (movie.poster != null && movie.poster.large != null) {
image.pixbuf = movie.poster.large;
} else {
- movie.notify.connect (this.on_movie_changed);
if (movie.poster != null && movie.poster.icon != null) {
// FIXME
image.pixbuf = movie.poster.icon.scale_simple (268, 424, Gdk.InterpType.BILINEAR);
@@ -65,23 +66,18 @@ public class MovieWindow : StackableWindow {
}
}
- // Text area
- string year = movie.year > 0 ? " (%d)".printf (movie.year) : "";
- string text = "%s%s\n%s".printf (movie.title, year, movie.secondary);
- var label = new Label (text);
- label.wrap = true;
- label.use_markup = true;
- label.set_alignment (0.0f, 0.0f);
+ title_label = new Label (title_label_markup (movie));
+ title_label.wrap = true;
+ title_label.use_markup = true;
+ title_label.set_alignment (0.0f, 0.0f);
var header = new HBox (false, 0);
- header.pack_start (label, true, true, 0);
- if (movie.rating > 0) {
- text = "%d.%d".printf (movie.rating / 10, movie.rating % 10);
- var rating = new Label (text);
- rating.use_markup = true;
- rating.set_alignment (0.5f, 0.0f);
- header.pack_start (rating, false, false, MARGIN_DOUBLE);
- }
+ header.pack_start (title_label, true, true, 0);
+
+ rating_label = new Label (rating_label_markup (movie));
+ rating_label.use_markup = true;
+ rating_label.set_alignment (0.5f, 0.0f);
+ header.pack_start (rating_label, false, false, MARGIN_DOUBLE);
plot = new Label (movie.get_plot ());
plot.wrap = true;
@@ -118,6 +114,38 @@ public class MovieWindow : StackableWindow {
// Connect signals
menu.movie_deleted.connect (() => { destroy (); });
Gdk.Screen.get_default ().size_changed.connect (on_orientation_changed);
+ movie.notify.connect (this.on_movie_changed);
+ }
+
+ private void update_title (Movie movie) {
+ Gdk.Color color;
+ this.ensure_style ();
+ if (this.style.lookup_color ("SecondaryTextColor", out color))
+ set_markup ("%s (%d)".printf (movie.title, color.to_string (), movie.year));
+ else
+ set_markup ("%s (%d)".printf (movie.title, movie.year));
+ }
+
+ private string title_label_markup (Movie movie) {
+ Gdk.Color color;
+ this.ensure_style ();
+ string year = "";
+ if (this.style.lookup_color ("SecondaryTextColor", out color)) {
+ if (movie.year > 0)
+ year = " (%d)".printf (color.to_string (), movie.year);
+ return "%s%s\n%s".printf (movie.title, year, color.to_string (), movie.secondary);
+ } else {
+ if (movie.year > 0)
+ year = " (%d)".printf (movie.year);
+ return "%s%s\n%s".printf (movie.title, year, movie.secondary);
+ }
+ }
+
+ private string rating_label_markup (Movie movie) {
+ if (movie.rating > 0)
+ return "%d.%d".printf (movie.rating / 10, movie.rating % 10);
+ else
+ return "";
}
private void receive_poster (Gdk.Pixbuf pixbuf, Movie movie) {
@@ -134,6 +162,13 @@ public class MovieWindow : StackableWindow {
private void on_movie_changed (GLib.Object source, GLib.ParamSpec spec) {
var movie = (Movie) source;
+ if ((spec.name == "title") || (spec.name == "year")) {
+ update_title (movie);
+ title_label.set_markup (title_label_markup (movie));
+ }
+ if (spec.name == "rating") {
+ rating_label.set_markup (rating_label_markup (movie));
+ }
if ((spec.name == "poster") && (movie.poster != null) && (movie.poster.large != null)) {
image.pixbuf = movie.poster.large;
}