import pygtk
import pango
import gobject
-from random import randint
-import random
+from maeviesui.util.moviemanager import MovieManager
pygtk.require("2.0")
import gtk
self.show_all()
- def _create_box(self, title, action):
+ def _create_button(self, title, subtitle, action):
box = gtk.VBox()
box.set_border_width(20)
- button = gtk.Button()
+ button = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT,
+ hildon.BUTTON_ARRANGEMENT_VERTICAL, title, subtitle)
button.connect("clicked", self._button_clicked, action)
- foot_label = gtk.Label()
- foot_label.set_text(title)
- box.pack_start(button,
- expand = True, fill = True)
- box.pack_start(foot_label,
- expand = False, fill = False)
+ box.pack_start(button, expand = True, fill = False)
return box
contents = gtk.HBox()
contents.set_border_width(60)
contents.set_homogeneous(True)
- contents.pack_start(self._create_box(title = "On Theaters",
- action = self.ACTION_THEATERS),
+ contents.pack_start(self._create_button("On Theaters", "Movies playing",
+ self.ACTION_THEATERS),
expand = True, fill = True)
- contents.pack_start(self._create_box(title = "Favorites",
- action = self.ACTION_FAVORITES),
+ contents.pack_start(self._create_button("Favorites", "Your saved searches",
+ self.ACTION_FAVORITES),
expand = True, fill = True)
- contents.pack_start(self._create_box(title = "Search",
- action = self.ACTION_SEARCH),
+ contents.pack_start(self._create_button("Search", "Enter a new search",
+ self.ACTION_SEARCH),
expand = True, fill = True)
return contents;
def _create_picker_button(self):
self._picker_button = hildon.PickerButton(gtk.HILDON_SIZE_FINGER_HEIGHT,
- hildon.BUTTON_ARRANGEMENT_VERTICAL)
+ hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
self._picker_button.set_title("Search for")
selector = hildon.TouchSelector(text = True)
self.search_term = search_term
self.search_category = search_category
- self._simulate_search()
+ self.moviemanager = MovieManager(self._populate_view)
+
content_area = hildon.PannableArea()
self._movies_view = MoviesView()
+ self._movies_view.connect('row-activated', self._row_activated_cb)
content_area.add(self._movies_view)
self.add(content_area)
+ self._start_search()
self.show_all()
- def _simulate_search(self):
+ def _row_activated_cb(self, view, path, column):
+ #movie = view.get_movie_from_path(path)
+ MovieWindow(None)
+
+ def _start_search(self):
self._show_banner()
hildon.hildon_gtk_window_set_progress_indicator(self, True)
- gobject.timeout_add(constants.TIMEOUT_TIME_MILLIS, self._populate_view)
-
- def _populate_view(self):
- self._movies_view.add_movies([MovieDecorator("The Lord of the Rings"),
- MovieDecorator("The Lord of the flies"),
- MovieDecorator("Gone by the wind"),
- MovieDecorator("Madagascar"),
- MovieDecorator("Madagascar 2"),
- MovieDecorator("2 Fast 2 Furious"),
- MovieDecorator("Fast & Furious"),
- MovieDecorator("Pitch Black"),
- ])
+ self.moviemanager.query(self.search_term)
+
+ def _populate_view(self, movies):
+ self._movies_view.add_movies(movies)
hildon.hildon_gtk_window_set_progress_indicator(self, False)
return False
}
self.append(row.values())
-if __name__ == "__main__":
- maevies = Maevies()
- maevies.run()
-
class AboutDialog(gtk.Dialog):
def __init__(self, parent):
self.set_title("About Maevies")
self.show_all()
-class MovieDecorator:
+class MovieWindow(hildon.StackableWindow):
- def __init__(self, name):
- self._name = name
- pass
+ _zombieland = {'Title' : "Zombieland", 'Release date' : "27 November 2009",
+ 'Genre' : "Action | Adventure | Comedy", 'Score' : "7.8",
+ 'Popularity' : "down 4%", 'Overview' : constants.LOREM_IPSUM}
+
+ def _create_contents(self, movie):
+ main_area = hildon.PannableArea()
- def get_name(self):
- return self._name
+ main_box = gtk.VBox(False, 20)
+ main_box.set_border_width(20)
+ upper_content = gtk.HBox(False, 20)
+ upper_content.set_border_width(20)
- def get_length(self):
- return "%sh:%sm" % (random.randrange(1, 2), random.randrange(0, 59))
+ image = gtk.Image()
+ image.set_from_pixbuf(gtk.IconTheme().load_icon('mediaplayer_default_album', 256, 0))
- def get_score(self):
- return "%s" % (random.randrange(6, 9))
+ side_content = gtk.VBox(False, 30)
- def get_info(self):
- return "<b>%s</b>\n<small><i>Length: </i>%s || <i>Score: </i>%s</small>" % (
- self.get_name(),
- self.get_length(),
- self.get_score())
+ for key in ["Title", "Release date", "Genre", "Score", "Popularity"]:
+ label = gtk.Label()
+ label.set_markup("<b>%(field)s:</b> <small>%(value)s</small>" % {'field' : key,
+ 'value' : movie[key]})
+ label.set_alignment(constants.LEFT_ALIGNMENT, constants.CENTER_ALIGNMENT)
+ side_content.pack_start(label, False, False)
- def get_image(self):
- return self._get_placeholder_pixbuf()
+ upper_content.pack_start(image, False, False)
+ upper_content.pack_start(side_content, True, True)
- def _get_placeholder_pixbuf(self):
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(constants.PLACEHOLDER_IMAGE,
- constants.IMAGE_WIDTH,
- constants.IMAGE_HEIGHT)
- return pixbuf
+ label = gtk.Label()
+ label.set_markup("<b>%(field)s:</b>\n %(value)s" % {'field' : 'Overview',
+ 'value' : movie['Overview']})
+ label.set_alignment(constants.LEFT_ALIGNMENT, constants.CENTER_ALIGNMENT)
+
+ main_box.pack_start(upper_content, False, False)
+ main_box.pack_start(label, False, False)
+
+ main_area.add_with_viewport(main_box)
+ return main_area
+
+ def __init__(self, movie):
+ super(MovieWindow, self).__init__()
+ self.add(self._create_contents(self._zombieland))
+ self.show_all()
+
+if __name__ == "__main__":
+ maevies = Maevies()
+ maevies.run()