+
+ read_from_file = FALSE;
+
+#if GTK_CHECK_VERSION(2,14,0)
+ /* try reading the page setup from file */
+ page_setup_filename = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, PAGE_SETUP_STORAGE_FILE, NULL);
+ keyfile = g_key_file_new();
+ key_file_read = g_key_file_load_from_file(keyfile, page_setup_filename, 0, NULL);
+ g_free(page_setup_filename);
+
+ if(key_file_read)
+ read_from_file = gtk_page_setup_load_key_file(page_setup, keyfile, NULL, NULL);
+ g_key_file_free(keyfile);
+
+ if(read_from_file) {
+ debug_print("Printing: Read page setup from key file\n");
+ }
+ else {
+ debug_print("Printing: Could not read page setup from key file\n");
+ }
+#else
+ key_file_read = FALSE;
+ keyfile = NULL;
+ page_setup_filename = NULL;
+#endif
+
+ /* if reading from file did not work, or has not been tried (GTK+ < 2.14), use prefs */
+ if(!read_from_file) {
+ /* paper size */
+ if (prefs_common.print_paper_type && *prefs_common.print_paper_type) {
+ GtkPaperSize *paper = gtk_paper_size_new(prefs_common.print_paper_type);
+ gtk_page_setup_set_paper_size(page_setup, paper);
+ gtk_paper_size_free(paper);
+ }
+ /* orientation */
+ gtk_page_setup_set_orientation(page_setup, prefs_common.print_paper_orientation);
+ /* margins */
+ if(prefs_common.print_margin_top != -1)
+ gtk_page_setup_set_top_margin(page_setup, 0.01*prefs_common.print_margin_top, PAGE_MARGIN_STORAGE_UNIT);
+ if(prefs_common.print_margin_bottom != -1)
+ gtk_page_setup_set_bottom_margin(page_setup, 0.01*prefs_common.print_margin_bottom, PAGE_MARGIN_STORAGE_UNIT);
+ if(prefs_common.print_margin_left != -1)
+ gtk_page_setup_set_left_margin(page_setup, 0.01*prefs_common.print_margin_left, PAGE_MARGIN_STORAGE_UNIT);
+ if(prefs_common.print_margin_right != -1)
+ gtk_page_setup_set_right_margin(page_setup, 0.01*prefs_common.print_margin_right, PAGE_MARGIN_STORAGE_UNIT);