From d483572faa5b9eaef8cf838612611b26b902922e Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Sat, 9 Jan 2010 14:13:56 +0100 Subject: [PATCH] IMDb plugin: make plot downloading optional --- src/plugins/imdb-download-dialog.vala | 11 +++++++++-- src/plugins/imdb-plugin.vala | 27 +++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/plugins/imdb-download-dialog.vala b/src/plugins/imdb-download-dialog.vala index 701195c..8173c0d 100644 --- a/src/plugins/imdb-download-dialog.vala +++ b/src/plugins/imdb-download-dialog.vala @@ -20,8 +20,11 @@ using Gtk; using Hildon; class IMDbDownloadDialog : Note { - public IMDbDownloadDialog (Gtk.Window window) { + private bool plots; + + public IMDbDownloadDialog (Gtk.Window window, bool _plots) { transient_parent = window; + plots = _plots; } construct { @@ -35,7 +38,11 @@ class IMDbDownloadDialog : Note { server.Progress += this.on_progress; server.DescriptionChanged += this.on_description_changed; - server.download (mirror, IMDbDownloader.MOVIES | IMDbDownloader.GENRES | IMDbDownloader.RATINGS | IMDbDownloader.AKAS); + int flags = IMDbDownloader.MOVIES | IMDbDownloader.GENRES | IMDbDownloader.RATINGS | IMDbDownloader.AKAS; + if (plots) + flags |= IMDbDownloader.PLOTS; + + server.download (mirror, flags); } catch (DBus.Error e) { warning ("Failed to invoke IMDb downloader: %s", e.message); } diff --git a/src/plugins/imdb-plugin.vala b/src/plugins/imdb-plugin.vala index 887b79a..2fbf482 100644 --- a/src/plugins/imdb-plugin.vala +++ b/src/plugins/imdb-plugin.vala @@ -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 (); -- 1.7.9.5