Search
lxdream.org :: lxdream/src/gtkui/gtkcb.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/gtkcb.c
changeset 630:50addb748df5
prev561:533f6b478071
next669:ab344e42bca9
author nkeynes
date Tue Feb 12 08:36:29 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Bug #55: Fix relative path handling
Canonicalize paths before passing to the file dialog
file annotate diff log raw
1.1 --- a/src/gtkui/gtkcb.c Tue Jan 01 05:08:38 2008 +0000
1.2 +++ b/src/gtkui/gtkcb.c Tue Feb 12 08:36:29 2008 +0000
1.3 @@ -43,13 +43,14 @@
1.4 gchar const *initial_dir )
1.5 {
1.6 GtkWidget *file;
1.7 + gchar *initial_path = get_absolute_path(initial_dir);
1.8 file = gtk_file_chooser_dialog_new( title, NULL,
1.9 GTK_FILE_CHOOSER_ACTION_OPEN,
1.10 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1.11 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1.12 NULL );
1.13 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
1.14 - gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_dir );
1.15 + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );
1.16 gtk_window_set_modal( GTK_WINDOW(file), TRUE );
1.17 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );
1.18 int result = gtk_dialog_run( GTK_DIALOG(file) );
1.19 @@ -58,19 +59,21 @@
1.20 action( filename );
1.21 }
1.22 gtk_widget_destroy(file);
1.23 + g_free(initial_path);
1.24 }
1.25
1.26 void save_file_dialog( char *title, file_callback_t action, char *pattern, char *patname,
1.27 gchar const *initial_dir )
1.28 {
1.29 GtkWidget *file;
1.30 + gchar *initial_path = get_absolute_path(initial_dir);
1.31 file = gtk_file_chooser_dialog_new( title, NULL,
1.32 GTK_FILE_CHOOSER_ACTION_SAVE,
1.33 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1.34 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
1.35 NULL );
1.36 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
1.37 - gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_dir );
1.38 + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );
1.39 gtk_window_set_modal( GTK_WINDOW(file), TRUE );
1.40 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );
1.41 int result = gtk_dialog_run( GTK_DIALOG(file) );
1.42 @@ -79,6 +82,7 @@
1.43 action( filename );
1.44 }
1.45 gtk_widget_destroy(file);
1.46 + g_free(initial_path);
1.47 }
1.48
1.49 void mount_action_callback( GtkAction *action, gpointer user_data)
1.50 @@ -131,6 +135,7 @@
1.51 GtkWidget *file, *preview, *frame, *align;
1.52 GtkRequisition size;
1.53 const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
1.54 + const gchar *path = get_absolute_path(dir);
1.55 file = gtk_file_chooser_dialog_new( _("Load state..."), NULL,
1.56 GTK_FILE_CHOOSER_ACTION_OPEN,
1.57 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1.58 @@ -153,7 +158,7 @@
1.59 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(file), align);
1.60 g_signal_connect( file, "update-preview", G_CALLBACK(load_state_preview_callback),
1.61 preview );
1.62 - gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), dir );
1.63 + gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), path );
1.64 gtk_window_set_modal( GTK_WINDOW(file), TRUE );
1.65 int result = gtk_dialog_run( GTK_DIALOG(file) );
1.66 if( result == GTK_RESPONSE_ACCEPT ) {
1.67 @@ -161,6 +166,7 @@
1.68 dreamcast_load_state( filename );
1.69 }
1.70 gtk_widget_destroy(file);
1.71 + g_free(path);
1.72 }
1.73
1.74 void save_state_action_callback( GtkAction *action, gpointer user_data)
.