Enforcing response codes in GtkFileChooserDialog



Hi,

GtkFileChooserDialog expects that it will have an "accept"-type button
with one of these response codes:

	GTK_RESPONSE_ACCEPT
	GTK_RESPONSE_OK
	GTK_RESPONSE_YES
	GTK_RESPONSE_APPLY

However, there are no checks to ensure that such a button actually
exists.  With the current state of
gtkfilechooserdefault.c:response_cb(), 
what happens if a file chooser dialog doesn't have a button with one
of those response codes is this:

1. You open a file chooser dialog for opening files.

2. Click on a folder in the file list, or select it using the
   keyboard.

3. Press Enter.  This will terminate the dialog, rather than making it
   visit the folder you chose.

This is bug #138263 in Epiphany, for which I wrote a simple patch.

I'm thinking that response_cb() should enforce having such a button.
What do people think of having something like this in it:

  if (!has_one_of_those_buttons (dialog))
    g_warning ("GtkFileChooserDialog expects to have at least one "
               "button with a response code of GTK_RESPONSE_ACCEPT, "
               "GTK_RESPONSE_OK, GTK_RESPONSE_YES, or "
               "GTK_RESPONSE_APPLY.  Please use one of these response "
               "codes rather than a custom one.");

I updated the reference docs to note this quirk.

  Federico





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