[gnumeric] preserve print to file uri
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] preserve print to file uri
- Date: Mon, 9 May 2011 06:16:24 +0000 (UTC)
commit 31422d8fbe9a0080cf6eb5961f7314b05083d620
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon May 9 00:14:56 2011 -0600
preserve print to file uri
2011-05-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print-info.h (_PrintInformation): new field printtofile_uri
(print_info_set_printtofile_from_settings): new
(print_info_get_printtofile_uri): new
* src/print-info.c (print_info_free): handle printtofile_uri
(print_info_new): ditto
(print_info_dup): ditto
(print_info_set_printtofile_from_settings): new
(print_info_get_printtofile_uri): new
* src/print.c (gnm_print_sheet): save and restore printtofile uri
from PrintInformation of the current sheet.
ChangeLog | 13 +++++++++++++
src/print-info.c | 28 ++++++++++++++++++++++++++++
src/print-info.h | 8 ++++++++
src/print.c | 45 +++++++++++++++++++++++++++++++++------------
4 files changed, 82 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 143bd08..f9ec9aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2011-05-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/print-info.h (_PrintInformation): new field printtofile_uri
+ (print_info_set_printtofile_from_settings): new
+ (print_info_get_printtofile_uri): new
+ * src/print-info.c (print_info_free): handle printtofile_uri
+ (print_info_new): ditto
+ (print_info_dup): ditto
+ (print_info_set_printtofile_from_settings): new
+ (print_info_get_printtofile_uri): new
+ * src/print.c (gnm_print_sheet): save and restore printtofile uri
+ from PrintInformation of the current sheet.
+
2011-05-08 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print.c (gnm_print_uri_change_extension): new
diff --git a/src/print-info.c b/src/print-info.c
index f7275d3..2d61c87 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -139,6 +139,7 @@ print_info_free (PrintInformation *pi)
print_hf_free (pi->header);
print_hf_free (pi->footer);
+ g_free (pi->printtofile_uri);
if (pi->page_setup)
g_object_unref (pi->page_setup);
@@ -298,6 +299,8 @@ print_info_new (gboolean load_defaults)
res->page_breaks.v = NULL;
res->page_breaks.h = NULL;
+ res->printtofile_uri = NULL;
+
if (load_defaults)
return print_info_load_defaults (res);
else
@@ -862,6 +865,9 @@ print_info_dup (PrintInformation const *src)
COPY(start_page);
COPY(n_copies);
+ g_free (dst->printtofile_uri);
+ dst->printtofile_uri = g_strdup (src->printtofile_uri);
+
if (dst->page_setup)
g_object_unref (dst->page_setup);
dst->page_setup = gtk_page_setup_copy (src->page_setup);
@@ -1499,3 +1505,25 @@ gnm_page_breaks_clean (GnmPageBreaks *breaks)
}
}
}
+
+
+void
+print_info_set_printtofile_from_settings (PrintInformation *pi,
+ GtkPrintSettings* settings,
+ gchar const *default_uri)
+{
+ char const *uri = gtk_print_settings_get
+ (settings,
+ GTK_PRINT_SETTINGS_OUTPUT_URI);
+ g_free (pi->printtofile_uri);
+ if (strcmp (uri, default_uri) == 0)
+ pi->printtofile_uri = NULL;
+ else
+ pi->printtofile_uri = g_strdup (uri);
+}
+
+char const *
+print_info_get_printtofile_uri (PrintInformation *pi)
+{
+ return pi->printtofile_uri;
+}
diff --git a/src/print-info.h b/src/print-info.h
index fc15a69..7fc0b81 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -95,6 +95,8 @@ struct _PrintInformation {
int start_page; /* < 0 implies auto */
int n_copies;
+ gchar *printtofile_uri;
+
/* page_setup doubles as a flag whether the defaults are loaded */
GtkPageSetup *page_setup;
};
@@ -170,6 +172,12 @@ void print_info_set_edge_to_above_footer (PrintInformation *pi,
double e_f);
void print_info_set_edge_to_below_header (PrintInformation *pi,
double e_h);
+void print_info_set_printtofile_from_settings
+ (PrintInformation *pi,
+ GtkPrintSettings *settings,
+ gchar const *default_uri);
+char const *print_info_get_printtofile_uri (PrintInformation *pi);
+
void print_info_set_breaks (PrintInformation *pi, GnmPageBreaks *breaks);
gboolean print_info_has_manual_breaks (PrintInformation *pi);
diff --git a/src/print.c b/src/print.c
index f9be03a..b5b6b7b 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1619,6 +1619,8 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
PRINT_SHEET_SELECTION, PRINT_ACTIVE_SHEET,
PRINT_SHEET_SELECTION_IGNORE_PRINTAREA};
GODoc *doc = wb_control_get_doc (wbc);
+ gchar *output_uri = NULL;
+ gchar const *saved_uri = NULL;
#ifdef PREVIEW_VIA_PDF
preview_via_pdf = preview;
@@ -1653,16 +1655,22 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
!sheet->print_info->print_black_and_white);
/* We should be setting the output file name to somethig reasonable */
- if (doc->uri != NULL
- && g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0) {
- gchar *output_uri
- = gnm_print_uri_change_extension (doc->uri, settings);
- if (output_uri != NULL) {
- gtk_print_settings_set (settings,
- GTK_PRINT_SETTINGS_OUTPUT_URI,
- output_uri);
- g_free (output_uri);
- }
+ saved_uri = print_info_get_printtofile_uri (sheet->print_info);
+ if (saved_uri != NULL &&
+ g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
+ output_uri = gnm_print_uri_change_extension (saved_uri,
+ settings);
+ else
+ saved_uri = NULL;
+ if (output_uri == NULL && doc->uri != NULL
+ && g_ascii_strncasecmp (doc->uri, "file:///", 8) == 0)
+ output_uri = gnm_print_uri_change_extension (doc->uri,
+ settings);
+ if (output_uri != NULL) {
+ gtk_print_settings_set (settings,
+ GTK_PRINT_SETTINGS_OUTPUT_URI,
+ output_uri);
+ g_free (output_uri);
}
gtk_print_operation_set_print_settings (print, settings);
@@ -1723,10 +1731,23 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
res = gtk_print_operation_run (print, action, parent, NULL);
switch (res) {
- case GTK_PRINT_OPERATION_RESULT_APPLY:
- gnm_conf_set_print_settings (gtk_print_operation_get_print_settings (print));
+ case GTK_PRINT_OPERATION_RESULT_APPLY: {
+ char const *printer;
+ settings = gtk_print_operation_get_print_settings (print);
+ gnm_conf_set_print_settings (settings);
gnm_insert_meta_date (GO_DOC (sheet->workbook), GSF_META_NAME_PRINT_DATE);
+ printer = gtk_print_settings_get_printer (settings);
+ if (strcmp (printer, "Print to File") == 0 ||
+ strcmp (printer, _("Print to File")) == 0) {
+ gchar *wb_output_uri =
+ gnm_print_uri_change_extension (doc->uri,
+ settings);
+ print_info_set_printtofile_from_settings
+ (sheet->print_info, settings, wb_output_uri);
+ g_free (wb_output_uri);
+ }
break;
+ }
case GTK_PRINT_OPERATION_RESULT_CANCEL:
printing_instance_delete (pi);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]