Revision 3259

View differences:

libsylph/prefs_common.c
515 515
	{"filesel_prev_open_dir", NULL, &prefs_common.prev_open_dir, P_STRING},
516 516
	{"filesel_prev_save_dir", NULL, &prefs_common.prev_save_dir, P_STRING},
517 517
	{"filesel_prev_folder_dir", NULL, &prefs_common.prev_folder_dir, P_STRING},
518
	{"filesel_save_file_type", "0", &prefs_common.save_file_type, P_INT},
518 519

  
519 520
	{NULL, NULL, NULL, P_OTHER}
520 521
};
libsylph/prefs_common.h
347 347
	gboolean nofilter_junk_sender_in_book; /* Junk Mail */
348 348

  
349 349
	gboolean alt_prefer_html;            /* Message */
350

  
351
	gint save_file_type;
350 352
};
351 353

  
352 354
extern PrefsCommon prefs_common;
src/messageview.c
934 934
	types[1].ext = "txt";
935 935
	types[2].type = _("Text (UTF-8)");
936 936
	types[2].ext = "txt";
937
	dest = filesel_save_as_type(filename, types, 0, &selected_type);
937
	dest = filesel_save_as_type(filename, types, prefs_common.save_file_type, &selected_type);
938 938

  
939 939
	g_free(filename);
940 940
	if (!dest)
......
962 962
	}
963 963

  
964 964
	g_free(dest);
965

  
966
	prefs_common.save_file_type = selected_type;
965 967
}
966 968

  
967 969
static gint messageview_delete_cb(GtkWidget *widget, GdkEventAny *event,
src/filesel.c
58 58
						    gboolean	 expanded);
59 59
static gboolean filesel_save_expander_get_expanded (GtkWidget	*dialog);
60 60

  
61
static gchar *filesel_get_filename_with_ext	(const gchar	*filename,
62
						 const gchar	*ext);
63

  
61 64
static void filesel_combo_changed_cb	(GtkComboBox		*combo_box,
62 65
					 gpointer		 data);
63 66

  
......
221 224

  
222 225
		gtk_widget_show_all(hbox);
223 226
		gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), hbox);
227
		if (default_type < 0 || default_type >= i)
228
			default_type = 0;
224 229
		gtk_combo_box_set_active(GTK_COMBO_BOX(combo), default_type);
225

  
226 230
		g_object_set_data(G_OBJECT(combo), "types", types);
227 231
		g_signal_connect(GTK_COMBO_BOX(combo), "changed",
228 232
				 G_CALLBACK(filesel_combo_changed_cb), dialog);
233

  
234
		if (file) {
235
			gchar *newfile;
236

  
237
			newfile = filesel_get_filename_with_ext
238
				(file, types[default_type].ext);
239
			gtk_file_chooser_set_current_name
240
				(GTK_FILE_CHOOSER(dialog), newfile);
241
			g_free(newfile);
242
		}
229 243
	}
230 244

  
231 245
	gtk_widget_show(dialog);
......
423 437
		return FALSE;
424 438
}
425 439

  
440
static gchar *filesel_get_filename_with_ext(const gchar *filename, const gchar *ext)
441
{
442
	gchar *base;
443
	gchar *new_filename;
444
	gchar *p;
445

  
446
	base = g_path_get_basename(filename);
447
	p = strrchr(base, '.');
448
	if (p)
449
		*p = '\0';
450
	new_filename = g_strconcat(base, ".", ext, NULL);
451
	debug_print("new_filename: %s\n", new_filename);
452
	g_free(base);
453

  
454
	return new_filename;
455
}
456

  
426 457
static void filesel_combo_changed_cb(GtkComboBox *combo_box, gpointer data)
427 458
{
428 459
	GtkFileChooser *chooser = data;
429 460
	gint active;
430 461
	gchar *filename;
431
	gchar *base;
432 462
	gchar *new_filename;
433
	gchar *p;
434 463
	FileselFileType *types;
435 464

  
436 465
	active = gtk_combo_box_get_active(combo_box);
437 466
	filename = gtk_file_chooser_get_filename(chooser);
467
	if (!filename)
468
		return;
438 469
	types = g_object_get_data(G_OBJECT(combo_box), "types");
439
	g_print("active: %d filename: %s\n", active, filename);
440
	g_print("type ext: %s\n", types[active].ext);
441
	base = g_path_get_basename(filename);
442
	p = strrchr(base, '.');
443
	if (p)
444
		*p = '\0';
445
	new_filename = g_strconcat(base, ".", types[active].ext, NULL);
446
	g_print("new_filename: %s\n", new_filename);
470
	debug_print("active: %d filename: %s\n", active, filename);
471
	debug_print("type ext: %s\n", types[active].ext);
472
	new_filename = filesel_get_filename_with_ext(filename, types[active].ext);
447 473
	gtk_file_chooser_set_current_name(chooser, new_filename);
448 474
	g_free(new_filename);
449
	g_free(base);
450 475
	g_free(filename);
451 476
}
452 477

  
src/summaryview.c
3919 3919
	types[2].type = _("Text (UTF-8)");
3920 3920
	types[2].ext = "txt";
3921 3921
	
3922
	dest = filesel_save_as_type(filename, types, 0, &selected_type);
3922
	dest = filesel_save_as_type(filename, types, prefs_common.save_file_type, &selected_type);
3923 3923

  
3924 3924
	g_free(filename);
3925 3925
	if (!dest)
......
3949 3949
	}
3950 3950

  
3951 3951
	g_free(dest);
3952

  
3953
	prefs_common.save_file_type = selected_type;
3952 3954
}
3953 3955

  
3954 3956
void summary_print(SummaryView *summaryview)
ChangeLog
1
2013-05-23
2

  
3
	* libsylph/prefs_common.[ch]
4
	  src/messageview.c
5
	  src/filesel.c
6
	  src/summaryview.c: save selected file type.
7

  
8

  
1 9
2013-05-21
2 10

  
3 11
	* src/filesel.[ch]

Also available in: Unified diff