Ejemplo n.º 1
0
    def _create_menu(self):
        """
        Create a view that is displayed when there is indexed TV-series in
        the video library.
        """
        #Create TV-series menu
        menu = ImageMenu(0.06, 0.18, 0.12, 0.25)
        menu.items_per_col = 2
        menu.visible_rows = 2
        menu.visible_cols = 7

        series = self.video_library.get_tv_series()
        series_list = [[serie.cover_art_url, serie] for serie in series]
        menu.async_add_videos(series_list)

        # Create list indicator
        self.list_indicator = ListIndicator(0.75, 0.76, 0.2, 0.045,
            ListIndicator.HORIZONTAL)
        self.list_indicator.set_maximum(len(series))
        self.list_indicator.show()
        self.add(self.list_indicator)

        # Create information labels
        self.series_title = Label(0.042, "title", 0.2, 0.75, "",
            font_weight="bold")
        self.series_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.series_title.set_line_wrap(False)
        self.series_title.width = 0.5
        self.add(self.series_title)

        self.series_info = Label(0.034, "subtitle", 0.2, 0.82, "")
        self.add(self.series_info)

        return menu
Ejemplo n.º 2
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)
Ejemplo n.º 3
0
    def __init__(self, albums, move_to_new_screen_callback, name="albums",
        tab_title=_("Albums")):
        Tab.__init__(self, name, tab_title, move_to_new_screen_callback)

        # Start the loading animation while the menu is loading
        self.throbber = LoadingAnimation(0.6, 0.1)
        self.throbber.show()
        self.add(self.throbber)

        if len(albums) < 4:
            x_percent = 0.2928
            visible_rows = 1
            visible_cols = 3
        elif len(albums) < 13:
            x_percent = 0.1464
            visible_rows = 2
            visible_cols = 6
        else:
            x_percent = 0.1098
            visible_rows = 3
            visible_cols = 8

        # Create albums menu
        self.menu = ImageMenu(0.07, 0.16, x_percent, self.y_for_x(x_percent))
        self.menu.visible_rows = visible_rows
        self.menu.visible_cols = visible_cols
        self.menu.items_per_col = self.menu.visible_rows
        self.add(self.menu)

        albums_list = [[album.album_art_url, album] for album in albums]
        self.menu.async_add_albums(albums_list)

        self.li = ListIndicator(0.77, 0.8, 0.18, 0.045,
            ListIndicator.HORIZONTAL)
        self.li.set_maximum(len(albums))
        self.li.show()
        self.add(self.li)

        # Create album information (displays current menuitem information)
        self.album_title = Label(0.045, "title", 0.22, 0.79, "")
        self.album_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.album_title.set_line_wrap(False)
        self.album_title.width = 0.366
        self.add(self.album_title)

        self.album_artist = Label(0.037, "subtitle", 0.22, 0.86, "")
        self.album_artist.set_ellipsize(pango.ELLIPSIZE_END)
        self.album_artist.set_line_wrap(False)
        self.album_artist.width = 0.366
        self.add(self.album_artist)

        self.album_tracks = Label(0.037, "subtitle", 0.22, 0.91, "")
        self.add(self.album_tracks)

        self.connect('activated', self._on_activated)
        self.connect('deactivated', self._on_deactivated)
        self.menu.connect("moved", self._update_album_info)
        self.menu.connect("selected", self._handle_select)
        self.menu.connect("activated", self._on_activated)
        self.menu.connect("filled", self._on_menu_filled)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def __init__(self, font_size, color_name, x_pos_percent, y_pos_percent,
        name=None, font_weight=""):
        """Initialize Clock label"""
        Label.__init__(self, font_size, color_name, x_pos_percent,
            y_pos_percent, name = None, font_weight = font_weight)

        self._24_hour_clock = True
        self.update_clock_label()
        gobject.timeout_add(1000 * 60, self.update_clock_label)
Ejemplo n.º 6
0
    def __init__(self, alpha, text, item_height, font_size, color_name):
        clutter.Group.__init__(self)

        self.label = Label(font_size, color_name, 0, 0)
        self.label.set_text(text)

        self.behaviour = LoopedPathBehaviour(alpha)
        self.behaviour.apply(self)

        self.add(self.label)
Ejemplo n.º 7
0
    def __init__(self, x, y, width, height, color="title"):
        Base.__init__(self)
        clutter.Group.__init__(self)

        self.width = self.get_abs_x(width)
        self.height = self.get_abs_y(height)
        self.bar_width = int(self.width * self.BAR_LENGTH)
        self.bar_x = int(self.width * self.INFO_LENGTH)
        self.media_length_x = (1 - self.INFO_LENGTH + 0.05) * width

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))

        self._color = self._color_to_cairo_color(
            self.config.theme.get_color(color))

        self._background = clutter.CairoTexture(self.bar_width, self.height)
        self._draw_background()
        self._background.set_position(self.bar_x, 0)
        self.add(self._background)

        self._foreground = clutter.CairoTexture(self.height, self.height)
        self._foreground.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self._draw_foreground()
        self._foreground.set_position(self.bar_x, 0)
        self.add(self._foreground)

        self.media_position = Label(0.037, "title", 0, 0, "")
        self.add(self.media_position)

        self.media_length = Label(0.037, "title", self.media_length_x, 0, "")
        self.add(self.media_length)

        self._media_player = None
        self._progress_bar_moving = False

        self._hide_timeout_key = None
        self.auto_display = False
        self._visible = None
        self._timeline = clutter.Timeline(500)
        self._alpha = clutter.Alpha(self._timeline, clutter.EASE_IN_OUT_SINE)
        self._behaviour = clutter.BehaviourOpacity(0, 255, self._alpha)
        self._behaviour.apply(self)

        self._progress = None
        # Call the property setter to initialize the displayed position.
        self.progress = 0

        # Preparation to pointer events handling.
        self._motion_handler = 0
        self.set_reactive(True)
        self.connect('scroll-event', self._on_scroll_event)
        self.connect('button-press-event', self._on_button_press_event)
        self.connect('button-release-event', self._on_button_release_event)
        self.connect('enter-event', self._on_enter_event)
        self.connect('leave-event', self._on_leave_event)
Ejemplo n.º 8
0
    def __init__(self, x, y, width, height, color="title"):
        Base.__init__(self)
        clutter.Group.__init__(self)

        self.width = self.get_abs_x(width)
        self.height = self.get_abs_y(height)
        self.bar_width = int(self.width * self.BAR_LENGTH)
        self.bar_x = int(self.width * self.INFO_LENGTH)
        self.media_length_x = (1 - self.INFO_LENGTH + 0.05) * width

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))

        self._color = self._color_to_cairo_color(
            self.config.theme.get_color(color))

        self._background = clutter.CairoTexture(self.bar_width, self.height)
        self._draw_background()
        self._background.set_position(self.bar_x, 0)
        self.add(self._background)

        self._foreground = clutter.CairoTexture(self.height, self.height)
        self._foreground.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self._draw_foreground()
        self._foreground.set_position(self.bar_x, 0)
        self.add(self._foreground)

        self.media_position = Label(0.037, "title", 0, 0, "")
        self.add(self.media_position)

        self.media_length = Label(0.037, "title", self.media_length_x, 0, "")
        self.add(self.media_length)

        self._media_player = None
        self._progress_bar_moving = False

        self._hide_timeout_key = None
        self.auto_display = False
        self._visible = None
        self._timeline = clutter.Timeline(500)
        self._alpha = clutter.Alpha(self._timeline, clutter.EASE_IN_OUT_SINE)
        self._behaviour = clutter.BehaviourOpacity(0, 255, self._alpha)
        self._behaviour.apply(self)

        self._progress = None
        # Call the property setter to initialize the displayed position.
        self.progress = 0

        # Preparation to pointer events handling.
        self._motion_handler = 0
        self.set_reactive(True)
        self.connect('scroll-event', self._on_scroll_event)
        self.connect('button-press-event', self._on_button_press_event)
        self.connect('button-release-event', self._on_button_release_event)
        self.connect('enter-event', self._on_enter_event)
        self.connect('leave-event', self._on_leave_event)
Ejemplo n.º 9
0
    def create_day(self, day, x, y):
        """Create the Texture and labels for one day"""
        self.add(Texture(day["Image"], x, y))

        self.add(Label(0.04167, "text", x, y + 0.2, day["Day"],
            font_weight="bold"))

        conditions_text = \
            _("High: %(high)s   Low: %(low)s\nCondition: %(cond)s") % \
            {'high': day["High"], 'low': day["Low"], 'cond': day["Condition"]}
        self.add(Label(0.03, "text", x, y + 0.25, conditions_text))
Ejemplo n.º 10
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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
    def _create_playing_preview(self):
        '''Create the Now Playing preview sidebar.'''
        preview = clutter.Group()

        # Video preview of current media
        video_texture = self.media_player.get_texture()
        if video_texture == None:
            video_texture = Texture(self.theme.getImage("default_album_art"))
        width, height = video_texture.get_size()
        x_ratio = (self.PREVIEW_WIDTH - 50) / float(width)
        y_ratio = (self.PREVIEW_HEIGHT - 50) / float(height)

        if x_ratio > y_ratio:
            video_texture.set_scale((self.PREVIEW_HEIGHT - 50) / float(height),
                                    (self.PREVIEW_HEIGHT - 50) / float(height))
            new_width = int(width * \
                ((self.PREVIEW_HEIGHT - 50) / float(height)))
            new_x = int(((self.PREVIEW_WIDTH - 50) - new_width) / 2.0)
            video_texture.set_position(int(new_x), 0)
            # Below are size and position calculations for border rectangle
            rect_x = new_x -3
            rect_y = -3
            new_width = (self.PREVIEW_HEIGHT - 50) / float(height) * width
            new_height = (self.PREVIEW_HEIGHT - 50) / float(height) * height
        else:
            video_texture.set_scale((self.PREVIEW_WIDTH - 50) / float(width),
                                    (self.PREVIEW_WIDTH - 50) / float(width))
            new_height = int(height * \
                ((self.PREVIEW_WIDTH - 50) / float(width)))
            new_y = int(((self.PREVIEW_HEIGHT - 50) - new_height) / 2.0)
            video_texture.set_position(0, int(new_y))
            rect_x = -3
            rect_y = new_y -3
            # Below are size and position calculations for border rectangle
            new_width = (self.PREVIEW_WIDTH - 50) / float(width) * width
            new_height = (self.PREVIEW_WIDTH - 50) / float(width) * height

        # Video frame
        rect = clutter.Rectangle()
        rect.set_size(int(new_width + 6), int(new_height + 6))
        rect.set_position(rect_x, rect_y)
        rect.set_color((128, 128, 128, 192))
        preview.add(rect)

        preview.add(video_texture)

        self._preview_title = Label(0.03, "text", 0.03, 0.74, "")
        preview.add(self._preview_title)

        return preview
Ejemplo n.º 13
0
class ScrollMenuItem(clutter.Group):
    """A Group containing a Label to which a LoopedPathBehaviour is applied."""
    __gtype_name__ = 'ScrollMenuItem'

    def __init__(self, alpha, text, item_height, font_size, color_name):
        clutter.Group.__init__(self)

        self.label = Label(font_size, color_name, 0, 0)
        self.label.set_text(text)

        self.behaviour = LoopedPathBehaviour(alpha)
        self.behaviour.apply(self)

        self.add(self.label)
Ejemplo n.º 14
0
class ScrollMenuItem(clutter.Group):
    """A Group containing a Label to which a LoopedPathBehaviour is applied."""

    __gtype_name__ = "ScrollMenuItem"

    def __init__(self, alpha, text, item_height, font_size, color_name):
        clutter.Group.__init__(self)

        self.label = Label(font_size, color_name, 0, 0)
        self.label.set_text(text)

        self.behaviour = LoopedPathBehaviour(alpha)
        self.behaviour.apply(self)

        self.add(self.label)
Ejemplo n.º 15
0
    def __init__(self, music_library, media_player):
        Screen.__init__(self, 'Disc')

        self.theme = self.config.theme
        self.music_library = music_library
        self.media_player = media_player
        # When album info is loaded we create Playlist object
        self.playlist = None

        self.art = None
        self.art2 = None
        self.in_behaviour = None
        self.out_behaviour = None
        self.li = None
        self.track_menu = None

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87, _("Audio Disc"),
            "screen_title")
        self.add(screen_title)

        # Display throbber animation while loading CD metadata
        self.throbber = LoadingAnimation(0.5, 0.5, 0.1)
        self.throbber.show()
        self.add(self.throbber)

        # Create and initialize screen items
        self.has_disc = True
        gobject.timeout_add(500, self._get_disc_information)
Ejemplo n.º 16
0
    def __init__(self, media_player, music_library,
                 move_to_new_screen_callback):
        Screen.__init__(self,
                        'Music',
                        move_to_new_screen_callback,
                        has_tabs=True)

        self.media_player = media_player
        self.theme = self.config.theme
        self.music_library = music_library

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87, _("Music"))
        self.add(screen_title)

        if self.music_library.number_of_tracks() == 0:
            self._create_no_music_information()
        else:
            tab1 = ArtistsTab(music_library, music_library.get_all_artists(),
                              move_to_new_screen_callback)
            tab2 = AlbumsTab(music_library.get_all_albums(),
                             move_to_new_screen_callback)

            self.add_tab(tab1)
            self.add_tab(tab2)
Ejemplo n.º 17
0
    def __init__(self, video_library, move_to_new_screen_callback, tv_series):
        Screen.__init__(self, 'TvSeries', move_to_new_screen_callback)

        self.theme = self.config.theme
        self.tv_series = tv_series
        self.video_library = video_library

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87,
                             self.tv_series.title)
        self.add(screen_title)

        self.art = None
        self.menu = None
        self._create_series_cover_texture()
        self.menu = self._create_season_menu()
        self.add(self.menu)

        #List indicator
        self.li = ListIndicator(0.8, 0.9, 0.2, 0.045, ListIndicator.VERTICAL)
        self.li.set_maximum(len(self.tv_series.seasons))
        self.add(self.li)

        self.menu.connect("moved", self._update_season_info)
        self.menu.connect("selected", self._handle_select)
Ejemplo n.º 18
0
    def __init__(self, media_player, move_to_new_screen_callback, episodes,
                 tv_series):
        Screen.__init__(self, 'TvEpisodes', move_to_new_screen_callback)

        self.episodes = episodes
        self.media_player = media_player
        self.theme = self.config.theme
        self.tv_series = tv_series

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87,
                             self.tv_series.title)
        self.add(screen_title)

        self.scroll_area = None
        self.title = None
        self.thumb = None
        self.menu = self._create_episode_menu()
        self.add(self.menu)
        self._create_episode_info_box()

        #List indicator
        self.li = ListIndicator(0.8, 0.9, 0.2, 0.045, ListIndicator.VERTICAL)
        self.li.set_maximum(len(self.episodes))
        self.add(self.li)

        self.menu.connect("moved", self._update_episode_info)
        self.menu.connect("selected", self._handle_select)
        self.menu.connect("activated", self._on_menu_activated)
Ejemplo n.º 19
0
    def __init__(self, media_player, music_library, move_to_new_screen_callback,
        album):
        Screen.__init__(self, 'Album', move_to_new_screen_callback)

        self.media_player = media_player
        self.theme = self.config.theme
        self.library = music_library
        self.album = album
        self.art = None
        self.track_menu = None

        # Create and initialize screen items
        self.track_menu = self._create_track_menu()
        self.add(self.track_menu)
        self._create_album_cover_texture()
        self._create_album_info()

        self.screen_title = Label(0.13, "screentitle", 0, 0.87, "")
        self.screen_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.screen_title.width = 0.8
        self.add(self.screen_title)

        #List indicator
        self.li = ListIndicator(0.74, 0.85, 0.2, 0.045, ListIndicator.VERTICAL)
        self.li.set_maximum(len(self.album.tracks))
        self.add(self.li)

        self.track_menu.active = True
        self.track_menu.connect('selected', self._on_menu_selected)
        self.track_menu.connect('moved', self._display_selected_track)
Ejemplo n.º 20
0
 def test_set_content(self):
     '''Test the use of the set_content method.'''
     self.scroll_area.set_content(Label(0.1, "screentitle", 0.1, 0.2,
                                        "foo"))
     self.assertFalse(self.scroll_area.content == self.label)
     self.scroll_area.set_content(self.label)
     self.assertTrue(self.scroll_area.content == self.label)
Ejemplo n.º 21
0
    def __init__(self, current_photo_index, images):
        Screen.__init__(self, 'Photo')

        self.animate = self.config.show_effects
        self.slideshow_step = self.config.slideshow_step

        self.zoom_level = 1
        self.index = current_photo_index
        self.images = images
        self.slideshow = False
        # Slideshow gobject timeout tag
        self.slideshow_timeout_tag = None

        # Create black background
        self.background = clutter.Rectangle()
        self.background.set_size(self.config.stage_width,
                                 self.config.stage_height)
        self.background.set_color((0, 0, 0, 255))
        self.add(self.background)

        # Screen Title (Displayed at the bottom left corner)
        self.screen_title = Label(0.13, "screentitle", 0, 0.87,
                                  _("Information"))
        self.add(self.screen_title)

        self.texture = None
        self._change_image(self.index)
Ejemplo n.º 22
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
Ejemplo n.º 23
0
    def __init__(self, x, y, width, height, direction):
        Base.__init__(self)
        clutter.Group.__init__(self)

        self.config = Configuration()

        # Size
        self.width = self.get_abs_x(width)
        self.height = self.get_abs_y(height)

        self.direction = direction
        self.delimiter = " | "
        self.current = 1
        self.maximum = 1

        self.theme = self.config.theme
        self.fg = self.theme.get_color("arrow_foreground")
        self.bg = self.theme.get_color("arrow_background")

        if direction == ListIndicator.VERTICAL:
            text_x_pos = width / 3
        else:
            text_x_pos = width / 2

        self.text = Label(
            height * 0.8, "text", text_x_pos, height / 2,
            str(self.maximum) + self.delimiter + str(self.maximum))
        self.text.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self.add(self.text)

        # Create arrows and calculate positions on screen
        if direction == ListIndicator.VERTICAL:
            self.arrow1 = ArrowTexture(5 * width / 7, height / 2, height / 2,
                                       self.fg, self.bg, ArrowTexture.UP)
            self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2,
                                       self.fg, self.bg, ArrowTexture.DOWN)

        elif direction == ListIndicator.HORIZONTAL:
            self.arrow1 = ArrowTexture(height / 2, height / 2, height / 2,
                                       self.fg, self.bg, ArrowTexture.LEFT)
            self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2,
                                       self.fg, self.bg, ArrowTexture.RIGHT)

        self.add(self.arrow1)
        self.add(self.arrow2)

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))
Ejemplo n.º 24
0
    def __init__(self, tracks, move_to_new_screen_callback, name="tracks",
        tab_title=_("Tracks")):
        Tab.__init__(self, name, tab_title, move_to_new_screen_callback)

        # Start the loading animation while the menu is loading
        self.throbber = LoadingAnimation(0.1, 0.1)
        self.throbber.show()
        self.add(self.throbber)

        self.menu = TextMenu(0.0586, 0.2083, 0.2928, 0.0781)
        self.menu.items_per_row = 3
        self.menu.visible_rows = 7
        self.menu.visible_cols = 3
        self.menu.active = False
        self.menu.cursor = None
        self.add(self.menu)

        tracks_list = [[track.title, None, track] for track in tracks]
        self.menu.async_add_artists(tracks_list)

        self.track_title = Label(0.045, "title", 0.22, 0.79, "")
        self.track_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.track_title.set_line_wrap(False)
        self.track_title.width = 0.366
        self.add(self.track_title)

        self.track_number = Label(0.037, "subtitle", 0.22, 0.86, "")
        self.track_number.set_ellipsize(pango.ELLIPSIZE_END)
        self.track_number.set_line_wrap(False)
        self.track_number.width = 0.366
        self.add(self.track_number)

        self.track_length = Label(0.037, "subtitle", 0.22, 0.91, "")
        self.add(self.track_length)

        self.li = ListIndicator(0.77, 0.8, 0.18, 0.045,
            ListIndicator.VERTICAL)
        self.li.set_maximum(len(tracks))
        self.li.show()
        self.add(self.li)

        self.connect('activated', self._on_activated)
        self.connect('deactivated', self._on_deactivated)
        self.menu.connect("moved", self._update_track_info)
        self.menu.connect("selected", self._handle_select)
        self.menu.connect("activated", self._on_activated)
        self.menu.connect("filled", self._on_menu_filled)
Ejemplo n.º 25
0
    def __init__(self, music_library, artists, move_to_new_screen_callback,
        name="artists", tab_title=_("Artists")):
        Tab.__init__(self, name, tab_title, move_to_new_screen_callback)
        self.library = music_library

        # Start the loading animation while the menu is loading
        self.throbber = LoadingAnimation(0.1, 0.1)
        self.throbber.show()
        self.add(self.throbber)

        self.menu = TextMenu(0.057, 0.208, 0.293, 0.078)
        self.menu.items_per_row = 3
        self.menu.visible_rows = 7
        self.menu.visible_cols = 3
        self.menu.active = False
        self.menu.cursor = None
        self.add(self.menu)

        artists_list = [[artist, None, artist] for artist in artists]
        self.menu.async_add_artists(artists_list)

        # Create artist label
        self.artist_title = Label(0.0416, "title", 0.22, 0.794, "")
        self.artist_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.artist_title.set_line_wrap(False)
        self.artist_title.width = 0.366
        self.add(self.artist_title)

        self.artist_albums = Label(0.0365, "subtitle", 0.22, 0.86, "")
        self.add(self.artist_albums)

        self.artist_tracks = Label(0.0365, "subtitle", 0.22, 0.911, "")
        self.add(self.artist_tracks)

        # Create artist menu list indicator
        self.li = ListIndicator(0.77, 0.8, 0.18, 0.045,
            ListIndicator.VERTICAL)
        self.li.set_maximum(len(artists))
        self.add(self.li)

        self.connect('activated', self._on_activated)
        self.connect('deactivated', self._on_deactivated)
        self.menu.connect("moved", self._update_artist_info)
        self.menu.connect("selected", self._handle_select)
        self.menu.connect("activated", self._on_activated)
        self.menu.connect("filled", self._on_menu_filled)
Ejemplo n.º 26
0
    def _get_disc_information(self):
        """
        Fetch album information from the Internet and create widgets based
        on received data.
        """
        try:
            disc = self.music_library.get_compact_disc_information()

            title = disc.title
            artist = disc.artist
            tracks = disc.tracks

            self.playlist = Playlist(tracks)
            self._create_album_info(title, artist, tracks, disc.length)
            self.track_menu = self._create_track_menu(tracks)
            self.add(self.track_menu)
            self._create_album_cover_texture(artist, title)

            self.li = ListIndicator(0.75, 0.8, 0.2, 0.045,
                ListIndicator.VERTICAL)
            self.li.set_maximum(len(tracks))
            self.add(self.li)

            art_file = os.path.join(self.config.ALBUM_ART_DIR,
                artist + " - " + title + ".jpg")
            if artist != "Unknown artist" and not os.path.exists(art_file):
                art_search = AlbumArtDownloader(title, artist,
                    self.config.ALBUM_ART_DIR, self._update_albumart)
                art_search.start()

        except cdrom.error:
            # No disc in drive
            self.has_disc = False
            no_disc = Label(0.05, "title", 0.5, 0.5,
                _("No audio disc in drive"))
            no_disc.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
            self.add(no_disc)

        # Remove loading animation
        self.throbber.hide()
        self.remove(self.throbber)
        del self.throbber

        # This function should be called only once (gobject timeout)
        return False
Ejemplo n.º 27
0
    def add_tab(self, tab):
        '''Add new tab to this tab group.'''
        # Add to the dictionary so that the tab can be called by name
        self._tabs[tab.name] = tab

        self.tabs_list.append(tab)

        tab.active = False

        # Set first tab visible
        if self.current_tab == None:
            self.current_tab = 0
            self.tabs_list[0].visible = True

        tab_title = Label(0.01, self.color, 0, 0, tab.title)
        self.labels.append(tab_title)
        tab_title.set_name(tab.name)

        self.add(tab_title)
        self._reposition_labels()

        tab_title.set_reactive(True)
        tab_title.connect('button-press-event', self._on_tab_title_button_press)

        timeline = clutter.Timeline(500)
        alpha = clutter.Alpha(timeline, clutter.EASE_IN_OUT_SINE)
        behaviour = clutter.BehaviourOpacity(255, 96, alpha)
        behaviour.apply(tab_title)
        self.timelines.append((timeline, alpha, behaviour))
Ejemplo n.º 28
0
    def __init__(self, move_to_new_screen_callback, title, images):
        Screen.__init__(self, 'Photographs', move_to_new_screen_callback)

        self.images = images

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87, title)
        self.add(screen_title)

        # Image Title (over album list)
        self.image_title = Label(0.04167, "title", 0.0586, 0.7943, " ")
        self.image_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.add(self.image_title)

        self.image_desc = Label(0.04167, "subtitle", 0.0586, 0.9115, " ")
        self.image_desc.set_line_wrap(True)
        self.image_desc.set_ellipsize(pango.ELLIPSIZE_END)
        self.add(self.image_desc)

        # Display throbber animation while loading photographs
        self.throbber = LoadingAnimation(0.9, 0.9)
        self.throbber.show()
        self.add(self.throbber)

        # List indicator
        self.li = None
        self._create_list_indicator()

        # Create photomenu
        self.menu = ImageMenu(0.03, 0.08, 0.12, self.y_for_x(0.12))
        self.menu.items_per_col = 3
        self.menu.visible_rows = 3
        self.menu.visible_cols = 8
        self.menu.active = True
        self.add(self.menu)

        photos = self.images
        photos_list = [[Texture(photo.get_thumbnail_url()), photo] \
            for photo in photos]
        self.menu.async_add(photos_list)

        self.menu.connect("selected", self._handle_select)
        self.menu.connect('moved', self._update_image_info)
        self.menu.connect("filled", self._on_menu_filled)
Ejemplo n.º 29
0
    def __init__(self, move_to_new_screen_callback, title, images):
        Screen.__init__(self, 'Photographs', move_to_new_screen_callback)

        self.images = images

        # Screen Title (Displayed at the bottom left corner)
        screen_title = Label(0.13, "screentitle", 0, 0.87, title)
        self.add(screen_title)

        # Image Title (over album list)
        self.image_title = Label(0.04167, "title", 0.0586, 0.7943, " ")
        self.image_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.add(self.image_title)

        self.image_desc = Label(0.04167, "subtitle", 0.0586, 0.9115, " ")
        self.image_desc.set_line_wrap(True)
        self.image_desc.set_ellipsize(pango.ELLIPSIZE_END)
        self.add(self.image_desc)

        # Display throbber animation while loading photographs
        self.throbber = LoadingAnimation(0.9, 0.9)
        self.throbber.show()
        self.add(self.throbber)

        # List indicator
        self.li = None
        self._create_list_indicator()

        # Create photomenu
        self.menu = ImageMenu(0.03, 0.08, 0.12, self.y_for_x(0.12))
        self.menu.items_per_col = 3
        self.menu.visible_rows = 3
        self.menu.visible_cols = 8
        self.menu.active = True
        self.add(self.menu)

        photos = self.images
        photos_list = [[Texture(photo.get_thumbnail_url()), photo] \
            for photo in photos]
        self.menu.async_add(photos_list)

        self.menu.connect("selected", self._handle_select)
        self.menu.connect('moved', self._update_image_info)
        self.menu.connect("filled", self._on_menu_filled)
Ejemplo n.º 30
0
    def _create_album_info(self, title, artist_name, tracks, length):
        """
        Create album info labels.
        @param title: Album title
        @param artist_name: Artist
        @param tracks: List of CompactDisc objects
        """
        album = Label(0.04167, "text", 0.50146, 0.13,
           artist_name + " - " + title, font_weight="bold")
        album.set_size(0.4393, 0.06510)
        album.set_ellipsize(pango.ELLIPSIZE_END)
        self.add(album)

        minutes = str(length / 60)

        num_of_tracks = Label(0.02604, "subtitle", 0.50146, 0.18,
            _("%(total)s tracks, %(time)s minutes") % \
            {'total': len(tracks), 'time': minutes}, font_weight="bold")
        self.add(num_of_tracks)
Ejemplo n.º 31
0
    def __init__(self,
                 font_size,
                 color_name,
                 x_pos_percent,
                 y_pos_percent,
                 name=None,
                 font_weight=""):
        """Initialize Clock label"""
        Label.__init__(self,
                       font_size,
                       color_name,
                       x_pos_percent,
                       y_pos_percent,
                       name=None,
                       font_weight=font_weight)

        self._24_hour_clock = True
        self.update_clock_label()
        gobject.timeout_add(1000 * 60, self.update_clock_label)
Ejemplo n.º 32
0
    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)
Ejemplo n.º 33
0
    def __init__(self, alpha, text, item_height, font_size, color_name):
        clutter.Group.__init__(self)

        self.label = Label(font_size, color_name, 0, 0)
        self.label.set_text(text)

        self.behaviour = LoopedPathBehaviour(alpha)
        self.behaviour.apply(self)

        self.add(self.label)
Ejemplo n.º 34
0
    def setUp(self):
        """Set up the test."""
        EntertainerTest.setUp(self)

        # Get a workable amount of text
        text = "Here is the start. "
        # pylint: disable-msg=W0612
        for i in range(0, 100):
            text += "Here is sentence number "

        self.label = Label(0.1, "screentitle", 0.1, 0.2, text)
        self.scroll_area = ScrollArea(0.5, 0.6, 0.1, 0.1, self.label)
Ejemplo n.º 35
0
    def __init__(self, media_player, track, name="playing",
            tab_title=_("Currently playing")):
        Tab.__init__(self, name, tab_title)

        album = track.album

        # Track name
        if track.number == 0:
            track_label_text = track.title
        else:
            track_label_text =  _("From %(number)d. %(title)s") % \
                {'number': track.number, 'title': track.title}

        self.track_label = Label(0.05, "text", 0.5, 0.33, track_label_text)
        self.track_label.set_ellipsize(pango.ELLIPSIZE_END)
        self.track_label.width = 0.4
        self.add(self.track_label)

        # Album name
        if album.year == 0:
            album_label_text = _("From %(title)s") % {'title': album.title}
        else:
            album_label_text = _("From %(title)s, %(year)s") % \
                {'title': album.title, 'year': album.year}

        self.album_label = Label(0.042, "subtitle", 0.5, 0.43, album_label_text)
        self.album_label.set_ellipsize(pango.ELLIPSIZE_END)
        self.album_label.width = 0.4
        self.add(self.album_label)

        # Artist name
        artist_text = _("By %(artist)s") % {'artist': track.artist}
        self.artist_label = Label(0.042, "subtitle", 0.5, 0.53, artist_text)
        self.artist_label.set_ellipsize(pango.ELLIPSIZE_END)
        self.artist_label.width = 0.4
        self.add(self.artist_label)

        self.progress_bar = ProgressBar(0.5, 0.667, 0.4, 0.04)
        self.progress_bar.media_player = media_player
        self.add(self.progress_bar)
Ejemplo n.º 36
0
    def _create_menu(self):
        """
        Create a view that is displayed when there are indexed clips in
        the video library.
        """
        menu = ImageMenu(0.04, 0.16, 0.23, self.y_for_x(0.23) * 0.7)
        menu.items_per_col = 2
        menu.visible_rows = 2
        menu.visible_cols = 4

        clips = self.video_library.get_video_clips()
        clips_list = [[clip.thumbnail_url, clip] for clip in clips]
        menu.async_add_clips(clips_list)

        # Create list indicator
        self.list_indicator = ListIndicator(0.7, 0.8, 0.2, 0.045,
                                            ListIndicator.HORIZONTAL)
        self.list_indicator.set_maximum(len(clips))
        self.list_indicator.show()
        self.add(self.list_indicator)

        # Create information labels
        self.clip_title = Label(0.042,
                                "title",
                                0.15,
                                0.77,
                                "",
                                font_weight="bold")
        self.clip_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.clip_title.set_line_wrap(False)
        self.clip_title.width = 0.5
        self.add(self.clip_title)

        self.clip_info = Label(0.034, "subtitle", 0.15, 0.85, "")
        self.clip_info.set_ellipsize(pango.ELLIPSIZE_END)
        self.clip_info.set_line_wrap(False)
        self.clip_info.width = 0.5
        self.add(self.clip_info)

        return menu
Ejemplo n.º 37
0
    def __init__(self,
                 move_to_previous_screen_callback,
                 question,
                 answers,
                 callbacks=None):
        Screen.__init__(self, 'Question')

        self.move_to_previous_screen_callback = move_to_previous_screen_callback
        self.answers = answers

        if callbacks is None:
            callbacks = []
        self.callbacks = callbacks

        screen_title = Label(0.13, "screentitle", 0, 0.87, _("Question"))
        self.add(screen_title)

        question_label = Label(0.04167, "text", 0.095, 0.13, str(question))
        self.add(question_label)

        self.menu = None
        self.display_answers()
Ejemplo n.º 38
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)
Ejemplo n.º 39
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)
Ejemplo n.º 40
0
    def _create_menu(self):
        """
        Create a view that is displayed when there is indexed TV-series in
        the video library.
        """
        #Create TV-series menu
        menu = ImageMenu(0.06, 0.18, 0.12, 0.25)
        menu.items_per_col = 2
        menu.visible_rows = 2
        menu.visible_cols = 7

        series = self.video_library.get_tv_series()
        series_list = [[serie.cover_art_url, serie] for serie in series]
        menu.async_add_videos(series_list)

        # Create list indicator
        self.list_indicator = ListIndicator(0.75, 0.76, 0.2, 0.045,
                                            ListIndicator.HORIZONTAL)
        self.list_indicator.set_maximum(len(series))
        self.list_indicator.show()
        self.add(self.list_indicator)

        # Create information labels
        self.series_title = Label(0.042,
                                  "title",
                                  0.2,
                                  0.75,
                                  "",
                                  font_weight="bold")
        self.series_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.series_title.set_line_wrap(False)
        self.series_title.width = 0.5
        self.add(self.series_title)

        self.series_info = Label(0.034, "subtitle", 0.2, 0.82, "")
        self.add(self.series_info)

        return menu
Ejemplo n.º 41
0
    def __init__(self, width, height, text, extra_text=None):
        MenuItem.__init__(self)

        self.width = width
        self.height = height
        self.theme = self.config.theme

        self.text = text
        self.extra_text = extra_text
        self.color = "menuitem_inactive"
        self.font_size = 0.03

        self.label = Label(self.font_size, self.color, 0, 0, "", "text_label")
        self.add(self.label)

        # Set extra text
        self.extra_label = None
        if extra_text is not None:
            self.extra_label = Label(self.font_size, self.color, 0, 0, "",
                                     "text_label")
            self.add(self.extra_label)

        self.update(text, extra_text)
Ejemplo n.º 42
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)
Ejemplo n.º 43
0
    def _create_no_photos_information(self):
        """
        Create textures and labels for information screen. This is displayed
        instead of album list if there are no photos available and it helps
        users to add new photographs 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 photographs available!"))
        self.add(info_title)

        # Create warning help text
        message = _(
            "There are no indexed photographs in the Entertainer media "
            "library. To add photographs, start the Content management tool "
            "and open the 'Images' tab. Now click on the 'Add' button and "
            "select some folders which contain image files.")
        info = Label(0.0417, "menuitem_inactive", 0.2804, 0.45, message)
        info.set_size(0.5, 0.5859)
        self.add(info)
Ejemplo n.º 44
0
    def __init__(self, width, height, text, extra_text=None):
        MenuItem.__init__(self)

        self.width = width
        self.height = height
        self.theme = self.config.theme

        self.text = text
        self.extra_text = extra_text
        self.color = "menuitem_inactive"
        self.font_size = 0.03

        self.label = Label(self.font_size, self.color, 0, 0, "",
            "text_label")
        self.add(self.label)

        # Set extra text
        self.extra_label = None
        if extra_text is not None:
            self.extra_label = Label(self.font_size, self.color, 0, 0,
                "", "text_label")
            self.add(self.extra_label)

        self.update(text, extra_text)
Ejemplo n.º 45
0
    def __init__(self):
        Screen.__init__(self, 'Weather')

        # Screen Title
        self.add(Label(0.13, "screentitle", 0, 0.87, _("Weather")))

        self.weather = Weather(self.config.weather_location)

        location = Label(0.04167, "text", 0.50, 0.13, self.weather.location,
            font_weight="bold")
        location.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self.add(location)

        # Show today's weather
        self.create_day(self.weather.forecasts[0], 0.1, 0.15)

        # Show tomorrow's weather
        self.create_day(self.weather.forecasts[1], 0.1, 0.5)

        # Show day 3
        self.create_day(self.weather.forecasts[2], 0.4, 0.5)

        # Show day 4
        self.create_day(self.weather.forecasts[3], 0.7, 0.5)
Ejemplo n.º 46
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)
Ejemplo n.º 47
0
    def _create_no_photos_information(self):
        """
        Create textures and labels for information screen. This is displayed
        instead of album list if there are no photos available and it helps
        users to add new photographs 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 photographs available!"))
        self.add(info_title)

        # Create warning help text
        message = _(
            "There are no indexed photographs in the Entertainer media "
            "library. To add photographs, start the Content management tool "
            "and open the 'Images' tab. Now click on the 'Add' button and "
            "select some folders which contain image files.")
        info = Label(0.0417, "menuitem_inactive", 0.2804, 0.45, message)
        info.set_size(0.5, 0.5859)
        self.add(info)
Ejemplo n.º 48
0
    def _create_menu(self):
        """
        Create a view that is displayed when there are indexed clips in
        the video library.
        """
        menu = ImageMenu(0.04, 0.16, 0.23, self.y_for_x(0.23) * 0.7)
        menu.items_per_col = 2
        menu.visible_rows = 2
        menu.visible_cols = 4

        clips = self.video_library.get_video_clips()
        clips_list = [[clip.thumbnail_url, clip] for clip in clips]
        menu.async_add_clips(clips_list)

        # Create list indicator
        self.list_indicator = ListIndicator(0.7, 0.8, 0.2, 0.045,
            ListIndicator.HORIZONTAL)
        self.list_indicator.set_maximum(len(clips))
        self.list_indicator.show()
        self.add(self.list_indicator)

        # Create information labels
        self.clip_title = Label(0.042, "title", 0.15, 0.77, "",
            font_weight="bold")
        self.clip_title.set_ellipsize(pango.ELLIPSIZE_END)
        self.clip_title.set_line_wrap(False)
        self.clip_title.width = 0.5
        self.add(self.clip_title)

        self.clip_info = Label(0.034, "subtitle", 0.15, 0.85, "")
        self.clip_info.set_ellipsize(pango.ELLIPSIZE_END)
        self.clip_info.set_line_wrap(False)
        self.clip_info.width = 0.5
        self.add(self.clip_info)

        return menu
Ejemplo n.º 49
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)
Ejemplo n.º 50
0
    def __init__(self, x, y, width, height, direction):
        Base.__init__(self)
        clutter.Group.__init__(self)

        self.config = Configuration()

        # Size
        self.width = self.get_abs_x(width)
        self.height = self.get_abs_y(height)

        self.direction = direction
        self.delimiter = " | "
        self.current = 1
        self.maximum = 1

        self.theme = self.config.theme
        self.fg = self.theme.get_color("arrow_foreground")
        self.bg = self.theme.get_color("arrow_background")

        if direction == ListIndicator.VERTICAL:
            text_x_pos = width / 3
        else:
            text_x_pos = width / 2

        self.text = Label(height * 0.8, "text", text_x_pos, height / 2,
            str(self.maximum) + self.delimiter + str(self.maximum))
        self.text.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
        self.add(self.text)

        # Create arrows and calculate positions on screen
        if direction == ListIndicator.VERTICAL:
            self.arrow1 = ArrowTexture(5 * width / 7, height / 2, height / 2,
                self.fg, self.bg, ArrowTexture.UP)
            self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2,
                self.fg, self.bg, ArrowTexture.DOWN)

        elif direction == ListIndicator.HORIZONTAL:
            self.arrow1 = ArrowTexture(height / 2, height / 2, height / 2,
                self.fg, self.bg, ArrowTexture.LEFT)
            self.arrow2 = ArrowTexture(6 * width / 7, height / 2, height / 2,
                self.fg, self.bg, ArrowTexture.RIGHT)

        self.add(self.arrow1)
        self.add(self.arrow2)

        self.set_position(self.get_abs_x(x), self.get_abs_y(y))
Ejemplo n.º 51
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
Ejemplo n.º 52
0
    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)
Ejemplo n.º 53
0
class TextMenuItem(MenuItem):
    """A menuitem widget that contains one or two labels."""

    def __init__(self, width, height, text, extra_text=None):
        MenuItem.__init__(self)

        self.width = width
        self.height = height
        self.theme = self.config.theme

        self.text = text
        self.extra_text = extra_text
        self.color = "menuitem_inactive"
        self.font_size = 0.03

        self.label = Label(self.font_size, self.color, 0, 0, "",
            "text_label")
        self.add(self.label)

        # Set extra text
        self.extra_label = None
        if extra_text is not None:
            self.extra_label = Label(self.font_size, self.color, 0, 0,
                "", "text_label")
            self.add(self.extra_label)

        self.update(text, extra_text)

    def animate_in(self):
        """Set labels font-size and color when an item gets selected."""
        self.font_size = 0.037
        self.color = "menuitem_active"
        self.update()

    def animate_out(self):
        """Set labels font-size and color when an item gets unselected."""
        self.font_size = 0.03
        self.color = "menuitem_inactive"
        self.update()

    def update(self, text=None, extra_text=None):
        """Updates text and dimensions of a TextMenuItem."""
        if text is None:
            text = self.text
        else:
            self.text = text

        if extra_text is None:
            extra_text = self.extra_text
        else:
            self.extra_text = extra_text

        try:
            first_line = text[:text.index('\n')]
        except ValueError:
            first_line = text

        self.label.font_size = self.font_size
        self.label.set_text(first_line)
        self.label.position = (0.01, (self.height - self.label.height) / 2)
        self.label.set_line_wrap(False)
        self.label.set_ellipsize(pango.ELLIPSIZE_END)

        # Set extra text
        if extra_text is not None:
            self.extra_label.font_size = self.font_size
            self.extra_label.set_text(extra_text)
            self.extra_label.position = (
                self.width * 0.98 - self.extra_label.width,
                (self.height - self.extra_label.height) / 2)

            self.label.width = (self.width - self.extra_label.width) * 0.9
        else:
            self.label.width = self.width * 0.95

        self.label.color = self.color
        if self.extra_label:
            self.extra_label.color = self.color