Re: GtkFileChooser (I figured it out ! - finally)
- From: David <dbree duo-county com>
- To: gtk-app-devel-list gnome org
- Subject: Re: GtkFileChooser (I figured it out ! - finally)
- Date: Thu, 2 Dec 2004 16:55:03 -0600
On Thu, Dec 02, 2004 at 12:35:00PM -0800, Harring Figueiredo wrote:
I finally figured it out... if we use any of the responses:
GTK_RESPONSE_ACCEPT
GTK_RESPONSE_OK
GTK_RESPONSE_YES
GTK_RESPONSE_APPLY
then, the dialog may decide to do something else and not close the dialog:
From the docs:
"This is because GtkFileChooserDialog must intercept responses and switch to
folders if appropriate, rather than letting the dialog terminate ? the
implementation uses these known response codes to know which responses can be
blocked if appropriate."
All I had to do was to come up with my own response ID.
That's odd.. If I understand your query correctly, I did something
similar to what you want using GTK_RESPONSE_ACCEPT and it performs
correctly. Here's the function I did..
This is a multi-purpose open function, used for either selecting a file
or folder, but if I pass FALSE for IsFile, it does, indeed, show only
directories and returns upon clicking on a directory.
--------------- cut ----------------
void
selectfile_open (glbls * hbuf, gchar * type, gboolean IsFile)
{
GtkWidget *fsel;
gchar *title = g_strconcat ("Select a ", type, NULL);
gint action_type;
if (IsFile)
{
action_type = GTK_FILE_CHOOSER_ACTION_OPEN;
}
else
{
action_type = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
}
hbuf->filename_to_return = NULL;
fsel = gtk_file_chooser_dialog_new (title,
GTK_WINDOW (window),
action_type,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL); /* Leak??? */
g_free (title);
if (gtk_dialog_run (GTK_DIALOG (fsel)) == GTK_RESPONSE_ACCEPT)
{
hbuf->filename_to_return =
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fsel));
}
gtk_widget_destroy (fsel);
}
------------------ cut ---------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]