Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / src / printsettings.hg
1 /* Copyright (C) 2006 The gtkmm Development Team
2  *
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.
7  *
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.
12  *
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.
16  */
17
18 #include <glibmm/object.h>
19 #include <gtkmm/enums.h>
20 #include <gtkmm/papersize.h>
21
22 _DEFS(gtkmm,gtk)
23 _PINCLUDE(glibmm/private/object_p.h)
24
25 namespace Gtk
26 {
27
28 _WRAP_ENUM(PrintDuplex, GtkPrintDuplex)
29 _WRAP_ENUM(PrintQuality, GtkPrintQuality)
30 _WRAP_ENUM(PrintPages, GtkPrintPages)
31 _WRAP_ENUM(PageSet, GtkPageSet)
32
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.
37  * 
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. 
41  *
42  * @newin2p10
43  *
44  * @ingroup Printing
45  */
46 class PrintSettings : public Glib::Object
47 {
48   _CLASS_GOBJECT(PrintSettings, GtkPrintSettings, GTK_PRINT_SETTINGS, Glib::Object, GObject)
49 protected:
50   _CTOR_DEFAULT
51
52 #if 0 //TODO: Reimplement, or add _construct_from_* functions in GTK+.
53 GtkPrintSettings *gtk_print_settings_new_from_file           (const gchar          *file_name,
54                                                               GError              **error);
55 GtkPrintSettings *gtk_print_settings_new_from_key_file       (GKeyFile             *key_file,
56                                                               const gchar          *group_name,
57                                                               GError              **error);
58 #endif
59
60 public:
61   _WRAP_CREATE()
62
63   /** Print settings keys.
64    */
65   class Keys
66   {
67   public:
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;
90
91     static const Glib::ustring OUTPUT_FILE_FORMAT;
92     static const Glib::ustring OUTPUT_URI;
93
94     static const Glib::ustring WIN32_DRIVER_VERSION;
95     static const Glib::ustring WIN32_DRIVER_EXTRA;
96   };
97
98   _IGNORE(gtk_print_settings_copy)
99
100   _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_print_settings_to_file, errthrow)
101
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)
104
105   /** This function adds the print settings from @a settings to @a key_file,
106    * in the "Print Settings" group.
107    * 
108    * @newin2p12
109    * @param key_file The Glib::KeyFile to save the print settings to.
110    */
111   void save_to_key_file(Glib::KeyFile& key_file);
112
113   //TODO: add a @see link?
114   _WRAP_METHOD(bool has_key(const Glib::ustring& key) const, gtk_print_settings_has_key)
115
116   _WRAP_METHOD(Glib::ustring get(const Glib::ustring& key) const, gtk_print_settings_get)
117
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)
120
121   /** For example, 
122    * void on_foreach_setting(const Glib::ustring& key, const Glib::ustring& value);
123    */
124   typedef sigc::slot<void, const Glib::ustring&, const Glib::ustring&> SlotForeach;
125
126   /** Calls a function for each print setting.
127   * @param slot The callback to call for each print setting.
128   */
129   void setting_foreach(const SlotForeach& slot);
130
131  _IGNORE(gtk_print_settings_foreach)
132
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)
135
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)
140
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)
143
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)
148
149   // helpers:
150
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)
153
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)
156
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)
160
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)
165
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)
168
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)
171
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)
174
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)
177
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)
180
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)
183
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)
186
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)
189
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)
192
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)
195
196   //This corresponds to GtkPageRange.
197   class PageRange
198   {
199   public:
200     PageRange();
201     PageRange(int start, int end);
202
203     int start;
204     int end;
205   };
206
207   Glib::ArrayHandle<PageRange> get_page_ranges() const;
208   void set_page_ranges(const Glib::ArrayHandle<PageRange>& page_ranges);
209
210   _IGNORE(gtk_print_settings_get_page_ranges, gtk_print_settings_set_page_ranges)
211
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)
214
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)
217
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)
220
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)
223
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)
226
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)
229
230   //There are no properties.
231 };
232
233 } // namespace Gtk