typeof (Movie)
};
private Gdk.Pixbuf no_poster;
+ public MovieSource source;
+ private string query;
+ public bool update_running;
construct {
set_column_types (base_type);
no_poster = null;
+ source = null;
+ update_running = false;
}
public void add (Movie movie, out TreeIter iter) {
return false;
}
+ public bool start_search (string _query) {
+ if (update_running)
+ return false;
+
+ query = _query;
+ try {
+ Thread.create (search_thread, false);
+ update_running = true;
+ } catch (ThreadError e) {
+ warning ("Failed to start search thread: %s", e.message);
+ }
+ return update_running;
+ }
+
+ // Update thread
+ private void* search_thread () {
+ stdout.printf ("search thread started: \"%s\"\n", query);
+
+ Gdk.threads_enter ();
+ clear ();
+ Gdk.threads_leave ();
+
+ if (source != null)
+ // FIXME - arbitrary limit
+ source.get_movies (query, receive_movie, 100);
+
+ update_running = false;
+
+ stdout.printf ("search thread stopped\n");
+ return null;
+ }
+
+ private void receive_movie (Movie movie) {
+ TreeIter iter;
+
+ Gdk.threads_enter ();
+ add (movie, out iter);
+ Gdk.threads_leave ();
+ }
+
// Implement TreeModel interface
public virtual GLib.Type get_column_type (int index_) {
return_val_if_fail (index_ >= 0 && index_ < Columns.N_COLUMNS, 0);