# HG changeset patch # User yaz # Date 1159458611 25200 # Node ID 5170463d8cc9d7f520f8e9854d927e69a8fdbd9c # Parent 70caa62ead63ed37db1f8122d91c373fe29e709b [svn] - gtk+-2.10's gtk_widget_destroy() sometimes causes an UI freeze. as a workaround, reuse allocated dialog. - when saving playlist without an extension, .xspf will be appended. diff -r 70caa62ead63 -r 5170463d8cc9 ChangeLog --- a/ChangeLog Thu Sep 28 08:39:14 2006 -0700 +++ b/ChangeLog Thu Sep 28 08:50:11 2006 -0700 @@ -1,3 +1,13 @@ +2006-09-28 15:39:14 +0000 Yoshiki Yazawa + revision [2459] + - fix for "bmp_rcfile_write_string: assertion `value != NULL' failed" + + trunk/audacious/controlsocket.c | 8 ++++---- + trunk/audacious/main.c | 6 ++++++ + trunk/audacious/prefswin.c | 12 +++++++++--- + 3 files changed, 19 insertions(+), 7 deletions(-) + + 2006-09-28 15:36:43 +0000 Yoshiki Yazawa revision [2457] - fix for "playlist.c:1482: Mutex not locked!" diff -r 70caa62ead63 -r 5170463d8cc9 audacious/ui_playlist.c --- a/audacious/ui_playlist.c Thu Sep 28 08:39:14 2006 -0700 +++ b/audacious/ui_playlist.c Thu Sep 28 08:50:11 2006 -0700 @@ -919,40 +919,80 @@ } static gchar * -playlist_file_selection(const gchar * title, - gboolean save, +playlist_file_selection_load(const gchar * title, const gchar * default_filename) { - GtkWidget *dialog, *button; + static GtkWidget *dialog = NULL; + GtkWidget *button; gchar *filename; g_return_val_if_fail(title != NULL, NULL); - dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), - save ? GTK_FILE_CHOOSER_ACTION_SAVE : - GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); - if (default_filename) - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), - default_filename); + if(!dialog) { + dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), + GTK_FILE_CHOOSER_ACTION_OPEN, NULL, NULL); + + if (default_filename) + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), + default_filename); - button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT); - gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); - GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT); + gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); - button = gtk_dialog_add_button(GTK_DIALOG(dialog), - save ? GTK_STOCK_SAVE : GTK_STOCK_OPEN, - GTK_RESPONSE_ACCEPT); - gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + button = gtk_dialog_add_button(GTK_DIALOG(dialog), + GTK_STOCK_OPEN, + GTK_RESPONSE_ACCEPT); + gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + } if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); else filename = NULL; - gtk_widget_destroy(dialog); + gtk_widget_hide(dialog); + return filename; +} + +static gchar * +playlist_file_selection_save(const gchar * title, + const gchar * default_filename) +{ + static GtkWidget *dialog = NULL; + GtkWidget *button; + gchar *filename; + + g_return_val_if_fail(title != NULL, NULL); + + if(!dialog) { + dialog = gtk_file_chooser_dialog_new(title, GTK_WINDOW(mainwin), + GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); + if (default_filename) + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), + default_filename); + + button = gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, + GTK_RESPONSE_REJECT); + gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); + GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); + + button = gtk_dialog_add_button(GTK_DIALOG(dialog), + GTK_STOCK_SAVE, + GTK_RESPONSE_ACCEPT); + gtk_button_set_use_stock(GTK_BUTTON(button), TRUE); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + } + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) + filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + else + filename = NULL; + + gtk_widget_hide(dialog); return filename; } @@ -960,7 +1000,7 @@ playlistwin_select_playlist_to_load(const gchar * default_filename) { gchar *filename = - playlist_file_selection(_("Load Playlist"), FALSE, default_filename); + playlist_file_selection_load(_("Load Playlist"), default_filename); if (filename) { playlistwin_load_playlist(filename); @@ -971,19 +1011,20 @@ static void playlistwin_select_playlist_to_save(const gchar * default_filename) { + gchar *dot = NULL, *basename = NULL; gchar *filename = - playlist_file_selection(_("Save Playlist"), TRUE, default_filename); + playlist_file_selection_save(_("Save Playlist"), default_filename); if (filename) { - /* Default to M3U if no filename has extension */ - - /* NOTE: This doesn't work correctly for hidden files - - descender */ - if (!strchr(filename, '.')) { - gchar *tmpstr = filename; - filename = g_strconcat(filename, ".m3u", NULL); - g_free(tmpstr); + /* Default to xspf if no filename has extension */ + basename = g_path_get_basename(filename); + dot = strrchr(basename, '.'); + if( dot == NULL || dot == basename) { + gchar *oldname = filename; + filename = g_strconcat(oldname, ".xspf", NULL); + g_free(oldname); } + g_free(basename); playlistwin_save_playlist(filename); g_free(filename);