1 /** \file
2 *
3 * Document properties dialog, Gtkmm-style
4 *
5 * Authors:
6 * bulia byak <buliabyak@users.sf.net>
7 * Bryce W. Harrington <bryce@bryceharrington.org>
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * Jon Phillips <jon@rejon.org>
10 * Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
11 *
12 * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
13 * Copyright (C) 2000 - 2005 Authors
14 *
15 * Released under GNU GPL. Read the file 'COPYING' for more information
16 */
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
24 #include <gtkmm.h>
25 #include "ui/widget/color-picker.h"
26 #include "ui/widget/scalar-unit.h"
28 #include "xml/node-event-vector.h"
29 #include "helper/units.h"
30 #include "prefs-utils.h"
32 #include "inkscape.h"
33 #include "verbs.h"
34 #include "document.h"
35 #include "desktop-handles.h"
36 #include "desktop.h"
37 #include "sp-namedview.h"
39 #include "document-properties.h"
41 #include "display/canvas-grid.h"
43 using std::pair;
45 namespace Inkscape {
46 namespace UI {
47 namespace Dialog {
49 #define SPACE_SIZE_X 15
50 #define SPACE_SIZE_Y 10
52 //===================================================
54 //---------------------------------------------------
56 static void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
57 static void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
58 static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
60 static Inkscape::XML::NodeEventVector const _repr_events = {
61 on_child_added, /* child_added */
62 on_child_removed, /* child_removed */
63 on_repr_attr_changed,
64 NULL, /* content_changed */
65 NULL /* order_changed */
66 };
69 DocumentProperties &
70 DocumentProperties::getInstance()
71 {
72 DocumentProperties &instance = *new DocumentProperties();
73 instance.init();
75 return instance;
76 }
78 DocumentProperties::DocumentProperties()
79 : UI::Widget::Panel ("", "dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
80 _page_page(1, 1), _page_guides(1, 1),
81 _page_snap(1, 1), _page_snap_dtls(1, 1),
82 _grids_label_crea("", Gtk::ALIGN_LEFT),
83 _grids_button_new(_("_New"), _("Create new grid.")),
84 _grids_button_remove(_("_Remove"), _("Remove selected grid.")),
85 _grids_label_def("", Gtk::ALIGN_LEFT),
86 _prefs_path("dialogs.documentoptions")
87 {
88 _tt.enable();
89 _getContents()->set_spacing (4);
90 _getContents()->pack_start(_notebook, true, true);
92 _notebook.append_page(_page_page, _("Page"));
93 _notebook.append_page(_page_guides, _("Guides"));
94 _notebook.append_page(_grids_vbox, _("Grids"));
95 _notebook.append_page(_page_snap, _("Snap"));
96 _notebook.append_page(_page_snap_dtls, _("Snap points"));
98 build_page();
99 build_guides();
100 build_gridspage();
101 build_snap();
102 build_snap_dtls();
104 _grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid));
105 _grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
107 signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced));
108 signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleActivateDesktop));
109 signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop));
110 }
112 void
113 DocumentProperties::init()
114 {
115 update();
117 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
118 repr->addListener (&_repr_events, this);
119 Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(getDesktop())->root);
120 root->addListener (&_repr_events, this);
122 show_all_children();
123 _grids_button_remove.hide();
124 }
126 DocumentProperties::~DocumentProperties()
127 {
128 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
129 repr->removeListenerByData (this);
130 Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(getDesktop())->root);
131 root->removeListenerByData (this);
132 }
134 //========================================================================
136 /**
137 * Helper function that attaches widgets in a 3xn table. The widgets come in an
138 * array that has two entries per table row. The two entries code for four
139 * possible cases: (0,0) means insert space in first column; (0, non-0) means
140 * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
141 * (non-0, non-0) means two widgets in columns 2 and 3.
142 **/
143 inline void
144 attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0)
145 {
146 for (unsigned i = 0, r = start; i < n; i += 2)
147 {
148 if (arr[i] && arr[i+1])
149 {
150 table.attach(*arr[i], 1, 2, r, r+1,
151 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
152 table.attach(*arr[i+1], 2, 3, r, r+1,
153 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
154 }
155 else
156 {
157 if (arr[i+1])
158 table.attach(*arr[i+1], 1, 3, r, r+1,
159 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
160 else if (arr[i])
161 {
162 Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
163 label.set_alignment (0.0);
164 table.attach (label, 0, 3, r, r+1,
165 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
166 }
167 else
168 {
169 Gtk::HBox *space = manage (new Gtk::HBox);
170 space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
171 table.attach (*space, 0, 1, r, r+1,
172 (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
173 }
174 }
175 ++r;
176 }
177 }
179 void
180 DocumentProperties::build_page()
181 {
182 _page_page.show();
184 _rcp_bg.init (_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"),
185 "pagecolor", "inkscape:pageopacity", _wr);
186 _rcb_canb.init (_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false);
187 _rcb_bord.init (_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false);
188 _rcp_bord.init (_("Border _color:"), _("Page border color"),
189 _("Color of the page border"),
190 "bordercolor", "borderopacity", _wr);
191 _rcb_shad.init (_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false);
192 _rum_deflt.init (_("Default _units:"), "inkscape:document-units", _wr);
194 Gtk::Label* label_gen = manage (new Gtk::Label);
195 label_gen->set_markup (_("<b>General</b>"));
196 Gtk::Label* label_bor = manage (new Gtk::Label);
197 label_bor->set_markup (_("<b>Border</b>"));
198 Gtk::Label *label_for = manage (new Gtk::Label);
199 label_for->set_markup (_("<b>Format</b>"));
200 _page_sizer.init (_wr);
202 Gtk::Widget *const widget_array[] =
203 {
204 label_gen, 0,
205 _rum_deflt._label, _rum_deflt._sel,
206 _rcp_bg._label, _rcp_bg._cp,
207 0, 0,
208 label_for, 0,
209 0, &_page_sizer,
210 0, 0,
211 label_bor, 0,
212 0, _rcb_canb._button,
213 0, _rcb_bord._button,
214 0, _rcb_shad._button,
215 _rcp_bord._label, _rcp_bord._cp,
216 };
218 attach_all(_page_page.table(), widget_array, G_N_ELEMENTS(widget_array));
219 }
221 void
222 DocumentProperties::build_guides()
223 {
224 _page_guides.show();
226 _rcb_sgui.init (_("Show _guides"), _("Show or hide guides"), "showguides", _wr);
227 _rcp_gui.init (_("Guide co_lor:"), _("Guideline color"),
228 _("Color of guidelines"), "guidecolor", "guideopacity", _wr);
229 _rcp_hgui.init (_("_Highlight color:"), _("Highlighted guideline color"),
230 _("Color of a guideline when it is under mouse"),
231 "guidehicolor", "guidehiopacity", _wr);
233 _rcbsng.init (_("_Snap guides while dragging"),
234 _("While dragging a guide, snap to object nodes or bounding box corners ('Nodes' or 'Bounding box corners' must be enabled in the 'Snap' tab)"),
235 "inkscape:snap-guide", _wr);
237 Gtk::Label *label_gui = manage (new Gtk::Label);
238 label_gui->set_markup (_("<b>Guides</b>"));
240 Gtk::Widget *const widget_array[] =
241 {
242 label_gui, 0,
243 0, _rcb_sgui._button,
244 _rcp_gui._label, _rcp_gui._cp,
245 _rcp_hgui._label, _rcp_hgui._cp,
246 0, _rcbsng._button,
247 };
249 attach_all(_page_guides.table(), widget_array, G_N_ELEMENTS(widget_array));
250 }
252 void
253 DocumentProperties::build_snap()
254 {
255 _page_snap.show();
256 //General options
257 _rcbsnbb.init (_("_Bounding box corners"),
258 _("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)"),
259 "inkscape:snap-bbox", _wr);
260 _rcbsnn.init (_("_Nodes"),
261 _("Snap nodes to grid lines, to guides, to paths, and to other nodes"),
262 "inkscape:snap-nodes", _wr);
264 //Options for snapping to objects
265 _rcbsnop.init (_("Snap to pat_hs"),
266 _("Snap nodes to object paths"),
267 "inkscape:object-paths", _wr);
268 _rcbsnon.init (_("Snap to n_odes"),
269 _("Snap nodes and guides to object nodes"),
270 "inkscape:object-nodes", _wr);
271 _rcbsnbbn.init (_("Snap to bounding box co_rners"),
272 _("Snap bounding box corners to other bounding box corners"),
273 "inkscape:bbox-nodes", _wr);
274 _rcbsnbbp.init (_("Snap to bounding box _edges"),
275 _("Snap bounding box corners and guides to bounding box edges"),
276 "inkscape:bbox-paths", _wr);
278 _rsu_sno.init (_("Snap _distance"), _("Snap at any d_istance"),
279 _("Snapping distance, in screen pixels, for snapping to objects"),
280 _("If set, objects snap to the nearest object, regardless of distance"),
281 "objecttolerance", _wr);
283 //Options for snapping to grids
284 _rsu_sn.init (_("Snap di_stance"), _("Snap at any dis_tance"),
285 _("Snapping distance, in screen pixels, for snapping to grid"),
286 _("If set, objects snap to the nearest grid line, regardless of distance"),
287 "gridtolerance", _wr);
289 //Options for snapping to guides
290 _rsu_gusn.init (_("Snap dist_ance"), _("Snap at any distan_ce"),
291 _("Snapping distance, in screen pixels, for snapping to guides"),
292 _("If set, objects snap to the nearest guide, regardless of distance"),
293 "guidetolerance", _wr);
295 //Other options to locate here: e.g. visual snapping indicators on/off
297 std::list<Gtk::ToggleButton*> slaves;
298 slaves.push_back(_rcbsnop._button);
299 slaves.push_back(_rcbsnon._button);
300 _rcbsnn.setSlaveButton(slaves);
302 slaves.clear();
303 slaves.push_back(_rcbsnbbp._button);
304 slaves.push_back(_rcbsnbbn._button);
305 _rcbsnbb.setSlaveButton(slaves);
307 Gtk::Label *label_g = manage (new Gtk::Label);
308 label_g->set_markup (_("<b>Snapping of</b>"));
309 Gtk::Label *label_o = manage (new Gtk::Label);
310 label_o->set_markup (_("<b>Snapping to objects</b>"));
311 Gtk::Label *label_gr = manage (new Gtk::Label);
312 label_gr->set_markup (_("<b>Snapping to grids</b>"));
313 Gtk::Label *label_gu = manage (new Gtk::Label);
314 label_gu->set_markup (_("<b>Snapping to guides</b>"));
315 Gtk::Label *label_m = manage (new Gtk::Label);
316 label_m->set_markup (_("<b>Miscellaneous</b>"));
318 Gtk::Widget *const array[] =
319 {
320 label_g, 0,
321 0, _rcbsnn._button,
322 0, _rcbsnbb._button,
323 0, 0,
324 0, 0,
325 0, 0,
326 0, 0,
327 label_o, 0,
328 0, _rcbsnop._button,
329 0, _rcbsnon._button,
330 0, _rcbsnbbp._button,
331 0, _rcbsnbbn._button,
332 0, _rsu_sno._vbox,
333 0, 0,
334 label_gr, 0,
335 0, _rsu_sn._vbox,
336 0, 0,
337 label_gu, 0,
338 0, _rsu_gusn._vbox
339 };
341 attach_all(_page_snap.table(), array, G_N_ELEMENTS(array));
342 }
344 void
345 DocumentProperties::build_snap_dtls()
346 {
347 _page_snap_dtls.show();
349 _rcbsigg.init (_("_Grid with guides"),
350 _("Snap to grid-guide intersections"),
351 "inkscape:snap-intersection-grid-guide", _wr);
353 _rcbsils.init (_("_Line segments"),
354 _("Snap to intersections of line segments ('snap to paths' must be enabled, see the previous tab)"),
355 "inkscape:snap-intersection-line-segments", _wr);
357 //Applies to both nodes and guides, but not to bboxes, that's why its located here
358 _rcbic.init (_("_Include the object's rotation center"),
359 _("Also snap the rotation center of an object when snapping nodes or guides"),
360 "inkscape:snap-center", _wr);
362 //Other options to locate here: e.g. visual snapping indicators on/off
364 Gtk::Label *label_i= manage (new Gtk::Label);
365 label_i->set_markup (_("<b>Snapping to intersections of</b>"));
366 Gtk::Label *label_m = manage (new Gtk::Label);
367 label_m->set_markup (_("<b>Miscellaneous</b>"));
369 Gtk::Widget *const array[] =
370 {
371 label_i, 0,
372 0, _rcbsigg._button,
373 0, _rcbsils._button,
374 0, 0,
375 label_m, 0,
376 0, _rcbic._button,
377 };
379 attach_all(_page_snap_dtls.table(), array, G_N_ELEMENTS(array));
380 }
382 /**
383 * Called for _updating_ the dialog (e.g. when a new grid was manually added in XML)
384 */
385 void
386 DocumentProperties::update_gridspage()
387 {
388 SPDesktop *dt = getDesktop();
389 SPNamedView *nv = sp_desktop_namedview(dt);
391 //remove all tabs
392 while (_grids_notebook.get_current_page() != -1) {
393 _grids_notebook.remove_page(-1);
394 }
396 //add tabs
397 bool grids_present = false;
398 for (GSList const * l = nv->grids; l != NULL; l = l->next) {
399 Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data;
400 _grids_notebook.append_page(grid->getWidget(), grid->repr->attribute("id"));
401 grids_present = true;
402 }
403 _grids_notebook.show_all();
405 if (grids_present)
406 _grids_button_remove.show();
407 else
408 _grids_button_remove.hide();
409 }
411 /**
412 * Build grid page of dialog.
413 */
414 void
415 DocumentProperties::build_gridspage()
416 {
417 /// \todo FIXME: gray out snapping when grid is off.
418 /// Dissenting view: you want snapping without grid.
420 SPDesktop *dt = getDesktop();
421 SPNamedView *nv = sp_desktop_namedview(dt);
423 _grids_label_crea.set_markup(_("<b>Creation</b>"));
424 _grids_label_def.set_markup(_("<b>Defined grids</b>"));
425 _grids_hbox_crea.pack_start(_grids_combo_gridtype, true, true);
426 _grids_hbox_crea.pack_start(_grids_button_new, true, true);
428 for (gint t = 0; t <= GRID_MAXTYPENR; t++) {
429 _grids_combo_gridtype.append_text( CanvasGrid::getName( (GridType) t ) );
430 }
431 _grids_combo_gridtype.set_active_text( CanvasGrid::getName(GRID_RECTANGULAR) );
433 for (GSList const * l = nv->grids; l != NULL; l = l->next) {
434 Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data;
435 _grids_notebook.append_page(grid->getWidget(), grid->repr->attribute("id"));
436 }
438 _grids_space.set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
440 _grids_vbox.set_spacing(4);
441 _grids_vbox.pack_start(_grids_label_crea, false, false);
442 _grids_vbox.pack_start(_grids_hbox_crea, false, false);
443 _grids_vbox.pack_start(_grids_space, false, false);
444 _grids_vbox.pack_start(_grids_label_def, false, false);
445 _grids_vbox.pack_start(_grids_notebook, false, false);
446 _grids_vbox.pack_start(_grids_button_remove, false, false);
447 _grids_button_remove.hide();
448 }
452 /**
453 * Update dialog widgets from desktop. Also call updateWidget routines of the grids.
454 */
455 void
456 DocumentProperties::update()
457 {
458 if (_wr.isUpdating()) return;
460 SPDesktop *dt = getDesktop();
461 SPNamedView *nv = sp_desktop_namedview(dt);
463 _wr.setUpdating (true);
464 set_sensitive (true);
466 //-----------------------------------------------------------page page
467 _rcp_bg.setRgba32 (nv->pagecolor);
468 _rcb_canb.setActive (nv->showborder);
469 _rcb_bord.setActive (nv->borderlayer == SP_BORDER_LAYER_TOP);
470 _rcp_bord.setRgba32 (nv->bordercolor);
471 _rcb_shad.setActive (nv->showpageshadow);
473 if (nv->doc_units)
474 _rum_deflt.setUnit (nv->doc_units);
476 double const doc_w_px = sp_document_width(sp_desktop_document(dt));
477 double const doc_h_px = sp_document_height(sp_desktop_document(dt));
478 _page_sizer.setDim (doc_w_px, doc_h_px);
480 //-----------------------------------------------------------guide
481 _rcb_sgui.setActive (nv->showguides);
482 _rcp_gui.setRgba32 (nv->guidecolor);
483 _rcp_hgui.setRgba32 (nv->guidehicolor);
485 //-----------------------------------------------------------snap
487 _rcbsnbb.setActive (nv->snap_manager.getSnapModeBBox());
488 _rcbsnn.setActive (nv->snap_manager.getSnapModeNode());
489 _rcbsng.setActive (nv->snap_manager.getSnapModeGuide());
490 _rcbic.setActive (nv->snap_manager.getIncludeItemCenter());
491 _rcbsnop.setActive(nv->snap_manager.object.getSnapToItemPath());
492 _rcbsnon.setActive(nv->snap_manager.object.getSnapToItemNode());
493 _rcbsnbbp.setActive(nv->snap_manager.object.getSnapToBBoxPath());
494 _rcbsnbbn.setActive(nv->snap_manager.object.getSnapToBBoxNode());
495 _rsu_sno.setValue (nv->objecttolerance);
497 _rsu_sn.setValue (nv->gridtolerance);
499 _rsu_gusn.setValue (nv->guidetolerance);
501 //-----------------------------------------------------------grids page
503 update_gridspage();
505 _wr.setUpdating (false);
506 }
508 //--------------------------------------------------------------------
510 void
511 DocumentProperties::on_response (int id)
512 {
513 if (id == Gtk::RESPONSE_DELETE_EVENT || id == Gtk::RESPONSE_CLOSE)
514 {
515 _rcp_bg.closeWindow();
516 _rcp_bord.closeWindow();
517 _rcp_gui.closeWindow();
518 _rcp_hgui.closeWindow();
519 }
521 if (id == Gtk::RESPONSE_CLOSE)
522 hide();
523 }
525 void
526 DocumentProperties::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *document)
527 {
528 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
529 repr->addListener(&_repr_events, this);
530 Inkscape::XML::Node *root = SP_OBJECT_REPR(document->root);
531 root->addListener(&_repr_events, this);
532 update();
533 }
535 void
536 DocumentProperties::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop)
537 {
538 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
539 repr->addListener(&_repr_events, this);
540 Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(desktop)->root);
541 root->addListener(&_repr_events, this);
542 update();
543 }
545 void
546 DocumentProperties::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop)
547 {
548 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
549 repr->removeListenerByData(this);
550 Inkscape::XML::Node *root = SP_OBJECT_REPR(sp_desktop_document(desktop)->root);
551 root->removeListenerByData(this);
552 }
554 static void
555 on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
556 {
557 if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data))
558 dialog->update_gridspage();
559 }
561 static void
562 on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
563 {
564 if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data))
565 dialog->update_gridspage();
566 }
570 /**
571 * Called when XML node attribute changed; updates dialog widgets.
572 */
573 static void
574 on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data)
575 {
576 if (DocumentProperties *dialog = static_cast<DocumentProperties *>(data))
577 dialog->update();
578 }
581 /*########################################################################
582 # BUTTON CLICK HANDLERS (callbacks)
583 ########################################################################*/
585 void
586 DocumentProperties::onNewGrid()
587 {
588 SPDesktop *dt = getDesktop();
589 Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(dt));
590 SPDocument *doc = sp_desktop_document(dt);
592 Glib::ustring typestring = _grids_combo_gridtype.get_active_text();
593 CanvasGrid::writeNewGridToRepr(repr, doc, CanvasGrid::getGridTypeFromName(typestring.c_str()));
594 }
597 void
598 DocumentProperties::onRemoveGrid()
599 {
600 gint pagenum = _grids_notebook.get_current_page();
601 if (pagenum == -1) // no pages
602 return;
604 Gtk::Widget *page = _grids_notebook.get_nth_page(pagenum);
605 if (!page) return;
607 Glib::ustring tabtext = _grids_notebook.get_tab_label_text(*page);
609 // find the grid with name tabtext (it's id) and delete that one.
610 SPDesktop *dt = getDesktop();
611 SPNamedView *nv = sp_desktop_namedview(dt);
612 Inkscape::CanvasGrid * found_grid = NULL;
613 for (GSList const * l = nv->grids; l != NULL; l = l->next) {
614 Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data;
615 gchar const *idtext = grid->repr->attribute("id");
616 if ( !strcmp(tabtext.c_str(), idtext) ) {
617 found_grid = grid;
618 break; // break out of for-loop
619 }
620 }
621 if (found_grid) {
622 // delete the grid that corresponds with the selected tab
623 // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer!
624 found_grid->repr->parent()->removeChild(found_grid->repr);
625 sp_document_done(sp_desktop_document(dt), SP_VERB_DIALOG_NAMEDVIEW, _("Remove grid"));
626 }
627 }
630 } // namespace Dialog
631 } // namespace UI
632 } // namespace Inkscape
634 /*
635 Local Variables:
636 mode:c++
637 c-file-style:"stroustrup"
638 c-file-offsets:((innamespace . 0)(inline-open . 0))
639 indent-tabs-mode:nilu
640 fill-column:99
641 End:
642 */
643 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :