public signal void movie_deleted ();
public MovieMenu (Movie _movie, MovieListStore _store, Gtk.Window window) {
+ bool can_rate = false;
movie = _movie;
store = _store;
parent_window = window;
append (button);
actions.append (action);
}
+ foreach (MovieSource source in plugin.get_sources ()) {
+ if (source.active && SourceFlags.RATING in source.get_flags ())
+ can_rate = true;
+ }
+ }
+ if (can_rate) {
+ var button = new Gtk.Button.with_label (_("Rate movie"));
+ button.clicked.connect (on_rate_movie);
+ append (button);
}
if (store.get_editable ()) {
var button = new Gtk.Button.with_label (_("Delete movie"));
show_all ();
}
+ private void on_rate_movie () {
+ var dialog = new Gtk.Dialog ();
+ dialog.set_title (_("Rate movie"));
+
+ var rating = new RatingWidget ();
+ var date = new Hildon.DateButton (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL);
+ date.set_title (_("Watched on"));
+ date.set_alignment (0.0f, 0.5f, 1.0f, 1.0f);
+
+ var content = (Gtk.VBox) dialog.get_content_area ();
+ content.pack_start (rating, true, false, 0);
+ content.pack_start (date, true, false, 0);
+
+ dialog.add_button (_("Done"), Gtk.ResponseType.OK);
+ dialog.show_all ();
+ var res = dialog.run ();
+ dialog.destroy ();
+ if (res == Gtk.ResponseType.OK) {
+ movie.julian_date = get_julian_date (date);
+ movie.rating = 10 * rating.get_rating ();
+ Banner.show_information (parent_window, null, _("Rated movie '%s': %.1f").printf (movie.title, movie.rating/10.0));
+ foreach (Plugin plugin in CinaestProgram.plugins) {
+ foreach (MovieSource source in plugin.get_sources ()) {
+ if (source.active && SourceFlags.RATING in source.get_flags ())
+ source.add_movie (movie);
+ }
+ }
+ }
+ }
+
+ private uint get_julian_date (DateButton button) {
+ var date = Date ();
+ uint year;
+ uint month;
+ uint day;
+ button.get_date (out year, out month, out day);
+ date.set_dmy ((DateDay) day, (DateMonth) month + DateMonth.JANUARY, (DateYear) year);
+ return date.get_julian ();
+ }
+
private void on_delete_movie () {
var dialog = new Note.confirmation (parent_window, _("Delete movie '%s'?").printf (movie.title));
var res = dialog.run ();