Comment récupérer le fichier sélectionné avec un widget gtk_recent_chooser_dialog_new
Ci-dessous voici mon code de demo

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <gtk/gtk.h>
    //recentchooserdialog.c
    /*
    gcc -std=c11 -Wall -fmax-errors=10 -Wextra recentchooserdialog.c -o recentchooserdialog `pkg-config --cflags --libs gtk+-3.0 `
    */
 
    int main(int argc, char *argv[])
    {    
        gtk_init(&argc, &argv);
        gboolean multiple = FALSE;
        //GList * files;
        GtkRecentInfo *info;
        gchar *chemin = NULL;
 
        GtkWidget *recentchooserdialog = gtk_recent_chooser_dialog_new("RecentChooserDialog", NULL, 
    							("_Cancel"), GTK_RESPONSE_CANCEL, 
    							("_Open"), GTK_RESPONSE_OK, NULL);
 
    	gtk_recent_chooser_set_limit(GTK_RECENT_CHOOSER(recentchooserdialog),-1);
    	gtk_recent_chooser_set_show_tips(GTK_RECENT_CHOOSER(recentchooserdialog),TRUE);
    	gtk_recent_chooser_set_select_multiple(GTK_RECENT_CHOOSER(recentchooserdialog), multiple);
 
        if (gtk_dialog_run(GTK_DIALOG(recentchooserdialog)) == GTK_RESPONSE_OK)
    	{
    		info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (recentchooserdialog));
    		if (multiple==TRUE)
    		{
    			/** how to get file names selected here **/
 
    		}
    		else
    		{
    			/** how to get one single filename selected here **/
    			// GtkRecentInfo *info;
    			info = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (recentchooserdialog));
    			if (info)
    				g_print("structur info exists\n ");
    			/* below is not the good casting */
                chemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(recentchooserdialog));
                g_print("selected path %s\n",chemin);
    		}
    		gtk_recent_info_unref (info);
    	}
    	gtk_widget_destroy (recentchooserdialog);
        return 0;
    }
Après de multiples recherches infructueuses je n'ai rien trouvé d'inspirant
Alors que pour un widget gtk_file_chooser_dialog_new on trouve la commande qui va bien avec

gtk_file_chooser_get_filename ou gtk_file_chooser_get_filenames action
j'ai du raté quelques peu le lien d'héritage et le bon niveau commun entre un gtk_file_chooser_dialog et un gtk_recent_chooser_dialog


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void cb_open (GtkWidget *widget, gpointer user_data)
    {
      GtkWidget *dialog = NULL;
      GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
 
      dialog = gtk_file_chooser_dialog_new ("Ouvrir un fichier", NULL,
                                              action,
                                              ("_Cancel"),
                                              GTK_RESPONSE_CANCEL,
                                              ("_Open"),
                                              GTK_RESPONSE_ACCEPT,
                                              NULL);
 
      if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
      {
        gchar *file_name = NULL;
 
        file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        g_print("fichier ouvert : %s \n",file_name);
 
        g_free (file_name), file_name = NULL;
      }
      gtk_widget_destroy (dialog);
    }
Quel serait l'action à passer pour récupérer une sélection multiple et surtout un chemin de fichier valide

Merci d'avance de l'aide apportée