X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fimdb-plugin.vala;h=ee7f6af6a35e837dd7267accc077c7554838e963;hb=fe104c2bbff9bd7576e1cd2d5091e8ba72e67381;hp=64d8bb384d41dbc7a8d11fd256bc117f842fd771;hpb=a227131f3236592460414b7f632a82d08c1db0d0;p=cinaest diff --git a/src/plugins/imdb-plugin.vala b/src/plugins/imdb-plugin.vala index 64d8bb3..ee7f6af 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, 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,15 +160,44 @@ 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); + + // User name + var hbox = new Gtk.HBox (false, MARGIN_DOUBLE); + var label = new Gtk.Label (_("User name")); + label.set_alignment (0, 0.5f); + sizegroup.add_widget (label); + var entry = new Hildon.Entry (SizeType.FINGER_HEIGHT); + hbox.pack_start (label, false, false, 0); + hbox.pack_start (entry, true, true, 0); + content.pack_start (hbox, true, true, 0); + + // Password + hbox = new Gtk.HBox (false, MARGIN_DOUBLE); + label = new Gtk.Label (_("Password")); + label.set_alignment (0, 0.5f); + sizegroup.add_widget (label); + entry = new Hildon.Entry (SizeType.FINGER_HEIGHT); + hbox.pack_start (label, false, false, 0); + hbox.pack_start (entry, true, true, 0); + content.pack_start (hbox, true, true, 0); + + dialog.add_button (_("Save"), ResponseType.ACCEPT); + // 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.")); }); + 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 (); @@ -181,9 +217,19 @@ class IMDbMovie : Movie { print ("IMDb get_plot(\"%s (%d)\")\n", title, year); return sqlite.get_plot ("%s (%d)".printf (title, year)); } + + public override List get_cast () { + var sqlite = new IMDbSqlite (Path.build_filename (Environment.get_user_cache_dir (), + "cinaest", "imdb.db", null)); + print ("IMDb get_cast(\"%s (%d)\")\n", title, year); + return sqlite.get_cast ("%s (%d)".printf (title, year)); + } } class IMDBSource : MovieSource { + SList result; + int results_waiting; + public override bool active { get; set construct; } public IMDBSource () { @@ -196,7 +242,12 @@ class IMDBSource : MovieSource { "cinaest", "imdb.db", null)); _get_callback = callback; + result = new SList (); + results_waiting = 0; int n = yield sqlite.query (filter, receive_movie, limit, cancellable); + if (results_waiting > 0) + _get_callback (result); + result = new SList (); return n; } @@ -212,7 +263,12 @@ class IMDBSource : MovieSource { } else { movie.secondary = movie.genres.to_string (); } - _get_callback (movie); + result.append (movie); + if (++results_waiting >= 10) { + _get_callback (result); + result = new SList (); + results_waiting = 0; + } } public override void add_movie (Movie movie) { @@ -229,8 +285,8 @@ class IMDBSource : MovieSource { return _("Movies on IMDb"); } - public override bool get_editable () { - return false; + public override SourceFlags get_flags () { + return 0; } }