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;
} |
Partager