Class: Gtk::PrintSettings

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

A GtkPrintSettings 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 GTK+ 2.10.

Instance Method Summary collapse

Instance Method Details

#collateTrueClass

Gets the value of %GTK_PRINT_SETTINGS_COLLATE.

Returns:

  • (TrueClass)

    whether to collate the printed pages

#collate=(collate) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_COLLATE.

Parameters:

  • collate (TrueClass)

    whether to collate the output

Returns:

  • (nil)

#copyGtk::PrintSettings

Copies a Gtk::PrintSettings object.

Returns:

#default_sourceString

Gets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE.

Returns:

  • (String)

    the default source

#default_source=(default_source) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_DEFAULT_SOURCE.

Parameters:

  • default_source (String)

    the default source

Returns:

  • (nil)

#ditherString

Gets the value of %GTK_PRINT_SETTINGS_DITHER.

Returns:

  • (String)

    the dithering that is used

#dither=(dither) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_DITHER.

Parameters:

  • dither (String)

    the dithering that is used

Returns:

  • (nil)

#duplexGtk::PrintDuplex

Gets the value of %GTK_PRINT_SETTINGS_DUPLEX.

Returns:

#duplex=(duplex) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_DUPLEX.

Parameters:

Returns:

  • (nil)

#finishingsString

Gets the value of %GTK_PRINT_SETTINGS_FINISHINGS.

Returns:

  • (String)

    the finishings

#finishings=(finishings) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_FINISHINGS.

Parameters:

  • finishings (String)

    the finishings

Returns:

  • (nil)

#foreach(func, user_data) ⇒ nil

Calls func for each key-value pair of settings.

Parameters:

  • func (Gtk::PrintSettingsFunc)

    the function to call

  • user_data (GObject)

    user data for func

Returns:

  • (nil)

#get(key) ⇒ String

Looks up the string value associated with key.

Parameters:

  • key (String)

    a key

Returns:

  • (String)

    the string value for key

#get_bool(key) ⇒ TrueClass

Returns the boolean represented by the value that is associated with key.

The string “true” represents true, any other string false.

Parameters:

  • key (String)

    a key

Returns:

  • (TrueClass)

    true, if key maps to a true value.

#get_double(key) ⇒ Float

Returns the double value associated with key, or 0.

Parameters:

  • key (String)

    a key

Returns:

  • (Float)

    the double value of key

#get_double_with_default(key, def) ⇒ Float

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().

Parameters:

  • key (String)

    a key

  • def (Float)

    the default value

Returns:

  • (Float)

    the floating point number associated with key

#get_int(key) ⇒ Integer

Returns the integer value of key, or 0.

Parameters:

  • key (String)

    a key

Returns:

  • (Integer)

    the integer value of key

#get_int_with_default(key, def) ⇒ Integer

Returns the value of key, interpreted as an integer, or the default value.

Parameters:

  • key (String)

    a key

  • def (Integer)

    the default value

Returns:

  • (Integer)

    the integer value of key

#get_length(key, unit) ⇒ Float

Returns the value associated with key, interpreted as a length. The returned value is converted to units.

Parameters:

  • key (String)

    a key

  • unit (Gtk::Unit)

    the unit of the return value

Returns:

  • (Float)

    the length value of key, converted to unit

#get_page_ranges(num_ranges) ⇒ Array<Gtk::PageRange>

Gets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES.

Parameters:

  • num_ranges (Integer)

    return location for the length of the returned array

Returns:

  • (Array<Gtk::PageRange>)

    an array of Gtk::PageRanges. Use g_free() to free the array when it is no longer needed.

#get_paper_height(unit) ⇒ Float

Gets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT, converted to unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the paper height, in units of unit

#get_paper_width(unit) ⇒ Float

Gets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH, converted to unit.

Parameters:

  • unit (Gtk::Unit)

    the unit for the return value

Returns:

  • (Float)

    the paper width, in units of unit

#has_key(key) ⇒ TrueClass

Returns true, if a value is associated with key.

Parameters:

  • key (String)

    a key

Returns:

  • (TrueClass)

    true, if key has a value

#load_file(file_name) ⇒ TrueClass

Reads the print settings from file_name. If the file could not be loaded then error is set to either a GFile::Error or #GKeyFileError. See gtk_print_settings_to_file().

Parameters:

  • file_name (Gtk::filename)

    the filename to read the settings from

Returns:

  • (TrueClass)

    true on success

#load_key_file(key_file, group_name) ⇒ TrueClass

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 GFile::Error or GKey::FileError.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to retrieve the settings from

  • group_name (String)

    the name of the group to use, or nil to use the default “Print Settings”

Returns:

  • (TrueClass)

    true on success

#media_typeString

Gets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE.

The set of media types is defined in PWG 5101.1-2002 PWG.

Returns:

  • (String)

    the media type

#media_type=(media_type) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_MEDIA_TYPE.

The set of media types is defined in PWG 5101.1-2002 PWG.

Parameters:

  • media_type (String)

    the media type

Returns:

  • (nil)

#n_copiesInteger

Gets the value of %GTK_PRINT_SETTINGS_N_COPIES.

Returns:

  • (Integer)

    the number of copies to print

#n_copies=(num_copies) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_N_COPIES.

Parameters:

  • num_copies (Integer)

    the number of copies

Returns:

  • (nil)

#newGtk::PrintSettings

Creates a new Gtk::PrintSettings object.

Returns:

#new_from_file(file_name) ⇒ Gtk::PrintSettings

Reads the print settings from file_name. Returns a new Gtk::PrintSettings object with the restored settings, or nil if an error occurred. If the file could not be loaded then error is set to either a GFile::Error or GKey::FileError. See gtk_print_settings_to_file().

Parameters:

  • file_name (Gtk::filename)

    the filename to read the settings from

Returns:

#new_from_gvariant(variant) ⇒ Gtk::PrintSettings

Deserialize print settings from an asv variant in the format produced by gtk_print_settings_to_gvariant().

Parameters:

  • variant (GLib::Variant)

    an asv #GVariant

Returns:

#new_from_key_file(key_file, group_name) ⇒ Gtk::PrintSettings

Reads the print settings from the group group_name in key_file. Returns a new Gtk::PrintSettings object with the restored settings, or nil if an error occurred. If the file could not be loaded then error is set to either a GFile::Error or #GKeyFileError.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to retrieve the settings from

  • group_name (String)

    the name of the group to use, or nil to use the default “Print Settings”

Returns:

#number_upInteger

Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP.

Returns:

  • (Integer)

    the number of pages per sheet

#number_up=(number_up) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP.

Parameters:

  • number_up (Integer)

    the number of pages per sheet

Returns:

  • (nil)

#number_up_layoutGtk::NumberUpLayout

Gets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.

Returns:

#number_up_layout=(number_up_layout) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_NUMBER_UP_LAYOUT.

Parameters:

Returns:

  • (nil)

#orientationGtk::PageOrientation

Get the value of %GTK_PRINT_SETTINGS_ORIENTATION, converted to a Gtk::PageOrientation.

Returns:

#orientation=(orientation) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_ORIENTATION.

Parameters:

Returns:

  • (nil)

#output_binString

Gets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN.

Returns:

  • (String)

    the output bin

#output_bin=(output_bin) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_OUTPUT_BIN.

Parameters:

  • output_bin (String)

    the output bin

Returns:

  • (nil)

#page_setGtk::PageSet

Gets the value of %GTK_PRINT_SETTINGS_PAGE_SET.

Returns:

#page_set=(page_set) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PAGE_SET.

Parameters:

Returns:

  • (nil)

#paper_sizeGtk::PaperSize

Gets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT, converted to a Gtk::PaperSize.

Returns:

  • (Gtk::PaperSize)

    the paper size

#paper_size=(paper_size) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PAPER_FORMAT, %GTK_PRINT_SETTINGS_PAPER_WIDTH and %GTK_PRINT_SETTINGS_PAPER_HEIGHT.

Parameters:

  • paper_size (Gtk::PaperSize)

    a paper size

Returns:

  • (nil)

Gets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES.

Returns:

Sets the value of %GTK_PRINT_SETTINGS_PRINT_PAGES.

Parameters:

Returns:

  • (nil)

#printerString

Convenience function to obtain the value of %GTK_PRINT_SETTINGS_PRINTER.

Returns:

  • (String)

    the printer name

#printer=(printer) ⇒ nil

Convenience function to set %GTK_PRINT_SETTINGS_PRINTER to printer.

Parameters:

  • printer (String)

    the printer name

Returns:

  • (nil)

#printer_lpiFloat

Gets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI.

Returns:

  • (Float)

    the resolution in lpi (lines per inch)

#printer_lpi=(lpi) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PRINTER_LPI.

Parameters:

  • lpi (Float)

    the resolution in lpi (lines per inch)

Returns:

  • (nil)

#qualityGtk::PrintQuality

Gets the value of %GTK_PRINT_SETTINGS_QUALITY.

Returns:

#quality=(quality) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_QUALITY.

Parameters:

Returns:

  • (nil)

#resolutionInteger

Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION.

Returns:

  • (Integer)

    the resolution in dpi

#resolution=(resolution) ⇒ nil

Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION, %GTK_PRINT_SETTINGS_RESOLUTION_X and %GTK_PRINT_SETTINGS_RESOLUTION_Y.

Parameters:

  • resolution (Integer)

    the resolution in dpi

Returns:

  • (nil)

#resolution_xInteger

Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_X.

Returns:

  • (Integer)

    the horizontal resolution in dpi

#resolution_yInteger

Gets the value of %GTK_PRINT_SETTINGS_RESOLUTION_Y.

Returns:

  • (Integer)

    the vertical resolution in dpi

#reverseTrueClass

Gets the value of %GTK_PRINT_SETTINGS_REVERSE.

Returns:

  • (TrueClass)

    whether to reverse the order of the printed pages

#reverse=(reverse) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_REVERSE.

Parameters:

  • reverse (TrueClass)

    whether to reverse the output

Returns:

  • (nil)

#scaleFloat

Gets the value of %GTK_PRINT_SETTINGS_SCALE.

Returns:

  • (Float)

    the scale in percent

#scale=(scale) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_SCALE.

Parameters:

  • scale (Float)

    the scale in percent

Returns:

  • (nil)

#set(key, value) ⇒ nil

Associates value with key.

Parameters:

  • key (String)

    a key

  • value (String)

    a string value, or nil

Returns:

  • (nil)

#set_bool(key, value) ⇒ nil

Sets key to a boolean value.

Parameters:

  • key (String)

    a key

  • value (TrueClass)

    a boolean

Returns:

  • (nil)

#set_double(key, value) ⇒ nil

Sets key to a double value.

Parameters:

  • key (String)

    a key

  • value (Float)

    a double value

Returns:

  • (nil)

#set_int(key, value) ⇒ nil

Sets key to an integer value.

Parameters:

  • key (String)

    a key

  • value (Integer)

    an integer

Returns:

  • (nil)

#set_length(key, value, unit) ⇒ nil

Associates a length in units of unit with key.

Parameters:

  • key (String)

    a key

  • value (Float)

    a length

  • unit (Gtk::Unit)

    the unit of length

Returns:

  • (nil)

#set_page_ranges(page_ranges, num_ranges) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PAGE_RANGES.

Parameters:

  • page_ranges (Array<Gtk::PageRange>)

    an array of Gtk::PageRanges

  • num_ranges (Integer)

    the length of page_ranges

Returns:

  • (nil)

#set_paper_height(height, unit) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PAPER_HEIGHT.

Parameters:

  • height (Float)

    the paper height

  • unit (Gtk::Unit)

    the units of height

Returns:

  • (nil)

#set_paper_width(width, unit) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_PAPER_WIDTH.

Parameters:

  • width (Float)

    the paper width

  • unit (Gtk::Unit)

    the units of width

Returns:

  • (nil)

#set_resolution_xy(resolution_x, resolution_y) ⇒ nil

Sets the values of %GTK_PRINT_SETTINGS_RESOLUTION, %GTK_PRINT_SETTINGS_RESOLUTION_X and %GTK_PRINT_SETTINGS_RESOLUTION_Y.

Parameters:

  • resolution_x (Integer)

    the horizontal resolution in dpi

  • resolution_y (Integer)

    the vertical resolution in dpi

Returns:

  • (nil)

#to_file(file_name) ⇒ TrueClass

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 GFile::Error or GKey::FileError.

Parameters:

  • file_name (Gtk::filename)

    the file to save to

Returns:

  • (TrueClass)

    true on success

#to_gvariantGLib::Variant

Serialize print settings to an asv variant.

Returns:

  • (GLib::Variant)

    a new, floating, #GVariant

#to_key_file(key_file, group_name) ⇒ nil

This function adds the print settings from settings to key_file.

Parameters:

  • key_file (GLib::KeyFile)

    the GKey::File to save the print settings to

  • group_name (String)

    the group to add the settings to in key_file, or nil to use the default “Print Settings”

Returns:

  • (nil)

#unset(key) ⇒ nil

Removes any value associated with key. This has the same effect as setting the value to nil.

Parameters:

  • key (String)

    a key

Returns:

  • (nil)

#use_colorTrueClass

Gets the value of %GTK_PRINT_SETTINGS_USE_COLOR.

Returns:

  • (TrueClass)

    whether to use color

#use_color=(use_color) ⇒ nil

Sets the value of %GTK_PRINT_SETTINGS_USE_COLOR.

Parameters:

  • use_color (TrueClass)

    whether to use color

Returns:

  • (nil)