1 /* Copyright (C) 2006 The gtkmm Development Team
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Library General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Library General Public License for more details.
13 * You should have received a copy of the GNU Library General Public
14 * License along with this library; if not, write to the Free
15 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include <glibmm/object.h>
19 #include <gtkmm/enums.h>
20 #include <gtkmm/papersize.h>
23 _PINCLUDE(glibmm/private/object_p.h)
28 _WRAP_ENUM(PrintDuplex, GtkPrintDuplex)
29 _WRAP_ENUM(PrintQuality, GtkPrintQuality)
30 _WRAP_ENUM(PrintPages, GtkPrintPages)
31 _WRAP_ENUM(PageSet, GtkPageSet)
33 /** A PrintSettings object represents the settings of a print dialog in a system-independent way.
34 * The main use for this object is that once you've printed you can get a settings object that
35 * represents the settings the user chose, and the next time you print you can pass that object
36 * in so that the user doesn't have to re-set all his settings.
38 * It's also possible to enumerate the settings so that you can easily save the settings for the
39 * next time your app runs, or even store them in a document. The predefined keys try to use shared
40 * values as much as possible so that moving such a document between systems still works.
46 class PrintSettings : public Glib::Object
48 _CLASS_GOBJECT(PrintSettings, GtkPrintSettings, GTK_PRINT_SETTINGS, Glib::Object, GObject)
52 #if 0 //TODO: Reimplement, or add _construct_from_* functions in GTK+.
53 GtkPrintSettings *gtk_print_settings_new_from_file (const gchar *file_name,
55 GtkPrintSettings *gtk_print_settings_new_from_key_file (GKeyFile *key_file,
56 const gchar *group_name,
63 /** Print settings keys.
68 static const Glib::ustring PRINTER;
69 static const Glib::ustring ORIENTATION;
70 static const Glib::ustring PAPER_FORMAT;
71 static const Glib::ustring PAPER_WIDTH;
72 static const Glib::ustring PAPER_HEIGHT;
73 static const Glib::ustring NUM_COPIES;
74 static const Glib::ustring DEFAULT_SOURCE;
75 static const Glib::ustring QUALITY;
76 static const Glib::ustring RESOLUTION;
77 static const Glib::ustring USE_COLOR;
78 static const Glib::ustring DUPLEX;
79 static const Glib::ustring COLLATE;
80 static const Glib::ustring REVERSE;
81 static const Glib::ustring MEDIA_TYPE;
82 static const Glib::ustring DITHER;
83 static const Glib::ustring SCALE;
84 static const Glib::ustring PRINT_PAGES;
85 static const Glib::ustring PAGE_RANGES;
86 static const Glib::ustring PAGE_SET;
87 static const Glib::ustring FINISHINGS;
88 static const Glib::ustring NUMBER_UP;
89 static const Glib::ustring OUTPUT_BIN;
91 static const Glib::ustring OUTPUT_FILE_FORMAT;
92 static const Glib::ustring OUTPUT_URI;
94 static const Glib::ustring WIN32_DRIVER_VERSION;
95 static const Glib::ustring WIN32_DRIVER_EXTRA;
98 _IGNORE(gtk_print_settings_copy)
100 _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_print_settings_to_file, errthrow)
102 #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
103 _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name) const, gtk_print_settings_to_key_file)
105 /** This function adds the print settings from @a settings to @a key_file,
106 * in the "Print Settings" group.
109 * @param key_file The Glib::KeyFile to save the print settings to.
111 void save_to_key_file(Glib::KeyFile& key_file);
113 //TODO: add a @see link?
114 _WRAP_METHOD(bool has_key(const Glib::ustring& key) const, gtk_print_settings_has_key)
116 _WRAP_METHOD(Glib::ustring get(const Glib::ustring& key) const, gtk_print_settings_get)
118 _WRAP_METHOD(void set(const Glib::ustring& key, const Glib::ustring& value), gtk_print_settings_set)
119 _WRAP_METHOD(void unset(const Glib::ustring& key), gtk_print_settings_unset)
122 * void on_foreach_setting(const Glib::ustring& key, const Glib::ustring& value);
124 typedef sigc::slot<void, const Glib::ustring&, const Glib::ustring&> SlotForeach;
126 /** Calls a function for each print setting.
127 * @param slot The callback to call for each print setting.
129 void setting_foreach(const SlotForeach& slot);
131 _IGNORE(gtk_print_settings_foreach)
133 _WRAP_METHOD(bool get_bool(const Glib::ustring& key) const, gtk_print_settings_get_bool)
134 _WRAP_METHOD(void set_bool(const Glib::ustring& key, bool value = true), gtk_print_settings_set_bool)
136 _WRAP_METHOD(double get_double(const Glib::ustring& key) const, gtk_print_settings_get_double)
137 _WRAP_METHOD(double get_double_with_default(const Glib::ustring& key, double def) const,
138 gtk_print_settings_get_double_with_default)
139 _WRAP_METHOD(void set_double(const Glib::ustring& key, double value), gtk_print_settings_set_double)
141 _WRAP_METHOD(double get_length(const Glib::ustring& key, Unit unit) const, gtk_print_settings_get_length)
142 _WRAP_METHOD(void set_length(const Glib::ustring& key, double value, Unit unit), gtk_print_settings_set_length)
144 _WRAP_METHOD(int get_int(const Glib::ustring& key) const, gtk_print_settings_get_int)
145 _WRAP_METHOD(int get_int_with_default(const Glib::ustring& key, int def) const,
146 gtk_print_settings_get_int_with_default)
147 _WRAP_METHOD(void set_int(const Glib::ustring& key, int value), gtk_print_settings_set_int)
151 _WRAP_METHOD(Glib::ustring get_printer() const, gtk_print_settings_get_printer)
152 _WRAP_METHOD(void set_printer(const Glib::ustring& name), gtk_print_settings_set_printer)
154 _WRAP_METHOD(PageOrientation get_orientation() const, gtk_print_settings_get_orientation)
155 _WRAP_METHOD(void set_orientation(PageOrientation orientation), gtk_print_settings_set_orientation)
157 _WRAP_METHOD(PaperSize get_paper_size(), gtk_print_settings_get_paper_size)
158 _WRAP_METHOD(const PaperSize get_paper_size() const, gtk_print_settings_get_paper_size, constversion)
159 _WRAP_METHOD(void set_paper_size(const PaperSize& paper_size), gtk_print_settings_set_paper_size)
161 _WRAP_METHOD(double get_paper_width(Unit unit) const, gtk_print_settings_get_paper_width)
162 _WRAP_METHOD(void set_paper_width(double width, Unit unit), gtk_print_settings_set_paper_width)
163 _WRAP_METHOD(double get_paper_height(Unit unit) const, gtk_print_settings_get_paper_height)
164 _WRAP_METHOD(void set_paper_height(double height, Unit unit), gtk_print_settings_set_paper_height)
166 _WRAP_METHOD(bool get_use_color() const, gtk_print_settings_get_use_color)
167 _WRAP_METHOD(void set_use_color(bool use_color = true), gtk_print_settings_set_use_color)
169 _WRAP_METHOD(bool get_collate() const, gtk_print_settings_get_collate)
170 _WRAP_METHOD(void set_collate(bool collate = true), gtk_print_settings_set_collate)
172 _WRAP_METHOD(bool get_reverse() const, gtk_print_settings_get_reverse)
173 _WRAP_METHOD(void set_reverse(bool reverse = true), gtk_print_settings_set_reverse)
175 _WRAP_METHOD(PrintDuplex get_duplex() const, gtk_print_settings_get_duplex)
176 _WRAP_METHOD(void set_duplex(PrintDuplex duplex), gtk_print_settings_set_duplex)
178 _WRAP_METHOD(PrintQuality get_quality() const, gtk_print_settings_get_quality)
179 _WRAP_METHOD(void set_quality(PrintQuality quality), gtk_print_settings_set_quality)
181 _WRAP_METHOD(int get_n_copies() const, gtk_print_settings_get_n_copies)
182 _WRAP_METHOD(void set_n_copies(int num_copies), gtk_print_settings_set_n_copies)
184 _WRAP_METHOD(int get_number_up() const, gtk_print_settings_get_number_up)
185 _WRAP_METHOD(void set_number_up(int number_up), gtk_print_settings_set_number_up)
187 _WRAP_METHOD(int get_resolution() const, gtk_print_settings_get_resolution)
188 _WRAP_METHOD(void set_resolution(int resolution), gtk_print_settings_set_resolution)
190 _WRAP_METHOD(double get_scale() const, gtk_print_settings_get_scale)
191 _WRAP_METHOD(void set_scale(double scale), gtk_print_settings_set_scale)
193 _WRAP_METHOD(PrintPages get_print_pages() const, gtk_print_settings_get_print_pages)
194 _WRAP_METHOD(void set_print_pages(PrintPages print_pages), gtk_print_settings_set_print_pages)
196 //This corresponds to GtkPageRange.
201 PageRange(int start, int end);
207 Glib::ArrayHandle<PageRange> get_page_ranges() const;
208 void set_page_ranges(const Glib::ArrayHandle<PageRange>& page_ranges);
210 _IGNORE(gtk_print_settings_get_page_ranges, gtk_print_settings_set_page_ranges)
212 _WRAP_METHOD(PageSet get_page_set() const, gtk_print_settings_get_page_set)
213 _WRAP_METHOD(void set_page_set(PageSet page_set), gtk_print_settings_set_page_set)
215 _WRAP_METHOD(Glib::ustring get_default_source() const, gtk_print_settings_get_default_source)
216 _WRAP_METHOD(void set_default_source(const Glib::ustring& default_source), gtk_print_settings_set_default_source)
218 _WRAP_METHOD(Glib::ustring get_media_type() const, gtk_print_settings_get_media_type)
219 _WRAP_METHOD(void set_media_type(const Glib::ustring& media_type), gtk_print_settings_set_media_type)
221 _WRAP_METHOD(Glib::ustring get_dither() const, gtk_print_settings_get_dither)
222 _WRAP_METHOD(void set_dither(const Glib::ustring& dither), gtk_print_settings_set_dither)
224 _WRAP_METHOD(Glib::ustring get_finishings() const, gtk_print_settings_get_finishings)
225 _WRAP_METHOD(void set_finishings(const Glib::ustring& finishings), gtk_print_settings_set_finishings)
227 _WRAP_METHOD(Glib::ustring get_output_bin() const, gtk_print_settings_get_output_bin)
228 _WRAP_METHOD(void set_output_bin(const Glib::ustring& output_bin), gtk_print_settings_set_output_bin)
230 //There are no properties.