Commit a3394adb authored by Marek Kasik's avatar Marek Kasik

glib: Make NumCopies preference available in API

Add poppler_document_get_print_n_copies() so that applications which
use poppler's glib frontend can access this preference.

poppler/poppler#290
parent 038340fa
......@@ -82,7 +82,8 @@ enum {
PROP_PERMISSIONS,
PROP_METADATA,
PROP_PRINT_SCALING,
PROP_PRINT_DUPLEX
PROP_PRINT_DUPLEX,
PROP_PRINT_N_COPIES
};
static void poppler_document_layers_free (PopplerDocument *document);
......@@ -1697,6 +1698,36 @@ poppler_document_get_print_duplex (PopplerDocument *document)
return duplex;
}
/**
* poppler_document_get_print_n_copies:
* @document: A #PopplerDocument
*
* Returns the suggested number of copies to be printed.
*
* Returns: Number of copies
*
* Since: 0.78
**/
gint
poppler_document_get_print_n_copies (PopplerDocument *document)
{
Catalog *catalog;
ViewerPreferences *preferences;
gint retval = 1;
g_return_val_if_fail (POPPLER_IS_DOCUMENT (document), 1);
catalog = document->doc->getCatalog ();
if (catalog && catalog->isOk ()) {
preferences = catalog->getViewerPreferences();
if (preferences) {
retval = preferences->getNumCopies();
}
}
return retval;
}
/**
* poppler_document_get_permissions:
* @document: A #PopplerDocument
......@@ -1933,6 +1964,9 @@ poppler_document_get_property (GObject *object,
case PROP_PRINT_DUPLEX:
g_value_set_enum (value, poppler_document_get_print_duplex (document));
break;
case PROP_PRINT_N_COPIES:
g_value_set_int (value, poppler_document_get_print_n_copies (document));
break;
case PROP_PERMISSIONS:
g_value_set_flags (value, poppler_document_get_permissions (document));
break;
......@@ -2228,6 +2262,21 @@ poppler_document_class_init (PopplerDocumentClass *klass)
POPPLER_PRINT_DUPLEX_NONE,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
/**
* PopplerDocument:print-n-copies:
*
* Suggested number of copies to be printed for this document
*
* Since: 0.78
*/
g_object_class_install_property (G_OBJECT_CLASS (klass),
PROP_PRINT_N_COPIES,
g_param_spec_int ("print-n-copies",
"Number of Copies to Print",
"Number of Copies Viewer Preference",
1, G_MAXINT, 1,
(GParamFlags) (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)));
/**
* PopplerDocument:permissions:
*
......
......@@ -396,6 +396,8 @@ POPPLER_PUBLIC
PopplerPrintScaling poppler_document_get_print_scaling (PopplerDocument *document);
POPPLER_PUBLIC
PopplerPrintDuplex poppler_document_get_print_duplex (PopplerDocument *document);
POPPLER_PUBLIC
gint poppler_document_get_print_n_copies (PopplerDocument *document);
/* Attachments */
POPPLER_PUBLIC
......
......@@ -176,6 +176,7 @@ poppler_document_get_pdf_version
poppler_document_get_pdf_version_string
poppler_document_get_permissions
poppler_document_get_print_duplex
poppler_document_get_print_n_copies
poppler_document_get_print_scaling
poppler_document_get_producer
poppler_document_get_subject
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment