Ejemplo n.º 1
0
    def _get_summary(self):
        source_files = self.source_files
        search = self.filter.search
        if search == "":
            return plural_of(len(source_files), "A total of %s file%s.", -1)

        files = 0
        matches = 0
        for source_file in source_files:
            source_file.update = True
            n = len(source_file.matches)
            if n > 0:
                files += 1
                matches += n

        return "A total of %s found with %s containing %d match%s." % (
            plural_of(len(source_files), "%s file%s", -1),
            plural_of(files, "%s file%s", -1),
            matches,
            "" if matches == 1 else "es",
        )
Ejemplo n.º 2
0
    def _check_cursor ( self, x, y ):
        """ Checks if the current mouse position is in the insert control zone
            (if active) and sets the cursor and tooltip accordingly.
        """
        # Set the cursor:
        cursor = 'arrow'
        n      = len( self.hidden )
        if (n > 0) and self.in_control( x, y ):
            dx, dy = self.control.size
            if self.is_vertical:
                if x > (dx / 2):
                    cursor = 'sizeew'
            elif y > (dy /2 ):
                cursor = 'sizens'

        self.control.cursor = cursor

        # Set the tooltip:
        tooltip   = ZoneTooltips[ self.zone ]
        show_zone = self.zone in ( LeftShowZone, RightShowZone )
        if (n > 1) and show_zone:
            tooltip += plural_of(
                n, 'Right-click to add all %s hidden item%s.\n'
            )

        if cursor == 'arrow':
            if self.size > self.control.size[ self.is_vertical ]:
                tooltip +=  'Use mouse wheel to scroll items.\n'
        elif show_zone:
            tooltip += 'Use mouse wheel to add hidden item.\n'

        if n > 1:
            tooltip = tooltip.replace(
                'hidden item.', plural_of( n, 'one of %s hidden item%s.' )
            )

        if self.highlighted is not None:
            tooltip += 'Drag to move item.'

        self.control.tooltip = tooltip.strip()
Ejemplo n.º 3
0
    def _check_tooltip ( self, event ):
        """ Sets the appropriate tooltip based on the mouse position specified
            by *event*.
        """
        left    = self.helper.can_scroll_left_up
        right   = self.helper.can_scroll_right_down
        left_up = ((event.x < (self.control.size[0] / 2)) if self.is_vertical
                   else (event.y < (self.control.size[1] / 2)))
        tooltip = ''
        if (left_up and left) or ((not left_up) and right):
            tooltip = ('Left click to scroll.\n'
                       'Left click and hold to auto-scroll.')

        if left or right:
            tooltip += '\nUse mouse wheel to scroll.'

        tooltip += '\nRight click to edit.'
        n        = len( self.helper.hidden )
        if n > 0:
            tooltip += '\nThere %s %s' % ( 'is' if n == 1 else 'are',
                                           plural_of( n, '%s hidden item%s.' ) )

        self.control.tooltip = tooltip.strip()