On Mon, 2003-01-20 at 07:54, Ahmad Baitalmal wrote:
> For multiple file selection, gtk.FileSelection.get_selections does not
> seem to be available in 1.99.14
> What am I missing?
Attached is my hack to add the missing get_selections functionality to
the GtkFileSelector. I was unable to convince my boss to ship a CVS of
Python/GTK (which fixes your problem) so I had to add the functionality
in Python.
It is not the most elegant code you'll ever see, but it seems to work...
--
Michael JasonSmith http://www.cosc.canterbury.ac.nz/~mpj17/
import gtk
import os, os.path
class MultipleFileSelector(gtk.FileSelection):
def __init__(self):
gtk.FileSelection.__init__(self, 'Select Files')
self.hide_fileop_buttons()
self.set_select_multiple(1)
self.file_list.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.ok_cb = ok_cb
self.cancel_cb = cancel_cb
self.show_all()
def get_select_multiple(self):
dirname = os.path.dirname(self.get_filename())
retval = []
selection = self.file_list.get_selection()
store = self.file_list.get_model()
iter = store.get_iter_first()
while iter != None:
if selection.iter_is_selected(iter):
filename = "%s%s%s" % (dirname, os.sep,
store.get_value(iter, 0))
retval.append(filename)
iter = store.iter_next(iter)
return retval