1 /**
2 * \brief Inkscape Preferences dialog
3 *
4 * Authors:
5 * Carl Hetherington
6 * Marco Scholten
7 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
8 * Bruno Dilly <bruno.dilly@gmail.com>
9 *
10 * Copyright (C) 2004-2007 Authors
11 *
12 * Released under GNU GPL. Read the file 'COPYING' for more information.
13 */
15 #ifdef HAVE_CONFIG_H
16 # include <config.h>
17 #endif
19 #include <gtkmm/main.h>
20 #include <gtkmm/frame.h>
21 #include <gtkmm/scrolledwindow.h>
22 #include <gtkmm/alignment.h>
24 #include "prefs-utils.h"
25 #include "inkscape-preferences.h"
26 #include "verbs.h"
27 #include "selcue.h"
28 #include "unit-constants.h"
29 #include <iostream>
30 #include "enums.h"
31 #include "inkscape.h"
32 #include "desktop-handles.h"
33 #include "message-stack.h"
34 #include "style.h"
35 #include "selection.h"
36 #include "selection-chemistry.h"
37 #include "xml/repr.h"
38 #include "ui/widget/style-swatch.h"
39 #include "display/nr-filter-gaussian.h"
41 namespace Inkscape {
42 namespace UI {
43 namespace Dialog {
45 InkscapePreferences::InkscapePreferences()
46 : Dialog ("dialogs.preferences", SP_VERB_DIALOG_DISPLAY),
47 _max_dialog_width(0),
48 _max_dialog_height(0),
49 _current_page(0)
50 {
51 //get the width of a spinbutton
52 Gtk::SpinButton* sb = new Gtk::SpinButton;
53 sb->set_width_chars(6);
54 this->get_vbox()->add(*sb);
55 this->show_all_children();
56 Gtk:: Requisition sreq;
57 sb->size_request(sreq);
58 _sb_width = sreq.width;
59 this->get_vbox()->remove(*sb);
60 delete sb;
62 //Main HBox
63 Gtk::HBox* hbox_list_page = Gtk::manage(new Gtk::HBox());
64 hbox_list_page->set_border_width(12);
65 hbox_list_page->set_spacing(12);
66 this->get_vbox()->add(*hbox_list_page);
68 //Pagelist
69 Gtk::Frame* list_frame = Gtk::manage(new Gtk::Frame());
70 Gtk::ScrolledWindow* scrolled_window = Gtk::manage(new Gtk::ScrolledWindow());
71 hbox_list_page->pack_start(*list_frame, false, true, 0);
72 _page_list.set_headers_visible(false);
73 scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
74 scrolled_window->add(_page_list);
75 list_frame->set_shadow_type(Gtk::SHADOW_IN);
76 list_frame->add(*scrolled_window);
77 _page_list_model = Gtk::TreeStore::create(_page_list_columns);
78 _page_list.set_model(_page_list_model);
79 _page_list.append_column("name",_page_list_columns._col_name);
80 Glib::RefPtr<Gtk::TreeSelection> page_list_selection = _page_list.get_selection();
81 page_list_selection->signal_changed().connect(sigc::mem_fun(*this, &InkscapePreferences::on_pagelist_selection_changed));
82 page_list_selection->set_mode(Gtk::SELECTION_BROWSE);
84 //Pages
85 Gtk::VBox* vbox_page = Gtk::manage(new Gtk::VBox());
86 Gtk::Frame* title_frame = Gtk::manage(new Gtk::Frame());
87 hbox_list_page->pack_start(*vbox_page, true, true, 0);
88 title_frame->add(_page_title);
89 vbox_page->pack_start(*title_frame, false, false, 0);
90 vbox_page->pack_start(_page_frame, true, true, 0);
91 _page_frame.set_shadow_type(Gtk::SHADOW_IN);
92 title_frame->set_shadow_type(Gtk::SHADOW_IN);
94 initPageMouse();
95 initPageScrolling();
96 initPageSteps();
97 initPageTools();
98 initPageWindows();
99 initPageClones();
100 initPageMasks();
101 initPageTransforms();
102 initPageFilters();
103 initPageSelecting();
104 initPageMisc();
106 //calculate the size request for this dialog
107 this->show_all_children();
108 _page_list.expand_all();
109 _page_list_model->foreach_iter(sigc::mem_fun(*this, &InkscapePreferences::SetMaxDialogSize));
110 this->set_size_request(_max_dialog_width, _max_dialog_height);
111 _page_list.collapse_all();
112 }
114 InkscapePreferences::~InkscapePreferences()
115 {
116 }
118 void InkscapePreferences::present()
119 {
120 _page_list_model->foreach_iter(sigc::mem_fun(*this, &InkscapePreferences::PresentPage));
121 Dialog::present();
122 }
124 Gtk::TreeModel::iterator InkscapePreferences::AddPage(DialogPage& p, Glib::ustring title, int id)
125 {
126 return AddPage(p, title, Gtk::TreeModel::iterator() , id);
127 }
129 Gtk::TreeModel::iterator InkscapePreferences::AddPage(DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id)
130 {
131 Gtk::TreeModel::iterator iter;
132 if (parent)
133 iter = _page_list_model->append((*parent).children());
134 else
135 iter = _page_list_model->append();
136 Gtk::TreeModel::Row row = *iter;
137 row[_page_list_columns._col_name] = title;
138 row[_page_list_columns._col_id] = id;
139 row[_page_list_columns._col_page] = &p;
140 return iter;
141 }
143 void InkscapePreferences::initPageMouse()
144 {
145 this->AddPage(_page_mouse, _("Mouse"), PREFS_PAGE_MOUSE);
146 _mouse_sens.init ( "options.cursortolerance", "value", 0.0, 30.0, 1.0, 1.0, 8.0, true, false);
147 _page_mouse.add_line( false, _("Grab sensitivity:"), _mouse_sens, _("pixels"),
148 _("How close on the screen you need to be to an object to be able to grab it with mouse (in screen pixels)"), false);
149 _mouse_thres.init ( "options.dragtolerance", "value", 0.0, 20.0, 1.0, 1.0, 4.0, true, false);
150 _page_mouse.add_line( false, _("Click/drag threshold:"), _mouse_thres, _("pixels"),
151 _("Maximum mouse drag (in screen pixels) which is considered a click, not a drag"), false);
153 _mouse_use_ext_input.init( _("Use pressure-sensitive tablet (requires restart)"), "options.useextinput", "value", true);
154 _page_mouse.add_line(true, "",_mouse_use_ext_input, "",
155 _("Use the capabilities of a tablet or other pressure-sensitive device. Disable this only if you have problems with the tablet (you can still use it as a mouse)"));
157 }
159 void InkscapePreferences::initPageScrolling()
160 {
161 this->AddPage(_page_scrolling, _("Scrolling"), PREFS_PAGE_SCROLLING);
162 _scroll_wheel.init ( "options.wheelscroll", "value", 0.0, 1000.0, 1.0, 1.0, 40.0, true, false);
163 _page_scrolling.add_line( false, _("Mouse wheel scrolls by:"), _scroll_wheel, _("pixels"),
164 _("One mouse wheel notch scrolls by this distance in screen pixels (horizontally with Shift)"), false);
165 _page_scrolling.add_group_header( _("Ctrl+arrows"));
166 _scroll_arrow_px.init ( "options.keyscroll", "value", 0.0, 1000.0, 1.0, 1.0, 10.0, true, false);
167 _page_scrolling.add_line( true, _("Scroll by:"), _scroll_arrow_px, _("pixels"),
168 _("Pressing Ctrl+arrow key scrolls by this distance (in screen pixels)"), false);
169 _scroll_arrow_acc.init ( "options.scrollingacceleration", "value", 0.0, 5.0, 0.01, 1.0, 0.35, false, false);
170 _page_scrolling.add_line( true, _("Acceleration:"), _scroll_arrow_acc, "",
171 _("Pressing and holding Ctrl+arrow will gradually speed up scrolling (0 for no acceleration)"), false);
172 _page_scrolling.add_group_header( _("Autoscrolling"));
173 _scroll_auto_speed.init ( "options.autoscrollspeed", "value", 0.0, 5.0, 0.01, 1.0, 0.7, false, false);
174 _page_scrolling.add_line( true, _("Speed:"), _scroll_auto_speed, "",
175 _("How fast the canvas autoscrolls when you drag beyond canvas edge (0 to turn autoscroll off)"), false);
176 _scroll_auto_thres.init ( "options.autoscrolldistance", "value", -600.0, 600.0, 1.0, 1.0, -10.0, true, false);
177 _page_scrolling.add_line( true, _("Threshold:"), _scroll_auto_thres, _("pixels"),
178 _("How far (in screen pixels) you need to be from the canvas edge to trigger autoscroll; positive is outside the canvas, negative is within the canvas"), false);
179 _scroll_space.init ( _("Left mouse button pans when Space is pressed"), "options.spacepans", "value", false);
180 _page_scrolling.add_line( false, "", _scroll_space, "",
181 _("When on, pressing and holding Space and dragging with left mouse button pans canvas (as in Adobe Illustrator). When off, Space temporarily switches to Selector tool (default)."));
182 _wheel_zoom.init ( _("Mouse wheel zooms by default"), "options.wheelzooms", "value", false);
183 _page_scrolling.add_line( false, "", _wheel_zoom, "",
184 _("When on, mouse wheel zooms without Ctrl and scrolls canvas with Ctrl; when off, it zooms with Ctrl and scrolls without Ctrl."));
185 }
187 void InkscapePreferences::initPageSteps()
188 {
189 this->AddPage(_page_steps, _("Steps"), PREFS_PAGE_STEPS);
191 _steps_arrow.init ( "options.nudgedistance", "value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
192 //nudgedistance is limited to 1000 in select-context.cpp: use the same limit here
193 _page_steps.add_line( false, _("Arrow keys move by:"), _steps_arrow, _("px"),
194 _("Pressing an arrow key moves selected object(s) or node(s) by this distance (in px units)"), false);
195 _steps_scale.init ( "options.defaultscale", "value", 0.0, 1000.0, 0.01, 1.0, 2.0, false, false);
196 //defaultscale is limited to 1000 in select-context.cpp: use the same limit here
197 _page_steps.add_line( false, _("> and < scale by:"), _steps_scale, _("px"),
198 _("Pressing > or < scales selection up or down by this increment (in px units)"), false);
199 _steps_inset.init ( "options.defaultoffsetwidth", "value", 0.0, 3000.0, 0.01, 1.0, 2.0, false, false);
200 _page_steps.add_line( false, _("Inset/Outset by:"), _steps_inset, _("px"),
201 _("Inset and Outset commands displace the path by this distance (in px units)"), false);
202 _steps_compass.init ( _("Compass-like display of angles"), "options.compassangledisplay", "value", true);
203 _page_steps.add_line( false, "", _steps_compass, "",
204 _("When on, angles are displayed with 0 at north, 0 to 360 range, positive clockwise; otherwise with 0 at east, -180 to 180 range, positive counterclockwise"));
205 int const num_items = 17;
206 Glib::ustring labels[num_items] = {"90", "60", "45", "36", "30", "22.5", "18", "15", "12", "10", "7.5", "6", "3", "2", "1", "0.5", _("None")};
207 int values[num_items] = {2, 3, 4, 5, 6, 8, 10, 12, 15, 18, 24, 30, 60, 90, 180, 360, 0};
208 _steps_rot_snap.set_size_request(_sb_width);
209 _steps_rot_snap.init("options.rotationsnapsperpi", "value", labels, values, num_items, 12);
210 _page_steps.add_line( false, _("Rotation snaps every:"), _steps_rot_snap, _("degrees"),
211 _("Rotating with Ctrl pressed snaps every that much degrees; also, pressing [ or ] rotates by this amount"), false);
212 _steps_zoom.init ( "options.zoomincrement", "value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true);
213 _page_steps.add_line( false, _("Zoom in/out by:"), _steps_zoom, _("%"),
214 _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false);
215 }
217 void InkscapePreferences::AddSelcueCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value)
218 {
219 PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
220 cb->init ( _("Show selection cue"), prefs_path, "selcue", def_value);
221 p.add_line( false, "", *cb, "", _("Whether selected objects display a selection cue (the same as in selector)"));
222 }
224 void InkscapePreferences::AddGradientCheckbox(DialogPage& p, const std::string& prefs_path, bool def_value)
225 {
226 PrefCheckButton* cb = Gtk::manage( new PrefCheckButton);
227 cb->init ( _("Enable gradient editing"), prefs_path, "gradientdrag", def_value);
228 p.add_line( false, "", *cb, "", _("Whether selected objects display gradient editing controls"));
229 }
231 void StyleFromSelectionToTool(gchar const *prefs_path, StyleSwatch *swatch)
232 {
233 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
234 if (desktop == NULL)
235 return;
237 Inkscape::Selection *selection = sp_desktop_selection(desktop);
239 if (selection->isEmpty()) {
240 sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE,
241 _("<b>No objects selected</b> to take the style from."));
242 return;
243 }
244 SPItem *item = selection->singleItem();
245 if (!item) {
246 /* TODO: If each item in the selection has the same style then don't consider it an error.
247 * Maybe we should try to handle multiple selections anyway, e.g. the intersection of the
248 * style attributes for the selected items. */
249 sp_desktop_message_stack(desktop)->flash(Inkscape::ERROR_MESSAGE,
250 _("<b>More than one object selected.</b> Cannot take style from multiple objects."));
251 return;
252 }
254 SPCSSAttr *css = take_style_from_item (item);
256 if (!css) return;
258 // only store text style for the text tool
259 if (!g_strrstr ((const gchar *) prefs_path, "text")) {
260 css = sp_css_attr_unset_text (css);
261 }
263 // we cannot store properties with uris - they will be invalid in other documents
264 css = sp_css_attr_unset_uris (css);
266 sp_repr_css_change (inkscape_get_repr (INKSCAPE, prefs_path), css, "style");
267 sp_repr_css_attr_unref (css);
269 // update the swatch
270 if (swatch) {
271 Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path);
272 if (tool_repr) {
273 SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style");
274 swatch->setStyle (css);
275 sp_repr_css_attr_unref(css);
276 }
277 }
278 }
280 void InkscapePreferences::AddNewObjectsStyle(DialogPage& p, const std::string& prefs_path)
281 {
284 p.add_group_header( _("Create new objects with:"));
285 PrefRadioButton* current = Gtk::manage( new PrefRadioButton);
286 current->init ( _("Last used style"), prefs_path, "usecurrent", 1, true, 0);
287 p.add_line( true, "", *current, "",
288 _("Apply the style you last set on an object"));
290 PrefRadioButton* own = Gtk::manage( new PrefRadioButton);
291 Gtk::HBox* hb = Gtk::manage( new Gtk::HBox);
292 Gtk::Alignment* align = Gtk::manage( new Gtk::Alignment);
293 own->init ( _("This tool's own style:"), prefs_path, "usecurrent", 0, false, current);
294 align->set(0,0,0,0);
295 align->add(*own);
296 hb->add(*align);
297 p.set_tip( *own, _("Each tool may store its own style to apply to the newly created objects. Use the button below to set it."));
298 p.add_line( true, "", *hb, "", "");
300 // style swatch
301 Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, prefs_path.c_str());
302 Gtk::Button* button = Gtk::manage( new Gtk::Button(_("Take from selection"),true));
303 StyleSwatch *swatch = 0;
304 if (tool_repr) {
305 SPCSSAttr *css = sp_repr_css_attr_inherited(tool_repr, "style");
306 swatch = new StyleSwatch(css, _("This tool's style of new objects"));
307 hb->add(*swatch);
308 sp_repr_css_attr_unref(css);
309 }
311 button->signal_clicked().connect( sigc::bind( sigc::ptr_fun(StyleFromSelectionToTool), prefs_path.c_str(), swatch) );
312 own->changed_signal.connect( sigc::mem_fun(*button, &Gtk::Button::set_sensitive) );
313 p.add_line( true, "", *button, "",
314 _("Remember the style of the (first) selected object as this tool's style"));
315 }
317 void InkscapePreferences::initPageTools()
318 {
319 Gtk::TreeModel::iterator iter_tools = this->AddPage(_page_tools, _("Tools"), PREFS_PAGE_TOOLS);
320 _path_tools = _page_list.get_model()->get_path(iter_tools);
322 _calligrapy_use_abs_size.init ( _("Width is in absolute units"), "tools.calligraphic", "abs_width", false);
323 _calligrapy_keep_selected.init ( _("Select new path"), "tools.calligraphic", "keep_selected", true);
324 _connector_ignore_text.init( _("Don't attach connectors to text objects"), "tools.connector", "ignoretext", true);
326 //Selector
327 this->AddPage(_page_selector, _("Selector"), iter_tools, PREFS_PAGE_TOOLS_SELECTOR);
329 AddSelcueCheckbox(_page_selector, "tools.select", false);
330 _page_selector.add_group_header( _("When transforming, show:"));
331 _t_sel_trans_obj.init ( _("Objects"), "tools.select", "show", "content", true, 0);
332 _page_selector.add_line( true, "", _t_sel_trans_obj, "",
333 _("Show the actual objects when moving or transforming"));
334 _t_sel_trans_outl.init ( _("Box outline"), "tools.select", "show", "outline", false, &_t_sel_trans_obj);
335 _page_selector.add_line( true, "", _t_sel_trans_outl, "",
336 _("Show only a box outline of the objects when moving or transforming"));
337 _page_selector.add_group_header( _("Per-object selection cue:"));
338 _t_sel_cue_none.init ( _("None"), "options.selcue", "value", Inkscape::SelCue::NONE, false, 0);
339 _page_selector.add_line( true, "", _t_sel_cue_none, "",
340 _("No per-object selection indication"));
341 _t_sel_cue_mark.init ( _("Mark"), "options.selcue", "value", Inkscape::SelCue::MARK, true, &_t_sel_cue_none);
342 _page_selector.add_line( true, "", _t_sel_cue_mark, "",
343 _("Each selected object has a diamond mark in the top left corner"));
344 _t_sel_cue_box.init ( _("Box"), "options.selcue", "value", Inkscape::SelCue::BBOX, false, &_t_sel_cue_none);
345 _page_selector.add_line( true, "", _t_sel_cue_box, "",
346 _("Each selected object displays its bounding box"));
348 _page_selector.add_group_header( _("Bounding box to use:"));
349 _t_sel_bbox_visual.init ( _("Visual bounding box"), "tools.select", "bounding_box", "visual", false, 0);
350 _page_selector.add_line( true, "", _t_sel_bbox_visual, "",
351 _("This bounding box includes stroke width, markers, filter margins, etc."));
352 _t_sel_bbox_geometric.init ( _("Geometric bounding box"), "tools.select", "bounding_box", "geometric", true, &_t_sel_bbox_visual);
353 _page_selector.add_line( true, "", _t_sel_bbox_geometric, "",
354 _("This bounding box includes only the bare path"));
356 //Node
357 this->AddPage(_page_node, _("Node"), iter_tools, PREFS_PAGE_TOOLS_NODE);
358 AddSelcueCheckbox(_page_node, "tools.nodes", true);
359 AddGradientCheckbox(_page_node, "tools.nodes", true);
360 //Zoom
361 this->AddPage(_page_zoom, _("Zoom"), iter_tools, PREFS_PAGE_TOOLS_ZOOM);
362 AddSelcueCheckbox(_page_zoom, "tools.zoom", true);
363 AddGradientCheckbox(_page_zoom, "tools.zoom", false);
364 //Shapes
365 Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES);
366 _path_shapes = _page_list.get_model()->get_path(iter_shapes);
367 this->AddSelcueCheckbox(_page_shapes, "tools.shapes", true);
368 this->AddGradientCheckbox(_page_shapes, "tools.shapes", true);
369 //Rectangle
370 this->AddPage(_page_rectangle, _("Rectangle"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_RECT);
371 this->AddNewObjectsStyle(_page_rectangle, "tools.shapes.rect");
372 //3D box
373 this->AddPage(_page_3dbox, _("3D Box"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_3DBOX);
374 this->AddNewObjectsStyle(_page_3dbox, "tools.shapes.3dbox");
375 //ellipse
376 this->AddPage(_page_ellipse, _("Ellipse"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_ELLIPSE);
377 this->AddNewObjectsStyle(_page_ellipse, "tools.shapes.arc");
378 //star
379 this->AddPage(_page_star, _("Star"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_STAR);
380 this->AddNewObjectsStyle(_page_star, "tools.shapes.star");
381 //spiral
382 this->AddPage(_page_spiral, _("Spiral"), iter_shapes, PREFS_PAGE_TOOLS_SHAPES_SPIRAL);
383 this->AddNewObjectsStyle(_page_spiral, "tools.shapes.spiral");
384 //Pencil
385 this->AddPage(_page_pencil, _("Pencil"), iter_tools, PREFS_PAGE_TOOLS_PENCIL);
386 this->AddSelcueCheckbox(_page_pencil, "tools.freehand.pencil", true);
387 _t_pencil_tolerance.init ( "tools.freehand.pencil", "tolerance", 0.0, 100.0, 0.5, 1.0, 10.0, false, false);
388 _page_pencil.add_line( false, _("Tolerance:"), _t_pencil_tolerance, "",
389 _("This value affects the amount of smoothing applied to freehand lines; lower values produce more uneven paths with more nodes"),
390 false );
391 this->AddNewObjectsStyle(_page_pencil, "tools.freehand.pencil");
392 //Pen
393 this->AddPage(_page_pen, _("Pen"), iter_tools, PREFS_PAGE_TOOLS_PEN);
394 this->AddSelcueCheckbox(_page_pen, "tools.freehand.pen", true);
395 this->AddNewObjectsStyle(_page_pen, "tools.freehand.pen");
396 //Calligraphy
397 this->AddPage(_page_calligraphy, _("Calligraphy"), iter_tools, PREFS_PAGE_TOOLS_CALLIGRAPHY);
398 this->AddNewObjectsStyle(_page_calligraphy, "tools.calligraphic");
399 _page_calligraphy.add_line( false, "", _calligrapy_use_abs_size, "",
400 _("If on, pen width is in absolute units (px) independent of zoom; otherwise pen width depends on zoom so that it looks the same at any zoom"));
401 _page_calligraphy.add_line( false, "", _calligrapy_keep_selected, "",
402 _("If on, each newly created object will be selected (deselecting previous selection)"));
403 //Paint Bucket
404 this->AddPage(_page_paintbucket, _("Paint Bucket"), iter_tools, PREFS_PAGE_TOOLS_PAINTBUCKET);
405 this->AddNewObjectsStyle(_page_paintbucket, "tools.paintbucket");
406 //Text
407 this->AddPage(_page_text, _("Text"), iter_tools, PREFS_PAGE_TOOLS_TEXT);
408 this->AddSelcueCheckbox(_page_text, "tools.text", true);
409 this->AddGradientCheckbox(_page_text, "tools.text", true);
410 this->AddNewObjectsStyle(_page_text, "tools.text");
411 //Gradient
412 this->AddPage(_page_gradient, _("Gradient"), iter_tools, PREFS_PAGE_TOOLS_GRADIENT);
413 this->AddSelcueCheckbox(_page_gradient, "tools.gradient", true);
414 //Connector
415 this->AddPage(_page_connector, _("Connector"), iter_tools, PREFS_PAGE_TOOLS_CONNECTOR);
416 this->AddSelcueCheckbox(_page_connector, "tools.connector", true);
417 _page_connector.add_line(false, "", _connector_ignore_text, "",
418 _("If on, connector attachment points will not be shown for text objects"));
419 //Dropper
420 this->AddPage(_page_dropper, _("Dropper"), iter_tools, PREFS_PAGE_TOOLS_DROPPER);
421 this->AddSelcueCheckbox(_page_dropper, "tools.dropper", true);
422 this->AddGradientCheckbox(_page_dropper, "tools.dropper", true);
423 }
425 void InkscapePreferences::initPageWindows()
426 {
427 _win_save_geom.init ( _("Save and restore window geometry for each document"), "options.savewindowgeometry", "value", 1, true, 0);
428 _win_save_geom_prefs.init ( _("Remember and use last window's geometry"), "options.savewindowgeometry", "value", 2, false, &_win_save_geom);
429 _win_save_geom_off.init ( _("Don't save window geometry"), "options.savewindowgeometry", "value", 0, false, &_win_save_geom);
431 _win_hide_task.init ( _("Dialogs are hidden in taskbar"), "options.dialogsskiptaskbar", "value", true);
432 _win_zoom_resize.init ( _("Zoom when window is resized"), "options.stickyzoom", "value", false);
433 _win_show_close.init ( _("Show close button on dialogs"), "dialogs", "showclose", false);
434 _win_ontop_none.init ( _("None"), "options.transientpolicy", "value", 0, false, 0);
435 _win_ontop_normal.init ( _("Normal"), "options.transientpolicy", "value", 1, true, &_win_ontop_none);
436 _win_ontop_agressive.init ( _("Aggressive"), "options.transientpolicy", "value", 2, false, &_win_ontop_none);
438 // FIXME: Temporary Win32 special code to enable transient dialogs
439 #ifdef WIN32
440 _win_ontop_win32.init ( _("Dialogs stay on top (experimental!)"), "options.dialogsontopwin32", "value", false);
441 #endif
443 _page_windows.add_group_header( _("Saving window geometry (size and position):"));
444 _page_windows.add_line( false, "", _win_save_geom_off, "",
445 _("Let the window manager determine placement of all windows"));
446 _page_windows.add_line( false, "", _win_save_geom_prefs, "",
447 _("Remember and use the last window's geometry (saves geometry to user preferences)"));
448 _page_windows.add_line( false, "", _win_save_geom, "",
449 _("Save and restore window geometry for each document (saves geometry in the document)"));
451 _page_windows.add_group_header( _("Dialogs on top:"));
452 #ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs
453 _page_windows.add_line( true, "", _win_ontop_none, "",
454 _("Dialogs are treated as regular windows"));
455 _page_windows.add_line( true, "", _win_ontop_normal, "",
456 _("Dialogs stay on top of document windows"));
457 _page_windows.add_line( true, "", _win_ontop_agressive, "",
458 _("Same as Normal but may work better with some window managers"));
459 #else
460 _page_windows.add_line( false, "", _win_ontop_win32, "",
461 _("Whether dialogs should stay on top of document windows. Read the ReleaseNotes on this issue! (Rightclick the taskbar button and press 'Restore' to bring back a minimized document window)"));
462 #endif
464 _page_windows.add_group_header( _("Miscellaneous:"));
465 #ifndef WIN32 // FIXME: Temporary Win32 special code to enable transient dialogs
466 _page_windows.add_line( false, "", _win_hide_task, "",
467 _("Whether dialog windows are to be hidden in the window manager taskbar"));
468 #endif
469 _page_windows.add_line( false, "", _win_zoom_resize, "",
470 _("Zoom drawing when document window is resized, to keep the same area visible (this is the default which can be changed in any window using the button above the right scrollbar)"));
471 _page_windows.add_line( false, "", _win_show_close, "",
472 _("Whether dialog windows have a close button (requires restart)"));
473 this->AddPage(_page_windows, _("Windows"), PREFS_PAGE_WINDOWS);
474 }
476 void InkscapePreferences::initPageClones()
477 {
478 _clone_option_parallel.init ( _("Move in parallel"), "options.clonecompensation", "value",
479 SP_CLONE_COMPENSATION_PARALLEL, true, 0);
480 _clone_option_stay.init ( _("Stay unmoved"), "options.clonecompensation", "value",
481 SP_CLONE_COMPENSATION_UNMOVED, false, &_clone_option_parallel);
482 _clone_option_transform.init ( _("Move according to transform"), "options.clonecompensation", "value",
483 SP_CLONE_COMPENSATION_NONE, false, &_clone_option_parallel);
484 _clone_option_unlink.init ( _("Are unlinked"), "options.cloneorphans", "value",
485 SP_CLONE_ORPHANS_UNLINK, true, 0);
486 _clone_option_delete.init ( _("Are deleted"), "options.cloneorphans", "value",
487 SP_CLONE_ORPHANS_DELETE, false, &_clone_option_unlink);
489 _page_clones.add_group_header( _("When the original moves, its clones and linked offsets:"));
490 _page_clones.add_line( true, "", _clone_option_parallel, "",
491 _("Clones are translated by the same vector as their original."));
492 _page_clones.add_line( true, "", _clone_option_stay, "",
493 _("Clones preserve their positions when their original is moved."));
494 _page_clones.add_line( true, "", _clone_option_transform, "",
495 _("Each clone moves according to the value of its transform= attribute. For example, a rotated clone will move in a different direction than its original."));
496 _page_clones.add_group_header( _("When the original is deleted, its clones:"));
497 _page_clones.add_line( true, "", _clone_option_unlink, "",
498 _("Orphaned clones are converted to regular objects."));
499 _page_clones.add_line( true, "", _clone_option_delete, "",
500 _("Orphaned clones are deleted along with their original."));
502 this->AddPage(_page_clones, _("Clones"), PREFS_PAGE_CLONES);
503 }
505 void InkscapePreferences::initPageMasks()
506 {
507 _mask_mask_on_top.init ( _("When applying, use the topmost selected object as clippath/mask"), "options.maskobject", "topmost", true);
508 _page_mask.add_line(true, "", _mask_mask_on_top, "",
509 _("Uncheck this to use the bottom selected object as the clipping path or mask"));
510 _mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "options.maskobject", "remove", true);
511 _page_mask.add_line(true, "", _mask_mask_remove, "",
512 _("After applying, remove the object used as the clipping path or mask from the drawing"));
513 this->AddPage(_page_mask, _("Clippaths and masks"), PREFS_PAGE_MASKS);
514 }
516 void InkscapePreferences::initPageTransforms()
517 {
518 _trans_scale_stroke.init ( _("Scale stroke width"), "options.transform", "stroke", true);
519 _trans_scale_corner.init ( _("Scale rounded corners in rectangles"), "options.transform", "rectcorners", false);
520 _trans_gradient.init ( _("Transform gradients"), "options.transform", "gradient", true);
521 _trans_pattern.init ( _("Transform patterns"), "options.transform", "pattern", false);
522 _trans_optimized.init ( _("Optimized"), "options.preservetransform", "value", 0, true, 0);
523 _trans_preserved.init ( _("Preserved"), "options.preservetransform", "value", 1, false, &_trans_optimized);
525 _page_transforms.add_line( false, "", _trans_scale_stroke, "",
526 _("When scaling objects, scale the stroke width by the same proportion"));
527 _page_transforms.add_line( false, "", _trans_scale_corner, "",
528 _("When scaling rectangles, scale the radii of rounded corners"));
529 _page_transforms.add_line( false, "", _trans_gradient, "",
530 _("Move gradients (in fill or stroke) along with the objects"));
531 _page_transforms.add_line( false, "", _trans_pattern, "",
532 _("Move patterns (in fill or stroke) along with the objects"));
533 _page_transforms.add_group_header( _("Store transformation:"));
534 _page_transforms.add_line( true, "", _trans_optimized, "",
535 _("If possible, apply transformation to objects without adding a transform= attribute"));
536 _page_transforms.add_line( true, "", _trans_preserved, "",
537 _("Always store transformation as a transform= attribute on objects"));
539 this->AddPage(_page_transforms, _("Transforms"), PREFS_PAGE_TRANSFORMS);
540 }
542 void InkscapePreferences::initPageFilters()
543 {
544 _blur_quality_best.init ( _("Best quality (slowest)"), "options.blurquality", "value",
545 BLUR_QUALITY_BEST, false, 0);
546 _blur_quality_better.init ( _("Better quality (slower)"), "options.blurquality", "value",
547 BLUR_QUALITY_BETTER, false, &_blur_quality_best);
548 _blur_quality_normal.init ( _("Average quality"), "options.blurquality", "value",
549 BLUR_QUALITY_NORMAL, true, &_blur_quality_best);
550 _blur_quality_worse.init ( _("Lower quality (faster)"), "options.blurquality", "value",
551 BLUR_QUALITY_WORSE, false, &_blur_quality_best);
552 _blur_quality_worst.init ( _("Lowest quality (fastest)"), "options.blurquality", "value",
553 BLUR_QUALITY_WORST, false, &_blur_quality_best);
555 _page_filters.add_group_header( _("Gaussian blur quality for display:"));
556 _page_filters.add_line( true, "", _blur_quality_best, "",
557 _("Best quality, but display may be very slow at high zooms (bitmap export always uses best quality)"));
558 _page_filters.add_line( true, "", _blur_quality_better, "",
559 _("Better quality, but slower display"));
560 _page_filters.add_line( true, "", _blur_quality_normal, "",
561 _("Average quality, acceptable display speed"));
562 _page_filters.add_line( true, "", _blur_quality_worse, "",
563 _("Lower quality (some artifacts), but display is faster"));
564 _page_filters.add_line( true, "", _blur_quality_worst, "",
565 _("Lowest quality (considerable artifacts), but display is fastest"));
567 this->AddPage(_page_filters, _("Filters"), PREFS_PAGE_FILTERS);
568 }
571 void InkscapePreferences::initPageSelecting()
572 {
573 _sel_all.init ( _("Select in all layers"), "options.kbselection", "inlayer", PREFS_SELECTION_ALL, false, 0);
574 _sel_current.init ( _("Select only within current layer"), "options.kbselection", "inlayer", PREFS_SELECTION_LAYER, true, &_sel_all);
575 _sel_recursive.init ( _("Select in current layer and sublayers"), "options.kbselection", "inlayer", PREFS_SELECTION_LAYER_RECURSIVE, false, &_sel_all);
576 _sel_hidden.init ( _("Ignore hidden objects"), "options.kbselection", "onlyvisible", true);
577 _sel_locked.init ( _("Ignore locked objects"), "options.kbselection", "onlysensitive", true);
578 _sel_layer_deselects.init ( _("Deselect upon layer change"), "options.selection", "layerdeselect", true);
580 _page_select.add_group_header( _("Ctrl+A, Tab, Shift+Tab:"));
581 _page_select.add_line( true, "", _sel_all, "",
582 _("Make keyboard selection commands work on objects in all layers"));
583 _page_select.add_line( true, "", _sel_current, "",
584 _("Make keyboard selection commands work on objects in current layer only"));
585 _page_select.add_line( true, "", _sel_recursive, "",
586 _("Make keyboard selection commands work on objects in current layer and all its sublayers"));
587 _page_select.add_line( true, "", _sel_hidden, "",
588 _("Uncheck this to be able to select objects that are hidden (either by themselves or by being in a hidden group or layer)"));
589 _page_select.add_line( true, "", _sel_locked, "",
590 _("Uncheck this to be able to select objects that are locked (either by themselves or by being in a locked group or layer)"));
592 _page_select.add_line( false, "", _sel_layer_deselects, "",
593 _("Uncheck this to be able to keep the current objects selected when the current layer changes"));
595 this->AddPage(_page_select, _("Selecting"), PREFS_PAGE_SELECTING);
596 }
599 void InkscapePreferences::initPageMisc()
600 {
601 _misc_export.init("dialogs.export.defaultxdpi", "value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false);
602 _page_misc.add_line( false, _("Default export resolution:"), _misc_export, _("dpi"),
603 _("Default bitmap resolution (in dots per inch) in the Export dialog"), false);
604 _misc_imp_bitmap.init( _("Import bitmap as <image>"), "options.importbitmapsasimages", "value", true);
605 _page_misc.add_line( false, "", _misc_imp_bitmap, "",
606 _("When on, an imported bitmap creates an <image> element; otherwise it is a rectangle with bitmap fill"), true);
607 _misc_comment.init( _("Add label comments to printing output"), "printing.debug", "show-label-comments", false);
608 _page_misc.add_line( false, "", _misc_comment, "",
609 _("When on, a comment will be added to the raw print output, marking the rendered output for an object with its label"), true);
610 _misc_small_toolbar.init( _("Make commands toolbar smaller"), "toolbox", "small", true);
611 _page_misc.add_line( false, "", _misc_small_toolbar, "",
612 _("Make the commands toolbar use the 'secondary' toolbar size (requires restart)"), true);
613 _misc_recent.init("options.maxrecentdocuments", "value", 0.0, 1000.0, 1.0, 1.0, 1.0, true, false);
614 _page_misc.add_line( false, _("Max recent documents:"), _misc_recent, "",
615 _("The maximum length of the Open Recent list in the File menu"), false);
616 _misc_simpl.init("options.simplifythreshold", "value", 0.0001, 1.0, 0.0001, 0.0010, 0.0010, false, false);
617 _page_misc.add_line( false, _("Simplification threshold:"), _misc_simpl, "",
618 _("How strong is the Simplify command by default. If you invoke this command several times in quick succession, it will act more and more aggressively; invoking it again after a pause restores the default threshold."), false);
619 int const num_items = 5;
620 Glib::ustring labels[num_items] = {_("None"), _("2x2"), _("4x4"), _("8x8"), _("16x16")};
621 int values[num_items] = {0, 1, 2, 3, 4};
622 _misc_overs_bitmap.set_size_request(_sb_width);
623 _misc_overs_bitmap.init("options.bitmapoversample", "value", labels, values, num_items, 1);
624 _page_misc.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false);
625 _misc_ocal_url.init("options.ocalurl", "str", true);
626 _page_misc.add_line( false, _("Open Clip Art Library Server Name:"), _misc_ocal_url, "", _("The server name of the Open Clip Art Library webdav server. It's used by the Import and Export to OCAL function."), true);
627 _misc_ocal_username.init("options.ocalusername", "str", true);
628 _page_misc.add_line( false, _("Open Clip Art Library Username:"), _misc_ocal_username, "", _("The username used to log into Open Clip Art Library."), true);
629 _misc_ocal_password.init("options.ocalpassword", "str", false);
630 _page_misc.add_line( false, _("Open Clip Art Library Password:"), _misc_ocal_password, "", _("The password used to log into Open Clip Art Library."), true);
632 this->AddPage(_page_misc, _("Misc"), PREFS_PAGE_MISC);
633 }
635 bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter)
636 {
637 Gtk::TreeModel::Row row = *iter;
638 DialogPage* page = row[_page_list_columns._col_page];
639 _page_frame.add(*page);
640 this->show_all_children();
641 Gtk:: Requisition sreq;
642 this->size_request(sreq);
643 _max_dialog_width=std::max(_max_dialog_width, sreq.width);
644 _max_dialog_height=std::max(_max_dialog_height, sreq.height);
645 _page_frame.remove();
646 return false;
647 }
649 bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter)
650 {
651 Gtk::TreeModel::Row row = *iter;
652 int desired_page = prefs_get_int_attribute("dialogs.preferences", "page", 0);
653 if (desired_page == row[_page_list_columns._col_id])
654 {
655 if (desired_page >= PREFS_PAGE_TOOLS && desired_page <= PREFS_PAGE_TOOLS_DROPPER)
656 _page_list.expand_row(_path_tools, false);
657 if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL)
658 _page_list.expand_row(_path_shapes, false);
659 _page_list.get_selection()->select(iter);
660 return true;
661 }
662 return false;
663 }
665 void InkscapePreferences::on_pagelist_selection_changed()
666 {
667 // show new selection
668 Glib::RefPtr<Gtk::TreeSelection> selection = _page_list.get_selection();
669 Gtk::TreeModel::iterator iter = selection->get_selected();
670 if(iter)
671 {
672 if (_current_page)
673 _page_frame.remove();
674 Gtk::TreeModel::Row row = *iter;
675 _current_page = row[_page_list_columns._col_page];
676 prefs_set_int_attribute("dialogs.preferences", "page", row[_page_list_columns._col_id]);
677 _page_title.set_markup("<span size='large'><b>" + row[_page_list_columns._col_name] + "</b></span>");
678 _page_frame.add(*_current_page);
679 _current_page->show();
680 while (Gtk::Main::events_pending())
681 {
682 Gtk::Main::iteration();
683 }
684 this->show_all_children();
685 }
686 }
688 } // namespace Dialog
689 } // namespace UI
690 } // namespace Inkscape
692 /*
693 Local Variables:
694 mode:c++
695 c-file-style:"stroustrup"
696 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
697 indent-tabs-mode:nil
698 fill-column:99
699 End:
700 */
701 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :