Advertisement
effemmeffe

gtk filechooser

Dec 6th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. void FileChooser(GtkWidget *widget, ChData *data)
  2. {
  3.     GtkWidget *dialog;
  4.     GtkFileChooser *chooser;
  5.     GtkFileChooserAction action;
  6.     gchar *filename;
  7.     gint res;
  8.  
  9.  
  10.     action = GTK_FILE_CHOOSER_ACTION_OPEN;
  11.  
  12.     dialog = gtk_file_chooser_dialog_new("Open File",
  13.                                          GTK_WINDOW(data->MainWindow),
  14.                                          action,
  15.                                          "_Cancel",
  16.                                          GTK_RESPONSE_CANCEL,
  17.                                          "_Open",
  18.                                          GTK_RESPONSE_ACCEPT,
  19.                                          NULL);
  20.  
  21.     res = gtk_dialog_run(GTK_DIALOG(dialog));
  22.     if (res == GTK_RESPONSE_ACCEPT)
  23.     {
  24.         chooser = GTK_FILE_CHOOSER(dialog);
  25.         gtk_file_chooser_set_select_multiple (chooser, TRUE);
  26.         filename = gtk_file_chooser_get_filename(chooser);
  27.  
  28.         g_free(filename);
  29.     }
  30.  
  31.     gtk_widget_destroy(dialog);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement