return count;
}
- public bool has_plots () {
- return (count ("Plots") > 0);
+ public bool has_table (string table) {
+ string sql = "SELECT * FROM sqlite_master WHERE type=\"table\" AND name=\"%s\"".printf (table);
+ Statement stmt;
+ int rc;
+
+ rc = db.prepare_v2 (sql, -1, out stmt);
+ if (rc != Sqlite.OK) {
+ stderr.printf ("SQL error: %d, %s\n", rc, db.errmsg ());
+ db.progress_handler (0, null);
+ return false;
+ }
+
+ do {
+ rc = stmt.step ();
+ if (rc == Sqlite.ROW)
+ return true;
+ } while (rc == Sqlite.ROW);
+
+ return false;
}
public string get_plot (string title) {
note.destroy ();
if (response == ResponseType.OK) {
- download_imdb (window, false);
+ download_imdb (window, false, false);
}
}
(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;
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 ();
}
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);
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);
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 ();