Catalog plugin: add watched movies list, special UI to add watched / loaned movies
authorPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 8 Dec 2009 23:00:15 +0000 (00:00 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 14 Jul 2010 21:34:08 +0000 (23:34 +0200)
src/plugins/catalog-plugin.vala
src/plugins/catalog-sqlite.vala

index 550a810..e562a24 100644 (file)
@@ -55,6 +55,9 @@ class CatalogPlugin : Plugin {
                source = new CatalogSource ("Loaned", _("Loaned movies"), _("Movies loaned to friends"), sqlite, !("Loaned" in hidden_sources));
                sources.append (source);
 
+               source = new CatalogSource ("Watched", _("Watched movies"), _("Watched / rated movies"), sqlite, !("Watched" in hidden_sources));
+               sources.append (source);
+
                source = new CatalogSource ("Watchlist", _("Watchlist"), _("Movies of interest"), sqlite, !("Watchlist" in hidden_sources));
                sources.append (source);
 
@@ -102,10 +105,62 @@ class CatalogPlugin : Plugin {
                int res = dialog.run ();
                if (res >= 0) {
                        var source = sources.nth_data (res);
-                       source.add_movie (movie);
 
-                       var banner = (Banner) Banner.show_information_with_markup (window, null, _("'%s' added to list '%s'").printf (movie.title, source.get_name ()));
-                       banner.set_timeout (1500);
+                       if (source.table == "Loaned") {
+                               var dialog = new Gtk.Dialog ();
+                               dialog.set_title (_("Add to loaned movies"));
+
+                               var contact = new Hildon.Entry (SizeType.FINGER_HEIGHT);
+                               contact.set_placeholder ("Contact");
+                               var date = new Hildon.DateButton (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL);
+                               date.set_title (_("Loaned on"));
+                               date.set_alignment (0.0f, 0.5f, 1.0f, 1.0f);
+
+                               content = (Gtk.VBox) dialog.get_content_area ();
+                               content.pack_start (contact, true, false, 0);
+                               content.pack_start (date, true, false, 0);
+
+                               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
+                               dialog.show_all ();
+                               res = dialog.run ();
+                               dialog.destroy ();
+                               if (res == Gtk.ResponseType.OK) {
+                                       source.add_movie (movie);
+
+                                       var banner = (Banner) Banner.show_information_with_markup (window, null, _("'%s' added to list of loaned movies").printf (movie.title, source.get_name ()));
+                                       banner.set_timeout (1500);
+                               }
+                       } else if (source.table == "Watched") {
+                               var dialog = new Gtk.Dialog ();
+                               dialog.set_title (_("Add to watched movies"));
+
+                               var rating = new RatingWidget ();
+                               var date = new Hildon.DateButton (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL);
+                               date.set_title (_("Watched on"));
+                               date.set_alignment (0.0f, 0.5f, 1.0f, 1.0f);
+
+                               content = (Gtk.VBox) dialog.get_content_area ();
+                               content.pack_start (rating, true, false, 0);
+                               content.pack_start (date, true, false, 0);
+
+                               dialog.add_button (_("Done"), Gtk.ResponseType.OK);
+                               dialog.show_all ();
+                               res = dialog.run ();
+                               dialog.destroy ();
+                               if (res == Gtk.ResponseType.OK) {
+                                       if (rating.get_rating () > 0)
+                                               movie.rating = 10 * rating.get_rating ();
+                                       source.add_movie (movie);
+
+                                       var banner = (Banner) Banner.show_information_with_markup (window, null, _("'%s' added to list of watched movies").printf (movie.title, source.get_name ()));
+                                       banner.set_timeout (1500);
+                               }
+                       } else {
+                               source.add_movie (movie);
+
+                               var banner = (Banner) Banner.show_information_with_markup (window, null, _("'%s' added to list '%s'").printf (movie.title, source.get_name ()));
+                               banner.set_timeout (1500);
+                       }
                }
                dialog.destroy ();
                dialog = null;
index 1e8d068..151fc1c 100644 (file)
@@ -130,7 +130,7 @@ class CatalogSqlite : Object {
        private int prepare () {
                int rc;
 
-               rc = db.exec ("CREATE TABLE IF NOT EXISTS Collection (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS Loaned (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS Watchlist (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0);", callback, null);
+               rc = db.exec ("CREATE TABLE IF NOT EXISTS Collection (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS Loaned (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS Watched (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0); CREATE TABLE IF NOT EXISTS Watchlist (Title TEXT NOT NULL, Year INTEGER, Rating INTEGER, Genres INTEGER NOT NULL DEFAULT 0);", callback, null);
                if (rc != Sqlite.OK) {
                        stderr.printf ("SQL error: %d, %s\n", rc, db.errmsg ());
                        return 1;