Exemplo n.º 1
0
    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER)

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
Exemplo n.º 2
0
    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER
        )

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')
Exemplo n.º 3
0
class ProgressButtonFormatter(Formatter):
    """
        Formatter which allows both for display of
        tag data as well as progress information
    """

    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER
        )

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')

    def format(self, current_time=None, total_time=None):
        """
            Returns a string suitable for progress buttons

            :param current_time: the current progress
            :type current_time: float
            :param total_time: the total length of a track
            :type total_time: float
            :returns: The formatted text
            :rtype: string
        """
        text = self.progress_formatter.format()
        self.track_formatter.props.format = text
        text = self.track_formatter.format(player.PLAYER.current)

        return text

    def get_option_value(self):
        """
            Retrieves the current user format
        """
        return settings.get_option(
            'plugin/minimode/progress_button_title_format',
            _('$title ($current_time / $total_time)'),
        )

    def on_option_set(self, event, settings, option):
        """
            Updates the internal format on setting change
        """
        if option == 'gui/progress_bar_text_format':
            GLib.idle_add(self.set_property, 'format', self.get_option_value())
Exemplo n.º 4
0
class ProgressButtonFormatter(Formatter):
    """
    Formatter which allows both for display of
    tag data as well as progress information
    """
    def __init__(self):
        Formatter.__init__(self, self.get_option_value())

        self.track_formatter = TrackFormatter('')
        self.progress_formatter = ProgressTextFormatter(
            self.props.format, player.PLAYER)

        event.add_ui_callback(self.on_option_set, 'plugin_minimode_option_set')

    def format(self, current_time=None, total_time=None):
        """
        Returns a string suitable for progress buttons

        :param current_time: the current progress
        :type current_time: float
        :param total_time: the total length of a track
        :type total_time: float
        :returns: The formatted text
        :rtype: string
        """
        text = self.progress_formatter.format()
        self.track_formatter.props.format = text
        text = self.track_formatter.format(player.PLAYER.current)

        return text

    def get_option_value(self):
        """
        Retrieves the current user format
        """
        return settings.get_option(
            'plugin/minimode/progress_button_title_format',
            _('$title ($current_time / $total_time)'),
        )

    def on_option_set(self, event, settings, option):
        """
        Updates the internal format on setting change
        """
        if option == 'gui/progress_bar_text_format':
            GLib.idle_add(self.set_property, 'format', self.get_option_value())