# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([libreptool], [0.2.1], [azagli@libero.it])
+AC_INIT([libreptool], [0.2.2], [azagli@libero.it])
AC_CONFIG_SRCDIR([src/rptprint.c])
AC_CONFIG_HEADER([config.h])
eRptOutputType output_type;
gchar *output_filename;
- guint copies;
+ GtkPrintSettings *gtk_print_settings;
gdouble width;
gdouble height;
priv->surface = NULL;
priv->cr = NULL;
priv->gtk_print_context = NULL;
+ priv->gtk_print_settings = NULL;
}
/**
}
}
+/**
+ * rpt_print_set_gtkprintsettings:
+ * @rpt_print: an #RptPrint object.
+ * @settings: a #GtkPrintSettings object.
+ *
+ */
+void
+rpt_print_set_gtkprintsettings (RptPrint *rpt_print, GtkPrintSettings *settings)
+{
+ g_return_if_fail (IS_RPT_PRINT (rpt_print));
+ g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings));
+
+ RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
+
+ if (GTK_IS_PRINT_SETTINGS (priv->gtk_print_settings))
+ {
+ g_object_unref (priv->gtk_print_settings);
+ }
+ priv->gtk_print_settings = gtk_print_settings_copy (settings);
+}
+
/**
* rpt_print_set_copies:
* @rpt_print: an #RptPrint object.
* @copies: number of copies.
*
+ * Deprecated:0.2.2: use rpt_print_set_gtkprintsettings() instead.
*/
void
rpt_print_set_copies (RptPrint *rpt_print, guint copies)
RptPrintPrivate *priv = RPT_PRINT_GET_PRIVATE (rpt_print);
- priv->copies = copies;
+ if (!GTK_IS_PRINT_SETTINGS (priv->gtk_print_settings))
+ {
+ priv->gtk_print_settings = gtk_print_settings_new ();
+ }
+ gtk_print_settings_set_n_copies (priv->gtk_print_settings, copies);
}
/**
g_signal_connect (G_OBJECT (operation), "draw-page",
G_CALLBACK (rpt_print_gtk_draw_page), (gpointer)rpt_print);
+ if (GTK_IS_PRINT_SETTINGS (priv->gtk_print_settings))
+ {
+ gtk_print_operation_set_print_settings (operation, priv->gtk_print_settings);
+ }
+
error = NULL;
locale_num = setlocale (LC_NUMERIC, "C");
res = gtk_print_operation_run (operation,
break;
case PROP_COPIES:
- g_value_set_uint (value, priv->copies);
+ if (priv->gtk_print_settings != NULL)
+ {
+ g_value_set_uint (value, gtk_print_settings_get_n_copies (priv->gtk_print_settings));
+ }
+ else
+ {
+ g_value_set_uint (value, 1);
+ }
break;
case PROP_PATH_RELATIVES_TO:
gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);
gtk_print_operation_set_n_pages (operation, priv->pages->nodeNr);
-
- GtkPrintSettings *settings = gtk_print_operation_get_print_settings (operation);
- if (settings == NULL)
- {
- settings = gtk_print_settings_new ();
- }
- gtk_print_settings_set_n_copies (settings, priv->copies);
- gtk_print_operation_set_print_settings (operation, settings);
}
static void
void rpt_print_set_output_type (RptPrint *rpt_print, eRptOutputType output_type);
void rpt_print_set_output_filename (RptPrint *rpt_print, const gchar *output_filename);
+void rpt_print_set_gtkprintsettings (RptPrint *rpt_print, GtkPrintSettings *settings);
void rpt_print_set_copies (RptPrint *rpt_print, guint copies);
void rpt_print_print (RptPrint *rpt_print, GtkWindow *transient);
static gchar *path_relatives_to = NULL;
static gchar *output_type = NULL;
static gchar *output_file_name = NULL;
+static gchar *printer_name = NULL;
+static gint copies = 1;
static GOptionEntry entries[] =
{
{ "path-relatives-to", 't', 0, G_OPTION_ARG_FILENAME, &path_relatives_to, "Path relatives to", "FILE-NAME" },
{ "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
{ "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
+ { "printer-name", 0, 0, G_OPTION_ARG_STRING, &printer_name, "Printer name", "PRINTER-NAME" },
+ { "copies", 0, 0, G_OPTION_ARG_INT, &copies, "Number of copies", "N_COPIES" },
{ NULL }
};
RptReport *rptr;
RptPrint *rptp;
+ GtkPrintSettings *settings;
+
g_type_init ();
context = g_option_context_new ("- test rptprint");
if (rptr != NULL)
{
+ rpt_report_set_output_type (rptr, rpt_common_stroutputtype_to_enum (output_type));
+ if (g_strcmp0 (output_type, "png") == 0
+ || g_strcmp0 (output_type, "pdf") == 0
+ || g_strcmp0 (output_type, "ps") == 0
+ || g_strcmp0 (output_type, "svg") == 0)
+ {
+ rpt_report_set_output_filename (rptr, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
+ }
+
xmlDoc *report = rpt_report_get_xml (rptr);
if (xml_rpt_file_name != NULL)
{
{
rpt_print_set_output_filename (rptp, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
}
+
+ if (printer_name != NULL)
+ {
+ if (!GTK_IS_PRINT_SETTINGS (settings))
+ {
+ settings = gtk_print_settings_new ();
+ }
+ gtk_print_settings_set_printer (settings, printer_name);
+ }
+ if (copies > 1)
+ {
+ if (!GTK_IS_PRINT_SETTINGS (settings))
+ {
+ settings = gtk_print_settings_new ();
+ }
+ gtk_print_settings_set_n_copies (settings, copies);
+ }
+
+ if (GTK_IS_PRINT_SETTINGS (settings))
+ {
+ rpt_print_set_gtkprintsettings (rptp, settings);
+ }
+
rpt_print_print (rptp, NULL);
}
else