Created
December 12, 2017 17:49
-
-
Save kion-dgl/14b9824072085acd65ef71f567aef3da to your computer and use it in GitHub Desktop.
Setting default name of an image using the GTK file chooser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void open_export(GApplication *app, gpointer user_data) { | |
GtkWidget *dialog; | |
gint res; | |
dialog = gtk_file_chooser_dialog_new ( | |
"Save Texture (.png)", | |
GTK_WINDOW(user_data), | |
GTK_FILE_CHOOSER_ACTION_SAVE, | |
"Cancel", | |
GTK_RESPONSE_CANCEL, | |
"Save", | |
GTK_RESPONSE_ACCEPT, | |
NULL | |
); | |
// Problem start: filename and folder are not set | |
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER(dialog), TRUE); | |
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), "~/Pictures"); | |
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER(dialog), "texture.png"); | |
res = gtk_dialog_run (GTK_DIALOG (dialog)); | |
// Problem end | |
if(res == GTK_RESPONSE_ACCEPT) { | |
char *filename; | |
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog)); | |
g_print("The user selected filename: %s\n", filename); | |
g_free (filename); | |
} | |
gtk_widget_destroy (dialog); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment