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, Osso.Context context) {
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 List<MovieAction> get_actions (Movie movie) {
42 List<MovieAction> list = null;
47 public override void settings_dialog (Gtk.Window window) {
48 GoogleSource source = (GoogleSource) sources.data;
49 var dialog = new Gtk.Dialog ();
50 dialog.set_transient_for (window);
51 dialog.set_title (_("Google plugin settings"));
53 var selector = new TouchSelectorEntry.text ();
54 selector.append_text ("Berlin");
56 var button = new PickerButton (SizeType.FINGER_HEIGHT, ButtonArrangement.HORIZONTAL);
57 button.set_title (_("Location"));
58 button.set_selector (selector);
59 button.set_value (source.location);
61 var content = (VBox) dialog.get_content_area ();
62 content.pack_start (button, true, true, 0);
64 dialog.add_button ("Done", ResponseType.ACCEPT);
67 int res = dialog.run ();
68 if (res == ResponseType.ACCEPT) {
69 source.location = button.get_value ();
74 public override unowned string get_name () {
79 class GoogleSource : MovieSource {
80 public string location;
81 public string description;
83 public override async void get_movies (MovieFilter filter, MovieSource.ReceiveMovieFunction callback, int limit, Cancellable? cancellable) {
84 var parser = new GoogleParser ();
86 yield parser.query (filter, location, callback, cancellable);
87 if (location == null) {
88 location = parser.location;
92 public override void add_movie (Movie movie) {
95 public override unowned string get_name () {
99 public override unowned string get_description () {
100 if (location != null && location != "") {
101 description = _("Movie Showtimes near %s").printf (location);
103 description = _("Movie Showtimes");
110 public Type register_plugin () {
111 // types are registered automatically
112 return typeof (GooglePlugin);