rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / papersize.ccg
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 <gtk/gtkpapersize.h>
19 #include <gtk/gtktypebuiltins.h>
20
21 namespace Gtk
22 {
23
24 //PaperSize::PaperSize()
25 //:
26 //  gobject_(gtk_paper_size_new(gtk_paper_size_get_default()))
27 //{}
28
29 PaperSize::PaperSize(const Glib::ustring& name)
30 :
31   gobject_(gtk_paper_size_new(name.c_str()))
32 {}
33
34 PaperSize::PaperSize(const Glib::ustring& ppd_name, const Glib::ustring& ppd_display_name, double width, double height)
35 :
36   gobject_(gtk_paper_size_new_from_ppd(ppd_name.c_str(),
37                                        ppd_display_name.c_str(),
38                                        gdouble(width),
39                                        gdouble(height)))
40 {}
41
42 PaperSize::PaperSize(const Glib::ustring& name, const Glib::ustring& display_name, double width, double height, Unit unit)
43 :
44   gobject_(gtk_paper_size_new_custom(name.c_str(),
45                                      display_name.c_str(),
46                                      gdouble(width),
47                                      gdouble(height),
48                                      GtkUnit(unit)))
49 {}
50
51 //TODO: Add an operator bool() so we can detect if this succeeded:
52 PaperSize::PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
53 :
54   gobject_(gtk_paper_size_new_from_key_file(const_cast<GKeyFile*>(key_file.gobj()), (group_name.empty() ? NULL : group_name.c_str()) , NULL /* GError */))
55 {}
56
57 bool PaperSize::equal(const PaperSize& other) const
58 {
59   return (static_cast<bool>(gtk_paper_size_is_equal(const_cast<GtkPaperSize*>(this->gobj()),
60                                                     const_cast<GtkPaperSize*>(other.gobj()))));
61 }
62
63 PaperSize::operator bool() const
64 {
65   return (gobj() != NULL);
66 }
67
68 void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
69 {
70   gtk_paper_size_to_key_file( gobj(), (key_file).gobj(), 0); 
71 }
72
73
74 } // namespace Gtk