Re: Multiple Selection



On Wed, 2001-08-29 at 16:57, Sven Neumann wrote:
> Hi,
> 
> Thomas Mailund <mailund mailund dk> writes:
> 
> > On Wed, 2001-08-29 at 00:23, Emre Turkay wrote:
> > > How can I do multiple selection with GtkFileSelection ?
> > 
> > You can't as far as I can see, at least not directly.  The
> > GtkFileSelection class only works for selecting single files.  You can
> > probably come up with some hack to use it to select several files, but I
> > think the best solution is to either sub-class it (*), or simply use a
> > list to load the files in a directory into a list and select them from
> > there.
> 
> I don't think       
> 
>    gtk_clist_set_selection_mode (GTK_CLIST (GTK_FILE_SELECTION (filesel)->file_list),
> 				 GTK_SELECTION_EXTENDED);
> 
> counts as a hack. It's a perfectly valid and documented way to get multiple
> selections in a GtkFileSelection.

I would rather not get into an argument about the finer semantics of the
word "hack" ;), but I *do* find this solution a bit offensive.  The fact
that you need to access the nested clist, both for setting this flag and
even worse for getting the selected files, without going through the
file selection's interface, makes me a bit uncomfortable.  In my opinion
objects shouldn't "talk to strangers" in this way.  If/when the
implementation of the selection widget changes, all the code that uses
implementation details such as this will need updating.  That was why I
suggested sub-classing the widget to provide multiple selection.  This
would provide an interface through which the same functionality could be
accessed, but where the actual implementation could be hidden.  Should
the FileSelection class change, the derived class would probably need
updating, but as long as the interface doesn't change, all other objects
using the derived class would continue to work unchanged.

But if this is the documented way to achive multiple file selection, I
guess it is safe from interface changes in the near future anyway.
Furthermore, if this is the idiom of the tool-kit I guess it is safer to
write code in this style rather than to take my advice and subclass.  In
this way more people will be familiar with the construction and will
have easier with reading the code.  As a general rule, though, I
wouldn't recommend accessing the data in any gtk object without going
through an interface function.

Anyway...I'm drifting off topic...you are probably right, it is not
really that hacky and I'm just being difficult...I'll just leave quietly
now...

	/mailund

-- 
Truth is not found in asking those who know, but in asking those no
one would think have the answers.
                                              -- John Murphy

Attachment: pgpWtm64MZ4lV.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]