Exemple #1
0
        def celldata(layout, cell, model, iter_, data):
            release = model.get_value(iter_)

            extra_info = ", ".join(
                filter(
                    None,
                    [
                        util.escape(release.date),
                        util.escape(release.country),
                        util.escape(release.medium_format),
                        util.escape(release.labelid),
                    ],
                )
            )

            artist_names = [a.name for a in release.artists]
            disc_count = release.disc_count
            track_count = release.track_count

            discs_text = numeric_phrase("%d disc", "%d discs", disc_count)
            tracks_text = numeric_phrase("%d track", "%d tracks", track_count)

            markup = "<b>%s</b>\n%s - %s, %s (%s)" % (
                util.escape(release.title),
                util.escape(", ".join(artist_names)),
                util.escape(discs_text),
                util.escape(tracks_text),
                extra_info,
            )
            cell.set_property("markup", markup)
Exemple #2
0
class Preferences(qltk.UniqueWindow, EditDisplayPatternMixin):
    _DEFAULT_PATTERN = DEFAULT_PATTERN_TEXT

    _PREVIEW_ITEM = FakeDisplayItem({
        "date": "2010-10-31",
        "~length": util.format_time_display(6319),
        "~long-length": util.format_time_long(6319),
        "~tracks": numeric_phrase("%d track", "%d tracks", 5),
        "~discs": numeric_phrase("%d disc", "%d discs", 2),
        "~#rating": 0.75,
        "album": _("An Example Album"),
        "~people": _SOME_PEOPLE + "..."})

    def __init__(self, browser):
        if self.is_not_unique():
            return
        super(Preferences, self).__init__()
        self.set_border_width(12)
        self.set_title(_("Album List Preferences"))
        self.set_default_size(420, 380)
        self.set_transient_for(qltk.get_top_parent(browser))
        # Do this config-driven setup at instance-time
        self._PREVIEW_ITEM["~rating"] = format_rating(0.75)

        box = Gtk.VBox(spacing=6)
        vbox = Gtk.VBox(spacing=6)
        cb = ConfigCheckButton(
            _("Show album _covers"), "browsers", "album_covers")
        cb.set_active(config.getboolean("browsers", "album_covers"))
        cb.connect('toggled', lambda s: browser.toggle_covers())
        vbox.pack_start(cb, False, True, 0)

        cb = ConfigCheckButton(
            _("Inline _search includes people"),
            "browsers", "album_substrings")
        cb.set_active(config.getboolean("browsers", "album_substrings"))
        vbox.pack_start(cb, False, True, 0)
        f = qltk.Frame(_("Options"), child=vbox)
        box.pack_start(f, False, True, 12)

        display_frame = self.edit_display_pane(browser, _("Album Display"))
        box.pack_start(display_frame, True, True, 0)

        main_box = Gtk.VBox(spacing=12)
        close = Button(_("_Close"), Icons.WINDOW_CLOSE)
        close.connect('clicked', lambda *x: self.destroy())
        b = Gtk.HButtonBox()
        b.set_layout(Gtk.ButtonBoxStyle.END)
        b.pack_start(close, True, True, 0)

        main_box.pack_start(box, True, True, 0)
        self.use_header_bar()

        if not self.has_close_button():
            main_box.pack_start(b, False, True, 0)
        self.add(main_box)

        close.grab_focus()
        self.show_all()
    def test_numeric_phrase(self):
        actual = numeric_phrase("%d green bottle", "%d green bottles", 1)
        self.failUnlessEqual(actual, "1 green bottle")

        with locale_numeric_conv():
            actual = numeric_phrase(
                "%d green bottle", "%d green bottles", 1234)
            self.failUnlessEqual(actual, "1,234 green bottles")
Exemple #4
0
    def test_numeric_phrase(self):
        actual = numeric_phrase("%d green bottle", "%d green bottles", 1)
        self.failUnlessEqual(actual, "1 green bottle")

        with locale_numeric_conv():
            actual = numeric_phrase(
                "%d green bottle", "%d green bottles", 1234)
            self.failUnlessEqual(actual, "1,234 green bottles")
Exemple #5
0
    def test_numeric_phrase_templated(self):
        actual = numeric_phrase("%(bottles)d green bottle",
                                "%(bottles)d green bottles", 1, "bottles")
        self.failUnlessEqual(actual, "1 green bottle")

        actual = numeric_phrase("%(bottles)d green bottle",
                                "%(bottles)d green bottles", 1234, "bottles")

        self.failUnlessEqual(actual, "1,234 green bottles")
    def test_numeric_phrase_templated(self):
        actual = numeric_phrase("%(bottles)d green bottle",
                                "%(bottles)d green bottles", 1, "bottles")
        self.failUnlessEqual(actual, "1 green bottle")

        actual = numeric_phrase("%(bottles)d green bottle",
                                "%(bottles)d green bottles", 1234, "bottles")

        self.failUnlessEqual(actual, "1,234 green bottles")
Exemple #7
0
    def test_numeric_phrase_translation_templated(self):
        # See issue 2166

        with use_dummy_ngettext("%(n)d text", "%(n)d texts",
                                "%(n)d translation", "%(n)d translations"):
            actual = numeric_phrase("%(n)d text", "%(n)d texts", 1, "n")
            self.failUnlessEqual(actual, "1 translation")

            actual = numeric_phrase("%(n)d text", "%(n)d texts", 2, "n")
            self.failUnlessEqual(actual, "2 translations")
Exemple #8
0
 def _paren(self):
     if self.shared:
         return numeric_phrase('missing from %d song',
                               'missing from %d songs', self.missing)
     elif self.complete:
         return numeric_phrase('different across %d song',
                               'different across %d songs', self.total)
     else:
         d = numeric_phrase('different across %d song',
                            'different across %d songs', self.have)
         m = numeric_phrase('missing from %d song', 'missing from %d songs',
                            self.missing)
         return ", ".join([d, m])
Exemple #9
0
 def _paren(self):
     if self.shared:
         return numeric_phrase('missing from %d song',
                               'missing from %d songs',
                               self.missing)
     elif self.complete:
         return numeric_phrase('different across %d song',
                               'different across %d songs',
                               self.total)
     else:
         d = numeric_phrase('different across %d song',
                            'different across %d songs',
                            self.have)
         m = numeric_phrase('missing from %d song',
                            'missing from %d songs',
                            self.missing)
         return ", ".join([d, m])
Exemple #10
0
 def test_numeric_phrase_locales(self):
     try:
         locale.setlocale(locale.LC_ALL, 'fr_FR.utf-8')
         actual = numeric_phrase("%(bottles)d green bottle",
                                 "%(bottles)d green bottles",
                                 1234, "bottles")
         self.failUnlessEqual(actual, "1 234 green bottles")
     finally:
         locale.setlocale(locale.LC_ALL, '')
Exemple #11
0
class Preferences(qltk.UniqueWindow, EditDisplayPatternMixin):
    _A_SIZE = 127 * 1024 * 1024
    _SOME_PEOPLE = "\n".join(
        tag(t) for t in ["artist", "performer", "composer", "arranger"])

    _DEFAULT_PATTERN = DEFAULT_PATTERN_TEXT

    _PREVIEW_ITEM = FakeDisplayItem({
        "date":
        "2015-11-31",
        "~length":
        format_time_display(6319),
        "~long-length":
        format_time_long(6319),
        "~tracks":
        numeric_phrase("%d track", "%d tracks", 27),
        "~#filesize":
        _A_SIZE,
        "~filesize":
        format_size(_A_SIZE),
        "~#rating":
        0.75,
        "~name":
        _("Example Playlist"),
        "~people":
        _SOME_PEOPLE + "..."
    })

    def __init__(self, browser):
        if self.is_not_unique():
            return
        super(Preferences, self).__init__()
        self.set_border_width(12)
        self.set_title(_("Playlist Browser Preferences"))
        self.set_default_size(420, 240)
        self.set_transient_for(qltk.get_top_parent(browser))

        box = Gtk.VBox(spacing=6)
        edit_frame = self.edit_display_pane(browser, _("Playlist display"))
        box.pack_start(edit_frame, False, True, 12)

        main_box = Gtk.VBox(spacing=12)
        close = Button(_("_Close"), Icons.WINDOW_CLOSE)
        close.connect('clicked', lambda *x: self.destroy())
        b = Gtk.HButtonBox()
        b.set_layout(Gtk.ButtonBoxStyle.END)
        b.pack_start(close, True, True, 0)

        main_box.pack_start(box, True, True, 0)
        self.use_header_bar()

        if not self.has_close_button():
            main_box.pack_start(b, False, True, 0)
        self.add(main_box)

        close.grab_focus()
        self.show_all()
Exemple #12
0
 def check_songs():
     desc = numeric_phrase("%d song", "%d songs", len(songs))
     with Task(_("Rescan songs"), desc) as task:
         task.copool(check_songs)
         for i, song in enumerate(songs):
             song = song._song
             if song in app.library:
                 app.library.reload(song)
             task.update((float(i) + 1) / len(songs))
             yield
Exemple #13
0
 def check_songs():
     desc = numeric_phrase("%d song", "%d songs", len(songs))
     with Task(_("Rescan songs"), desc) as task:
         task.copool(check_songs)
         for i, song in enumerate(songs):
             song = song._song
             if song in app.library:
                 app.library.reload(song)
             task.update((float(i) + 1) / len(songs))
             yield
Exemple #14
0
 def test_numeric_phrase_locales(self):
     try:
         locale.setlocale(locale.LC_ALL, 'fr_FR.utf-8')
     except locale.Error:
         # fr_FR not installed
         pass
     else:
         actual = numeric_phrase("%(bottles)d green bottle",
                                 "%(bottles)d green bottles", 1234,
                                 "bottles")
         self.failUnlessEqual(actual, "1 234 green bottles")
     finally:
         locale.setlocale(locale.LC_ALL, '')
Exemple #15
0
        def celldata(layout, cell, model, iter_, data):
            release = model.get_value(iter_)

            extra_info = ", ".join(
                filter(None, [
                    util.escape(release.date),
                    util.escape(release.country),
                    util.escape(release.medium_format),
                    util.escape(release.labelid)
                ]))

            artist_names = [a.name for a in release.artists]
            disc_count = release.disc_count
            track_count = release.track_count

            discs_text = numeric_phrase("%d disc", "%d discs", disc_count)
            tracks_text = numeric_phrase("%d track", "%d tracks", track_count)

            markup = "<b>%s</b>\n%s - %s, %s (%s)" % (
                util.escape(release.title), util.escape(
                    ", ".join(artist_names)), util.escape(discs_text),
                util.escape(tracks_text), extra_info)
            cell.set_property('markup', markup)
Exemple #16
0
        def cell_data(column, cell, model, iter_, data):
            album = model.get_album(iter_)

            if album is None:
                text = "<b>%s</b>\n" % _("All Albums")
                text += numeric_phrase("%d album", "%d albums", len(model) - 1)
                markup = text
            else:
                markup = self.display_pattern % album

            if self.__last_render == markup:
                return
            self.__last_render = markup
            cell.markup = markup
            cell.set_property('markup', markup)
Exemple #17
0
        def cell_data(column, cell, model, iter_, data):
            album = model.get_album(iter_)

            if album is None:
                text = "<b>%s</b>\n" % _("All Albums")
                text += numeric_phrase("%d album", "%d albums", len(model) - 1)
                markup = text
            else:
                markup = self.display_pattern % album

            if self.__last_render == markup:
                return
            self.__last_render = markup
            cell.markup = markup
            cell.set_property('markup', markup)
Exemple #18
0
    def __init__(self, parent, paths, description):
        title = numeric_phrase("Delete %(file_count)d file permanently?",
                               "Delete %(file_count)d files permanently?",
                               len(paths), "file_count")

        super(DeleteDialog, self).__init__(
            get_top_parent(parent),
            title, description,
            buttons=Gtk.ButtonsType.NONE)

        area = self.get_message_area()
        exp = FileListExpander(paths)
        exp.show()
        area.pack_start(exp, False, True, 0)

        self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
        self.add_icon_button(_("_Delete Files"), Icons.EDIT_DELETE,
                             self.RESPONSE_DELETE)
        self.set_default_response(Gtk.ResponseType.CANCEL)
Exemple #19
0
    def __init__(self, parent, paths, description):
        title = numeric_phrase("Delete %(file_count)d file permanently?",
                               "Delete %(file_count)d files permanently?",
                               len(paths), "file_count")

        super().__init__(get_top_parent(parent),
                         title,
                         description,
                         buttons=Gtk.ButtonsType.NONE)

        area = self.get_message_area()
        exp = FileListExpander(paths)
        exp.show()
        area.pack_start(exp, False, True, 0)

        self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
        self.add_icon_button(_("_Delete Files"), Icons.EDIT_DELETE,
                             self.RESPONSE_DELETE)
        self.set_default_response(Gtk.ResponseType.CANCEL)
Exemple #20
0
    def __init__(self, parent, paths, description):

        title = numeric_phrase("Move %(file_count)d file to the trash?",
                               "Move %(file_count)d files to the trash?",
                               len(paths), "file_count")
        super(TrashDialog, self).__init__(
            get_top_parent(parent),
            title, description,
            buttons=Gtk.ButtonsType.NONE)

        area = self.get_message_area()
        exp = FileListExpander(paths)
        exp.show()
        area.pack_start(exp, False, True, 0)

        self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
        self.add_icon_button(_("_Move to Trash"), Icons.USER_TRASH,
                             self.RESPONSE_TRASH)
        self.set_default_response(Gtk.ResponseType.CANCEL)
Exemple #21
0
    def __init__(self, parent, paths, description):

        title = numeric_phrase("Move %(file_count)d file to the trash?",
                               "Move %(file_count)d files to the trash?",
                               len(paths), "file_count")
        super().__init__(get_top_parent(parent),
                         title,
                         description,
                         buttons=Gtk.ButtonsType.NONE)

        area = self.get_message_area()
        exp = FileListExpander(paths)
        exp.show()
        area.pack_start(exp, False, True, 0)

        self.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
        self.add_icon_button(_("_Move to Trash"), Icons.USER_TRASH,
                             self.RESPONSE_TRASH)
        self.set_default_response(Gtk.ResponseType.CANCEL)
Exemple #22
0
    def __changed(self, selector, selection, label):
        model, rows = selection.get_selected_rows()
        files = []

        if len(rows) < 2:
            count = len(model or [])
        else:
            count = len(rows)
        label.set_text(numeric_phrase("%d song", "%d songs", count))

        for row in rows:
            filename = model[row][0]
            if not os.path.exists(filename):
                pass
            elif filename in self.__library:
                song = self.__library[filename]
                if song("~#mtime") + 1. < mtime(filename):
                    try:
                        song.reload()
                    except AudioFileError:
                        pass
                files.append(song)
            else:
                files.append(formats.MusicFile(filename))
        files = list(filter(None, files))
        if len(files) == 0:
            self.set_title("Ex Falso")
        elif len(files) == 1:
            self.set_title("%s - Ex Falso" % files[0].comma("title"))
        else:
            params = ({'title': files[0].comma("title"),
                       'count': format_int_locale(len(files) - 1)})
            self.set_title(
                "%s - Ex Falso" %
                (ngettext("%(title)s and %(count)s more",
                          "%(title)s and %(count)s more", len(files) - 1)
                 % params))
        self.__library.add(files)
        self.emit('changed', files)
    def __changed(self, selector, selection, label):
        model, rows = selection.get_selected_rows()
        files = []

        if len(rows) < 2:
            count = len(model or [])
        else:
            count = len(rows)
        label.set_text(numeric_phrase("%d song", "%d songs", count))

        for row in rows:
            filename = model[row][0]
            if not os.path.exists(filename):
                pass
            elif filename in self.__library:
                song = self.__library[filename]
                if song("~#mtime") + 1. < mtime(filename):
                    try:
                        song.reload()
                    except AudioFileError:
                        pass
                files.append(song)
            else:
                files.append(formats.MusicFile(filename))
        files = list(filter(None, files))
        if len(files) == 0:
            self.set_title("Ex Falso")
        elif len(files) == 1:
            self.set_title("%s - Ex Falso" % files[0].comma("title"))
        else:
            params = ({
                'title': files[0].comma("title"),
                'count': format_int_locale(len(files) - 1)
            })
            self.set_title("%s - Ex Falso" % (ngettext(
                "%(title)s and %(count)s more", "%(title)s and %(count)s more",
                len(files) - 1) % params))
        self.__library.add(files)
        self.emit('changed', files)
Exemple #24
0
 def test_numeric_phrase_locales(self):
     with locale_numeric_conv(thousands_sep=" "):
         actual = numeric_phrase("%(bottles)d green bottle",
                                 "%(bottles)d green bottles",
                                 1234, "bottles")
         self.failUnlessEqual(actual, "1 234 green bottles")
Exemple #25
0
 def status_text(self, count, time=None):
     return numeric_phrase("%(count)d station", "%(count)d stations", count,
                           'count')
Exemple #26
0
class Preferences(qltk.UniqueWindow, EditDisplayPatternMixin):
    _DEFAULT_PATTERN = DEFAULT_PATTERN_TEXT

    _PREVIEW_ITEM = FakeDisplayItem({
        "date":
        "2010-10-31",
        "~length":
        util.format_time_display(6319),
        "~long-length":
        util.format_time_long(6319),
        "~tracks":
        numeric_phrase("%d track", "%d tracks", 5),
        "~discs":
        numeric_phrase("%d disc", "%d discs", 2),
        "~#rating":
        0.75,
        "album":
        _("An Example Album"),
        "~people":
        _SOME_PEOPLE + "..."
    })

    def __init__(self, browser):
        if self.is_not_unique():
            return
        super().__init__()
        self.set_border_width(12)
        self.set_title(_("Cover Grid Preferences"))
        self.set_default_size(420, 380)
        self.set_transient_for(qltk.get_top_parent(browser))
        # Do this config-driven setup at instance-time
        self._PREVIEW_ITEM["~rating"] = format_rating(0.75)
        self.mag_lock = False

        box = Gtk.VBox(spacing=6)
        vbox = Gtk.VBox(spacing=6)
        cb = ConfigCheckButton(_("Show album _text"), "browsers", "album_text")
        cb.set_active(config.getboolean("browsers", "album_text"))
        cb.connect('toggled', lambda s: browser.toggle_text())
        vbox.pack_start(cb, False, True, 0)

        cb2 = ConfigCheckButton(_("Show \"All Albums\" Item"), "browsers",
                                "covergrid_all")
        cb2.set_active(config.getboolean("browsers", "covergrid_all", True))

        def refilter(s):
            mod = browser.view.get_model()
            if mod:
                mod.refilter()

        cb2.connect('toggled', refilter)
        vbox.pack_start(cb2, False, True, 0)

        cb3 = ConfigCheckButton(_("Wide Mode"), "browsers", "covergrid_wide")
        cb3.set_active(config.getboolean("browsers", "covergrid_wide", False))
        cb3.connect('toggled', lambda s: browser.toggle_wide())
        vbox.pack_start(cb3, False, True, 0)

        # Redraws the covers only when the user releases the slider
        def mag_button_press(*_):
            self.mag_lock = True

        def mag_button_release(mag, _):
            self.mag_lock = False
            mag_changed(mag)

        def mag_changed(mag):
            if self.mag_lock:
                return
            newmag = mag.get_value()
            oldmag = config.getfloat("browsers", "covergrid_magnification", 3.)
            if newmag == oldmag:
                print_d("Covergrid magnification haven't changed: {0}".format(
                    newmag))
                return
            print_d('Covergrid magnification update from {0} to {1}'.format(
                oldmag, newmag))
            config.set("browsers", "covergrid_magnification", mag.get_value())
            browser.update_mag()

        mag_scale = Gtk.HScale(adjustment=Gtk.Adjustment.new(
            config.getfloat("browsers", "covergrid_magnification", 3), 0., 10.,
            .5, .5, 0))
        mag_scale.set_tooltip_text(_("Cover Magnification"))
        l = Gtk.Label(label=_("Cover Magnification"))
        mag_scale.set_value_pos(Gtk.PositionType.RIGHT)
        mag_scale.connect('button-press-event', mag_button_press)
        mag_scale.connect('button-release-event', mag_button_release)
        mag_scale.connect('value-changed', mag_changed)

        vbox.pack_start(l, False, True, 0)
        vbox.pack_start(mag_scale, False, True, 0)

        f = qltk.Frame(_("Options"), child=vbox)
        box.pack_start(f, False, True, 12)

        display_frame = self.edit_display_pane(browser, _("Album Display"))
        box.pack_start(display_frame, True, True, 0)

        main_box = Gtk.VBox(spacing=12)
        close = Button(_("_Close"), Icons.WINDOW_CLOSE)
        close.connect('clicked', lambda *x: self.destroy())
        b = Gtk.HButtonBox()
        b.set_layout(Gtk.ButtonBoxStyle.END)
        b.pack_start(close, True, True, 0)

        main_box.pack_start(box, True, True, 0)
        self.use_header_bar()

        if not self.has_close_button():
            main_box.pack_start(b, False, True, 0)
        self.add(main_box)

        close.grab_focus()
        self.show_all()
Exemple #27
0
 def status_text(self, count, time=None):
     tmpl = numeric_phrase("%d song", "%d songs", count)
     return tmpl + " (%s)" % time
Exemple #28
0
 def test_numeric_phrase_locales(self):
     with set_locale('fr_FR.utf-8'):
         actual = numeric_phrase("%(bottles)d green bottle",
                                 "%(bottles)d green bottles",
                                 1234, "bottles")
         self.failUnlessEqual(actual, "1 234 green bottles")
Exemple #29
0
 def status_text(self, count: int, time: Optional[str] = None) -> str:
     return numeric_phrase("%(count)d station", "%(count)d stations", count,
                           'count')
Exemple #30
0
 def counter(i):
     return _("Never") if i == 0 \
         else numeric_phrase("%(n)d time", "%(n)d times", i, "n")
Exemple #31
0
    def __init__(self, model):
        songs_text = numeric_phrase("%d duplicate group",
                                    "%d duplicate groups",
                                    len(model))
        super(DuplicateDialog, self).__init__()
        self.set_destroy_with_parent(True)
        self.set_title("Quod Libet - %s (%s)" % (Duplicates.PLUGIN_NAME,
                                                 songs_text))
        self.finished = False
        self.set_default_size(960, 480)
        self.set_border_width(6)
        swin = Gtk.ScrolledWindow()
        swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        swin.set_shadow_type(Gtk.ShadowType.IN)
        # Set up the browser view
        view = DuplicateSongsView(model)

        def cell_text(column, cell, model, iter_, index):
            text = model[iter_][index]
            cell.markup = text
            cell.set_property("markup", text)

        # Set up the columns
        for i, (tag, f) in enumerate(DuplicatesTreeModel.TAG_MAP):
            e = (Pango.EllipsizeMode.START if tag == '~filename'
                else Pango.EllipsizeMode.END)
            render = Gtk.CellRendererText()
            render.set_property("ellipsize", e)
            col = Gtk.TreeViewColumn(util.tag(tag), render)
            # Numeric columns are better smaller here.
            if tag.startswith("~#"):
                col.set_fixed_width(80)
                col.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
            else:
                col.set_expand(True)
                col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
            col.set_resizable(True)
            col.set_cell_data_func(render, cell_text, i + 1)
            view.append_column(col)

        view.connect('popup-menu', self.__songs_popup_menu)
        swin.add(view)
        # A basic information area
        hbox = Gtk.HBox(spacing=6)

        def expand_all(*args):
            model = view.get_model()
            for row in model:
                if view.row_expanded(row.path):
                    view.collapse_row(row.path)
            else:
                for row in model:
                    view.expand_row(row.path, False)

        expand = Gtk.Button(_("Collapse / Expand all"))
        connect_obj(expand, "clicked", expand_all, view)
        hbox.pack_start(expand, False, True, 0)

        label = Gtk.Label(label=_("Duplicate key expression is '%s'") %
                Duplicates.get_key_expression())
        hbox.pack_start(label, True, True, 0)
        close = Button(_("_Close"), Icons.WINDOW_CLOSE)
        close.connect('clicked', self.__quit)
        hbox.pack_start(close, False, True, 0)

        vbox = Gtk.VBox(spacing=6)
        vbox.pack_start(swin, True, True, 0)
        vbox.pack_start(hbox, False, True, 0)
        self.add(vbox)
        self.show_all()
Exemple #32
0
 def status_text(self, count, time=None):
     return numeric_phrase("%(count)d station", "%(count)d stations",
                           count, 'count')
Exemple #33
0
    def __init__(self, model):
        songs_text = numeric_phrase("%d duplicate group",
                                    "%d duplicate groups",
                                    len(model))
        super(DuplicateDialog, self).__init__()
        self.set_destroy_with_parent(True)
        self.set_title("Quod Libet - %s (%s)" % (Duplicates.PLUGIN_NAME,
                                                 songs_text))
        self.finished = False
        self.set_default_size(960, 480)
        self.set_border_width(6)
        swin = Gtk.ScrolledWindow()
        swin.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        swin.set_shadow_type(Gtk.ShadowType.IN)
        # Set up the browser view
        view = DuplicateSongsView(model)

        def cell_text(column, cell, model, iter_, index):
            text = model[iter_][index]
            cell.markup = text
            cell.set_property("markup", text)

        # Set up the columns
        for i, (tag, f) in enumerate(DuplicatesTreeModel.TAG_MAP):
            e = (Pango.EllipsizeMode.START if tag == '~filename'
                else Pango.EllipsizeMode.END)
            render = Gtk.CellRendererText()
            render.set_property("ellipsize", e)
            col = Gtk.TreeViewColumn(util.tag(tag), render)
            # Numeric columns are better smaller here.
            if tag.startswith("~#"):
                col.set_fixed_width(80)
                col.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
            else:
                col.set_expand(True)
                col.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE)
            col.set_resizable(True)
            col.set_cell_data_func(render, cell_text, i + 1)
            view.append_column(col)

        view.connect('popup-menu', self.__songs_popup_menu)
        swin.add(view)
        # A basic information area
        hbox = Gtk.HBox(spacing=6)

        def expand_all(*args):
            model = view.get_model()
            for row in model:
                if view.row_expanded(row.path):
                    view.collapse_row(row.path)
            else:
                for row in model:
                    view.expand_row(row.path, False)

        expand = Gtk.Button(_("Collapse / Expand all"))
        connect_obj(expand, "clicked", expand_all, view)
        hbox.pack_start(expand, False, True, 0)

        label = Gtk.Label(label=_("Duplicate key expression is '%s'") %
                Duplicates.get_key_expression())
        hbox.pack_start(label, True, True, 0)
        close = Button(_("_Close"), Icons.WINDOW_CLOSE)
        close.connect('clicked', self.__quit)
        hbox.pack_start(close, False, True, 0)

        vbox = Gtk.VBox(spacing=6)
        vbox.pack_start(swin, True, True, 0)
        vbox.pack_start(hbox, False, True, 0)
        self.add(vbox)
        self.show_all()
 def test_numeric_phrase_locales(self):
     with locale_numeric_conv(thousands_sep=" "):
         actual = numeric_phrase("%(bottles)d green bottle",
                                 "%(bottles)d green bottles",
                                 1234, "bottles")
         self.failUnlessEqual(actual, "1 234 green bottles")
Exemple #35
0
 def status_text(self, count, time=None):
     tmpl = numeric_phrase("%d song", "%d songs", count)
     return tmpl + " (%s)" % time
Exemple #36
0
 def counter(i):
     return _("Never") if i == 0 \
         else numeric_phrase("%(n)d time", "%(n)d times", i, "n")
Exemple #37
0
 def status_text(self, count: int, time: Optional[str] = None) -> str:
     tmpl = numeric_phrase("%d song", "%d songs", count)
     return f"{tmpl} ({time})" if time else tmpl