def update_duration(self):
     """
         Update track duration
     """
     self._track.reset("duration")
     duration = ms_to_string(self._track.duration)
     self.__duration_label.set_label(duration)
Exemplo n.º 2
0
 def __on_change_value(self, scale, scroll_type, value):
     """
         Update label
         @param scale as Gtk.Scale
         @param scroll_type as Gtk.ScrollType
         @param value as float
     """
     value = min(value, scale.get_adjustment().get_upper())
     time_string = ms_to_string(value)
     self.__time_label.set_markup("<span font_features='tnum'>%s</span>" %
                                  time_string)
Exemplo n.º 3
0
 def _on_duration_changed(self, player, track_id):
     """
         Update duration
         @param player as Player
         @param track_id as int
     """
     if track_id == player.current_track.id:
         duration = player.current_track.duration
         self.__progress.set_range(0.0, duration)
         time_string = ms_to_string(duration)
         self.__total_time_label.set_markup(
             "<span font_features='tnum'>%s</span>" % time_string)
Exemplo n.º 4
0
 def update_position(self, value=None):
     """
         Update progress bar position
         @param value as int
     """
     if not self.__seeking:
         if value is None and App().player.get_status() != Gst.State.PAUSED:
             value = App().player.position
         if value is not None and value >= 0:
             self.__progress.set_value(value)
             time_string = ms_to_string(value)
             self.__time_label.set_markup(
                 "<span font_features='tnum'>%s</span>" % time_string)
     return True
Exemplo n.º 5
0
    def _on_current_changed(self, player):
        """
            Update scale on current changed
            @param player as Player
        """
        style_context = self.__progress.get_style_context()
        style_context.remove_class("youtube-scale")
        if App().player.current_track.id is None:
            self.__total_time_label.set_text("")
            self.__time_label.set_text("")
            return

        self.__progress.set_value(0.0)
        self.__time_label.set_markup("<span font_features='tnum'>0:00</span>")
        if App().player.current_track.is_web:
            style_context.add_class("youtube-scale")
        self.__progress.set_range(0.0, App().player.current_track.duration)
        time_string = ms_to_string(App().player.current_track.duration)
        self.__total_time_label.set_markup(
            "<span font_features='tnum'>%s</span>" % time_string)
 def __init__(self, track, album_artist_ids, view_type):
     """
         Init row widgets
         @param track as Track
         @param album_artist_ids as [int]
         @param view_type as ViewType
     """
     # We do not use Gtk.Builder for speed reasons
     Gtk.ListBoxRow.__init__(self)
     self.__view_type = view_type
     self._track = track
     self._grid = Gtk.Grid()
     self._grid.set_property("valign", Gtk.Align.CENTER)
     self._grid.set_column_spacing(5)
     self._grid.show()
     self._indicator = IndicatorWidget(self, view_type)
     self._indicator.show()
     self._grid.add(self._indicator)
     self._num_label = Gtk.Label.new()
     self._num_label.set_ellipsize(Pango.EllipsizeMode.END)
     self._num_label.set_width_chars(4)
     self._num_label.get_style_context().add_class("dim-label")
     self.update_number_label()
     self._grid.add(self._num_label)
     self.__title_label = Gtk.Label.new(
         GLib.markup_escape_text(self._track.name))
     self.__title_label.set_use_markup(True)
     self.__title_label.set_property("has-tooltip", True)
     self.__title_label.connect("query-tooltip", on_query_tooltip)
     self.__title_label.set_property("hexpand", True)
     self.__title_label.set_property("halign", Gtk.Align.START)
     self.__title_label.set_property("xalign", 0)
     self.__title_label.set_ellipsize(Pango.EllipsizeMode.END)
     self.__title_label.show()
     self._grid.add(self.__title_label)
     featuring_artist_ids = track.get_featuring_artist_ids(album_artist_ids)
     if featuring_artist_ids:
         artists = []
         for artist_id in featuring_artist_ids:
             artists.append(App().artists.get_name(artist_id))
         artists_label = Gtk.Label.new(
             GLib.markup_escape_text(", ".join(artists)))
         artists_label.set_use_markup(True)
         artists_label.set_property("has-tooltip", True)
         artists_label.connect("query-tooltip", on_query_tooltip)
         artists_label.set_property("hexpand", True)
         artists_label.set_property("halign", Gtk.Align.END)
         artists_label.set_ellipsize(Pango.EllipsizeMode.END)
         artists_label.set_opacity(0.3)
         artists_label.set_margin_end(5)
         artists_label.show()
         self._grid.add(artists_label)
     duration = ms_to_string(self._track.duration)
     self.__duration_label = Gtk.Label.new(duration)
     self.__duration_label.get_style_context().add_class("dim-label")
     self.__duration_label.show()
     self._grid.add(self.__duration_label)
     self.__action_button = None
     if self.__view_type & (ViewType.PLAYBACK | ViewType.PLAYLISTS):
         self.__action_button = Gtk.Button.new_from_icon_name(
             "list-remove-symbolic", Gtk.IconSize.MENU)
         self.__action_button.set_tooltip_text(_("Remove from playlist"))
     elif self.__view_type & (ViewType.ALBUM | ViewType.ARTIST):
         self.__action_button = Gtk.Button.new_from_icon_name(
             "view-more-symbolic", Gtk.IconSize.MENU)
     if self.__action_button is None:
         self.__duration_label.set_margin_end(MARGIN_SMALL)
     else:
         self.__action_button.show()
         self.__action_button.connect("clicked",
                                      self.__on_action_button_clicked)
         self.__action_button.set_margin_end(MARGIN_SMALL)
         self.__action_button.set_relief(Gtk.ReliefStyle.NONE)
         context = self.__action_button.get_style_context()
         context.add_class("menu-button")
         self._grid.add(self.__action_button)
     self.add(self._grid)
     self.set_indicator(self._get_indicator_type())
     self.update_duration()
     self.get_style_context().add_class("trackrow")