tags:

views:

175

answers:

1

In my code, I have lines like this:

Builder builder = new Builder();
builder.AddFromFile(gladefile);
FileChooserDialog dialog =
    (FileChooserDialog) builder.GetObject("dialog");

dialog.DefaultResponse = ResponseType.Ok;

Is there a way to set the default response in the glade file, rather than doing it manually?

+1  A: 

Yes. When you create a GtkFileChooserDialog in Glade, you add the buttons to the dialog's button box. For example, "OK" and "Cancel". To make the "OK" button default, select the "OK" button, go to the "Common" properties, and turn on "Can default" and "Has default".

ptomato
It looks like I have to put in the actual integer value of the response. Is there a way to use Gtk constants for this?
Matthew
I'm not sure what you mean. In code, you set the default response by passing a specific integer response code. In Glade, you can't do that, instead you set the default response by picking the actual default button.As far as I can tell, what happens when you call `dialog.DefaultResponse = ResponseType.Ok` is that GTK looks for the _last_ button in the dialog that generates that specific response code, and sets that button to be the default. In Glade, you can only circumvent that, and directly set a button to be default. You don't need to (and can't) put in a response code.
ptomato