changeset 898:212d4738438d

Use the message box dialog, inform user when the path is not a directory when returning from file selector of HVSC or ROM paths. Adjust path to the "most likely" one.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 08:28:35 +0200
parents cfc20df88401
children f02613ceadcf
files src/xs_config.c
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/xs_config.c	Fri Nov 09 08:24:46 2012 +0200
+++ b/src/xs_config.c	Fri Nov 09 08:28:35 2012 +0200
@@ -1110,10 +1110,18 @@
 {
     (void) button;
     (void) user_data;
+    gchar *path, *result = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_hvsc_selector));
+    if (!xs_is_dir_path(result))
+    {
+        path = xs_get_dir_path(result);
+        xs_messagebox("Warning",
+            "Selected HVSC path '%s' does not seem like a path, adjusting to '%s'.\n",
+            result, path);
+    }
+    else
+        path = result;
 
-    /* Selection was accepted! */
-    gtk_entry_set_text(GTK_ENTRY(LUW("cfg_hvsc_path")),
-        gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_hvsc_selector)));
+    gtk_entry_set_text(GTK_ENTRY(LUW("cfg_hvsc_path")), path);
 
     /* Close file selector window */
     gtk_widget_destroy(xs_hvsc_selector);
@@ -1150,10 +1158,18 @@
 {
     (void) button;
     (void) user_data;
+    gchar *path, *result = gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_rom_selector));
+    if (!xs_is_dir_path(result))
+    {
+        path = xs_get_dir_path(result);
+        xs_messagebox("Warning",
+            "Selected ROM path '%s' does not seem like a path, adjusting to '%s'.\n",
+            result, path);
+    }
+    else
+        path = result;
 
-    /* Selection was accepted! */
-    gtk_entry_set_text(GTK_ENTRY(LUW("cfg_rom_path")),
-        gtk_file_selection_get_filename(GTK_FILE_SELECTION(xs_rom_selector)));
+    gtk_entry_set_text(GTK_ENTRY(LUW("cfg_rom_path")), path);
 
     /* Close file selector window */
     gtk_widget_destroy(xs_rom_selector);