document-properties.cpp revision 280e31bdf7f5ffd28f8b14565c1d93de4070bd0c
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * @brief Document properties dialog, Gtkmm-style
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * bulia byak <buliabyak@users.sf.net>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Bryce W. Harrington <bryce@bryceharrington.org>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Lauris Kaplinski <lauris@kaplinski.com>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Jon Phillips <jon@rejon.org>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Diederik van Lierop <mail@diedenrezi.nl>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl>
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Copyright (C) 2000 - 2008 Authors
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Released under GNU GPL. Read the file 'COPYING' for more information
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich#endif // ENABLE_LCMS
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich#define INKSCAPE_ICON_GRID_AXONOM "grid_axonom"
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich//===================================================
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich//---------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichstatic void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichstatic void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichstatic void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichstatic Inkscape::XML::NodeEventVector const _repr_events = {
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich DocumentProperties &instance = *new DocumentProperties();
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _page_page(1, 1, true, true), _page_guides(1, 1),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _page_snap(1, 1), _page_snap_dtls(1, 1), _page_cms(1, 1),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcp_bg(_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"), "pagecolor", "inkscape:pageopacity", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcp_bord(_("Border _color:"), _("Page border color"), _("Color of the page border"), "bordercolor", "borderopacity", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rum_deflt(_("Default _units:"), "inkscape:document-units", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //General snap options
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsng(_("_Snap guides while dragging"), _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled in the 'Snap' tab; only a small part of the guide near the cursor will snap)"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbs(_("_Enable snapping"), _("Toggle snapping on or off"), "inkscape:snap-global", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnbb(_("_Bounding box corners"), _("Only available in the selector tool: snap bounding box corners to guides, to grids, and to other bounding boxes (but not to nodes or paths)"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnn(_("_Nodes"), _("Snap nodes (e.g. path nodes, special points in shapes, gradient handles, text base points, transformation origins, etc.) to guides, to grids, to paths and to other nodes"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Options for snapping to objects
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnop(_("Snap to path_s"), _("Snap nodes to object paths"), "inkscape:object-paths", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnon(_("Snap to n_odes"), _("Snap nodes and guides to object nodes"), "inkscape:object-nodes", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnbbp(_("Snap to bounding bo_x edges"), _("Snap bounding box corners and guides to bounding box edges"), "inkscape:bbox-paths", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnbbn(_("Snap to bounding box co_rners"), _("Snap bounding box corners to other bounding box corners"), "inkscape:bbox-nodes", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsnpb(_("Snap to page border"), _("Snap bounding box corners and nodes to the page border"), "inkscape:snap-page", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Applies to both nodes and guides, but not to bboxes, that's why its located here
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbic( _("Rotation _center"), _("Consider the rotation center of an object when snapping"), "inkscape:snap-center", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsm( _("_Smooth nodes"), _("Snap to smooth nodes too, instead of only snapping to cusp nodes"), "inkscape:snap-smooth-nodes", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbmp( _("_Midpoints"), _("Snap midpoints of straight line segments"), "inkscape:snap-midpoints", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsigg(_("_Grid with guides"), _("Snap to grid-guide intersections"), "inkscape:snap-intersection-grid-guide", _wr),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rcbsils(_("_Paths"), _("Snap to intersections of paths ('snap to paths' must be enabled, see the previous tab)"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //TRANSLATORS: In Grid|_New translate only the word _New. It ref to grid
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _grids_button_new(Q_("Grid|_New"), _("Create new grid.")),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _grids_button_remove(_("_Remove"), _("Remove selected grid.")),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //---------------------------------------------------------------
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _getContents()->pack_start(_notebook, true, true);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_page_page, _("Page"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_page_guides, _("Guides"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_grids_vbox, _("Grids"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_page_snap, _("Snap"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_page_snap_dtls, _("Snap points"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _notebook.append_page(_page_cms, _("Color Management"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich#endif // ENABLE_LCMS
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(getDesktop())->root);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(getDesktop())->root);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich//========================================================================
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * Helper function that attaches widgets in a 3xn table. The widgets come in an
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * array that has two entries per table row. The two entries code for four
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * possible cases: (0,0) means insert space in first column; (0, non-0) means
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich * (non-0, non-0) means two widgets in columns 2 and 3.
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichattach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0)
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich for (unsigned i = 0, r = start; i < n; i += 2)
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0;
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich if (dynamic_cast<Inkscape::UI::Widget::PageSizer*>(arr[i+1])) {
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich // only the PageSizer in Document Properties|Page should be stretched vertically
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label* label_gen = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label* label_bor = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_for = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_gui = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rsu_sno.init (_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("If set, objects only snap to another object when it's within the range specified below"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Options for snapping to grids
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rsu_sn.init (_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("If set, objects only snap to a grid line when it's within the range specified below"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Options for snapping to guides
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _rsu_gusn.init (_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich _("If set, objects only snap to a guide when it's within the range specified below"),
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Other options to locate here: e.g. visual snapping indicators on/off
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_g = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_w = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_w->set_markup (_("<b>What snaps</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_o = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_o->set_markup (_("<b>Snap to objects</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_gr = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_gr->set_markup (_("<b>Snap to grids</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_gu = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_gu->set_markup (_("<b>Snap to guides</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich attach_all(_page_snap.table(), array, G_N_ELEMENTS(array));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich //Other options to locate here: e.g. visual snapping indicators on/off
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_i= manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_i->set_markup (_("<b>Snapping intersections of</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Gtk::Label *label_m = manage (new Gtk::Label);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich label_m->set_markup (_("<b>Special points to consider</b>"));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich attach_all(_page_snap_dtls.table(), array, G_N_ELEMENTS(array));
d3314a865df296da3830c262165d32c1741b653cKlaus Luettichlcms_profile_get_name (cmsHPROFILE profile, const gchar **name)
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich if (*name && ! g_utf8_validate (*name, -1, NULL))
d3314a865df296da3830c262165d32c1741b653cKlaus LuettichDocumentProperties::populate_available_profiles(){
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich Glib::ListHandle<Gtk::Widget*> children = _menu.get_children();
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich for ( Glib::ListHandle<Gtk::Widget*>::iterator it2 = children.begin(); it2 != children.end(); ++it2 ) {
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich std::list<Glib::ustring> sources = ColorProfile::getProfileDirs();
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich // Use this loop to iterate through a list of possible document locations.
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich for ( std::list<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) {
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich if ( Inkscape::IO::file_test( it->c_str(), G_FILE_TEST_EXISTS )
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich && Inkscape::IO::file_test( it->c_str(), G_FILE_TEST_IS_DIR )) {
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich GDir *directory = g_dir_open(it->c_str(), 0, &err);
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich gchar *safeDir = Inkscape::IO::sanitizeString(it->c_str());
d3314a865df296da3830c262165d32c1741b653cKlaus Luettich g_warning(_("Color profiles directory (%s) is unavailable."), safeDir);
if (!desktop){
if (!defsRepr){
while ( current ) {
while ( current ) {
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile"));
_page_cms.table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(_combo_avail, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
_page_cms.table().attach(_link_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
// TODO restore? _LinkedProfilesList.set_fixed_height_mode(true);
_LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release));
create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
if (current) {
_emb_profiles_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box));
bool grids_present = false;
case GRID_RECTANGULAR:
case GRID_AXONOMETRIC:
grids_present = true;
if (grids_present)
(void)nv;
set_sensitive (true);
#if ENABLE_LCMS
// TODO: copied from fill-and-stroke.cpp factor out into new ui/widget file?
label_image)));
return *_tab_label_box;
hide();
update();
update();
on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data)
for (GSList const * l = nv->grids; l != NULL; l = l->next, i++) { // not a very nice fix, but works.
if (pagenum == i) {
if (found_grid) {