| Top |
A CtkPrintSettings object represents the settings of a print dialog in a system-independent way. The main use for this object is that once you’ve printed you can get a settings object that represents the settings the user chose, and the next time you print you can pass that object in so that the user doesn’t have to re-set all his settings.
Its also possible to enumerate the settings so that you can easily save the settings for the next time your app runs, or even store them in a document. The predefined keys try to use shared values as much as possible so that moving such a document between systems still works.
Printing support was added in CTK+ 2.10.
void (*CtkPrintSettingsFunc) (const gchar *key,const gchar *value,gpointer user_data);
CtkPrintSettings *
ctk_print_settings_new (void);
Creates a new CtkPrintSettings object.
Since: 2.10
CtkPrintSettings *
ctk_print_settings_copy (CtkPrintSettings *other);
Copies a CtkPrintSettings object.
Since: 2.10
gboolean ctk_print_settings_has_key (CtkPrintSettings *settings,const gchar *key);
Returns TRUE, if a value is associated with key
.
Since: 2.10
const gchar * ctk_print_settings_get (CtkPrintSettings *settings,const gchar *key);
Looks up the string value associated with key
.
Since: 2.10
void ctk_print_settings_set (CtkPrintSettings *settings,const gchar *key,const gchar *value);
Associates value
with key
.
Since: 2.10
void ctk_print_settings_unset (CtkPrintSettings *settings,const gchar *key);
Removes any value associated with key
.
This has the same effect as setting the value to NULL.
Since: 2.10
void ctk_print_settings_foreach (CtkPrintSettings *settings,CtkPrintSettingsFunc func,gpointer user_data);
Calls func
for each key-value pair of settings
.
Since: 2.10
gboolean ctk_print_settings_get_bool (CtkPrintSettings *settings,const gchar *key);
Returns the boolean represented by the value
that is associated with key
.
The string “true” represents TRUE, any other
string FALSE.
Since: 2.10
void ctk_print_settings_set_bool (CtkPrintSettings *settings,const gchar *key,gboolean value);
Sets key
to a boolean value.
Since: 2.10
gdouble ctk_print_settings_get_double (CtkPrintSettings *settings,const gchar *key);
Returns the double value associated with key
, or 0.
Since: 2.10
gdouble ctk_print_settings_get_double_with_default (CtkPrintSettings *settings,const gchar *key,gdouble def);
Returns the floating point number represented by
the value that is associated with key
, or default_val
if the value does not represent a floating point number.
Floating point numbers are parsed with g_ascii_strtod().
Since: 2.10
void ctk_print_settings_set_double (CtkPrintSettings *settings,const gchar *key,gdouble value);
Sets key
to a double value.
Since: 2.10
gdouble ctk_print_settings_get_length (CtkPrintSettings *settings,const gchar *key,CtkUnit unit);
Returns the value associated with key
, interpreted
as a length. The returned value is converted to units
.
Since: 2.10
void ctk_print_settings_set_length (CtkPrintSettings *settings,const gchar *key,gdouble value,CtkUnit unit);
Associates a length in units of unit
with key
.
Since: 2.10
gint ctk_print_settings_get_int (CtkPrintSettings *settings,const gchar *key);
Returns the integer value of key
, or 0.
Since: 2.10
gint ctk_print_settings_get_int_with_default (CtkPrintSettings *settings,const gchar *key,gint def);
Returns the value of key
, interpreted as
an integer, or the default value.
Since: 2.10
void ctk_print_settings_set_int (CtkPrintSettings *settings,const gchar *key,gint value);
Sets key
to an integer value.
Since: 2.10
const gchar *
ctk_print_settings_get_printer (CtkPrintSettings *settings);
Convenience function to obtain the value of
CTK_PRINT_SETTINGS_PRINTER.
Since: 2.10
void ctk_print_settings_set_printer (CtkPrintSettings *settings,const gchar *printer);
Convenience function to set CTK_PRINT_SETTINGS_PRINTER
to printer
.
Since: 2.10
CtkPageOrientation
ctk_print_settings_get_orientation (CtkPrintSettings *settings);
Get the value of CTK_PRINT_SETTINGS_ORIENTATION,
converted to a CtkPageOrientation.
Since: 2.10
void ctk_print_settings_set_orientation (CtkPrintSettings *settings,CtkPageOrientation orientation);
Sets the value of CTK_PRINT_SETTINGS_ORIENTATION.
Since: 2.10
CtkPaperSize *
ctk_print_settings_get_paper_size (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_PAPER_FORMAT,
converted to a CtkPaperSize.
Since: 2.10
void ctk_print_settings_set_paper_size (CtkPrintSettings *settings,CtkPaperSize *paper_size);
Sets the value of CTK_PRINT_SETTINGS_PAPER_FORMAT,
CTK_PRINT_SETTINGS_PAPER_WIDTH and
CTK_PRINT_SETTINGS_PAPER_HEIGHT.
Since: 2.10
gdouble ctk_print_settings_get_paper_width (CtkPrintSettings *settings,CtkUnit unit);
Gets the value of CTK_PRINT_SETTINGS_PAPER_WIDTH,
converted to unit
.
Since: 2.10
void ctk_print_settings_set_paper_width (CtkPrintSettings *settings,gdouble width,CtkUnit unit);
Sets the value of CTK_PRINT_SETTINGS_PAPER_WIDTH.
Since: 2.10
gdouble ctk_print_settings_get_paper_height (CtkPrintSettings *settings,CtkUnit unit);
Gets the value of CTK_PRINT_SETTINGS_PAPER_HEIGHT,
converted to unit
.
Since: 2.10
void ctk_print_settings_set_paper_height (CtkPrintSettings *settings,gdouble height,CtkUnit unit);
Sets the value of CTK_PRINT_SETTINGS_PAPER_HEIGHT.
Since: 2.10
gboolean
ctk_print_settings_get_use_color (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_USE_COLOR.
Since: 2.10
void ctk_print_settings_set_use_color (CtkPrintSettings *settings,gboolean use_color);
Sets the value of CTK_PRINT_SETTINGS_USE_COLOR.
Since: 2.10
gboolean
ctk_print_settings_get_collate (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_COLLATE.
Since: 2.10
void ctk_print_settings_set_collate (CtkPrintSettings *settings,gboolean collate);
Sets the value of CTK_PRINT_SETTINGS_COLLATE.
Since: 2.10
gboolean
ctk_print_settings_get_reverse (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_REVERSE.
Since: 2.10
void ctk_print_settings_set_reverse (CtkPrintSettings *settings,gboolean reverse);
Sets the value of CTK_PRINT_SETTINGS_REVERSE.
Since: 2.10
CtkPrintDuplex
ctk_print_settings_get_duplex (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_DUPLEX.
Since: 2.10
void ctk_print_settings_set_duplex (CtkPrintSettings *settings,CtkPrintDuplex duplex);
Sets the value of CTK_PRINT_SETTINGS_DUPLEX.
Since: 2.10
CtkPrintQuality
ctk_print_settings_get_quality (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_QUALITY.
Since: 2.10
void ctk_print_settings_set_quality (CtkPrintSettings *settings,CtkPrintQuality quality);
Sets the value of CTK_PRINT_SETTINGS_QUALITY.
Since: 2.10
gint
ctk_print_settings_get_n_copies (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_N_COPIES.
Since: 2.10
void ctk_print_settings_set_n_copies (CtkPrintSettings *settings,gint num_copies);
Sets the value of CTK_PRINT_SETTINGS_N_COPIES.
Since: 2.10
gint
ctk_print_settings_get_number_up (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_NUMBER_UP.
Since: 2.10
void ctk_print_settings_set_number_up (CtkPrintSettings *settings,gint number_up);
Sets the value of CTK_PRINT_SETTINGS_NUMBER_UP.
Since: 2.10
CtkNumberUpLayout
ctk_print_settings_get_number_up_layout
(CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.
Since: 2.14
void ctk_print_settings_set_number_up_layout (CtkPrintSettings *settings,CtkNumberUpLayout number_up_layout);
Sets the value of CTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.
Since: 2.14
gint
ctk_print_settings_get_resolution (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_RESOLUTION.
Since: 2.10
void ctk_print_settings_set_resolution (CtkPrintSettings *settings,gint resolution);
Sets the values of CTK_PRINT_SETTINGS_RESOLUTION,
CTK_PRINT_SETTINGS_RESOLUTION_X and
CTK_PRINT_SETTINGS_RESOLUTION_Y.
Since: 2.10
void ctk_print_settings_set_resolution_xy (CtkPrintSettings *settings,gint resolution_x,gint resolution_y);
Sets the values of CTK_PRINT_SETTINGS_RESOLUTION,
CTK_PRINT_SETTINGS_RESOLUTION_X and
CTK_PRINT_SETTINGS_RESOLUTION_Y.
settings |
||
resolution_x |
the horizontal resolution in dpi |
|
resolution_y |
the vertical resolution in dpi |
Since: 2.16
gint
ctk_print_settings_get_resolution_x (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_RESOLUTION_X.
Since: 2.16
gint
ctk_print_settings_get_resolution_y (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_RESOLUTION_Y.
Since: 2.16
gdouble
ctk_print_settings_get_printer_lpi (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_PRINTER_LPI.
Since: 2.16
void ctk_print_settings_set_printer_lpi (CtkPrintSettings *settings,gdouble lpi);
Sets the value of CTK_PRINT_SETTINGS_PRINTER_LPI.
Since: 2.16
gdouble
ctk_print_settings_get_scale (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_SCALE.
Since: 2.10
void ctk_print_settings_set_scale (CtkPrintSettings *settings,gdouble scale);
Sets the value of CTK_PRINT_SETTINGS_SCALE.
Since: 2.10
CtkPrintPages
ctk_print_settings_get_print_pages (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_PRINT_PAGES.
Since: 2.10
void ctk_print_settings_set_print_pages (CtkPrintSettings *settings,CtkPrintPages pages);
Sets the value of CTK_PRINT_SETTINGS_PRINT_PAGES.
Since: 2.10
CtkPageRange * ctk_print_settings_get_page_ranges (CtkPrintSettings *settings,gint *num_ranges);
Gets the value of CTK_PRINT_SETTINGS_PAGE_RANGES.
an array
of CtkPageRanges. Use g_free() to free the array when
it is no longer needed.
[array length=num_ranges][transfer full]
Since: 2.10
void ctk_print_settings_set_page_ranges (CtkPrintSettings *settings,CtkPageRange *page_ranges,gint num_ranges);
Sets the value of CTK_PRINT_SETTINGS_PAGE_RANGES.
settings |
||
page_ranges |
an array of CtkPageRanges. |
[array length=num_ranges] |
num_ranges |
the length of |
Since: 2.10
CtkPageSet
ctk_print_settings_get_page_set (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_PAGE_SET.
Since: 2.10
void ctk_print_settings_set_page_set (CtkPrintSettings *settings,CtkPageSet page_set);
Sets the value of CTK_PRINT_SETTINGS_PAGE_SET.
Since: 2.10
const gchar *
ctk_print_settings_get_default_source (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_DEFAULT_SOURCE.
Since: 2.10
void ctk_print_settings_set_default_source (CtkPrintSettings *settings,const gchar *default_source);
Sets the value of CTK_PRINT_SETTINGS_DEFAULT_SOURCE.
Since: 2.10
const gchar *
ctk_print_settings_get_media_type (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_MEDIA_TYPE.
The set of media types is defined in PWG 5101.1-2002 PWG.
Since: 2.10
void ctk_print_settings_set_media_type (CtkPrintSettings *settings,const gchar *media_type);
Sets the value of CTK_PRINT_SETTINGS_MEDIA_TYPE.
The set of media types is defined in PWG 5101.1-2002 PWG.
Since: 2.10
const gchar *
ctk_print_settings_get_dither (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_DITHER.
Since: 2.10
void ctk_print_settings_set_dither (CtkPrintSettings *settings,const gchar *dither);
Sets the value of CTK_PRINT_SETTINGS_DITHER.
Since: 2.10
const gchar *
ctk_print_settings_get_finishings (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_FINISHINGS.
Since: 2.10
void ctk_print_settings_set_finishings (CtkPrintSettings *settings,const gchar *finishings);
Sets the value of CTK_PRINT_SETTINGS_FINISHINGS.
Since: 2.10
const gchar *
ctk_print_settings_get_output_bin (CtkPrintSettings *settings);
Gets the value of CTK_PRINT_SETTINGS_OUTPUT_BIN.
Since: 2.10
void ctk_print_settings_set_output_bin (CtkPrintSettings *settings,const gchar *output_bin);
Sets the value of CTK_PRINT_SETTINGS_OUTPUT_BIN.
Since: 2.10
CtkPrintSettings * ctk_print_settings_new_from_file (const gchar *file_name,GError **error);
Reads the print settings from file_name
. Returns a new CtkPrintSettings
object with the restored settings, or NULL if an error occurred. If the
file could not be loaded then error is set to either a GFileError or
GKeyFileError. See ctk_print_settings_to_file().
file_name |
the filename to read the settings from. |
[type filename] |
error |
return location for errors, or |
[allow-none] |
Since: 2.12
CtkPrintSettings * ctk_print_settings_new_from_key_file (GKeyFile *key_file,const gchar *group_name,GError **error);
Reads the print settings from the group group_name
in key_file
. Returns a
new CtkPrintSettings object with the restored settings, or NULL if an
error occurred. If the file could not be loaded then error is set to either
a GFileError or GKeyFileError.
key_file |
the GKeyFile to retrieve the settings from |
|
group_name |
the name of the group to use, or |
[allow-none] |
error |
return location for errors, or |
[allow-none] |
Since: 2.12
CtkPrintSettings *
ctk_print_settings_new_from_gvariant (GVariant *variant);
Deserialize print settings from an a{sv} variant in
the format produced by ctk_print_settings_to_gvariant().
Since: 3.22
gboolean ctk_print_settings_load_file (CtkPrintSettings *settings,const gchar *file_name,GError **error);
Reads the print settings from file_name
. If the file could not be loaded
then error is set to either a GFileError or GKeyFileError.
See ctk_print_settings_to_file().
settings |
||
file_name |
the filename to read the settings from. |
[type filename] |
error |
return location for errors, or |
[allow-none] |
Since: 2.14
gboolean ctk_print_settings_load_key_file (CtkPrintSettings *settings,GKeyFile *key_file,const gchar *group_name,GError **error);
Reads the print settings from the group group_name
in key_file
. If the
file could not be loaded then error is set to either a GFileError or
GKeyFileError.
settings |
||
key_file |
the GKeyFile to retrieve the settings from |
|
group_name |
the name of the group to use, or |
[allow-none] |
error |
return location for errors, or |
[allow-none] |
Since: 2.14
gboolean ctk_print_settings_to_file (CtkPrintSettings *settings,const gchar *file_name,GError **error);
This function saves the print settings from settings
to file_name
. If the
file could not be loaded then error is set to either a GFileError or
GKeyFileError.
settings |
||
file_name |
the file to save to. |
[type filename] |
error |
return location for errors, or |
[allow-none] |
Since: 2.12
void ctk_print_settings_to_key_file (CtkPrintSettings *settings,GKeyFile *key_file,const gchar *group_name);
This function adds the print settings from settings
to key_file
.
settings |
||
key_file |
the GKeyFile to save the print settings to |
|
group_name |
the group to add the settings to in |
[nullable] |
Since: 2.12
GVariant *
ctk_print_settings_to_gvariant (CtkPrintSettings *settings);
Serialize print settings to an a{sv} variant.
Since: 3.22
Used to determine the layout of pages on a sheet when printing multiple pages per sheet.
struct CtkPageRange {
gint start;
gint end;
};
See also ctk_print_settings_set_page_ranges().
#define CTK_PRINT_SETTINGS_OUTPUT_DIR "output-dir"
The key used by the “Print to file” printer to store the directory to which the output should be written.
Since: 3.6
#define CTK_PRINT_SETTINGS_OUTPUT_BASENAME "output-basename"
The key used by the “Print to file” printer to store the file name of the output without the path to the directory and the file extension.
Since: 3.6
#define CTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT "output-file-format"
The key used by the “Print to file” printer to store the format of the output. The supported values are “PS” and “PDF”.
#define CTK_PRINT_SETTINGS_OUTPUT_URI "output-uri"
The key used by the “Print to file” printer to store the URI to which the output should be written. CTK+ itself supports only “file://” URIs.
#define CTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA "win32-driver-extra"