1 /**
2 * \brief Inkscape Preferences dialog
3 *
4 * Authors:
5 * Marco Scholten
6 * Bruno Dilly <bruno.dilly@gmail.com>
7 *
8 * Copyright (C) 2004, 2006, 2007 Authors
9 *
10 * Released under GNU GPL. Read the file 'COPYING' for more information.
11 */
13 #ifndef INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
14 #define INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
16 #include <iostream>
17 #include <vector>
18 #include <gtkmm/table.h>
19 #include <gtkmm/comboboxtext.h>
20 #include <gtkmm/spinbutton.h>
21 #include <gtkmm/tooltips.h>
22 #include <gtkmm/treeview.h>
23 #include <gtkmm/radiobutton.h>
24 #include <gtkmm/box.h>
25 #include <gtkmm/frame.h>
26 #include <gtkmm/filechooserbutton.h>
27 #include <sigc++/sigc++.h>
28 #include <glibmm/i18n.h>
30 #include "ui/widget/color-picker.h"
31 #include "ui/widget/unit-menu.h"
33 namespace Inkscape {
34 namespace UI {
35 namespace Widget {
37 class PrefCheckButton : public Gtk::CheckButton
38 {
39 public:
40 void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
41 bool default_value);
42 protected:
43 std::string _prefs_path;
44 std::string _attr;
45 bool _int_value;
46 void on_toggled();
47 };
49 class PrefRadioButton : public Gtk::RadioButton
50 {
51 public:
52 void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
53 int int_value, bool default_value, PrefRadioButton* group_member);
54 void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
55 const std::string& string_value, bool default_value, PrefRadioButton* group_member);
56 sigc::signal<void, bool> changed_signal;
57 protected:
58 std::string _prefs_path;
59 std::string _attr;
60 std::string _string_value;
61 int _value_type;
62 enum
63 {
64 VAL_INT,
65 VAL_STRING
66 };
67 int _int_value;
68 void on_toggled();
69 };
71 class PrefSpinButton : public Gtk::SpinButton
72 {
73 public:
74 void init(const std::string& prefs_path, const std::string& attr,
75 double lower, double upper, double step_increment, double page_increment,
76 double default_value, bool is_int, bool is_percent);
77 protected:
78 std::string _prefs_path;
79 std::string _attr;
80 bool _is_int;
81 bool _is_percent;
82 void on_value_changed();
83 };
85 class PrefCombo : public Gtk::ComboBoxText
86 {
87 public:
88 void init(const std::string& prefs_path, const std::string& attr,
89 Glib::ustring labels[], int values[], int num_items, int default_value);
90 protected:
91 std::string _prefs_path;
92 std::string _attr;
93 std::vector<int> _values;
94 void on_changed();
95 };
97 class PrefEntry : public Gtk::Entry
98 {
99 public:
100 void init(const std::string& prefs_path, const std::string& attr,
101 bool mask);
102 protected:
103 std::string _prefs_path;
104 std::string _attr;
105 void on_changed();
106 };
108 class PrefEntryButtonHBox : public Gtk::HBox
109 {
110 public:
111 void init(const std::string& prefs_path, const std::string& attr,
112 bool mask, gchar* default_string);
113 protected:
114 std::string _prefs_path;
115 std::string _attr;
116 gchar* _default_string;
117 Gtk::Button *relatedButton;
118 Gtk::Entry *relatedEntry;
119 void onRelatedEntryChangedCallback();
120 void onRelatedButtonClickedCallback();
121 };
123 class PrefFileButton : public Gtk::FileChooserButton
124 {
125 public:
126 void init(const std::string& prefs_path, const std::string& attr);
128 protected:
129 std::string _prefs_path;
130 std::string _attr;
131 void onFileChanged();
132 };
134 class PrefColorPicker : public ColorPicker
135 {
136 public:
137 PrefColorPicker() : ColorPicker("", "", 0, false) {};
138 virtual ~PrefColorPicker() {};
140 void init(const Glib::ustring& label, const std::string& prefs_path, const std::string& attr,
141 guint32 default_rgba);
143 protected:
144 std::string _prefs_path;
145 std::string _attr;
146 virtual void on_changed (guint32 rgba);
147 };
149 class PrefUnit : public UnitMenu
150 {
151 public:
152 void init(const std::string& prefs_path, const std::string& attr);
153 protected:
154 std::string _prefs_path;
155 std::string _attr;
156 void on_changed();
157 };
159 class DialogPage : public Gtk::Table
160 {
161 public:
162 DialogPage();
163 void add_line(bool indent, const Glib::ustring label, Gtk::Widget& widget, const Glib::ustring suffix, const Glib::ustring& tip, bool expand = true);
164 void add_group_header(Glib::ustring name);
165 void set_tip(Gtk::Widget& widget, const Glib::ustring& tip);
166 protected:
167 Gtk::Tooltips _tooltips;
168 };
171 } // namespace Widget
172 } // namespace UI
173 } // namespace Inkscape
175 #endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
177 /*
178 Local Variables:
179 mode:c++
180 c-file-style:"stroustrup"
181 c-file-offsets:((innamespace . 0)(inline-open . 0))
182 indent-tabs-mode:nil
183 fill-column:99
184 End:
185 */
186 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :