Ejemplo n.º 1
0
 def test_initial(self):
     for path in ["/", "/home", os.environ["HOME"], "/usr/bin"]:
         dirlist = DirectoryTree(path)
         model, rows = dirlist.get_selection().get_selected_rows()
         selected = [model[row][0] for row in rows]
         dirlist.destroy()
         self.failUnlessEqual([path], selected)
Ejemplo n.º 2
0
 def test_bad_initial(self):
     for path in ["/", os.environ["HOME"]]:
         newpath = os.path.join(path, "bin/file/does/not/exist")
         dirlist = DirectoryTree(newpath)
         model, rows = dirlist.get_selection().get_selected_rows()
         selected = [model[row][0] for row in rows]
         dirlist.destroy()
         self.failUnlessEqual([path], selected)
Ejemplo n.º 3
0
 def test_popup(self):
     dt = DirectoryTree(None, folders=self.ROOTS)
     menu = dt._create_menu()
     dt._popup_menu(menu)
     children = menu.get_children()
     self.failUnlessEqual(len(children), 4)
     delete = children[1]
     self.failUnlessEqual(delete.get_label(), __("_Delete"))
     self.failUnless(delete.get_sensitive())
Ejemplo n.º 4
0
 def test_popup(self):
     dt = DirectoryTree(None, folders=self.ROOTS)
     menu = dt._create_menu()
     dt._popup_menu(menu)
     children = menu.get_children()
     self.failUnlessEqual(len(children), 4)
     delete = children[1]
     self.failUnlessEqual(delete.get_label(), __("_Delete"))
     self.failUnless(delete.get_sensitive())
Ejemplo n.º 5
0
 def test_bad_initial(self):
     invalid = os.path.join("bin", "file", "does", "not", "exist")
     for path in self.ROOTS:
         newpath = os.path.join(path, invalid)
         dirlist = DirectoryTree(newpath, folders=self.ROOTS)
         selected = dirlist.get_selected_paths()
         dirlist.destroy()
         # select the last valid parent directory
         self.assertEqual(len(selected), 1)
         self.assertTrue(selected[0].startswith(path))
Ejemplo n.º 6
0
 def test_bad_initial(self):
     invalid = os.path.join("bin", "file", "does", "not", "exist")
     for path in self.ROOTS:
         newpath = os.path.join(path, invalid)
         dirlist = DirectoryTree(newpath, folders=self.ROOTS)
         selected = dirlist.get_selected_paths()
         dirlist.destroy()
         # select the last valid parent directory
         self.assertEqual(len(selected), 1)
         self.assertTrue(selected[0].startswith(path))
Ejemplo n.º 7
0
    def test_initial(self):
        paths = ["/", get_home_dir(), "/usr/bin"]
        if os.name == "nt":
            paths = [u"C:\\", get_home_dir()]

        for path in paths:
            dirlist = DirectoryTree(path, folders=self.ROOTS)
            model, rows = dirlist.get_selection().get_selected_rows()
            selected = [model[row][0] for row in rows]
            dirlist.destroy()
            self.failUnlessEqual([path], selected)
Ejemplo n.º 8
0
    def test_initial(self):
        paths = ["/", get_home_dir(), "/usr/bin"]
        if os.name == "nt":
            paths = [u"C:\\", get_home_dir()]

        for path in paths:
            dirlist = DirectoryTree(path, folders=self.ROOTS)
            model, rows = dirlist.get_selection().get_selected_rows()
            selected = [model[row][0] for row in rows]
            dirlist.destroy()
            self.failUnlessEqual([path], selected)
Ejemplo n.º 9
0
    def test_initial(self):
        if os.name == "nt":
            paths = [u"C:\\", get_home_dir()]
        else:
            paths = ["/", get_home_dir(), sys.prefix]

        for path in paths:
            dirlist = DirectoryTree(path, folders=self.ROOTS)
            model, rows = dirlist.get_selection().get_selected_rows()
            selected = [model[row][0] for row in rows]
            dirlist.destroy()
            self.failUnlessEqual([os.path.normpath(path)], selected)
Ejemplo n.º 10
0
 def test_multiple_selections(self):
     dt = DirectoryTree(None, folders=self.ROOTS)
     menu = dt._create_menu()
     dt._popup_menu(menu)
     children = menu.get_children()
     select_sub = children[3]
     self.failUnless("sub-folders" in select_sub.get_label().lower())
     self.failUnless(select_sub.get_sensitive())
     sel = dt.get_selection()
     model = dt.get_model()
     for it, pth in model.iterrows(None):
         sel.select_iter(it)
     self.failUnless(select_sub.get_sensitive(),
                     msg="Select All should work for multiple")
     self.failIf(children[0].get_sensitive(),
                 msg="New Folder should be disabled for multiple")
     self.failUnless(children[3].get_sensitive(),
                     msg="Refresh should be enabled for multiple")
Ejemplo n.º 11
0
    def __init__(self, library, main):
        super(FileSystem, self).__init__()
        sw = ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)

        folders = filter(None, split_scan_dirs(config.get("settings", "scan")))

        dt = DirectoryTree(folders=folders)
        targets = [("text/x-quodlibet-songs", gtk.TARGET_SAME_APP, 1),
                   ("text/uri-list", 0, 2)]
        dt.drag_source_set(gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
        dt.connect('drag-data-get', self.__drag_data_get)

        sel = dt.get_selection()
        sel.unselect_all()
        sel.connect_object('changed', copool.add, self.__songs_selected, dt)
        if main:
            dt.connect('row-activated', lambda *a: self.emit("activated"))
        sw.add(dt)
        self.pack_start(sw)
        self.show_all()
Ejemplo n.º 12
0
 def test_multiple_selections(self):
     dt = DirectoryTree(None, folders=self.ROOTS)
     menu = dt._create_menu()
     dt._popup_menu(menu)
     children = menu.get_children()
     select_sub = children[3]
     self.failUnless("sub-folders" in select_sub.get_label().lower())
     self.failUnless(select_sub.get_sensitive())
     sel = dt.get_selection()
     model = dt.get_model()
     for it, pth in model.iterrows(None):
         sel.select_iter(it)
     self.failUnless(select_sub.get_sensitive(),
                     msg="Select All should work for multiple")
     self.failIf(children[0].get_sensitive(),
                 msg="New Folder should be disabled for multiple")
     self.failUnless(children[3].get_sensitive(),
                     msg="Refresh should be enabled for multiple")
Ejemplo n.º 13
0
 def test_bad_go_to(self):
     newpath = fsnative(u"/woooooo/bar/fun/broken")
     dirlist = DirectoryTree(fsnative(u"/"), folders=self.ROOTS)
     dirlist.go_to(newpath)
     dirlist.destroy()
Ejemplo n.º 14
0
 def test_bad_go_to(self):
     newpath = fsnative(u"/woooooo/bar/fun/broken")
     dirlist = DirectoryTree(fsnative(u"/"), folders=self.ROOTS)
     dirlist.go_to(newpath)
     dirlist.destroy()
Ejemplo n.º 15
0
 def test_bad_go_to(self):
     newpath = "/woooooo/bar/fun/broken"
     dirlist = DirectoryTree("/")
     dirlist.go_to(newpath)
     dirlist.destroy()
 def test_bad_go_to(self):
     newpath = "/woooooo/bar/fun/broken"
     dirlist = DirectoryTree("/", folders=self.ROOTS)
     dirlist.go_to(newpath)
     dirlist.destroy()