document-properties.cpp revision c026f3fa6df4c655f56c0aa5d2fc30bed8758004
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Document properties dialog, Gtkmm-style
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * bulia byak <buliabyak@users.sf.net>
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Bryce W. Harrington <bryce@bryceharrington.org>
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Lauris Kaplinski <lauris@kaplinski.com>
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Jon Phillips <jon@rejon.org>
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Copyright (C) 2000 - 2005 Authors
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Released under GNU GPL. Read the file 'COPYING' for more information
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg//===================================================
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg//---------------------------------------------------
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_doc_replaced (SPDesktop* dt, SPDocument* doc);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_activate_desktop (Inkscape::Application *, SPDesktop* dt, void*);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic void on_deactivate_desktop (Inkscape::Application *, SPDesktop* dt, void*);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgstatic Inkscape::XML::NodeEventVector const _repr_events = {
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg : UI::Widget::Panel ("", "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _grids_button_new(_("_New"), _("Create new grid.")),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _grids_button_remove(_("_Remove"), _("Remove selected grid.")),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _getContents()->pack_start(_notebook, true, true);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _notebook.append_page(_page_page, _("Page"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _notebook.append_page(_page_guides, _("Guides"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _notebook.append_page(_grids_vbox, _("Grids"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _notebook.append_page(_page_snap, _("Snap"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _notebook.append_page(_page_snap_dtls, _("Snap details"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(SP_ACTIVE_DESKTOP)->root);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop",
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(SP_ACTIVE_DESKTOP)->root);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg//========================================================================
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * Helper function that attaches widgets in a 3xn table. The widgets come in an
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * array that has two entries per table row. The two entries code for four
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * possible cases: (0,0) means insert space in first column; (0, non-0) means
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg * (non-0, non-0) means two widgets in columns 2 and 3.
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburgattach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0)
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg for (unsigned i = 0, r = start; i < n; i += 2)
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcp_bg.init (_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcb_canb.init (_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcb_bord.init (_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcp_bord.init (_("Border _color:"), _("Page border color"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Color of the page border"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcb_shad.init (_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rum_deflt.init (_("Default _units:"), "inkscape:document-units", _wr);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label* label_gen = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label* label_bor = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label *label_for = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcb_sgui.init (_("Show _guides"), _("Show or hide guides"), "showguides", _wr);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcp_gui.init (_("Guide co_lor:"), _("Guideline color"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Color of guidelines"), "guidecolor", "guideopacity", _wr);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcp_hgui.init (_("_Highlight color:"), _("Highlighted guideline color"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Color of a guideline when it is under mouse"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label *label_gui = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg //General options
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap bounding box corners to grid lines, to guides, and to other bounding boxes (Snapping of bounding boxes is only available in the selector tool)"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap nodes to grid lines, to guides, to paths, and to other nodes"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg //Options for snapping to objects
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap nodes to object paths"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap nodes and guides to object nodes"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcbsnbbn.init (_("Snap to bounding box co_rners"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap bounding box corners to other bounding box corners"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rcbsnbbp.init (_("Snap to bounding box _edges"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snap bounding box corners and guides to bounding box edges"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rsu_sno.init (_("Snap _distance"), _("Snap at any d_istance"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snapping distance, in screen pixels, for snapping to objects"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("If set, objects snap to the nearest object, regardless of distance"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg //Options for snapping to grids
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rsu_sn.init (_("Snap di_stance"), _("Snap at any dis_tance"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snapping distance, in screen pixels, for snapping to grid"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("If set, objects snap to the nearest grid line, regardless of distance"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg //Options for snapping to guides
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _rsu_gusn.init (_("Snap dist_ance"), _("Snap at any distan_ce"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("Snapping distance, in screen pixels, for snapping to guides"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg _("If set, objects snap to the nearest guide, regardless of distance"),
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg //Other options to locate here: e.g. visual snapping indicators on/off
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label *label_g = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg label_g->set_markup (_("<b>Snapping of</b>"));
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg Gtk::Label *label_o = manage (new Gtk::Label);
5003b4008868032decd27b09f87bc1222ce1b783Joe Bandenburg label_o->set_markup (_("<b>Snapping to objects</b>"));
label_g, 0,
label_o, 0,
label_gr, 0,
label_gu, 0,
_("Snap to intersections of line segments ('snap to paths' must be enabled, see the previous tab)"),
_("While dragging a guide, snap to object nodes or bounding box corners ('snap to nodes' or 'snap to bounding box corners', both on the previous tab, must be enabled)"),
label_i, 0,
label_m, 0,
bool grids_present = false;
grids_present = true;
if (grids_present)
set_sensitive (true);
hide();
on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void * /*data*/)
if (!_instance)
on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void * /*data*/)
if (!_instance)
on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer)
if (!_instance)
if (!_instance)
_instance->_doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
if (!_instance)
if (!_instance)
if (!page) return;
if (found_grid) {