1 /* This file is part of Cinaest.
3 * Copyright (C) 2009 Philipp Zabel
5 * Cinaest is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * Cinaest is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Cinaest. If not, see <http://www.gnu.org/licenses/>.
22 class GooglePlugin : Plugin {
23 List<MovieSource> sources;
25 public override void hello (Gtk.Window window) {
26 stdout.printf ("Google Plugin Loaded.\n");
28 var source = new GoogleSource ();
30 sources = new List<MovieSource> ();
31 sources.append (source);
33 // FIXME - this forces the inclusion of config.h
34 (void) Config.GETTEXT_PACKAGE;
37 public override unowned List<MovieSource> get_sources () {
41 public override void settings_dialog (Gtk.Window window) {
42 GoogleSource source = (GoogleSource) sources.data;
43 var dialog = new Gtk.Dialog ();
44 dialog.set_transient_for (window);
45 dialog.set_title (_("Google plugin settings"));
47 var selector = new TouchSelectorEntry.text ();
48 selector.append_text ("Berlin");
50 var button = new PickerButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL);
51 button.set_title (_("Location"));
52 button.set_selector (selector);
53 button.set_value (source.location);
55 var content = (VBox) dialog.get_content_area ();
56 content.pack_start (button, true, true, 0);
58 dialog.add_button ("Done", ResponseType.ACCEPT);
61 int res = dialog.run ();
62 if (res == ResponseType.ACCEPT) {
63 source.location = button.get_value ();
68 public override unowned string get_name () {
73 class GoogleSource : MovieSource {
74 public string location;
75 public string description;
77 public override void get_movies (MovieFilter filter, MovieSource.ReceiveMovieFunction callback, int limit, Cancellable? cancellable) {
78 var parser = new GoogleParser (filter, location, callback, cancellable);
81 public override void add_movie (Movie movie) {
84 public override unowned string get_name () {
88 public override unowned string get_description () {
89 if (location != null && location != "") {
90 description = _("Movie Showtimes near %s").printf (location);
92 description = _("Movie Showtimes");
99 public Type register_plugin () {
100 // types are registered automatically
101 return typeof (GooglePlugin);