IMDb plugin: add settings dialog
authorPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 9 Nov 2009 09:46:55 +0000 (10:46 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 11 Nov 2009 18:08:12 +0000 (19:08 +0100)
Makefile.am
src/plugin-interface.vala
src/plugins/imdb-plugin.vala

index a0ed6bc..ff47cbe 100644 (file)
@@ -75,7 +75,8 @@ libimdb_plugin_la_VALASOURCES = \
         src/plugin-interface.vala \
         src/plugins/imdb-download-dialog.vala
 
-libimdb_plugin_la_VALAFLAGS = --vapidir ./vapi --pkg dbus-glib-1 --pkg hildon-1 --pkg sqlite3
+libimdb_plugin_la_VALAFLAGS = --vapidir ./vapi --pkg config \
+       --pkg dbus-glib-1 --pkg hildon-1 --pkg sqlite3
 libimdb_plugin_la_CFLAGS = ${DBUS_CFLAGS} ${HILDON_CFLAGS} ${SQLITE3_CFLAGS}
 libimdb_plugin_la_LIBADD = ${DBUS_LIBS} ${HILDON_LIBS} ${SQLITE3_LIBS}
 libimdb_plugin_la_LDFLAGS = -module
index 0203fdd..df453b0 100644 (file)
@@ -21,6 +21,8 @@ public abstract class Plugin : Object {
 
        public abstract unowned List<MovieSource> get_sources ();
 
+       public abstract void settings_dialog (Gtk.Window window);
+
        public abstract unowned string get_name ();
 }
 
index f91f3cd..972d89f 100644 (file)
@@ -43,6 +43,9 @@ class IMDbPlugin : Plugin {
 
                sources = new List<MovieSource> ();
                sources.append (source);
+
+               // FIXME - this forces the inclusion of config.h
+               (void) Config.GETTEXT_PACKAGE;
        }
 
        private void download_imdb (Gtk.Window window) {
@@ -84,6 +87,37 @@ class IMDbPlugin : Plugin {
                return sources;
        }
 
+       public override void settings_dialog (Gtk.Window window) {
+               var dialog = new Gtk.Dialog ();
+               dialog.set_transient_for (window);
+               dialog.set_title (_("IMDb plugin settings"));
+
+               string filename = Path.build_filename (Environment.get_user_cache_dir(),
+                                                      "cinaest", "imdb.db", null);
+               var file = File.new_for_path (filename);
+               var info = file.query_info (FILE_ATTRIBUTE_TIME_MODIFIED, FileQueryInfoFlags.NONE, null);
+               TimeVal tv;
+               info.get_modification_time (out tv);
+
+               var date = Date ();
+               date.set_time_val (tv);
+               char[] s = new char[64];
+               date.strftime (s, "%x");
+
+               var download = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Download"), "Last update: " + (string) s);
+
+               VBox content = (VBox) dialog.get_content_area ();
+               content.pack_start (download, true, true, 0);
+
+               download.clicked.connect (() => {
+                       download_imdb (window);
+               });
+
+               dialog.show_all ();
+               dialog.run ();
+               dialog.destroy ();
+       }
+
        public override unowned string get_name () {
                return "IMDb";
        }