- file_dialog = gtk_file_selection_new(FILENAME_DESCRIPTION);
-
- /* Connect the file dialog's OK button up to a handler. */
- gtk_signal_connect(
- GTK_OBJECT(GTK_FILE_SELECTION(file_dialog)->ok_button),
- "clicked", GTK_SIGNAL_FUNC(FileOpenDialog_OK), file_dialog);
-
- /*
- * Ensure that the file selection dialog box is destroyed when the user
- * clicks CANCEL.
- */
- gtk_signal_connect_object(
- GTK_OBJECT(GTK_FILE_SELECTION(file_dialog)->cancel_button),
- "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy),
- (gpointer) file_dialog);
-
- /* Show the dialog. */
- gtk_widget_show(GTK_WIDGET(file_dialog));
-
- /*
- * To have the main window of our application being unusable while
- * using the dialog.
- */
- gtk_window_set_modal(GTK_WINDOW(file_dialog), TRUE);
+ file_dialog = gtk_file_chooser_dialog_new(
+ FILENAME_DESCRIPTION, NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+
+ if (strlen(previous_folder) == 0) {
+ /* Opening file chooser to current working directory. */
+ cwd = g_get_current_dir();
+ dir = cwd;
+ } else {
+ /* Opening file chooser to previous opened directory. */
+ dir = previous_folder;
+ }
+
+ gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(file_dialog), dir);
+
+ if (cwd)
+ g_free(cwd);
+
+ if (gtk_dialog_run(GTK_DIALOG(file_dialog)) == GTK_RESPONSE_ACCEPT) {
+ char *selected_file;
+
+ selected_file = gtk_file_chooser_get_filename(
+ GTK_FILE_CHOOSER(file_dialog));
+
+ if (selected_file != NULL) {
+ log_info("emugtk_File = %s", selected_file);
+
+ remember_current_folder(GTK_FILE_CHOOSER(file_dialog));
+
+ emugtk_new_file(selected_file);
+ g_free(selected_file);
+ }
+ }
+
+ gtk_widget_destroy(file_dialog);