Search
lxdream.org :: lxdream/src/gtkui/gtkcb.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/gtkcb.c
changeset 1034:7044e01148f0
prev1017:f94af28e38b7
next1036:af7b0c5905dd
author nkeynes
date Wed Jun 24 02:41:12 2009 +0000 (14 years ago)
permissions -rw-r--r--
last change Add initial VMU support
file annotate diff log raw
1.1 --- a/src/gtkui/gtkcb.c Wed Jun 03 04:00:52 2009 +0000
1.2 +++ b/src/gtkui/gtkcb.c Wed Jun 24 02:41:12 2009 +0000
1.3 @@ -39,10 +39,11 @@
1.4 }
1.5 }
1.6
1.7 -void open_file_dialog( const char *title, file_callback_t action, const char *pattern, const char *patname,
1.8 - const gchar *initial_dir )
1.9 +gchar *open_file_dialog( const char *title, const char *pattern, const char *patname,
1.10 + const gchar *initial_dir )
1.11 {
1.12 GtkWidget *file;
1.13 + gchar *filename = NULL;
1.14 gchar *initial_path = get_absolute_path(initial_dir);
1.15 file = gtk_file_chooser_dialog_new( title, NULL,
1.16 GTK_FILE_CHOOSER_ACTION_OPEN,
1.17 @@ -55,17 +56,19 @@
1.18 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );
1.19 int result = gtk_dialog_run( GTK_DIALOG(file) );
1.20 if( result == GTK_RESPONSE_ACCEPT ) {
1.21 - gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
1.22 - action( filename );
1.23 + filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
1.24 }
1.25 gtk_widget_destroy(file);
1.26 g_free(initial_path);
1.27 +
1.28 + return filename;
1.29 }
1.30
1.31 -void save_file_dialog( const char *title, file_callback_t action, const char *pattern, const char *patname,
1.32 +gchar *save_file_dialog( const char *title, const char *pattern, const char *patname,
1.33 const gchar *initial_dir )
1.34 {
1.35 GtkWidget *file;
1.36 + gchar *filename;
1.37 gchar *initial_path = get_absolute_path(initial_dir);
1.38 file = gtk_file_chooser_dialog_new( title, NULL,
1.39 GTK_FILE_CHOOSER_ACTION_SAVE,
1.40 @@ -78,17 +81,37 @@
1.41 gtk_dialog_set_default_response( GTK_DIALOG(file), GTK_RESPONSE_ACCEPT );
1.42 int result = gtk_dialog_run( GTK_DIALOG(file) );
1.43 if( result == GTK_RESPONSE_ACCEPT ) {
1.44 - gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
1.45 - action( filename );
1.46 + filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
1.47 }
1.48 gtk_widget_destroy(file);
1.49 g_free(initial_path);
1.50 + return filename;
1.51 +}
1.52 +
1.53 +void open_file_dialog_cb( const char *title, file_callback_t action, const char *pattern, const char *patname,
1.54 + const gchar *initial_dir )
1.55 +{
1.56 + gchar *filename = open_file_dialog( title, pattern, patname, initial_dir );
1.57 + if( filename != NULL ) {
1.58 + action( filename );
1.59 + g_free(filename);
1.60 + }
1.61 +}
1.62 +
1.63 +void save_file_dialog_cb( const char *title, file_callback_t action, const char *pattern, const char *patname,
1.64 + const gchar *initial_dir )
1.65 +{
1.66 + gchar *filename = save_file_dialog( title, pattern, patname, initial_dir );
1.67 + if( filename != NULL ) {
1.68 + action(filename);
1.69 + g_free(filename);
1.70 + }
1.71 }
1.72
1.73 void mount_action_callback( GtkAction *action, gpointer user_data)
1.74 {
1.75 const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.76 - open_file_dialog( "Open...", gdrom_mount_image, NULL, NULL, dir );
1.77 + open_file_dialog_cb( "Open...", gdrom_mount_image, NULL, NULL, dir );
1.78 }
1.79 void reset_action_callback( GtkAction *action, gpointer user_data)
1.80 {
1.81 @@ -108,7 +131,7 @@
1.82 void load_binary_action_callback( GtkAction *action, gpointer user_data)
1.83 {
1.84 const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.85 - open_file_dialog( "Open Binary...", file_load_magic, NULL, NULL, dir );
1.86 + open_file_dialog_cb( "Open Binary...", file_load_magic, NULL, NULL, dir );
1.87 }
1.88
1.89 void load_state_preview_callback( GtkFileChooser *chooser, gpointer user_data )
1.90 @@ -172,7 +195,7 @@
1.91 void save_state_action_callback( GtkAction *action, gpointer user_data)
1.92 {
1.93 const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
1.94 - save_file_dialog( "Save state...", dreamcast_save_state, "*.dst", _("lxDream Save State (*.dst)"), dir );
1.95 + save_file_dialog_cb( "Save state...", dreamcast_save_state, "*.dst", _("lxDream Save State (*.dst)"), dir );
1.96 }
1.97 void about_action_callback( GtkAction *action, gpointer user_data)
1.98 {
1.99 @@ -247,7 +270,7 @@
1.100 void save_scene_action_callback( GtkAction *action, gpointer user_data)
1.101 {
1.102 const gchar *dir = lxdream_get_config_value(CONFIG_SAVE_PATH);
1.103 - save_file_dialog( _("Save next scene..."), pvr2_save_next_scene, "*.dsc", _("lxdream scene file (*.dsc)"), dir );
1.104 + save_file_dialog_cb( _("Save next scene..."), pvr2_save_next_scene, "*.dsc", _("lxdream scene file (*.dsc)"), dir );
1.105 }
1.106
1.107 int debug_window_get_selected_row( debug_window_t data );
.