IMDb plugin: make plot downloading optional
[cinaest] / src / plugins / imdb-plugin.vala
index 298cb54..2fbf482 100644 (file)
@@ -36,7 +36,7 @@ class IMDbPlugin : Plugin {
                        note.destroy ();
 
                        if (response == ResponseType.OK) {
-                               download_imdb (window);
+                               download_imdb (window, false);
                        }
                }
 
@@ -51,7 +51,7 @@ class IMDbPlugin : Plugin {
                (void) Config.GETTEXT_PACKAGE;
        }
 
-       private void download_imdb (Gtk.Window window) {
+       private void download_imdb (Gtk.Window window, bool plots) {
                var picker = new PickerDialog (window);
                var selector = new TouchSelector.text ();
                string[] mirrors;
@@ -80,7 +80,7 @@ class IMDbPlugin : Plugin {
                picker.destroy();
 
                if (res == ResponseType.OK) {
-                       var download = new IMDbDownloadDialog (window);
+                       var download = new IMDbDownloadDialog (window, plots);
                        download.run (server, mirror);
                        download.destroy ();
                }
@@ -118,6 +118,19 @@ class IMDbPlugin : Plugin {
                dialog.set_transient_for (window);
                dialog.set_title (_("IMDb plugin settings"));
 
+               bool download_plots;
+               try {
+                       var sqlite = new IMDbSqlite (Path.build_filename (Environment.get_user_cache_dir (),
+                                                    "cinaest", "imdb.db", null));
+                       download_plots = sqlite.has_plots ();
+               } catch (Error e) {
+                       download_plots = false;
+               }
+
+               var plots = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
+               plots.set_label (_("Download and store movie plots"));
+               plots.set_active (download_plots);
+
                string updated;
                string filename = Path.build_filename (Environment.get_user_cache_dir(),
                                                       "cinaest", "imdb.db", null);
@@ -139,10 +152,16 @@ class IMDbPlugin : Plugin {
                var download = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Download"), _("Last update: ") + updated);
 
                VBox content = (VBox) dialog.get_content_area ();
+               content.pack_start (plots, true, true, 0);
                content.pack_start (download, true, true, 0);
 
+               // Connect signals
+               plots.toggled.connect (() => {
+                       if (download_plots != plots.get_active ())
+                               Hildon.Banner.show_information (window, null, _("Redownload the IMDb for this change to take effect."));
+               });
                download.clicked.connect (() => {
-                       download_imdb (window);
+                       download_imdb (window, plots.get_active ());
                });
 
                dialog.show_all ();
@@ -164,9 +183,6 @@ class IMDBSource : MovieSource {
 
        MovieSource.ReceiveMovieFunction _get_callback;
        public override async int get_movies (MovieFilter filter, MovieSource.ReceiveMovieFunction callback, int limit, Cancellable? cancellable) {
-               // IMDb has too many movies
-               if (filter.title == "" && filter.year_min == 0 && filter.year_max == 0 && filter.genres.field == 0 && filter.rating_min == 0)
-                       return;
                var sqlite = new IMDbSqlite (Path.build_filename (Environment.get_user_cache_dir (),
                                             "cinaest", "imdb.db", null));