Re: gtk_file_selection_new
- From: John Cupitt ng-london org uk
- To: chip_rodden hotmail com
- Cc: gtk-list gnome org
- Subject: Re: gtk_file_selection_new
- Date: Mon, 21 Jan 2002 12:17:51 -0000
Chip Rodden wrote:
> I'm trying to modify a gtk program which uses a file selection
> widget.(gtk_file_selection_new) I have maybe 3 hours of experience
> looking at gtk code so I'm fairly clueless. What I am trying to do is
> to limit the user to just one directory where he can open from or save
> files to.
Hi Chip, you need to hide the widgets you don't want:
#include <gtk/gtk.h>
int
main( int argc, char **argv )
{
GtkWidget *fsb;
GtkWidget *but;
GtkWidget *wid;
gtk_set_locale();
gtk_init( &argc, &argv );
fsb = gtk_file_selection_new( "" );
gtk_widget_hide( GTK_FILE_SELECTION( fsb )->dir_list->parent );
gtk_widget_hide( GTK_FILE_SELECTION( fsb )->history_pulldown );
gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION( fsb ) );
gtk_widget_show( fsb );
gtk_main();
return( 0 );
}
This isn't bulletproof though :-( for example, a user could type
"../fred" and select a file in the parent directory.
You'll need to either also get rid of the text selection area and do
that stuff yourself, or carefully sanity check the results of the dialog
and pop and error box if you think the user is messing about.
John
==========================================================
Coming soon:
Aelbert Cuyp 13 February - 12 May 2002
For information and tickets:
http://www.nationalgallery.org.uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]