Commit 0cdbd233 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

delay the creation of a GnomePrintConfig until it is really necessary.


2004-10-16  Jody Goldberg <jody@gnome.org>

	* src/print-info.c : delay the creation of a GnomePrintConfig until it
	  is really necessary.
parent 2245aace
......@@ -10,9 +10,6 @@ Release Critical
debian 272697
http://bugzilla.gnome.org/show_bug.cgi?id=152434
: file save gremlins
: provide undo for dropped objects from sheet_objects_relocate
: provide undo for dropped objects from sheet_objects_clear
: undo of pasting copy/cut of objects
......@@ -52,13 +49,6 @@ debian 272697
Worries
We init gnome_print at sheet creation time. With cups this can cause
hangs at startup if the server isn't answering. --> delay init.
It's also damn slow : Patch available to delay instantiating the
print_config until necessary but it does not help because importers
are still forcing it's creation. There is some redhat work to speed up
the printer dialog that may help.
-------------------------------------------------------------------------------
Pending Patches
---------------
......@@ -156,6 +146,7 @@ Target Features
- input message (Stored)
- load/save of external references
- all the merged cell singleton bugs
- Drag and Drop
- R1C1
- finish corba plugin
......@@ -166,9 +157,9 @@ Target Features
- repeat (http://bugzilla.gnome.org/show_bug.cgi?id=143244) (DONE)
- ssconvert for non-gnome (DONE)
Excel i/o
Excel i/o (DONE)
- 'Forms' import (DONE)
- Properties of 'Forms'
- Properties of 'Forms' (DONE)
-------------------------------------------------------------------------------
Short Term Goals
......
2004-10-16 Jody Goldberg <jody@gnome.org>
* src/print-info.c : delay the creation of a GnomePrintConfig until it
is really necessary.
2004-10-16 Jody Goldberg <jody@gnome.org>
* src/func.c (function_call_with_list) : Everything can now return an
......
Gnumeric 1.3.92
Hal Ashburner:
* Some function documentation cleanups.
Jody:
* Enable selecting and moving multiple drawing objects
* Swap X & Y axis content when importing xls bar plots. [#154734]
* Basic handling for XL 'Forms' Objects
* Fix handling of empty arguments in nested expressions
* Delay gnome-print init to decrease startup time
Morten:
* Implement Edit->Select->Input. [#154735]
......
2004-10-16 Jody Goldberg <jody@gnome.org>
* src/print-info.c : delay the creation of a GnomePrintConfig until it
is really necessary.
2004-10-16 Jody Goldberg <jody@gnome.org>
* src/func.c (function_call_with_list) : Everything can now return an
......
......@@ -2328,8 +2328,9 @@ excel_read_FORMULA (BiffQuery *q, ExcelReadSheet *esheet)
cell = sheet_cell_fetch (esheet->sheet, col, row);
g_return_if_fail (cell != NULL);
d (1, fprintf (stderr,"Formula in %s!%s;\n",
cell->base.sheet->name_quoted, cell_name (cell)););
d (1, fprintf (stderr,"Formula in %s!%s == 0x%x;\n",
cell->base.sheet->name_quoted, cell_name (cell),
GSF_LE_GET_GUINT32 (q->data + 16)););
/* TODO TODO TODO: Wishlist
* We should make an array of minimum sizes for each BIFF type
......
......@@ -357,8 +357,9 @@ excel_write_SETUP (BiffPut *bp, ExcelWriteSheet *esheet)
if (pi != NULL && pi->print_comments)
options |= 0x20;
if (pi == NULL ||
!print_info_get_margins (pi, &header, &footer, &dummy, &dummy))
if (NULL != pi)
print_info_get_margins (pi, &header, &footer, &dummy, &dummy);
else
header = footer = 0.;
header = points_to_inches (header);
footer = points_to_inches (footer);
......
......@@ -1350,7 +1350,7 @@ xml_sax_named_expr_prop (GsfXMLIn *gsf_state, G_GNUC_UNUSED GsfXMLBlob *blob)
}
static void
xml_sax_orientation_end (GsfXMLIn *gsf_state, xmlChar const **attrs)
xml_sax_orientation (GsfXMLIn *gsf_state, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)gsf_state;
char const *content = state->base.content->str;
......@@ -1366,16 +1366,14 @@ xml_sax_orientation_end (GsfXMLIn *gsf_state, xmlChar const **attrs)
}
static void
xml_sax_paper_end (GsfXMLIn *gsf_state, xmlChar const **attrs)
xml_sax_paper (GsfXMLIn *gsf_state, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)gsf_state;
char const *content = state->base.content->str;
g_return_if_fail(state->sheet->print_info != NULL);
g_return_if_fail(state->sheet->print_info->print_config != NULL);
gnome_print_config_set(state->sheet->print_info->print_config,
(guchar *)GNOME_PRINT_KEY_PAPER_SIZE, (guchar *)content);
print_info_set_paper (state->sheet->print_info, content);
}
......@@ -1454,8 +1452,8 @@ GSF_XML_IN_NODE_FULL (START, WB, GNM, "Workbook", FALSE, TRUE, FALSE, &xml_sax_w
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_HEADER, GNM, "Footer", FALSE, NULL, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_FOOTER, GNM, "Header", FALSE, NULL, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ORDER, GNM, "order", TRUE, NULL, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_PAPER, GNM, "paper", TRUE, NULL, &xml_sax_paper_end),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ORIENT, GNM, "orientation", TRUE, NULL, &xml_sax_orientation_end),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_PAPER, GNM, "paper", TRUE, &xml_sax_paper, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ORIENT, GNM, "orientation", TRUE, &xml_sax_orientation, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ONLY_STYLE, GNM, "even_if_only_styles", TRUE, NULL, NULL),
GSF_XML_IN_NODE (SHEET, SHEET_STYLES, GNM, "Styles", FALSE, NULL, NULL),
......
......@@ -277,7 +277,7 @@ xml_write_print_hf (GnmOutputXML *state, char const *name,
static void
xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
{
guchar *paper_name;
char const *paper_name;
double header = 0, footer = 0, left = 0, right = 0;
g_return_if_fail (pi != NULL);
......@@ -344,12 +344,9 @@ xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
xml_write_print_hf (state, GMR "Header", pi->header);
xml_write_print_hf (state, GMR "Footer", pi->footer);
paper_name = gnome_print_config_get (pi->print_config,
(guchar *)GNOME_PRINT_KEY_PAPER_SIZE);
if (paper_name) {
paper_name = print_info_get_paper (pi);
if (paper_name)
gsf_xml_out_simple_element (state->output, GMR "paper", paper_name);
g_free (paper_name);
}
gsf_xml_out_end_element (state->output);
}
......
......@@ -125,7 +125,7 @@ static struct {
N_("Started the MS Excel import/export engine, and 'GnmStyle'") },
{ "Lutz Muller", GNM_FEATURE_HACKER,
N_("SheetObject improvement") },
{ "Yukihiro Nakai", GNM_QA,
{ "Yukihiro Nakai", GNM_FEATURE_HACKER | GNM_TRANSLATION | GNM_QA,
N_("Support for non-Latin languages") },
{ "Emmanuel Pacaud", GNM_CORE | GNM_FEATURE_HACKER,
N_("Many plot types for charting engine.") },
......
......@@ -135,6 +135,7 @@ typedef struct {
Sheet *sheet;
GladeXML *gui;
PrintInformation *pi;
GnomePrintConfig *gp_config;
GtkWidget *dialog;
GtkWidget *sheet_selector;
GtkWidget *unit_selector;
......@@ -216,8 +217,7 @@ get_paper_pswidth (PrinterSetupState *state)
{
double height;
double width;
if (gnome_print_job_get_page_size_from_config (state->pi->print_config,
&width, &height))
if (gnome_print_config_get_page_size (state->gp_config, &width, &height))
return width;
else
return 1.0;
......@@ -234,8 +234,7 @@ get_paper_psheight (PrinterSetupState *state)
{
double height;
double width;
if (gnome_print_job_get_page_size_from_config (state->pi->print_config,
&width, &height))
if (gnome_print_config_get_page_size (state->gp_config, &width, &height))
return height;
else
return 0.0;
......@@ -503,7 +502,7 @@ canvas_update (PrinterSetupState *state)
preview_page_create (state);
set_vertical_bounds (state);
unit_txt = gnome_print_config_get (state->pi->print_config, GNOME_PRINT_KEY_PREFERED_UNIT);
unit_txt = gnome_print_config_get (state->gp_config, GNOME_PRINT_KEY_PREFERED_UNIT);
if (unit_txt) {
gnome_print_unit_selector_set_unit (GNOME_PRINT_UNIT_SELECTOR
(state->unit_selector),
......@@ -659,7 +658,7 @@ cb_unit_selector_changed (GnomePrintUnitSelector *sel, PrinterSetupState *state)
unit = gnome_print_unit_selector_get_unit (sel);
if (unit) {
gnome_print_config_set (state->pi->print_config, GNOME_PRINT_KEY_PREFERED_UNIT,
gnome_print_config_set (state->gp_config, GNOME_PRINT_KEY_PREFERED_UNIT,
unit->abbr);
spin_button_adapt_to_unit (state->margins.header.spin, unit);
spin_button_adapt_to_unit (state->margins.footer.spin, unit);
......@@ -708,9 +707,9 @@ do_setup_margin (PrinterSetupState *state)
G_CALLBACK (cb_unit_selector_changed), state);
gtk_widget_show (state->unit_selector);
unit_editor_configure (&state->margins.header, state, "spin-header",
unit_editor_configure (&state->margins.top, state, "spin-header",
MAX (pm->top.points - header, 0.0));
unit_editor_configure (&state->margins.footer, state, "spin-footer",
unit_editor_configure (&state->margins.bottom, state, "spin-footer",
MAX (pm->bottom.points - footer, 0.0));
container = GTK_BOX (glade_xml_get_widget (state->gui,
......@@ -1419,8 +1418,8 @@ do_setup_page (PrinterSetupState *state)
gui = state->gui;
table = GTK_TABLE (glade_xml_get_widget (gui, "table-paper-selector"));
paper_selector = gnome_paper_selector_new_with_flags (pi->print_config,
GNOME_PAPER_SELECTOR_MARGINS);
paper_selector = gnome_paper_selector_new_with_flags (
state->gp_config, GNOME_PAPER_SELECTOR_MARGINS);
gtk_widget_show (paper_selector);
gtk_table_attach_defaults (table, paper_selector, 0, 1, 0, 1);
......@@ -1510,12 +1509,12 @@ cb_do_print_ok (G_GNUC_UNUSED GtkWidget *w,
wbcg_edit_detach_guru (state->wbcg);
wbcg_edit_finish (state->wbcg, WBC_EDIT_ACCEPT, NULL);
fetch_settings (state);
print_info_load_config (state->pi, state->gp_config);
if (gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (
glade_xml_get_widget (state->gui,
"is_default_check")))) {
print_info_save (state->pi);
printf ("Saved settings\n");
}
cmd_print_setup (WORKBOOK_CONTROL (state->wbcg),
print_setup_get_sheet (state), state->pi);
......@@ -1660,6 +1659,7 @@ printer_setup_state_new (WorkbookControlGUI *wbcg, Sheet *sheet)
state->sheet = sheet;
state->gui = gui;
state->pi = print_info_dup(sheet->print_info);
state->gp_config = print_info_make_config (state->pi);
state->customize_header = NULL;
state->customize_footer = NULL;
......@@ -1676,7 +1676,8 @@ printer_setup_state_new (WorkbookControlGUI *wbcg, Sheet *sheet)
static void
printer_setup_state_free (PrinterSetupState *state)
{
g_object_unref (G_OBJECT (state->gui));
g_object_unref (state->gui);
g_object_unref (state->gp_config);
print_hf_free (state->header);
print_hf_free (state->footer);
......@@ -1738,8 +1739,8 @@ do_fetch_margins (PrinterSetupState *state)
print_info_get_margins (state->pi, &header, &footer, &left, &right);
m->top = unit_info_to_print_unit (&state->margins.header, state);
m->bottom = unit_info_to_print_unit (&state->margins.footer, state);
m->top = unit_info_to_print_unit (&state->margins.top, state);
m->bottom = unit_info_to_print_unit (&state->margins.bottom, state);
m->top.points += header;
m->bottom.points += footer;
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* print-info.c: Print information management. This keeps
* track of what the print parameters for a sheet are.
......@@ -117,8 +119,9 @@ print_info_free (PrintInformation *pi)
print_hf_free (pi->header);
print_hf_free (pi->footer);
gnome_print_config_unref(pi->print_config);
g_free (pi->paper);
g_free (pi->gp_config_str);
g_free (pi);
}
......@@ -214,12 +217,6 @@ print_info_new (void)
pi = g_new0 (PrintInformation, 1);
pi->print_config =
gnm_app_prefs->printer_config ?
gnome_print_config_from_string (gnm_app_prefs->printer_config,
0) :
gnome_print_config_default ();
/* Scaling */
if (gnm_app_prefs->print_scale_percentage)
pi->scaling.type = PERCENTAGE;
......@@ -266,6 +263,10 @@ print_info_new (void)
pi->repeat_left.use = load_range (gnm_app_prefs->print_repeat_left,
&pi->repeat_left.range);
pi->orientation = PRINT_ORIENT_VERTICAL;
pi->n_copies = 1;
pi->gp_config_str = NULL;
pi->paper = NULL;
return pi;
}
......@@ -340,9 +341,8 @@ print_info_save (PrintInformation const *pi)
save_formats ();
gnm_gconf_set_printer_config
(gnome_print_config_to_string (pi->print_config,
0));
if (NULL != pi->gp_config_str)
gnm_gconf_set_printer_config (pi->gp_config_str);
gnm_gconf_set_printer_header (pi->header->left_format,
pi->header->middle_format,
pi->header->right_format);
......@@ -589,9 +589,6 @@ print_info_dup (PrintInformation const *src_pi)
dst_pi = print_info_new ();
gnome_print_config_unref (dst_pi->print_config);
dst_pi->print_config = gnome_print_config_dup (src_pi->print_config);
/* Print Scaling */
dst_pi->scaling.type = src_pi->scaling.type;
dst_pi->scaling.percentage = src_pi->scaling.percentage;
......@@ -623,79 +620,61 @@ print_info_dup (PrintInformation const *src_pi)
dst_pi->repeat_top = src_pi->repeat_top;
dst_pi->repeat_left = src_pi->repeat_left;
dst_pi->orientation = src_pi->orientation;
dst_pi->n_copies = src_pi->n_copies;
g_free (dst_pi->gp_config_str);
dst_pi->gp_config_str = g_strdup (src_pi->gp_config_str);
g_free (dst_pi->paper);
dst_pi->paper = g_strdup (src_pi->paper);
return dst_pi;
}
gboolean
void
print_info_get_margins (PrintInformation const *pi,
double *top, double *bottom, double *left, double *right)
{
gboolean res_top, res_bottom, res_left, res_right;
g_return_val_if_fail (pi->print_config != NULL, FALSE);
g_return_if_fail (pi != NULL);
res_top = gnome_print_config_get_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_TOP,
top, NULL);
res_bottom = gnome_print_config_get_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM,
bottom, NULL);
res_left = gnome_print_config_get_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_LEFT,
left, NULL);
res_right = gnome_print_config_get_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT,
right, NULL);
return res_top && res_bottom && res_left && res_right;
if (NULL != top)
*top = pi->margins.header;
if (NULL != bottom)
*bottom = pi->margins.footer;
if (NULL != left)
*left = pi->margins.left;
if (NULL != right)
*right = pi->margins.right;
}
void
print_info_set_margin_header (PrintInformation *pi, double top)
print_info_set_margin_header (PrintInformation *pi, double header)
{
g_return_if_fail (pi->print_config != NULL);
gnome_print_config_set_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_TOP,
top, GNOME_PRINT_PS_UNIT);
g_return_if_fail (pi != NULL);
pi->margins.header = header;
}
void
print_info_set_margin_footer (PrintInformation *pi, double bottom)
print_info_set_margin_footer (PrintInformation *pi, double footer)
{
g_return_if_fail (pi->print_config != NULL);
gnome_print_config_set_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM,
bottom, GNOME_PRINT_PS_UNIT);
g_return_if_fail (pi != NULL);
pi->margins.footer = footer;
}
void
print_info_set_margin_left (PrintInformation *pi, double left)
print_info_set_margin_left (PrintInformation *pi, double left)
{
g_return_if_fail (pi->print_config != NULL);
gnome_print_config_set_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_LEFT,
left, GNOME_PRINT_PS_UNIT);
g_return_if_fail (pi != NULL);
pi->margins.left = left;
}
void
print_info_set_margin_right (PrintInformation *pi, double right)
print_info_set_margin_right (PrintInformation *pi, double right)
{
g_return_if_fail (pi->print_config != NULL);
gnome_print_config_set_length (pi->print_config,
GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT,
right, GNOME_PRINT_PS_UNIT);
g_return_if_fail (pi != NULL);
pi->margins.right = right;
}
void
print_info_set_margins (PrintInformation *pi,
double top, double bottom, double left, double right)
{
g_return_if_fail (pi->print_config != NULL);
print_info_set_margin_header (pi, top);
print_info_set_margin_footer (pi, bottom);
print_info_set_margin_left (pi, left);
......@@ -703,80 +682,121 @@ print_info_set_margins (PrintInformation *pi,
}
void
print_info_set_n_copies (PrintInformation *pi, guint copies)
print_info_set_n_copies (PrintInformation *pi, int copies)
{
g_return_if_fail (pi->print_config != NULL);
gnome_print_config_set_int (pi->print_config,
GNOME_PRINT_KEY_NUM_COPIES,
(gint)copies);
g_return_if_fail (pi != NULL);
pi->n_copies = copies;
}
guint
print_info_get_n_copies (PrintInformation const *pi)
{
int res = 1;
g_return_val_if_fail (pi->print_config != NULL, 1);
if (gnome_print_config_get_int (pi->print_config,
GNOME_PRINT_KEY_NUM_COPIES, &res))
return res;
return 1;
g_return_val_if_fail (pi != NULL, 1);
return pi->n_copies;
}
void
print_info_set_paper (PrintInformation *pi, char const *paper)
{
g_return_if_fail (pi != NULL);
g_free (pi->paper);
pi->paper = g_strdup (paper);
}
char const *
print_info_get_paper (PrintInformation const *pi)
{
g_return_val_if_fail (pi != NULL, "A4");
return pi->paper;
}
void
print_info_set_orientation (PrintInformation *pi, PrintOrientation orient)
{
g_return_if_fail (pi->print_config != NULL);
switch (orient) {
case PRINT_ORIENT_HORIZONTAL:
gnome_print_config_set (pi->print_config,
GNOME_PRINT_KEY_ORIENTATION,
"R90");
break;
g_return_if_fail (pi != NULL);
pi->orientation = orient;
}
PrintOrientation
print_info_get_orientation (PrintInformation const *pi)
{
g_return_val_if_fail (pi != NULL, PRINT_ORIENT_VERTICAL);
return pi->orientation;
}
GnomePrintConfig *
print_info_make_config (PrintInformation const *pi)
{
GnomePrintConfig *res = (NULL != pi->gp_config_str)
? gnome_print_config_from_string (pi->gp_config_str, 0)
: ((NULL != gnm_app_prefs->printer_config)
? gnome_print_config_from_string (gnm_app_prefs->printer_config, 0)
: gnome_print_config_default ());
if (NULL != pi->paper)
gnome_print_config_set (res, GNOME_PRINT_KEY_PAPER_SIZE, pi->paper);
gnome_print_config_set_length (res, GNOME_PRINT_KEY_PAGE_MARGIN_TOP,
pi->margins.header, GNOME_PRINT_PS_UNIT);
gnome_print_config_set_length (res, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM,
pi->margins.footer, GNOME_PRINT_PS_UNIT);
gnome_print_config_set_length (res, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT,
pi->margins.left, GNOME_PRINT_PS_UNIT);
gnome_print_config_set_length (res, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT,
pi->margins.right, GNOME_PRINT_PS_UNIT);
gnome_print_config_set_int (res, GNOME_PRINT_KEY_NUM_COPIES, pi->n_copies);
switch (pi->orientation) {
case PRINT_ORIENT_VERTICAL:
gnome_print_config_set (pi->print_config,
GNOME_PRINT_KEY_ORIENTATION,
"R0");
gnome_print_config_set (res, GNOME_PRINT_KEY_ORIENTATION, "R0");
break;
case PRINT_ORIENT_HORIZONTAL:
gnome_print_config_set (res, GNOME_PRINT_KEY_ORIENTATION, "R90");
break;
case PRINT_ORIENT_HORIZONTAL_UPSIDE_DOWN:
gnome_print_config_set (pi->print_config,
GNOME_PRINT_KEY_ORIENTATION,
"R270");
gnome_print_config_set (res, GNOME_PRINT_KEY_ORIENTATION, "R270");
break;
case PRINT_ORIENT_VERTICAL_UPSIDE_DOWN:
gnome_print_config_set (pi->print_config,
GNOME_PRINT_KEY_ORIENTATION,
"R180");
gnome_print_config_set (res, GNOME_PRINT_KEY_ORIENTATION, "R180");
break;
}
return res;
}
PrintOrientation
print_info_get_orientation (PrintInformation const *pi)
void
print_info_load_config (PrintInformation *pi, GnomePrintConfig *config)
{
guchar *orient = NULL;
PrintOrientation res = PRINT_ORIENT_VERTICAL;
g_return_val_if_fail (pi->print_config != NULL, res);
orient = gnome_print_config_get (pi->print_config,
GNOME_PRINT_KEY_ORIENTATION);
guchar *str = NULL;
double d_tmp;
int tmp;
g_return_val_if_fail (orient != NULL, res);
if (strcmp (orient, "R0") == 0)
res = PRINT_ORIENT_VERTICAL;
else if (strcmp (orient, "R90") == 0)
res = PRINT_ORIENT_HORIZONTAL;
else if (strcmp (orient, "R180") == 0)
res = PRINT_ORIENT_VERTICAL_UPSIDE_DOWN;
else if (strcmp (orient, "R270") == 0)
res = PRINT_ORIENT_HORIZONTAL_UPSIDE_DOWN;
g_free (orient);
return res;
g_return_if_fail (pi != NULL);
g_return_if_fail (config != NULL);
g_free (pi->gp_config_str);
pi->gp_config_str = gnome_print_config_to_string (config, 0);
if (gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &d_tmp, NULL))
pi->margins.header = d_tmp;
if (gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &d_tmp, NULL))
pi->margins.footer = d_tmp;
if (gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &d_tmp, NULL))
pi->margins.left = d_tmp;
if (gnome_print_config_get_length (config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &d_tmp, NULL))
pi->margins.right = d_tmp;
if (gnome_print_config_get_int (config, GNOME_PRINT_KEY_NUM_COPIES, &tmp))
pi->n_copies = tmp;
else
pi->n_copies = 1;
g_free (pi->paper);
pi->paper = gnome_print_config_get (config, GNOME_PRINT_KEY_PAPER_SIZE);
str = gnome_print_config_get (config, GNOME_PRINT_KEY_ORIENTATION);
if (str != NULL) {
if (strcmp (str, "R0") == 0)
pi->orientation = PRINT_ORIENT_VERTICAL;
else if (strcmp (str, "R90") == 0)
pi->orientation = PRINT_ORIENT_HORIZONTAL;
else if (strcmp (str, "R180") == 0)
pi->orientation = PRINT_ORIENT_VERTICAL_UPSIDE_DOWN;
else if (strcmp (str, "R270") == 0)
pi->orientation = PRINT_ORIENT_HORIZONTAL_UPSIDE_DOWN;
g_free (str);
}
}
......@@ -49,6 +49,7 @@ typedef struct {
typedef struct {
PrintUnit top; /* see print.c for the definition (these are header/footer) */
PrintUnit bottom;
double left, right, header, footer;
} PrintMargins;
/* Header/Footer definition */
......@@ -85,7 +86,10 @@ struct _PrintInformation {
PrintHF *header;
PrintHF *footer;
GnomePrintConfig *print_config;
PrintOrientation orientation;
int n_copies;
char *gp_config_str;
char *paper;
};
typedef enum {
......@@ -103,6 +107,8 @@ PrintInformation *print_info_new (void);
PrintInformation *print_info_dup (PrintInformation const *pi);
void print_info_free (PrintInformation *pi);
void print_info_save (PrintInformation const *pi);
GnomePrintConfig *print_info_make_config (PrintInformation const *pi);
void print_info_load_config (PrintInformation *pi, GnomePrintConfig *config);
PrintHF *print_hf_new (char const *left,
char const *middle,
......@@ -126,8 +132,11 @@ double unit_convert (double value,
void print_init (void);
void print_shutdown (void);
void print_info_set_n_copies (PrintInformation *pi, guint copies);
gboolean print_info_get_margins (PrintInformation const *pi,
void print_info_set_n_copies (PrintInformation *pi, int copies);
guint print_info_get_n_copies (PrintInformation const *pi);
void print_info_set_paper (PrintInformation *pi, char const *paper);
char const *print_info_get_paper (PrintInformation const *pi);
void print_info_get_margins (PrintInformation const *pi,
double *header, double *footer, double *left, double *right);
void print_info_set_margins (PrintInformation *pi,
double header, double footer, double left, double right);
......@@ -138,7 +147,6 @@ void print_info_set_margin_right (PrintInformation *pi, double right);
void print_info_set_orientation (PrintInformation *pi,
PrintOrientation orient);
PrintOrientation print_info_get_orientation (PrintInformation const *pi);
guint print_info_get_n_copies (PrintInformation const *pi);
/* Formats known */
extern GList *hf_formats;
......
......@@ -110,6 +110,9 @@ typedef struct {
*/
HFRenderInfo *render_info;
GnomeFont *decoration_font;
/* 6: The config */
GnomePrintConfig *gp_config;
} PrintJobInfo;
static void
......@@ -1174,16 +1177,13 @@ workbook_print_all (PrintJobInfo *pj, Workbook *wb)
static void
print_job_info_update_from_config (PrintJobInfo *pj)
{
double width = 1.0, height = 1.0;
double header = 0, footer = 0, left = 0, right = 0;
/* We shouldn't use this specific sheet info since the specs */
/* for other sheets may differ! */
PrintMargins *pm = &pj->sheet->print_info->margins;
gnome_print_job_get_page_size_from_config (pj->pi->print_config,
&width, &height);
pj->width = width;
pj->height = height;
if (!gnome_print_config_get_page_size (pj->gp_config, &pj->width, &pj->height))
pj->width = pj->height = 1.;
print_info_get_margins (pj->pi, &header, &footer, &left, &right);
pj->x_points = pj->width - (left + right);
......@@ -1204,6 +1204,7 @@ print_job_info_get (Sheet *sheet, PrintRange range, gboolean const preview)
*/
pj->sheet = sheet;
pj->pi = print_info_dup (sheet->print_info);
pj->gp_config = print_info_make_config (pj->pi);
/*
* Values that should be entered in a dialog box
......@@ -1218,7 +1219,6 @@ print_job_info_get (Sheet *sheet, PrintRange range, gboolean const preview)
/* Precompute information */
print_job_info_update_from_config (pj);
/*
* Setup render info
*/
......@@ -1239,11 +1239,13 @@ print_job_info_get (Sheet *sheet, PrintRange range, gboolean const preview)
static void
print_job_info_destroy (PrintJobInfo *pj)
{
print_info_load_config (pj->sheet->print_info, pj->gp_config);
g_object_unref (pj->gp_config);
hf_render_info_destroy (pj->render_info);
if (pj->decoration_font)
g_object_unref (G_OBJECT (pj->decoration_font));
g_object_unref (pj->decoration_font);
if (pj->print_context)
g_object_unref (G_OBJECT (pj->