def test_date(self):
        column = create_songlist_column("~#added")
        self._render_column(column)

        # column reuse triggers warning somwhow
        column = create_songlist_column("~#added")
        self._render_column(column, **{"~#added": 100})
    def test_date(self):
        column = create_songlist_column("~#added")
        self._render_column(column)

        # column reuse triggers warning somwhow
        column = create_songlist_column("~#added")
        self._render_column(column, **{"~#added": 100})
    def test_rating(self):
        column = create_songlist_column("~rating")
        text = self._render_column(column)
        self.assertNotEqual(text, "0.67")

        column = create_songlist_column("~#rating")
        text = self._render_column(column)
        self.assertEqual(text, "0.67")
    def test_rating(self):
        column = create_songlist_column("~rating")
        text = self._render_column(column)
        self.assertNotEqual(text, "0.67")

        column = create_songlist_column("~#rating")
        text = self._render_column(column)
        self.assertEqual(text, "0.67")
Exemplo n.º 5
0
    def set_column_headers(self, headers):
        if len(headers) == 0:
            return

        self.handler_block(self.__csig)

        old_sort = self.get_sort_orders()
        for column in self.get_columns():
            self.remove_column(column)

        if self._first_column:
            column = self._first_column()
            self.append_column(column)

        cws = config.getstringlist("memory", "column_widths")
        column_widths = {}
        for i in range(0, len(cws), 2):
            column_widths[cws[i]] = int(cws[i + 1])

        ce = config.getstringlist("memory", "column_expands")
        column_expands = {}
        for i in range(0, len(ce), 2):
            column_expands[ce[i]] = int(ce[i + 1])

        for t in headers:
            column = create_songlist_column(t)
            if column.get_resizable():
                if t in column_widths:
                    column.set_fixed_width(column_widths[t])
                if t in column_expands:
                    column.set_expand(column_expands[t])
                else:
                    column.set_expand(True)

            def column_clicked(column, *args):
                # if ctrl is held during the sort click, append a sort key
                # or change order if already sorted
                ctrl_held = False
                event = Gtk.get_current_event()
                if event:
                    ok, state = event.get_state()
                    if ok and state & Gdk.ModifierType.CONTROL_MASK:
                        ctrl_held = True

                self.toggle_column_sort(column, replace=not ctrl_held)

            column.connect('clicked', column_clicked)
            column.connect('button-press-event', self.__showmenu)
            column.connect('popup-menu', self.__showmenu)
            column.connect('notify::width', self.__column_width_changed)
            column.set_reorderable(True)
            self.append_column(column)

        self.columns_autosize()
        self.set_sort_orders(old_sort)

        self.handler_unblock(self.__csig)
Exemplo n.º 6
0
    def set_column_headers(self, headers):
        if len(headers) == 0:
            return

        self.handler_block(self.__csig)

        old_sort = self.get_sort_orders()
        for column in self.get_columns():
            self.remove_column(column)

        if self._first_column:
            column = self._first_column()
            self.append_column(column)

        cws = config.getstringlist("memory", "column_widths")
        column_widths = {}
        for i in range(0, len(cws), 2):
            column_widths[cws[i]] = int(cws[i + 1])

        ce = config.getstringlist("memory", "column_expands")
        column_expands = {}
        for i in range(0, len(ce), 2):
            column_expands[ce[i]] = int(ce[i + 1])

        for t in headers:
            column = create_songlist_column(t)
            if column.get_resizable():
                if t in column_widths:
                    column.set_fixed_width(column_widths[t])
                if t in column_expands:
                    column.set_expand(column_expands[t])
                else:
                    column.set_expand(True)

            def column_clicked(column, *args):
                # if ctrl is held during the sort click, append a sort key
                # or change order if already sorted
                ctrl_held = False
                event = Gtk.get_current_event()
                if event:
                    ok, state = event.get_state()
                    if ok and state & qltk.get_primary_accel_mod():
                        ctrl_held = True

                self.toggle_column_sort(column, replace=not ctrl_held)

            column.connect('clicked', column_clicked)
            column.connect('button-press-event', self.__showmenu)
            column.connect('popup-menu', self.__showmenu)
            column.connect('notify::width', self.__column_width_changed)
            column.set_reorderable(True)
            self.append_column(column)

        self.set_sort_orders(old_sort)
        self.columns_autosize()

        self.handler_unblock(self.__csig)
    def test_custom_datecol_format(self):
        format = "%Y%m%d %H:%M:%S PLAINTEXT"
        quodlibet.config.settext("settings", "datecolumn_timestamp_format",
                                 format)

        d = datetime.datetime(year=1999, month=5, day=1,
                              hour=23, minute=11, second=59)
        stamp = int(time.mktime(d.timetuple()))
        column = create_songlist_column("~#added")
        text = self._render_column(column, **{"~#added": stamp})
        self.assertEqual(text, "19990501 23:11:59 PLAINTEXT")
    def test_nonconfigured_datecol_format(self):
        # make sure config option is unset by default
        text = quodlibet.config.gettext("settings",
                                        "datecolumn_timestamp_format")
        self.assertEqual(text, "")

        # make sure unset config option does not result in the
        # behaviour for testcase for set option above
        d = datetime.datetime(year=1999, month=5, day=1,
                              hour=23, minute=11, second=59)
        stamp = int(time.mktime(d.timetuple()))
        column = create_songlist_column("~#added")
        text = self._render_column(column, **{"~#added": stamp})
        self.assertNotEqual(text, "19990501 23:11:59 PLAINTEXT")
    def test_custom_datecol_format(self):
        format = "%Y%m%d %H:%M:%S PLAINTEXT"
        quodlibet.config.settext("settings", "datecolumn_timestamp_format",
                                 format)

        d = datetime.datetime(year=1999,
                              month=5,
                              day=1,
                              hour=23,
                              minute=11,
                              second=59)
        stamp = int(time.mktime(d.timetuple()))
        column = create_songlist_column("~#added")
        text = self._render_column(column, **{"~#added": stamp})
        self.assertEqual(text, "19990501 23:11:59 PLAINTEXT")
Exemplo n.º 10
0
    def set_column_headers(self, headers):
        if len(headers) == 0:
            return

        self.handler_block(self.__csig)

        old_sort = self.is_sorted() and self.get_sort_by()
        for column in self.get_columns():
            self.remove_column(column)

        if self._first_column:
            column = self._first_column()
            self.append_column(column)

        cws = config.getstringlist("memory", "column_widths")
        column_widths = {}
        for i in range(0, len(cws), 2):
            column_widths[cws[i]] = int(cws[i + 1])

        ce = config.getstringlist("memory", "column_expands")
        column_expands = {}
        for i in range(0, len(ce), 2):
            column_expands[ce[i]] = int(ce[i + 1])

        for t in headers:
            column = create_songlist_column(t)
            if column.get_resizable():
                if t in column_widths:
                    column.set_fixed_width(column_widths[t])
                if t in column_expands:
                    column.set_expand(column_expands[t])
                else:
                    column.set_expand(True)

            column.connect('clicked', self.set_sort_by)
            column.connect('button-press-event', self.__showmenu)
            column.connect('popup-menu', self.__showmenu)
            column.connect('notify::width', self.__column_width_changed)
            column.set_reorderable(True)
            self.append_column(column)

        self.columns_autosize()
        if old_sort:
            header, order = old_sort
            self.set_sort_by(None, header, order, False)

        self.handler_unblock(self.__csig)
Exemplo n.º 11
0
    def test_nonconfigured_datecol_format(self):
        # make sure config option is unset by default
        text = quodlibet.config.gettext("settings",
                                        "datecolumn_timestamp_format")
        self.assertEqual(text, "")

        # make sure unset config option does not result in the
        # behaviour for testcase for set option above
        d = datetime.datetime(year=1999,
                              month=5,
                              day=1,
                              hour=23,
                              minute=11,
                              second=59)
        stamp = int(time.mktime(d.timetuple()))
        column = create_songlist_column("~#added")
        text = self._render_column(column, **{"~#added": stamp})
        self.assertNotEqual(text, "19990501 23:11:59 PLAINTEXT")
Exemplo n.º 12
0
 def test_bpm(self):
     column = create_songlist_column("bpm")
     text = self._render_column(column, **{"bpm": "123"})
     self.assertEqual(text, "123")
Exemplo n.º 13
0
 def test_initialkey(self):
     column = create_songlist_column("initialkey")
     text = self._render_column(column, **{"initialkey": "F"})
     self.assertEqual(text, "F")
Exemplo n.º 14
0
 def test_artist(self):
     column = create_songlist_column("artist")
     self._render_column(column)
Exemplo n.º 15
0
 def test_people(self):
     column = create_songlist_column("~people")
     self._render_column(column)
Exemplo n.º 16
0
 def test_basename(self):
     column = create_songlist_column("~basename")
     self._render_column(column)
Exemplo n.º 17
0
 def test_pattern(self):
     column = create_songlist_column("<artist>-<album>")
     self._render_column(column)
 def test_filesize(self):
     column = create_songlist_column("~#filesize")
     self._render_column(column)
 def test_people(self):
     column = create_songlist_column("~people")
     self._render_column(column)
Exemplo n.º 20
0
 def test_length(self):
     column = create_songlist_column("~length")
     self._render_column(column)
Exemplo n.º 21
0
 def test_filesize(self):
     column = create_songlist_column("~#filesize")
     self._render_column(column)
 def test_bitrate(self):
     column = create_songlist_column("~#bitrate")
     self._render_column(column)
 def test_basename(self):
     column = create_songlist_column("~basename")
     self._render_column(column)
 def test_pattern(self):
     column = create_songlist_column("<artist>-<album>")
     self._render_column(column)
 def test_length(self):
     column = create_songlist_column("~length")
     self._render_column(column)
Exemplo n.º 26
0
 def test_bitrate(self):
     column = create_songlist_column("~#bitrate")
     self._render_column(column)
 def test_rating(self):
     column = create_songlist_column("~rating")
     self._render_column(column)
 def test_artist(self):
     column = create_songlist_column("artist")
     self._render_column(column)