Пример #1
0
 def __expanded(self, iter, path, model):
     window = self.get_window()
     if window:
         window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
         Gtk.main_iteration_do(False)
     try:
         try:
             if model is None:
                 return
             while model.iter_has_child(iter):
                 model.remove(model.iter_children(iter))
             folder = model[iter][0]
             for path in listdir(folder):
                 try:
                     if not os.path.isdir(path):
                         continue
                     for filename in listdir(path):
                         if os.path.isdir(filename):
                             niter = model.append(iter, [path])
                             model.append(niter, ["dummy"])
                             break
                     else:
                         model.append(iter, [path])
                 except OSError:
                     pass
             if not model.iter_has_child(iter):
                 return True
         except OSError:
             pass
     finally:
         if window:
             window.set_cursor(None)
Пример #2
0
 def __expanded(self, iter, path, model):
     window = self.get_window()
     if window:
         window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
         Gtk.main_iteration_do(False)
     try:
         try:
             if model is None:
                 return
             while model.iter_has_child(iter):
                 model.remove(model.iter_children(iter))
             folder = model[iter][0]
             for path in listdir(folder):
                 try:
                     if not os.path.isdir(path):
                         continue
                     for filename in listdir(path):
                         if os.path.isdir(filename):
                             niter = model.append(iter, [path])
                             model.append(niter, ["dummy"])
                             break
                     else:
                         model.append(iter, [path])
                 except OSError:
                     pass
             if not model.iter_has_child(iter):
                 return True
         except OSError:
             pass
     finally:
         if window:
             window.set_cursor(None)
Пример #3
0
    def __dir_selection_changed(self, selection, filelist):
        # dir selection changed, refill the file list

        fselect = filelist.get_selection()
        fselect.handler_block(self.__sig)
        fmodel, frows = fselect.get_selected_rows()
        selected = [fmodel[row][0] for row in frows]

        fmodel = filelist.get_model()
        fmodel.clear()
        dmodel, rows = selection.get_selected_rows()
        dirs = [dmodel[row][0] for row in rows]
        for dir_ in dirs:
            try:
                files = filter(self.__filter, listdir(dir_))
                for file_ in sorted(files):
                    filename = os.path.join(dir_, file_)
                    if (os.access(filename, os.R_OK) and
                            not os.path.isdir(filename)):
                        fmodel.append([filename])
            except OSError:
                pass

        for iter_, filename in fmodel.iterrows():
            if filename in selected:
                fselect.select_iter(iter_)

        fselect.handler_unblock(self.__sig)
        fselect.emit('changed')
Пример #4
0
    def __dir_selection_changed(self, selection, filelist):
        # dir selection changed, refill the file list

        fselect = filelist.get_selection()
        fselect.handler_block(self.__sig)
        fmodel, frows = fselect.get_selected_rows()
        selected = [fmodel[row][0] for row in frows]

        fmodel = filelist.get_model()
        fmodel.clear()
        dmodel, rows = selection.get_selected_rows()
        dirs = [dmodel[row][0] for row in rows]
        for dir_ in dirs:
            try:
                files = filter(self.__filter, listdir(dir_))
                for file_ in sorted(files):
                    filename = os.path.join(dir_, file_)
                    if (os.access(filename, os.R_OK)
                            and not os.path.isdir(filename)):
                        fmodel.append([filename])
            except OSError:
                pass

        for iter_, filename in fmodel.iterrows():
            if filename in selected:
                fselect.select_iter(iter_)

        fselect.handler_unblock(self.__sig)
        fselect.emit('changed')