コード例 #1
0
    def _create_album_preview(self, album):
        """
        Create a clutter.Group that contains album preview actors.
        """
        group = clutter.Group()
        group.set_position(self.get_abs_x(0.07), self.get_abs_y(0.1953))

        # Preview images
        images = album.get_preview_images(3)
        self.preview_textures = []

        max_w = 0.4026
        max_h = 0.5599
        abs_max_w = self.get_abs_x(max_w)
        abs_max_h = self.get_abs_y(max_h)

        for image in images:
            pix_buffer = gtk.gdk.pixbuf_new_from_file(
                image.get_thumbnail_url())
            ratio = float(pix_buffer.get_width())
            ratio /= float(pix_buffer.get_height())

            # Resize and center preview texture
            if ratio > 1:
                texture = EyeCandyTexture(0.0, 0.0, max_w, max_h / ratio,
                                          pix_buffer)
                new_y = int((abs_max_h - abs_max_h / ratio) / 2.0)
                texture.set_position(0, new_y)
            else:
                texture = EyeCandyTexture(0.0, 0.0, max_w * ratio, max_h,
                                          pix_buffer)
                new_x = int((abs_max_w - abs_max_w * ratio) / 2.0)
                texture.set_position(new_x, 0)

            texture.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0)
            texture.set_opacity(0)

            self.preview_textures.append(texture)
            group.add(texture)
        self.preview_textures[0].set_opacity(255)

        title = Label(0.03646,
                      "title",
                      0.4649,
                      0,
                      album.get_title(),
                      font_weight="bold")
        title.width = 0.4758
        title.set_ellipsize(pango.ELLIPSIZE_END)
        group.add(title)

        desc = Label(0.026, "subtitle", 0.4649, 0.0521,
                     album.get_description())
        desc.width = 0.4758
        group.add(desc)

        return group
コード例 #2
0
ファイル: photo_albums.py プロジェクト: tiwilliam/entertainer
    def _create_album_preview(self, album):
        """
        Create a clutter.Group that contains album preview actors.
        """
        group = clutter.Group()
        group.set_position(self.get_abs_x(0.07), self.get_abs_y(0.1953))

        # Preview images
        images = album.get_preview_images(3)
        self.preview_textures = []

        max_w = 0.4026
        max_h = 0.5599
        abs_max_w = self.get_abs_x(max_w)
        abs_max_h = self.get_abs_y(max_h)

        for image in images:
            pix_buffer = gtk.gdk.pixbuf_new_from_file(image.get_thumbnail_url())
            ratio = float(pix_buffer.get_width())
            ratio /= float(pix_buffer.get_height())

            # Resize and center preview texture
            if ratio > 1:
                texture = EyeCandyTexture(0.0, 0.0, max_w, max_h / ratio,
                    pix_buffer)
                new_y = int((abs_max_h - abs_max_h / ratio) / 2.0)
                texture.set_position(0, new_y)
            else:
                texture = EyeCandyTexture(0.0, 0.0, max_w * ratio,
                    max_h, pix_buffer)
                new_x = int((abs_max_w - abs_max_w * ratio) / 2.0)
                texture.set_position(new_x, 0)

            texture.set_rotation(clutter.Y_AXIS, 25, 0, 0, 0)
            texture.set_opacity(0)

            self.preview_textures.append(texture)
            group.add(texture)
        self.preview_textures[0].set_opacity(255)

        title = Label(0.03646, "title", 0.4649, 0, album.get_title(),
            font_weight="bold")
        title.width = 0.4758
        title.set_ellipsize(pango.ELLIPSIZE_END)
        group.add(title)

        desc = Label(0.026, "subtitle", 0.4649, 0.0521, album.get_description())
        desc.width = 0.4758
        group.add(desc)

        return group
コード例 #3
0
    def _create_episode_info_box(self):
        """
        Create a texture that is displayed next to track list. This texture
        displays album cover art.
        """
        self._create_thumbnail_texture()

        # Title
        self.title = Label(0.04,
                           "title",
                           0.05,
                           0.55,
                           self.menu.selected_userdata.title,
                           font_weight="bold")
        self.title.set_ellipsize(pango.ELLIPSIZE_END)
        self.title.set_line_wrap(False)
        self.title.width = 0.4
        self.add(self.title)

        # Plot
        plot = Label(0.029, "subtitle", 0, 0, self.menu.selected_userdata.plot)
        plot.width = 0.4

        self.scroll_area = ScrollArea(0.05, 0.63, 0.4, 0.15, plot)
        self.scroll_area.connect("activated", self._on_scroll_area_activated)
        self.add(self.scroll_area)
コード例 #4
0
    def __init__(self, music_library, track, name="lyrics",
        tab_title=_("Lyrics")):
        Tab.__init__(self, name, tab_title)
        self.track = track
        self.lyrics_area = None
        self.library = music_library
        self.lyrics_text = ""

        if self.track.has_lyrics():
            self.lyrics_text = self.track.lyrics
            lyrics = Label(0.037, "subtitle", 0, 0, self.lyrics_text)
            lyrics.set_line_wrap_mode(pango.WRAP_WORD)
            lyrics.width = 0.366

            self.lyrics_area = ScrollArea(0.5, 0.23, 0.4, 0.57, lyrics)
            self.lyrics_area.connect("activated", self._on_activated)
            self.add(self.lyrics_area)

            self.connect('activated', self._on_activated)
            self.connect('deactivated', self._on_deactivated)
        else:
            # Display throbber animation while searching for lyrics
            self.throbber = LoadingAnimation(0.7, 0.5, 0.1)
            self.throbber.show()
            self.add(self.throbber)
            self.track.fetch_lyrics(self._lyrics_search_callback)
コード例 #5
0
ファイル: tv_episodes.py プロジェクト: tiwilliam/entertainer
    def _update_episode_info(self, event=None):
        '''Update information from this episode.'''
        self.li.set_current(self.menu.selected_index + 1)

        self._create_thumbnail_texture()
        self.title.set_text(self.menu.selected_userdata.title)
        self.title.width = 0.4

        plot = Label(0.029, "subtitle", 0, 0, self.menu.selected_userdata.plot)
        plot.width = 0.4
        self.scroll_area.set_content(plot)
コード例 #6
0
    def _update_episode_info(self, event=None):
        '''Update information from this episode.'''
        self.li.set_current(self.menu.selected_index + 1)

        self._create_thumbnail_texture()
        self.title.set_text(self.menu.selected_userdata.title)
        self.title.width = 0.4

        plot = Label(0.029, "subtitle", 0, 0, self.menu.selected_userdata.plot)
        plot.width = 0.4
        self.scroll_area.set_content(plot)
コード例 #7
0
ファイル: tab.py プロジェクト: tiwilliam/entertainer
    def show_empty_tab_notice(self, title=_("Empty tab"),
            message_body=_("This tab doesn't contain any elements.")):
        '''
        Create an information box that is displayed if there is no widgets in
        this tab. This method should be called only from child class as needed.
        '''

        # Create warning icon
        info_icon = Texture(self.theme.getImage("warning_icon"), 0.28, 0.27)
        self.add(info_icon)

        # Create warning title
        info_title = Label(0.0625, "title", 0.33, 0.27, title)
        self.add(info_title)

        # Create warning help text
        info = Label(0.042, "menuitem_inactive", 0.28, 0.4, message_body)
        info.width = 0.57
        self.add(info)
コード例 #8
0
ファイル: album.py プロジェクト: tiwilliam/entertainer
    def _create_album_info(self):
        """
        Create album info labels.
        """
        if self.album.year != 0:
            album_text = self.album.title + ", " + str(self.album.year)
        else:
            album_text = self.album.title
        album = Label(0.0416, "text", 0.5, 0.13, album_text, font_weight="bold")
        album.set_ellipsize(pango.ELLIPSIZE_END)
        album.set_line_wrap(False)
        album.width = 0.45
        self.add(album)

        length = str(self.album.length / 60)
        num_of_tracks_text = _("%(total)s tracks, %(time)s minutes") % \
            {'total': len(self.album.tracks), 'time': length}
        num_of_tracks = Label(0.028, "subtitle", 0.5, 0.18,
            num_of_tracks_text, font_weight="bold")
        self.add(num_of_tracks)
コード例 #9
0
    def _lyrics_search_callback(self, lyrics_text):
        '''This function is called when lyrics search is over.'''
        self.throbber.hide()

        # Save the results to help determine if the tab can activate.
        self.lyrics_text = lyrics_text

        if lyrics_text == "":
            no_lyrics = Label(0.037, "title", 0.7, 0.5,
                _("No lyrics found for this track"))
            no_lyrics.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
            self.add(no_lyrics)
        else:
            lyrics = Label(0.037, "subtitle", 0, 0, lyrics_text)
            lyrics.set_line_wrap_mode(pango.WRAP_WORD)
            lyrics.width = 0.366

            self.lyrics_area = ScrollArea(0.5, 0.23, 0.4, 0.57, lyrics)
            self.lyrics_area.connect("activated", self._on_activated)
            self.add(self.lyrics_area)
            self.library.save_lyrics(self.track, lyrics_text)
コード例 #10
0
    def __init__(self, media_player, music_library, artist,
        move_to_new_screen_callback):
        Screen.__init__(self, 'Artist', move_to_new_screen_callback,
            has_tabs=True)
        self.media_player = media_player

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87, artist)
        screen_title.set_ellipsize(pango.ELLIPSIZE_END)
        screen_title.width = 1
        self.add(screen_title)

        # Tabs
        albums = music_library.get_albums_by_artist(artist)
        if albums:
            tab1 = AlbumsTab(albums, move_to_new_screen_callback)
            self.add_tab(tab1)

        tracks = music_library.get_tracks_by_artist(artist)
        if tracks:
            tab2 = TracksTab(tracks, move_to_new_screen_callback)
            self.add_tab(tab2)
コード例 #11
0
ファイル: tv_episodes.py プロジェクト: tiwilliam/entertainer
    def _create_episode_info_box(self):
        """
        Create a texture that is displayed next to track list. This texture
        displays album cover art.
        """
        self._create_thumbnail_texture()

        # Title
        self.title = Label(0.04, "title", 0.05, 0.55,
            self.menu.selected_userdata.title, font_weight="bold")
        self.title.set_ellipsize(pango.ELLIPSIZE_END)
        self.title.set_line_wrap(False)
        self.title.width = 0.4
        self.add(self.title)

        # Plot
        plot = Label(0.029, "subtitle", 0, 0, self.menu.selected_userdata.plot)
        plot.width = 0.4

        self.scroll_area = ScrollArea(0.05, 0.63, 0.4, 0.15, plot)
        self.scroll_area.connect("activated", self._on_scroll_area_activated)
        self.add(self.scroll_area)
コード例 #12
0
ファイル: music.py プロジェクト: tiwilliam/entertainer
    def _create_no_music_information(self):
        """
        Create textures and labels for information screen. This is displayed
        instead of artist list if there are no tracks available and it helps
        users to add new music to the system.
        """
        # Create warning icon
        warning_icon = Texture(self.theme.getImage("warning_icon"), 0.28, 0.27)
        self.add(warning_icon)

        # Create warning title
        info_title = Label(0.0625, "title", 0.3367, 0.2709,
            _("No music available!"))
        self.add(info_title)

        # Create warning help text
        message = _(
            "There are no indexed artists in the Entertainer media "
            "library. To add music, start the Content management tool "
            "and open the 'Music' tab. Now click on the 'Add' button and "
            "select some folders which contain music files.")
        info = Label(0.0417, "menuitem_inactive", 0.2804, 0.45, message)
        info.width = 0.5
        self.add(info)
コード例 #13
0
    def _create_no_music_information(self):
        """
        Create textures and labels for information screen. This is displayed
        instead of artist list if there are no tracks available and it helps
        users to add new music to the system.
        """
        # Create warning icon
        warning_icon = Texture(self.theme.getImage("warning_icon"), 0.28, 0.27)
        self.add(warning_icon)

        # Create warning title
        info_title = Label(0.0625, "title", 0.3367, 0.2709,
                           _("No music available!"))
        self.add(info_title)

        # Create warning help text
        message = _(
            "There are no indexed artists in the Entertainer media "
            "library. To add music, start the Content management tool "
            "and open the 'Music' tab. Now click on the 'Add' button and "
            "select some folders which contain music files.")
        info = Label(0.0417, "menuitem_inactive", 0.2804, 0.45, message)
        info.width = 0.5
        self.add(info)
コード例 #14
0
    def create_movie_information(self):
        '''Create clutter parts related to movie information'''

        # Movie art texture
        if self.movie.has_cover_art():
            pixbuf = gtk.gdk.pixbuf_new_from_file(self.movie.cover_art_url)
        else:
            pixbuf = gtk.gdk.pixbuf_new_from_file(
                self.theme.getImage("default_movie_art"))
        movie_art = EyeCandyTexture(0.33, 0.1, 0.1, 0.25, pixbuf)
        self.add(movie_art)

        # Movie title
        title = Label(0.04, "title", 0.47, 0.1, self.movie.title,
            font_weight="bold")
        title.set_ellipsize(pango.ELLIPSIZE_END)
        title.set_size(0.5124, 0.05208)
        self.add(title)

        # Movie release year
        year_text = _("Released in %(year)s") % {'year': self.movie.year}
        year = Label(0.032, "subtitle", 0.47, 0.3, year_text)
        year.set_ellipsize(pango.ELLIPSIZE_END)
        year.set_size(0.5124, 0.05208)
        self.add(year)

        # Show only 2 genres (or one if there is only one)
        genres_list = self.movie.genres
        if len(genres_list) == 0:
            genres_text = _("Unknown")
        else:
            genres_text = "/".join(genres_list[:2])

        # Runtime and genres
        info_text = _("%(runtime)s min, %(genre)s") % \
            {'runtime': self.movie.runtime, 'genre': genres_text}
        info = Label(0.032, "subtitle", 0.47, 0.24, info_text)
        info.set_ellipsize(pango.ELLIPSIZE_END)
        info.set_size(0.5124, 0.05208)
        self.add(info)

        # Stars (rating)
        star = Texture(self.theme.getImage("star"))
        star.hide()
        self.add(star)
        star2 = Texture(self.theme.getImage("star2"))
        star2.hide()
        self.add(star2)

        for i in range(self.movie.rating):
            tex = clutter.Clone(star)
            tex.set_position(
                self.get_abs_x(0.47) + (self.get_abs_x(0.0366) * i),
                self.get_abs_y(0.17))
            tex.set_size(self.get_abs_x(0.024), self.get_abs_y(0.04))
            self.add(tex)

        dark_star = 5 - self.movie.rating
        for i in range(dark_star):
            tex = clutter.Clone(star2)
            tex.set_position(self.get_abs_x(0.47) + (self.get_abs_x(0.0366) * \
                (i + self.movie.rating)), self.get_abs_y(0.17))
            tex.set_size(self.get_abs_x(0.024), self.get_abs_y(0.04))
            self.add(tex)

        # Plot
        plot = Label(0.029, "subtitle", 0, 0, self.movie.plot)
        plot.set_justify(True)
        plot.set_line_wrap_mode(pango.WRAP_WORD)
        plot.set_line_wrap(True)
        plot.width = 0.5124
        self.scroll_area = ScrollArea(0.33, 0.38, 0.5124, 0.3516, plot)
        self.add(self.scroll_area)

        # Actors
        self.add(Label(0.032, "title", 0.33, 0.8, _("Starring")))

        actors_list = self.movie.actors
        if len(actors_list) == 0:
            actors_text = _("Unknown")
        else:
            actors_text = ", ".join(actors_list[:5])
        actors = Label(0.032, "subtitle", 0.46, 0.8, actors_text)
        actors.set_ellipsize(pango.ELLIPSIZE_END)
        actors.set_size(0.5124, 0.05208)
        self.add(actors)

        # Directors
        self.add(Label(0.032, "title", 0.33, 0.86, _("Directed by")))

        directors_list = self.movie.directors
        if len(directors_list) == 0:
            directors_text = _("Unknown")
        else:
            directors_text = ", ".join(directors_list[:2])
        directors = Label(0.032, "subtitle", 0.46, 0.86, directors_text)
        directors.set_ellipsize(pango.ELLIPSIZE_END)
        directors.set_size(0.5124, 0.05208)
        self.add(directors)

        # Writers
        self.add(Label(0.032, "title", 0.33, 0.92, _("Written by")))

        writers_list = self.movie.writers
        if len(directors_list) == 0:
            writers_text = _("Unknown")
        else:
            writers_text = ", ".join(writers_list[:2])
        writers = Label(0.032, "subtitle", 0.46, 0.92, writers_text)
        writers.set_ellipsize(pango.ELLIPSIZE_END)
        writers.set_size(0.5124, 0.05208)
        self.add(writers)