IMDb plugin: optionally download actors and actresses
[cinaest] / src / plugins / imdb-plugin.vala
index 4ac86c5..b37e653 100644 (file)
@@ -36,7 +36,7 @@ class IMDbPlugin : Plugin {
                        note.destroy ();
 
                        if (response == ResponseType.OK) {
-                               download_imdb (window, false);
+                               download_imdb (window, false, false);
                        }
                }
 
@@ -51,7 +51,7 @@ class IMDbPlugin : Plugin {
                (void) Config.GETTEXT_PACKAGE;
        }
 
-       private void download_imdb (Gtk.Window window, bool plots) {
+       private void download_imdb (Gtk.Window window, bool plots, bool actors) {
                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, plots);
+                       var download = new IMDbDownloadDialog (window, plots, actors);
                        download.run (server, mirror);
                        download.destroy ();
                }
@@ -119,18 +119,25 @@ class IMDbPlugin : Plugin {
                dialog.set_title (_("IMDb plugin settings"));
 
                bool download_plots;
+               bool download_actors;
                try {
                        var sqlite = new IMDbSqlite (Path.build_filename (Environment.get_user_cache_dir (),
                                                     "cinaest", "imdb.db", null));
-                       download_plots = sqlite.has_plots ();
+                       download_plots = sqlite.has_table ("Plots");
+                       download_actors = sqlite.has_table ("Actors");
                } catch (Error e) {
                        download_plots = false;
+                       download_actors = false;
                }
 
                var plots = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
                plots.set_label (_("Download and store movie plots"));
                plots.set_active (download_plots);
 
+               var actors = new Hildon.CheckButton (SizeType.FINGER_HEIGHT);
+               actors.set_label (_("Download and store actors and actresses"));
+               actors.set_active (download_actors);
+
                string updated;
                string filename = Path.build_filename (Environment.get_user_cache_dir(),
                                                       "cinaest", "imdb.db", null);
@@ -153,6 +160,7 @@ class IMDbPlugin : Plugin {
 
                VBox content = (VBox) dialog.get_content_area ();
                content.pack_start (plots, true, true, 0);
+               content.pack_start (actors, true, true, 0);
                content.pack_start (download, true, true, 0);
 
                 var sizegroup = new Gtk.SizeGroup (SizeGroupMode.HORIZONTAL);
@@ -184,8 +192,12 @@ class IMDbPlugin : Plugin {
                        if (download_plots != plots.get_active ())
                                Hildon.Banner.show_information (window, null, _("Redownload the IMDb for this change to take effect."));
                });
+               actors.toggled.connect (() => {
+                       if (download_actors != actors.get_active ())
+                               Hildon.Banner.show_information (window, null, _("Redownload the IMDb for this change to take effect."));
+               });
                download.clicked.connect (() => {
-                       download_imdb (window, plots.get_active ());
+                       download_imdb (window, plots.get_active (), actors.get_active ());
                });
 
                dialog.show_all ();