Re: file selection
- From: Paul Santa Maria <paulsm1021 yahoo com>
- To: srinivas comodo com
- Cc: gtk-app-devel-list gnome org
- Subject: Re: file selection
- Date: Wed, 18 May 2005 12:40:06 -0700 (PDT)
Hi -
No - actually, all you need to do is:
1. Launch the file selection dialog
2. Check the return value
I've cut/pasted an example below.
'Hope that helps .. PSM
===============================================================
// Prototype
GtkWidget * mk_file_chooser ();
/*****************************************************************************
* file_open_cb: "File, Open" event handler
*
* NOTES:
* - file_open_cb can be called either via "File, Open" menu option or
* "File Open" toolbar.
*
* - It merely gets the filename and notifies the application object
* (via the "setNewFileName ()" method) to actually read the file
* and re-draw the image.
*****************************************************************************
*/
void
file_open_cb (GtkWidget *widget, gpointer data)
{
// Create file dialog
GtkWidget *filesel = mk_file_chooser ();
// Run as a modal dialog: use gtk_dialog_run() (vs. "gtk_widget_show ()")
gint result = gtk_dialog_run (GTK_DIALOG(filesel));
// If GTK_RESPONSE_ACCEPT (-5), then notify the application object
switch (result)
{
case GTK_RESPONSE_OK:
case GTK_RESPONSE_ACCEPT:
theApp->setNewFileName (
gtk_file_selection_get_filename (
GTK_FILE_SELECTION (filesel)));
break;
case GTK_RESPONSE_CANCEL:
default:
fprintf (stderr, "NO ACTION: File selection CANCELLED!\n");
break;
}
// Done: de-allocate the dialog
gtk_widget_destroy (filesel);
}
/*****************************************************************************
* mk_file_chooser: Create popup file selection dialog
*****************************************************************************
*/
GtkWidget *
mk_file_chooser ()
{
GtkWidget *filew = gtk_file_selection_new ("File selection");
// Disable the (dangerous!) "rename file" and "delete file" options
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (filew));
// Set filename
gtk_file_selection_set_filename (GTK_FILE_SELECTION(filew),
"data/*.hbs");
/* NOTE:
* We do *not* need to register any callbacks: we'll just check
* the return status and, if GTK_RESPONSE_OK (-5), we'll read the filename
*/
return filew;
}
Message: 2
Date: Mon, 16 May 2005 21:00:51 -0400
From: Antonio Gomes <tonikitoo gmail com>
Subject: Re: file selection
To: srinivas comodo com
Cc: gtk-app-devel-list gnome org
Message-ID: <7eb9ad7105051618004309fa30 mail gmail com>
Content-Type: text/plain; charset=ISO-8859-1
why don't you take a look at the gtk_file_chooser's source code ?
regards
On 5/12/05, srinivas <srinivas comodo com> wrote:
hi;
i used
filew = gtk_file_selection_new ("Folder Selection");
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filew), "***.png");
gtk_file_selection_get_filename (GTK_FILE_SELECTION (filew));
gtk_widget_show(filew);
to select and display file/folder list, i can able to display widget,
but i can't able to select the file. no buttons in the widget as delete
file, rename, cancel and ok are not working. what else i have to include
in my pgm to get that functionality.
thanks;
vasu
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]