gtk: nsf and load/save statedialogs remember last directory
This commit is contained in:
parent
8ff01bbe57
commit
1561c3583e
|
@ -213,8 +213,13 @@ InitConfig()
|
||||||
config->addOption("mute", "SDL.MuteCapture", 0);
|
config->addOption("mute", "SDL.MuteCapture", 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// prefixed with _ because they are internal (not cli options)
|
||||||
#ifdef _GTK
|
#ifdef _GTK
|
||||||
config->addOption("", "SDL.LastOpenFile", "/");
|
config->addOption("_lastopenfile", "SDL.LastOpenFile", "/");
|
||||||
|
config->addOption("_laststatefrom", "SDL.LastLoadStateFrom", "/");
|
||||||
|
config->addOption("_lastopennsf", "SDL.LastOpenNSF", "/");
|
||||||
|
config->addOption("_lastsavestateas", "SDL.LastSaveStateAs", "/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fcm -> fm2 conversion
|
// fcm -> fm2 conversion
|
||||||
|
|
|
@ -1211,6 +1211,10 @@ void loadNSF ()
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
||||||
|
|
||||||
|
const char* last_dir;
|
||||||
|
g_config->getOption("SDL.LastOpenNSF", &last_dir);
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir);
|
||||||
|
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNSF);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterNSF);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterZip);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterZip);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
||||||
|
@ -1230,6 +1234,8 @@ void loadNSF ()
|
||||||
gtk_dialog_run(GTK_DIALOG(d));
|
gtk_dialog_run(GTK_DIALOG(d));
|
||||||
gtk_widget_destroy(d);
|
gtk_widget_destroy(d);
|
||||||
}
|
}
|
||||||
|
g_config->setOption("SDL.LastOpenNSF", filename);
|
||||||
|
g_config->save();
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1310,6 +1316,7 @@ void loadGame ()
|
||||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
||||||
gtk_widget_destroy (fileChooser);
|
gtk_widget_destroy (fileChooser);
|
||||||
g_config->setOption("SDL.LastOpenFile", filename);
|
g_config->setOption("SDL.LastOpenFile", filename);
|
||||||
|
g_config->save();
|
||||||
closeGame();
|
closeGame();
|
||||||
if(LoadGame(filename) == 0)
|
if(LoadGame(filename) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1342,9 +1349,15 @@ void saveStateAs()
|
||||||
gtk_file_filter_add_pattern(filterAll, "*");
|
gtk_file_filter_add_pattern(filterAll, "*");
|
||||||
gtk_file_filter_set_name(filterAll, "All Files");
|
gtk_file_filter_set_name(filterAll, "All Files");
|
||||||
|
|
||||||
|
const char* last_dir;
|
||||||
|
g_config->getOption("SDL.LastSaveStateAs", &last_dir);
|
||||||
|
|
||||||
fileChooser = gtk_file_chooser_dialog_new ("Save State As", GTK_WINDOW(MainWindow),
|
fileChooser = gtk_file_chooser_dialog_new ("Save State As", GTK_WINDOW(MainWindow),
|
||||||
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir);
|
||||||
|
|
||||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(fileChooser), ".sav");
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(fileChooser), ".sav");
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
||||||
|
@ -1355,6 +1368,8 @@ void saveStateAs()
|
||||||
|
|
||||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
||||||
FCEUI_SaveState(filename);
|
FCEUI_SaveState(filename);
|
||||||
|
g_config->setOption("SDL.LastSaveStateAs", filename);
|
||||||
|
g_config->save();
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
gtk_widget_destroy (fileChooser);
|
gtk_widget_destroy (fileChooser);
|
||||||
|
@ -1380,6 +1395,11 @@ void loadStateFrom()
|
||||||
fileChooser = gtk_file_chooser_dialog_new ("Load State From", GTK_WINDOW(MainWindow),
|
fileChooser = gtk_file_chooser_dialog_new ("Load State From", GTK_WINDOW(MainWindow),
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||||
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
|
||||||
|
|
||||||
|
const char* last_dir;
|
||||||
|
g_config->getOption("SDL.LastLoadStateFrom", &last_dir);
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(fileChooser), last_dir);
|
||||||
|
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterSav);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fileChooser), filterAll);
|
||||||
|
|
||||||
|
@ -1389,8 +1409,11 @@ void loadStateFrom()
|
||||||
|
|
||||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
|
||||||
FCEUI_LoadState(filename);
|
FCEUI_LoadState(filename);
|
||||||
|
g_config->setOption("SDL.LastLoadStateFrom", filename);
|
||||||
|
g_config->save();
|
||||||
g_free(filename);
|
g_free(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (fileChooser);
|
gtk_widget_destroy (fileChooser);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue