Ejemplo n.º 1
0
 def test_basic(self):
     self.failIf(get_scan_dirs())
     if os.name == "nt":
         set_scan_dirs([u"C:\\foo", u"D:\\bar", u""])
         self.failUnlessEqual(get_scan_dirs(), [u"C:\\foo", u"D:\\bar"])
     else:
         set_scan_dirs(["foo", "bar", ""])
         self.failUnlessEqual(get_scan_dirs(), ["foo", "bar"])
Ejemplo n.º 2
0
 def test_basic(self):
     self.failIf(get_scan_dirs())
     if os.name == "nt":
         set_scan_dirs([u"C:\\foo", u"D:\\bar", u""])
         self.failUnlessEqual(get_scan_dirs(), [u"C:\\foo", u"D:\\bar"])
     else:
         set_scan_dirs(["foo", "bar", ""])
         self.failUnlessEqual(get_scan_dirs(), ["foo", "bar"])
Ejemplo n.º 3
0
    def open_chooser(self, action):
        last_dir = self.last_dir
        if not os.path.exists(last_dir):
            last_dir = get_home_dir()

        class MusicFolderChooser(FolderChooser):
            def __init__(self, parent, init_dir):
                super(MusicFolderChooser,
                      self).__init__(parent, _("Add Music"), init_dir)

                cb = Gtk.CheckButton(_("Watch this folder for new songs"))
                # enable if no folders are being watched
                cb.set_active(not get_scan_dirs())
                cb.show()
                self.set_extra_widget(cb)

            def run(self):
                fns = super(MusicFolderChooser, self).run()
                cb = self.get_extra_widget()
                return fns, cb.get_active()

        class MusicFileChooser(FileChooser):
            def __init__(self, parent, init_dir):
                super(MusicFileChooser,
                      self).__init__(parent, _("Add Music"), formats.filter,
                                     init_dir)

        if action.get_name() == "AddFolders":
            dialog = MusicFolderChooser(self, last_dir)
            fns, do_watch = dialog.run()
            dialog.destroy()
            if fns:
                fns = map(glib2fsnative, fns)
                # scan them
                self.last_dir = fns[0]
                copool.add(self.__library.scan,
                           fns,
                           cofuncid="library",
                           funcid="library")

                # add them as library scan directory
                if do_watch:
                    dirs = get_scan_dirs()
                    for fn in fns:
                        if fn not in dirs:
                            dirs.append(fn)
                    set_scan_dirs(dirs)
        else:
            dialog = MusicFileChooser(self, last_dir)
            fns = dialog.run()
            dialog.destroy()
            if fns:
                fns = map(glib2fsnative, fns)
                self.last_dir = os.path.dirname(fns[0])
                for filename in map(os.path.realpath, fns):
                    self.__library.add_filename(filename)
Ejemplo n.º 4
0
    def open_chooser(self, action):
        last_dir = self.last_dir
        if not os.path.exists(last_dir):
            last_dir = get_home_dir()

        class MusicFolderChooser(FolderChooser):
            def __init__(self, parent, init_dir):
                super(MusicFolderChooser, self).__init__(
                    parent, _("Add Music"), init_dir)

                cb = Gtk.CheckButton(_("Watch this folder for new songs"))
                # enable if no folders are being watched
                cb.set_active(not get_scan_dirs())
                cb.show()
                self.set_extra_widget(cb)

            def run(self):
                fns = super(MusicFolderChooser, self).run()
                cb = self.get_extra_widget()
                return fns, cb.get_active()

        class MusicFileChooser(FileChooser):
            def __init__(self, parent, init_dir):
                super(MusicFileChooser, self).__init__(
                    parent, _("Add Music"), formats.filter, init_dir)

        if action.get_name() == "AddFolders":
            dialog = MusicFolderChooser(self, last_dir)
            fns, do_watch = dialog.run()
            dialog.destroy()
            if fns:
                fns = map(glib2fsnative, fns)
                # scan them
                self.last_dir = fns[0]
                copool.add(self.__library.scan, fns, cofuncid="library",
                           funcid="library")

                # add them as library scan directory
                if do_watch:
                    dirs = get_scan_dirs()
                    for fn in fns:
                        if fn not in dirs:
                            dirs.append(fn)
                    set_scan_dirs(dirs)
        else:
            dialog = MusicFileChooser(self, last_dir)
            fns = dialog.run()
            dialog.destroy()
            if fns:
                fns = map(glib2fsnative, fns)
                self.last_dir = os.path.dirname(fns[0])
                for filename in map(os.path.realpath, fns):
                    self.__library.add_filename(filename)
Ejemplo n.º 5
0
 def __save(self):
     set_scan_dirs(list(self.model.itervalues()))
Ejemplo n.º 6
0
 def test_set_scan_dirs_colons(self):
     set_scan_dirs([STANDARD_PATH, GVFS_PATH])
     expected = GVFS_PATH if is_windows() else GVFS_PATH_ESCAPED
     self.assertEqual(self.scan_dirs, "%s:%s" % (STANDARD_PATH, expected))
Ejemplo n.º 7
0
 def test_set_scan_dirs_multiple(self):
     set_scan_dirs([OTHER_PATH, STANDARD_PATH])
     self.assertEqual(self.scan_dirs,
                      "%s:%s" % (OTHER_PATH, STANDARD_PATH))
Ejemplo n.º 8
0
 def test_set_scan_dirs_single(self):
     set_scan_dirs([STANDARD_PATH])
     self.assertEqual(self.scan_dirs, STANDARD_PATH)
Ejemplo n.º 9
0
 def test_set_scan_dirs_empty(self):
     set_scan_dirs([])
     self.assertEqual(self.scan_dirs, "")
Ejemplo n.º 10
0
 def __save(self):
     set_scan_dirs([r[0] for r in self.model])
Ejemplo n.º 11
0
 def __save(self):
     set_scan_dirs([r[0] for r in self.model])
Ejemplo n.º 12
0
 def test_set_scan_dirs_colons(self):
     set_scan_dirs([STANDARD_PATH, GVFS_PATH])
     expected = GVFS_PATH if ON_WINDOWS else GVFS_PATH_ESCAPED
     self.assertEqual(self.scan_dirs, "%s:%s" % (STANDARD_PATH, expected))
Ejemplo n.º 13
0
 def test_set_scan_dirs_multiple(self):
     set_scan_dirs([OTHER_PATH, STANDARD_PATH])
     self.assertEqual(self.scan_dirs,
                      "%s:%s" % (OTHER_PATH, STANDARD_PATH))
Ejemplo n.º 14
0
 def test_set_scan_dirs_single(self):
     set_scan_dirs([STANDARD_PATH])
     self.assertEqual(self.scan_dirs, STANDARD_PATH)
Ejemplo n.º 15
0
 def test_set_scan_dirs_empty(self):
     set_scan_dirs([])
     self.assertEqual(self.scan_dirs, "")
Ejemplo n.º 16
0
 def __save(self):
     set_scan_dirs(list(self.model.itervalues()))