]> git.plutz.net Git - gladerunner/commitdiff
handle canceling of file dialogs
authorPaul Hänsch <paul@plutz.net>
Mon, 10 Aug 2026 19:39:54 +0000 (21:39 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 10 Aug 2026 19:39:54 +0000 (21:39 +0200)
gladerunner.c

index 6429cb253997eb76c479a67d8f5ec4c74b057e38..c5fe15b41a0b11a19571d8b15d240ebcc27c2cbf 100644 (file)
@@ -118,8 +118,12 @@ void e_filechooser_activate(GtkWidget *wdg, gpointer user_data) {
 void e_filechooser_response(GtkNativeDialog *wdg, gint id, gpointer user_data) {
   GtkFileChooser *e = GTK_FILE_CHOOSER(wdg);
   char *file = gtk_file_chooser_get_filename(e);
-  printf("%s %i\n%s\n", user_data, strlen(file), file);
-  free(file);
+  if (file) {
+    printf("%s %i\n%s\n", user_data, strlen(file), file);
+    free(file);
+  } else {
+    printf("%s CANCEL\n", user_data);
+  }
 }
 
 gboolean s_switch_state_set(GtkWidget *wdg, gboolean state, gpointer d) {