2010-07-03 12 views

Répondre

5

Malheureusement, je ne pense pas que ce soit possible. J'ai joué un peu avec ça dans le dialogue "créer un torrent" dans Transmission, et j'ai fini par utiliser un radibox pour activer l'un des deux boutons de sélection, l'un en mode fichier et l'autre en mode dossier.

1

Vous pouvez ajouter un autre bouton. Voici un petit exemple qui illustre comment vous pourriez le faire.

void filechooser(GtkWidget* widget, gpointer data) { 
    // we will pass the filepath by reference 
    string* filepath = (string*) data; 
    GtkWidget *dialog = gtk_file_chooser_dialog_new(
     "Open File", NULL, 
     GTK_FILE_CHOOSER_ACTION_OPEN, 
     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); 
    // add a button which allows the user to select a folder 
    const guint selected = 0; // response from the button 
    gtk_dialog_add_button(GTK_DIALOG(dialog),"Select",selected); 
    // get the path the user selected 
    guint response = gtk_dialog_run(GTK_DIALOG(dialog)); 
    if(response == GTK_RESPONSE_ACCEPT || response == selected){ 
     *filepath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); 
    } 
    gtk_widget_destroy(dialog); 
} 

Notez que le bouton « Sélectionner » dans mon exemple fait la même action que « Open » si un fichier est sélectionné, il est seulement vraiment différent pour les dossiers.