Movie list window: let the caller show the window
[cinaest] / src / poster / movie-poster-factory.vala
index 4068354..4c74c00 100644 (file)
@@ -1,3 +1,21 @@
+/* This file is part of Cinaest.
+ *
+ * Copyright (C) 2009 Philipp Zabel
+ *
+ * Cinaest is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cinaest is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
+ */
+
 using GLib;
 
 namespace MoviePoster {
@@ -18,15 +36,19 @@ namespace MoviePoster {
                                server = conn.get_object ("org.maemo.movieposter.GoogleImages",
                                                          "/org/maemo/movieposter/GoogleImages",
                                                          "org.maemo.movieposter.Provider");
-                               server.Fetched += this.on_poster_fetched;
+                               server.Fetched.connect (this.on_poster_fetched);
                        } catch (Error e) {
                                warning ("Couldn't connect to Google image downloader: %s\n", e.message);
                        }
                        gc = GConf.Client.get_default ();
 
-                       download_posters = gc.get_bool ("/apps/cinaest/download_posters");
-                       gc.add_dir ("/apps/cinaest", GConf.ClientPreloadType.ONELEVEL);
-                       cxnid = gc.notify_add ("/apps/cinaest/download_posters", on_download_posters_changed);
+                       try {
+                               download_posters = gc.get_bool ("/apps/cinaest/download_posters");
+                               gc.add_dir ("/apps/cinaest", GConf.ClientPreloadType.ONELEVEL);
+                               cxnid = gc.notify_add ("/apps/cinaest/download_posters", on_download_posters_changed);
+                       } catch (Error e) {
+                               stdout.printf ("Error installing GConf notification: %s\n", e.message);
+                       }
                }
 
                private static void on_download_posters_changed (GConf.Client gc, uint cxnid, GConf.Entry entry) {
@@ -49,7 +71,7 @@ namespace MoviePoster {
                        } else if (server != null && download_posters) {
                                var request = new Request ();
 
-                               request.handle = server.fetch (movie.title.down (), movie.year.to_string (), "movie");
+                               request.handle = server.Fetch (movie.title.down (), movie.year.to_string (), "movie");
                                request.movie = movie;
                                request.callback = callback;
                                request.width = 268;
@@ -69,7 +91,7 @@ namespace MoviePoster {
                        } else if (server != null && download_posters) {
                                var request = new Request ();
 
-                               request.handle = server.fetch_thumbnail (movie.title.down (), movie.year.to_string (), "movie");
+                               request.handle = server.FetchThumbnail (movie.title.down (), movie.year.to_string (), "movie");
                                request.movie = movie;
                                request.callback = callback;
                                request.width = (int) width;
@@ -110,11 +132,10 @@ namespace MoviePoster {
                }
 
                public void clear_queue () {
-
-                       // FIXME
-                       if (server != null)
-                               server.unqueue (0);
-
+                       if (server != null) {
+                               foreach (Request r in requests)
+                                       server.Unqueue (r.handle);
+                       }
                        requests = null;
                }
        }
@@ -128,7 +149,7 @@ namespace MoviePoster {
 
                public void unqueue () {
                        if (Factory.get_instance ().server != null)
-                               Factory.get_instance ().server.unqueue (this.handle);
+                               Factory.get_instance ().server.Unqueue (this.handle);
 
                        Factory.get_instance ().requests.remove (this);
                }