Merge lp:~inkscape.dev/inkscape/guides-improvements into lp:~inkscape.dev/inkscape/trunk

Proposed by hermes ramirez
Status: Work in progress
Proposed branch: lp:~inkscape.dev/inkscape/guides-improvements
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 5623 lines (+2147/-1318)
48 files modified
build.xml (+0/-8)
doc/HACKING.txt (+1/-1)
doc/architecture.txt (+1/-1)
share/icons/icons.svg (+2/-2)
src/Makefile_insert (+1/-1)
src/attributes.cpp (+2/-0)
src/attributes.h (+2/-0)
src/box3d.cpp (+1/-1)
src/desktop-events.cpp (+138/-54)
src/desktop.cpp (+27/-7)
src/desktop.h (+4/-0)
src/display/Makefile_insert (+2/-0)
src/display/canvas-axonomgrid.cpp (+15/-13)
src/display/canvas-axonomgrid.h (+10/-0)
src/display/canvas-grid.cpp (+14/-10)
src/display/canvas-guide.cpp (+549/-0)
src/display/canvas-guide.h (+92/-0)
src/display/guideline.cpp (+38/-6)
src/display/guideline.h (+4/-0)
src/document-undo.cpp (+24/-20)
src/document.cpp (+4/-4)
src/file.cpp (+117/-1)
src/guide-manager.cpp (+154/-0)
src/guide-manager.h (+65/-0)
src/guide-snapper.cpp (+5/-4)
src/helper/geom.cpp (+15/-1)
src/helper/geom.h (+3/-0)
src/line-snapper.cpp (+1/-1)
src/main.cpp (+2/-1)
src/satisfied-guide-cns.cpp (+1/-1)
src/snap.cpp (+11/-10)
src/sp-guide.cpp (+0/-540)
src/sp-guide.h (+0/-88)
src/sp-item-notify-moveto.cpp (+1/-1)
src/sp-item-rm-unsatisfied-cns.cpp (+1/-1)
src/sp-item-update-cns.cpp (+2/-3)
src/sp-item.cpp (+2/-2)
src/sp-line.cpp (+6/-5)
src/sp-namedview.cpp (+30/-6)
src/sp-namedview.h (+7/-2)
src/sp-path.cpp (+3/-3)
src/sp-rect.cpp (+6/-6)
src/ui/dialog/document-properties.cpp (+687/-450)
src/ui/dialog/document-properties.h (+92/-57)
src/ui/dialog/guides.cpp (+2/-3)
src/ui/dialog/layers.cpp (+1/-2)
src/ui/tools/tool-base.cpp (+1/-1)
src/verbs.cpp (+1/-1)
To merge this branch: bzr merge lp:~inkscape.dev/inkscape/guides-improvements
Reviewer Review Type Date Requested Status
Inkscape Developers Pending
Review via email: mp+116144@code.launchpad.net
To post a comment you must log in.
Revision history for this message
ScislaC (scislac) wrote :

This is currently an ongoing GSOC project and is not ready for merging. This is an outside branch and has not been merged yet.

11501. By Samuel Chase

debugging info

11502. By Samuel Chase

merged with trunk r:11573

11503. By Samuel Chase

debugging information with line numbers

11504. By Samuel Chase

commented out debugging information

11505. By Samuel Chase

removed debugging information. partially working labels.

11506. By Samuel Chase

Fix for Bug #1029033

11507. By Samuel Chase

memory leak fix.

11508. By Samuel Chase

merged with trunk

11509. By Samuel Chase

added two buttons. experimental prototyping. needs a lot of fixing.

11510. By Samuel Chase

removed unnecessary file

11511. By Samuel Chase

added guide-manager.cpp, guide-manager.h. Got inkscape to build.

11512. By Samuel Chase

made guide_manager a pointer.

11513. By Samuel Chase

removed inclusion of header

11514. By Samuel Chase

I can see!

11515. By Samuel Chase

basic guide information displayed in TreeView

11516. By Samuel Chase

added some checking macros.

11517. By Samuel Chase

NULL checks. eye and lock ImageTogglers

11518. By Samuel Chase

cosmetic changes

11519. By Samuel Chase

removed the header-row, and the Guide-no. column

11520. By Samuel Chase

Fixed bug in which guides without labels caused Inkscape to crash.

11521. By Samuel Chase

NULL check for getAttribute

11522. By Samuel Chase

merged with trunk

11523. By Samuel Chase

trying to get the "Delete" button to work

11524. By Samuel Chase

rearrangement of code

11525. By Samuel Chase

The "Delete" button works.

11526. By Samuel Chase

attempt to make the guide-lable editable in-place

11527. By Samuel Chase

revert to r:11525. New approach needed.

11528. By Samuel Chase

basic class design for GuideManager

11529. By Samuel Chase

empty constructor

11530. By Samuel Chase

it buids.

11531. By Samuel Chase

duplicated the code in layer-manager.cpp in guide-manager.cpp and commented it all out

11532. By Samuel Chase

Well, it builds.

11533. By Samuel Chase

implemented destructor, removed some unnecessary commented code

11534. By Samuel Chase

removed more unecessary commented code

11535. By Samuel Chase

merged with trunk

11536. By Samuel Chase

as SPNamedView::connectModified is being used, names changed appropriately

11537. By Samuel Chase

cosmetic changes. The Delete button doesn't work any more

11538. By Samuel Chase

The "Delete" button works again. Also removed some unncessary commented out code

11539. By Samuel Chase

fixed the SP_IS_GUIDE check

11540. By Samuel Chase

implementing _rebuild. Initial stages

11541. By Samuel Chase

still _rebuilding

11542. By Samuel Chase

merged with trunk

11543. By Samuel Chase

rudimentary _rebuild()

11544. By Samuel Chase

merged with trunk

11545. By Samuel Chase

All new guides will be created as "inkscape:guide".

11546. By Samuel Chase

first broken attempt to transform old-style guides to new style guides

11547. By Samuel Chase

more broken things.

11548. By Samuel Chase

Horrible attempt #1.

11549. By Samuel Chase

position and orientation attribute reading code same as that of canvas-guide.cpp. and a few other cleanups

11550. By Samuel Chase

Reading from SVG using streams works

11551. By Samuel Chase

reverted

11552. By Samuel Chase

added comment

11553. By Samuel Chase

merge with trunk

11554. By Samuel Chase

height is read from the document instead of using getHeight(). using sp_repr_set_double makes things a little less ugly.

11555. By Samuel Chase

merge with trunk

11556. By Samuel Chase

added the enable attribute. GC'd the node

11557. By Samuel Chase

sp_namedview_convert_old_guides now has the same arguments as sp_namedview_generate_old_grid, kinda.

11558. By Johan Engelen

enable console output for windows builds

11559. By Johan Engelen

backwards compatibility: convert old-style guides to new-style

11560. By Johan Engelen

guides default enabled

11561. By Samuel Chase

merged with trunk

11562. By Samuel Chase

merged with trunk

11563. By Samuel Chase

merged with trunk

11564. By Johan Engelen

work on changing coord system for grids too. display is good now. snapping is still in old coordsystem

11565. By Johan Engelen

fix grid snapping. i think grids are now in same coord system as everything else. the UI is now awkward, as the origin location does not correspond to what is put on the rulers... (similar to guide dialog (double-click on guide))

11566. By Johan Engelen

1. fix axonomgrid snapping
2. fix alt-drag grid-multiple snapping

11567. By Johan Engelen

merge trunnk.......

11568. By Johan Engelen

correctly move guides and grids when resizing page to drawing/selection

11569. By Samuel Chase

Merge with trunk.

11570. By Samuel Chase

Attempt to merge canvas-guide.cpp with a newer sp-guide.cpp from trunk

11571. By Samuel Chase

Merge with trunk.

11572. By Samuel Chase

Add <glibmm/threads.h> include to make Inkscape build again.

11573. By Samuel Chase

Change sodipodi:guide to inkscape:guide

11574. By Samuel Chase

Merge with trunk.

11575. By Samuel Chase

Merge with trunk

11576. By Samuel Chase

Merge with trunk

11577. By Samuel Chase

Remove warning. Stylistic changes

* Change from sodipodi:guide to inkscape:guide.
  Earlier there was a warning on console "unknown type: sodipodi:guide" when
  the icons.svg file was read. This warning was from factory.h

* Trivial stylistic changes in document-properties.cpp

11578. By Samuel Chase

Update documentation

11579. By Samuel Chase

Fix build error in document-properties.cc

- Change GTK+ code to use GTKMM instead
- Minor stylistic changes

11580. By Samuel Chase

Modularise method by creating helper method

11581. By Samuel Chase

Stylistic Changes

Break long lines
Spaces around infix aritmetic operators

11582. By Samuel Chase

clang-formatt document-properties.cpp

11583. By Samuel Chase

Fix formatting of widget_array[]

11584. By Samuel Chase

Merge with trunk.

11585. By Samuel Chase

Merge with trunk

11586. By Samuel Chase

Refactor populate_guides_list()

- Remove unnecessary checks.
- Remove C-style cast.
- Use more descriptive variable names.
- Fix unrelated documentation formatting.

11587. By Samuel Chase

Implement multiple guide selection and deletion

- Some unrelated stylistic refactoring
- Made some functions private

11588. By Samuel Chase

Fix Undo for guide-multi-delete

- Some unrelated stylistic change.

11589. By Samuel Chase

Remove unnecessary headers

11590. By Samuel Chase

Intermediate GTK3 migration attempt commit

11591. By Samuel Chase

Merge with trunk

11592. By Samuel Chase

Merge with trunk

Unmerged revisions

11592. By Samuel Chase

Merge with trunk

11591. By Samuel Chase

Merge with trunk

11590. By Samuel Chase

Intermediate GTK3 migration attempt commit

11589. By Samuel Chase

Remove unnecessary headers

11588. By Samuel Chase

Fix Undo for guide-multi-delete

- Some unrelated stylistic change.

11587. By Samuel Chase

Implement multiple guide selection and deletion

- Some unrelated stylistic refactoring
- Made some functions private

11586. By Samuel Chase

Refactor populate_guides_list()

- Remove unnecessary checks.
- Remove C-style cast.
- Use more descriptive variable names.
- Fix unrelated documentation formatting.

11585. By Samuel Chase

Merge with trunk

11584. By Samuel Chase

Merge with trunk.

11583. By Samuel Chase

Fix formatting of widget_array[]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'build.xml'
2--- build.xml 2014-09-02 23:51:04 +0000
3+++ build.xml 2014-09-23 18:22:24 +0000
4@@ -354,13 +354,6 @@
5 <flags>
6 -Wall -Wformat -Werror=format-security -Wextra -Wpointer-arith -Wcast-align -Wsign-compare -Wswitch
7 -Werror=return-type
8- <!-- - -> -Werror <!-- -->
9- <!-- A list of warnings that should not error *yet*, any help is welcome in fixing the code generating these warnings! -->
10- <!-- libcroco is using guchar where it should use gchar, so we need: --> -Wno-error=pointer-sign
11- -Wno-error=unused-parameter -Wno-error=unused-but-set-variable -Wno-error=strict-overflow -Wno-error=write-strings
12- <!-- Format warnings are obviously bad errors, but with the current old compiler on Windows (gcc 4.6.) we run into a problem with long long ints...
13- The errors can be restored by removing these flags after updating to a newer compiler (soon after 0.91 release hopefully) -->
14- -Wno-error=format -Wno-error=format-extra-args
15 -O2
16 -mms-bitfields
17 -fopenmp
18@@ -530,7 +523,6 @@
19 stripcommand="${archutil}strip"
20 objcopycommand="${archutil}objcopy">
21 <flags>
22- -mwindows
23 -mthreads
24 </flags>
25 <fileset dir="${build}/obj">
26
27=== modified file 'doc/HACKING.txt'
28--- doc/HACKING.txt 2010-03-20 11:18:53 +0000
29+++ doc/HACKING.txt 2014-09-23 18:22:24 +0000
30@@ -30,7 +30,7 @@
31 of something you'd like to work on. If not, here are just a few ways you
32 can help:
33
34- * Pick a bug, fix it, and send in a patch ("diff -uNrp" or "cvs diff -up")
35+ * Pick a bug, fix it, and send in a patch ("diff -uNrp" or "bzr diff")
36 * Choose a feature you want to see developed, and make it
37 * If you speak a language in addition to English, work on your
38 language's i18n file in the po/ directory
39
40=== modified file 'doc/architecture.txt'
41--- doc/architecture.txt 2006-01-16 02:36:01 +0000
42+++ doc/architecture.txt 2014-09-23 18:22:24 +0000
43@@ -159,7 +159,7 @@
44 SPObjectGroup ABSTRACT
45 SPNamedView <sodipodi:namedview>
46 SPClipPath <clipPath>
47- SPGuide <sodipodi:guide>
48+ SPGuide <inkscape:guide>
49 SPPaintServer ABSTRACT
50 SPGradient ABSTRACT
51 SPLinearGradient <linearGradient>
52
53=== modified file 'share/icons/icons.svg'
54--- share/icons/icons.svg 2014-06-13 16:06:01 +0000
55+++ share/icons/icons.svg 2014-09-23 18:22:24 +0000
56@@ -866,8 +866,8 @@
57 </defs>
58 <sodipodi:namedview inkscape:guide-bbox="true" inkscape:current-layer="svg1" inkscape:grid-bbox="true" inkscape:pageopacity="1.0000000" pagecolor="#e8e8e4" snaptoguides="true" showguides="true" inkscape:window-y="0" inkscape:window-x="40" inkscape:window-height="745" inkscape:window-width="1326" inkscape:cy="417.9499" inkscape:cx="364.8285" inkscape:zoom="3.343024" gridtolerance="6" snaptogrid="false" showgrid="false" id="base" inkscape:document-units="px" inkscape:grid-points="true" guidetolerance="8" fill="#8ab3de" stroke="#646464" inkscape:object-nodes="false" objecttolerance="11" inkscape:snap-bbox="false" inkscape:snap-nodes="true" inkscape:bbox-nodes="false" inkscape:bbox-paths="false" inkscape:snap-global="false" inkscape:snap-center="false" inkscape:snap-midpoints="false" inkscape:snap-intersection-paths="true" inkscape:object-paths="false" inkscape:snap-object-midpoints="true" inkscape:window-maximized="1" inkscape:snap-grids="true" inkscape:snap-smooth-nodes="false" inkscape:snap-text-baseline="false" inkscape:snap-page="true" inkscape:snap-bbox-midpoints="false" inkscape:snap-bbox-edge-midpoints="false">
59 <inkscape:grid type="xygrid" id="grid9252" originx="0px" originy="0px" spacingx="0.5px" spacingy="0.5px" empspacing="2" visible="true" enabled="true" snapvisiblegridlinesonly="true" />
60-<sodipodi:guide orientation="0,1" position="630.08101,968.02815" id="guide4946" />
61-<sodipodi:guide orientation="0,1" position="618.47896,943.93157" id="guide4948" />
62+<inkscape:guide orientation="0,1" position="630.08101,968.02815" id="guide4946" />
63+<inkscape:guide orientation="0,1" position="618.47896,943.93157" id="guide4948" />
64 </sodipodi:namedview>
65 <metadata id="metadata1810">
66 <rdf:RDF>
67
68=== modified file 'src/Makefile_insert'
69--- src/Makefile_insert 2014-07-31 14:31:01 +0000
70+++ src/Makefile_insert 2014-09-23 18:22:24 +0000
71@@ -61,6 +61,7 @@
72 gradient-chemistry.cpp gradient-chemistry.h \
73 gradient-drag.cpp gradient-drag.h \
74 graphlayout.cpp graphlayout.h \
75+ guide-manager.cpp guide-manager.h \
76 guide-snapper.cpp guide-snapper.h \
77 help.cpp help.h \
78 helper-fns.h \
79@@ -157,7 +158,6 @@
80 sp-gradient-vector.h \
81 sp-guide-attachment.h \
82 sp-guide-constraint.h \
83- sp-guide.cpp sp-guide.h \
84 sp-image.cpp sp-image.h \
85 sp-item.cpp sp-item.h \
86 sp-item-group.cpp sp-item-group.h \
87
88=== modified file 'src/attributes.cpp'
89--- src/attributes.cpp 2014-08-01 09:04:51 +0000
90+++ src/attributes.cpp 2014-09-23 18:22:24 +0000
91@@ -124,6 +124,8 @@
92 /* SPGuide */
93 {SP_ATTR_ORIENTATION, "orientation"},
94 {SP_ATTR_POSITION, "position"},
95+ {SP_ATTR_ENABLE, "enable"},
96+ {SP_ATTR_GROUP, "group"},
97 /* SPImage */
98 {SP_ATTR_X, "x"},
99 {SP_ATTR_Y, "y"},
100
101=== modified file 'src/attributes.h'
102--- src/attributes.h 2014-08-01 09:04:51 +0000
103+++ src/attributes.h 2014-09-23 18:22:24 +0000
104@@ -125,6 +125,8 @@
105 /* SPGuide */
106 SP_ATTR_ORIENTATION,
107 SP_ATTR_POSITION,
108+ SP_ATTR_ENABLE,
109+ SP_ATTR_GROUP,
110 /* SPImage */
111 SP_ATTR_X,
112 SP_ATTR_Y,
113
114=== modified file 'src/box3d.cpp'
115--- src/box3d.cpp 2014-07-22 19:15:15 +0000
116+++ src/box3d.cpp 2014-09-23 18:22:24 +0000
117@@ -31,7 +31,7 @@
118 #include "persp3d-reference.h"
119 #include "uri.h"
120 #include <2geom/line.h>
121-#include "sp-guide.h"
122+#include "display/canvas-guide.h"
123 #include "sp-namedview.h"
124 #include "preferences.h"
125
126
127=== modified file 'src/desktop-events.cpp'
128--- src/desktop-events.cpp 2014-07-22 19:16:13 +0000
129+++ src/desktop-events.cpp 2014-09-23 18:22:24 +0000
130@@ -34,11 +34,15 @@
131 #include "document-undo.h"
132 #include "ui/tools/tool-base.h"
133 #include "helper/action.h"
134+// #include "helper/unit-menu.h"
135+// #include "helper/units.h"
136+#include "helper/geom.h"
137 #include "message-context.h"
138 #include "preferences.h"
139 #include "snap.h"
140 #include "display/sp-canvas.h"
141-#include "sp-guide.h"
142+#include "display/canvas-guide.h"
143+// #include "sp-metrics.h"
144 #include "sp-namedview.h"
145 #include "tools-switch.h"
146 #include "verbs.h"
147@@ -49,7 +53,7 @@
148
149 static void snoop_extended(GdkEvent* event, SPDesktop *desktop);
150 static void init_extended();
151-void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem *guide, Geom::Point &event_dt, Geom::Point &normal);
152+void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem *guide, Geom::Point &event_dt, Geom::Point &normal_dt);
153
154 /* Root item handler */
155
156@@ -74,7 +78,7 @@
157 return sp_event_context_root_handler(desktop->event_context, event);
158 }
159
160-static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw, bool horiz)
161+static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw, bool horiz_ruler)
162 {
163 static bool clicked = false;
164 static bool dragged = false;
165@@ -84,7 +88,7 @@
166 static gint xp = 0, yp = 0; // where drag started
167
168 SPDesktop *desktop = dtw->desktop;
169- GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(dtw->canvas));
170+ GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(dtw->canvas));
171
172 gint width, height;
173
174@@ -94,7 +98,7 @@
175 gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height);
176 #else
177 gdk_window_get_pointer(window, &wx, &wy, NULL);
178- gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
179+ gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height, NULL /*depth*/);
180 #endif
181
182 Geom::Point const event_win(wx, wy);
183@@ -110,14 +114,16 @@
184
185 Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
186 Geom::Point const event_dt(desktop->w2d(event_w));
187+ Geom::Point const event_doc(desktop->w2doc(event_w));
188
189 // calculate the normal of the guidelines when dragged from the edges of rulers.
190 Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright
191- Geom::Point normal_tr_to_bl(1.,1.); //topright to bottomleft
192+ Geom::Point normal_tr_to_bl(1.,1.); //topright to bottomleft
193 normal_bl_to_tr.normalize();
194 normal_tr_to_bl.normalize();
195+
196 Inkscape::CanvasGrid * grid = sp_namedview_get_first_enabled_grid(desktop->namedview);
197- if (grid){
198+ if (grid) {
199 if (grid->getGridType() == Inkscape::GRID_AXONOMETRIC ) {
200 Inkscape::CanvasAxonomGrid *axonomgrid = dynamic_cast<Inkscape::CanvasAxonomGrid *>(grid);
201 if (event->button.state & GDK_CONTROL_MASK) {
202@@ -130,25 +136,48 @@
203 }
204 }
205 }
206- if (horiz) {
207+
208+ /*
209+
210+ The following if-else block determines whether the guides created are horizontal,
211+ vertical or angled.
212+
213+ Horizontal guides are created by clicked and dragging from the ruler on the left,
214+ vertical guides from the ruler on top and diagonal guides by clicking and
215+ dragging within 50 px of all the ends of the guides.
216+
217+ horiz_ruler: true when the mouse click occurs at the ruler at the top, and false
218+ for the ruler at the left.
219+
220+ Geom::Point normal_bl_to_tr(-1.,1.); //bottomleft to topright (desktop co-ords)
221+ The vector (-1, 1) is a normal for a topleft->bottomright guide in document
222+ co-ordinates.
223+
224+ Geom::Point normal_tr_to_bl(1.,1.); //topright to bottomleft (desktop co-ords)
225+ The vector (1, 1) is a normal for a bottomleft->topright guide in document
226+ co-ordinates.
227+
228+ */
229+
230+ if (horiz_ruler) {
231 if (wx < 50) {
232- normal = normal_bl_to_tr;
233+ normal = normal_tr_to_bl;
234 } else if (wx > width - 50) {
235- normal = normal_tr_to_bl;
236+ normal = normal_bl_to_tr;
237 } else {
238 normal = Geom::Point(0.,1.);
239 }
240 } else {
241 if (wy < 50) {
242- normal = normal_bl_to_tr;
243+ normal = normal_tr_to_bl;
244 } else if (wy > height - 50) {
245- normal = normal_tr_to_bl;
246+ normal = normal_bl_to_tr;
247 } else {
248 normal = Geom::Point(1.,0.);
249 }
250 }
251
252- guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal);
253+ guide = sp_guideline_new(desktop->guides, NULL, event_doc, normal);
254 sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor);
255
256 #if GTK_CHECK_VERSION(3,0,0)
257@@ -156,12 +185,12 @@
258 gtk_widget_get_window(widget),
259 GDK_OWNERSHIP_NONE,
260 FALSE,
261- (GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
262+ (GdkEventMask) (GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
263 NULL,
264 event->button.time);
265 #else
266 gdk_pointer_grab(gtk_widget_get_window (widget), FALSE,
267- (GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
268+ (GdkEventMask) (GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ),
269 NULL, NULL,
270 event->button.time);
271 #endif
272@@ -171,7 +200,8 @@
273 if (clicked) {
274 Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
275 Geom::Point event_dt(desktop->w2d(event_w));
276-
277+ Geom::Point event_doc(desktop->w2doc(event_w));
278+
279 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
280 gint tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
281 if ( ( abs( (gint) event->motion.x - xp ) < tolerance )
282@@ -182,15 +212,23 @@
283 dragged = true;
284
285 // explicitly show guidelines; if I draw a guide, I want them on
286- if ((horiz ? wy : wx) >= 0) {
287+ if ((horiz_ruler ? wy : wx) >= 0) {
288 desktop->namedview->setGuides(true);
289 }
290
291 if (!(event->motion.state & GDK_SHIFT_MASK)) {
292- sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal);
293+ // FIXME: snapping will need to be fixed later.
294+ Geom::Point normal_dt = transform_normal(normal, desktop->doc2dt());
295+ sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal_dt);
296+ // sp_dt_ruler_snap_new_guide calls a function that changes the values of
297+ // normal and event_dt. This is why the variables holding the document
298+ // co-ordinate values need to be updated.
299+ event_doc = desktop->dt2doc(event_dt);
300+ normal = transform_normal(normal_dt, desktop->dt2doc());
301 }
302+
303 sp_guideline_set_normal(SP_GUIDELINE(guide), normal);
304- sp_guideline_set_position(SP_GUIDELINE(guide), event_dt);
305+ sp_guideline_set_position(SP_GUIDELINE(guide), event_doc);
306
307 desktop->set_coordinate_status(event_dt);
308 }
309@@ -206,28 +244,41 @@
310 #endif
311
312 Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
313+
314 Geom::Point event_dt(desktop->w2d(event_w));
315+ Geom::Point event_doc(desktop->w2doc(event_w));
316
317 if (!(event->button.state & GDK_SHIFT_MASK)) {
318- sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal);
319+ Geom::Point normal_dt = transform_normal(normal, desktop->doc2dt());
320+ sp_dt_ruler_snap_new_guide(desktop, guide, event_dt, normal_dt);
321+ // sp_dt_ruler_snap_new_guide calls a function that changes the values of
322+ // normal and event_dt. This is why the variables holding the document
323+ // co-ordinate values need to be updated.
324+ event_doc = desktop->dt2doc(event_dt);
325+ normal = transform_normal(normal_dt, desktop->dt2doc());
326 }
327
328 sp_canvas_item_destroy(guide);
329 guide = NULL;
330- if ((horiz ? wy : wx) >= 0) {
331+ if ((horiz_ruler ? wy : wx) >= 0) {
332 Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
333- Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide");
334+ Inkscape::XML::Node *repr = NULL;
335+
336+ repr = xml_doc->createElement("inkscape:guide");
337+
338 sp_repr_set_point(repr, "orientation", normal);
339- sp_repr_set_point(repr, "position", event_dt);
340+ sp_repr_set_point(repr, "position", event_doc);
341+ sp_repr_set_boolean(repr, "enable", true);
342+ repr->setAttribute("group", "default");
343 desktop->namedview->appendChild(repr);
344 Inkscape::GC::release(repr);
345- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
346+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE,
347 _("Create guide"));
348 }
349 desktop->set_coordinate_status(event_dt);
350
351 if (!dragged) {
352- // Ruler click (without drag) toggle the guide visibility on and off
353+ // Clicking on the ruler (without dragging) toggles the guide visibility on and off
354 Inkscape::XML::Node *repr = desktop->namedview->getRepr();
355 sp_namedview_toggle_guides(sp_desktop_document(desktop), repr);
356
357@@ -246,7 +297,9 @@
358 int sp_dt_hruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
359 {
360 if (event->type == GDK_MOTION_NOTIFY) {
361- sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_HRULER);
362+ sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget,
363+ (gpointer) dtw, (GdkEventMotion *) event,
364+ Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_HRULER);
365 }
366 return sp_dt_ruler_event(widget, event, dtw, true);
367 }
368@@ -254,16 +307,18 @@
369 int sp_dt_vruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
370 {
371 if (event->type == GDK_MOTION_NOTIFY) {
372- sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_VRULER);
373+ sp_event_context_snap_delay_handler(dtw->desktop->event_context,
374+ (gpointer) widget, (gpointer) dtw, (GdkEventMotion *) event,
375+ Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_VRULER);
376 }
377 return sp_dt_ruler_event(widget, event, dtw, false);
378 }
379
380 static Geom::Point drag_origin;
381 static SPGuideDragType drag_type = SP_DRAG_NONE;
382-//static bool reset_drag_origin = false; // when Ctrl is pressed while dragging, this is used to trigger resetting of the
383-// // drag origin to that location so that constrained movement is more intuitive
384-
385+//static bool reset_drag_origin = false;
386+// when Ctrl is pressed while dragging, this is used to trigger resetting of the
387+// drag origin to that location so that constrained movement is more intuitive
388 // Min distance from anchor to initiate rotation, measured in screenpixels
389 #define tol 40.0
390
391@@ -274,7 +329,7 @@
392
393 SPGuide *guide = SP_GUIDE(data);
394 SPDesktop *desktop = static_cast<SPDesktop*>(g_object_get_data(G_OBJECT(item->canvas), "SPDesktop"));
395-
396+
397 switch (event->type) {
398 case GDK_2BUTTON_PRESS:
399 if (event->button.button == 1) {
400@@ -289,7 +344,7 @@
401 if (event->button.button == 1) {
402 Geom::Point const event_w(event->button.x, event->button.y);
403 Geom::Point const event_dt(desktop->w2d(event_w));
404-
405+
406 // Due to the tolerance allowed when grabbing a guide, event_dt will generally
407 // be close to the guide but not just exactly on it. The drag origin calculated
408 // here must be exactly on the guide line though, otherwise
409@@ -321,9 +376,9 @@
410 break;
411 case GDK_MOTION_NOTIFY:
412 if (drag_type != SP_DRAG_NONE) {
413- Geom::Point const motion_w(event->motion.x,
414- event->motion.y);
415+ Geom::Point const motion_w(event->motion.x, event->motion.y);
416 Geom::Point motion_dt(desktop->w2d(motion_w));
417+ Geom::Point motion_doc(desktop->w2doc(motion_w));
418
419 sp_event_context_snap_delay_handler(desktop->event_context, (gpointer) item, data, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_HANDLER);
420
421@@ -336,31 +391,46 @@
422 // be forced to be on the guide. If we don't snap however, then
423 // the origin should still be constrained to the guide. So let's do
424 // that explicitly first:
425+
426+ // guideConstrainedSnap modifies it's arguments. Points in document
427+ // co-ordinates have to be passed to the guide-snapping functions because they
428+ // operate on points in desktop co-ordinates.
429+
430 Geom::Line line(guide->point_on_line, guide->angle());
431- Geom::Coord t = line.nearestPoint(motion_dt);
432- motion_dt = line.pointAt(t);
433+ Geom::Coord t = line.nearestPoint(motion_doc);
434+ motion_doc = line.pointAt(t);
435 if (!(event->motion.state & GDK_SHIFT_MASK)) {
436 m.guideConstrainedSnap(motion_dt, *guide);
437 }
438 } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
439 // cannot use shift here to disable snapping, because we already use it for rotating the guide
440+
441+ Geom::Point point_on_line_dt = desktop->doc2dt(guide->point_on_line);
442+ Geom::Point normal_to_line_dt = transform_normal(guide->normal_to_line, desktop->doc2dt());
443+
444 if (drag_type == SP_DRAG_ROTATE) {
445- m.guideFreeSnap(motion_dt, guide->point_on_line, true, false);
446+ m.guideFreeSnap(motion_dt, point_on_line_dt, true, false);
447 } else {
448- m.guideFreeSnap(motion_dt, guide->normal_to_line, false, true);
449+ m.guideFreeSnap(motion_dt, normal_to_line_dt, false, true);
450 }
451+
452+ guide->point_on_line = desktop->dt2doc(point_on_line_dt);
453+ guide->normal_to_line = transform_normal(normal_to_line_dt, desktop->dt2doc());
454+
455 }
456 m.unSetup();
457
458+ motion_doc = desktop->dt2doc(motion_dt);
459+
460 switch (drag_type) {
461 case SP_DRAG_TRANSLATE:
462 {
463- sp_guide_moveto(*guide, motion_dt, false);
464+ sp_guide_moveto(*guide, motion_doc, false);
465 break;
466 }
467 case SP_DRAG_ROTATE:
468 {
469- Geom::Point pt = motion_dt - guide->point_on_line;
470+ Geom::Point pt = motion_doc - guide->point_on_line;
471 Geom::Angle angle(pt);
472 if (event->motion.state & GDK_CONTROL_MASK) {
473 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
474@@ -383,7 +453,7 @@
475 }
476 case SP_DRAG_MOVE_ORIGIN:
477 {
478- sp_guide_moveto(*guide, motion_dt, false);
479+ sp_guide_moveto(*guide, motion_doc, false);
480 break;
481 }
482 case SP_DRAG_NONE:
483@@ -404,6 +474,7 @@
484 Geom::Point const event_w(event->button.x,
485 event->button.y);
486 Geom::Point event_dt(desktop->w2d(event_w));
487+ Geom::Point event_doc(desktop->w2doc(event_w));
488
489 SnapManager &m = desktop->namedview->snap_manager;
490 m.setup(desktop, true, NULL, NULL, guide);
491@@ -412,32 +483,43 @@
492 // be forced to be on the guide. If we don't snap however, then
493 // the origin should still be constrained to the guide. So let's
494 // do that explicitly first:
495- Geom::Line line(guide->point_on_line, guide->angle());
496+ Geom::Line line(desktop->doc2dt(guide->point_on_line), guide->angle());
497 Geom::Coord t = line.nearestPoint(event_dt);
498 event_dt = line.pointAt(t);
499+
500 if (!(event->button.state & GDK_SHIFT_MASK)) {
501 m.guideConstrainedSnap(event_dt, *guide);
502 }
503 } else if (!((drag_type == SP_DRAG_ROTATE) && (event->motion.state & GDK_CONTROL_MASK))) {
504 // cannot use shift here to disable snapping, because we already use it for rotating the guide
505+
506+ Geom::Point point_on_line_dt = desktop->doc2dt(guide->point_on_line);
507+ Geom::Point normal_to_line_dt = transform_normal(guide->normal_to_line, desktop->doc2dt());
508+
509 if (drag_type == SP_DRAG_ROTATE) {
510- m.guideFreeSnap(event_dt, guide->point_on_line, true, false);
511+ m.guideFreeSnap(event_dt, point_on_line_dt, true, false);
512 } else {
513- m.guideFreeSnap(event_dt, guide->normal_to_line, false, true);
514+ m.guideFreeSnap(event_dt, normal_to_line_dt, false, true);
515 }
516+
517+ guide->point_on_line = desktop->dt2doc(point_on_line_dt);
518+ guide->normal_to_line = transform_normal(normal_to_line_dt, desktop->dt2doc());
519 }
520+
521 m.unSetup();
522
523+ event_doc = desktop->dt2doc(event_dt);
524+
525 if (sp_canvas_world_pt_inside_window(item->canvas, event_w)) {
526 switch (drag_type) {
527 case SP_DRAG_TRANSLATE:
528 {
529- sp_guide_moveto(*guide, event_dt, true);
530+ sp_guide_moveto(*guide, event_doc, true);
531 break;
532 }
533 case SP_DRAG_ROTATE:
534 {
535- Geom::Point pt = event_dt - guide->point_on_line;
536+ Geom::Point pt = event_doc - guide->point_on_line;
537 Geom::Angle angle(pt);
538 if (event->motion.state & GDK_CONTROL_MASK) {
539 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
540@@ -455,12 +537,13 @@
541 }
542 }
543 }
544+
545 sp_guide_set_normal(*guide, Geom::Point::polar(angle).cw(), true);
546 break;
547 }
548 case SP_DRAG_MOVE_ORIGIN:
549 {
550- sp_guide_moveto(*guide, event_dt, true);
551+ sp_guide_moveto(*guide, event_doc, true);
552 break;
553 }
554 case SP_DRAG_NONE:
555@@ -609,7 +692,7 @@
556 if ( devName
557 && (avoidName != devName)
558 && (devSrc != GDK_SOURCE_MOUSE) ) {
559-// g_message("Adding '%s' as [%d]", devName, devSrc);
560+ // g_message("Adding '%s' as [%d]", devName, devSrc);
561
562 // Set the initial tool for the device
563 switch ( devSrc ) {
564@@ -714,10 +797,11 @@
565 }
566
567
568-void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem * /*guide*/, Geom::Point &event_dt, Geom::Point &normal)
569+void sp_dt_ruler_snap_new_guide(SPDesktop *desktop, SPCanvasItem * /*guide*/, Geom::Point &event_dt, Geom::Point &normal_dt)
570 {
571 SnapManager &m = desktop->namedview->snap_manager;
572 m.setup(desktop);
573+
574 // We're dragging a brand new guide, just pulled of the rulers seconds ago. When snapping to a
575 // path this guide will change it slope to become either tangential or perpendicular to that path. It's
576 // therefore not useful to try tangential or perpendicular snapping, so this will be disabled temporarily
577@@ -728,17 +812,17 @@
578 // We only have a temporary guide which is not stored in our document yet.
579 // Because the guide snapper only looks in the document for guides to snap to,
580 // we don't have to worry about a guide snapping to itself here
581- Geom::Point normal_orig = normal;
582- m.guideFreeSnap(event_dt, normal, false, false);
583+ Geom::Point normal_orig = normal_dt;
584+ m.guideFreeSnap(event_dt, normal_dt, false, false);
585 // After snapping, both event_dt and normal have been modified accordingly; we'll take the normal (of the
586 // curve we snapped to) to set the normal the guide. And rotate it by 90 deg. if needed
587 if (pref_perp) { // Perpendicular snapping to paths is requested by the user, so let's do that
588- if (normal != normal_orig) {
589- normal = Geom::rot90(normal);
590+ if (normal_dt != normal_orig) {
591+ normal_dt = Geom::rot90(normal_dt);
592 }
593 }
594 if (!(pref_tang || pref_perp)) { // if we don't want to snap either perpendicularly or tangentially, then
595- normal = normal_orig; // we must restore the normal to it's original state
596+ normal_dt = normal_orig; // we must restore the normal to it's original state
597 }
598 // Restore the preferences
599 m.snapprefs.setSnapPerp(pref_perp);
600
601=== modified file 'src/desktop.cpp'
602--- src/desktop.cpp 2014-04-20 00:36:33 +0000
603+++ src/desktop.cpp 2014-09-23 18:22:24 +0000
604@@ -60,6 +60,7 @@
605 #include "layer-fns.h"
606 #include "layer-manager.h"
607 #include "layer-model.h"
608+#include "guide-manager.h"
609 #include "macros.h"
610 #include "message-context.h"
611 #include "message-stack.h"
612@@ -101,6 +102,7 @@
613 selection( 0 ),
614 event_context( 0 ),
615 layer_manager( 0 ),
616+ guide_manager( 0 ),
617 event_log( 0 ),
618 temporary_item_list( 0 ),
619 snapindicator( 0 ),
620@@ -241,11 +243,12 @@
621 // will not work (the snap indicator is on top of the node handler; is the snapindicator
622 // being selected? or does it intercept some of the events that should have gone to the
623 // node handler? see bug https://bugs.launchpad.net/inkscape/+bug/414142)
624+
625 gridgroup = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
626- guides = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
627- sketch = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
628+ guides = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
629+ sketch = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
630 tempgroup = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
631- controls = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
632+ controls = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
633
634 // Set the select tool as the active tool.
635 set_event_context2("/tools/select");
636@@ -272,6 +275,8 @@
637 /* Connect event for page resize */
638 _doc2dt[5] = document->getHeight().value("px");
639 sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
640+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (gridgroup), _doc2dt);
641+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (guides), _doc2dt);
642
643 _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
644
645@@ -284,8 +289,10 @@
646 }
647
648 namedview->show(this);
649- /* Ugly hack */
650+ /* Ugly hack */
651+
652 activate_guides (true);
653+
654 /* Ugly hack */
655 _namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
656
657@@ -331,6 +338,7 @@
658 /* setup LayerManager */
659 // (Setting up after the connections are all in place, as it may use some of them)
660 layer_manager = new Inkscape::LayerManager( this );
661+ guide_manager = new Inkscape::GuideManager( this );
662
663 showGrids(namedview->grids_visible, false);
664
665@@ -822,8 +830,8 @@
666 int clear = FALSE;
667 if (!Geom::are_near(newscale, scale, Geom::EPSILON * scale)) {
668 // zoom changed - set new zoom factors
669- _d2w = Geom::Scale(newscale, -newscale);
670- _w2d = Geom::Scale(1/newscale, 1/-newscale);
671+ _d2w = Geom::Scale(newscale, -newscale);
672+ _w2d = Geom::Scale(1/newscale, 1/-newscale);
673 redrawDesktop();
674 clear = TRUE;
675 zoomChanged = true;
676@@ -1618,6 +1626,8 @@
677 {
678 _doc2dt[5] = height;
679 sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
680+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (gridgroup), _doc2dt);
681+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (guides), _doc2dt);
682 Geom::Rect const a(Geom::Point(0, 0), Geom::Point(width, height));
683 SP_CTRLRECT(page)->setRectangle(a);
684 SP_CTRLRECT(page_border)->setRectangle(a);
685@@ -1803,12 +1813,22 @@
686 return p * _w2d;
687 }
688
689+Geom::Affine SPDesktop::w2doc() const
690+{
691+ return w2d() * dt2doc();
692+}
693+
694+Geom::Point SPDesktop::w2doc(Geom::Point const &p) const
695+{
696+ return p * w2d() * dt2doc();
697+}
698+
699 Geom::Point SPDesktop::d2w(Geom::Point const &p) const
700 {
701 return p * _d2w;
702 }
703
704-Geom::Affine SPDesktop::doc2dt() const
705+Geom::Affine SPDesktop::doc2dt () const
706 {
707 return _doc2dt;
708 }
709
710=== modified file 'src/desktop.h'
711--- src/desktop.h 2014-05-15 21:51:32 +0000
712+++ src/desktop.h 2014-09-23 18:22:24 +0000
713@@ -78,6 +78,7 @@
714 class MessageContext;
715 class Selection;
716 class LayerManager;
717+ class GuideManager;
718 class EventLog;
719 namespace UI {
720 namespace Dialog {
721@@ -142,6 +143,7 @@
722 Inkscape::Selection *selection;
723 Inkscape::UI::Tools::ToolBase *event_context;
724 Inkscape::LayerManager *layer_manager;
725+ Inkscape::GuideManager *guide_manager;
726 Inkscape::EventLog *event_log;
727 DocumentInterface *dbus_document_interface;
728 Inkscape::Display::TemporaryItemList *temporary_item_list;
729@@ -404,6 +406,8 @@
730
731 Geom::Affine w2d() const; //transformation from window to desktop coordinates (used for zooming)
732 Geom::Point w2d(Geom::Point const &p) const;
733+ Geom::Affine w2doc() const;
734+ Geom::Point w2doc(Geom::Point const &p) const;
735 Geom::Point d2w(Geom::Point const &p) const;
736 Geom::Affine doc2dt() const;
737 Geom::Affine dt2doc() const;
738
739=== modified file 'src/display/Makefile_insert'
740--- src/display/Makefile_insert 2014-03-27 01:33:44 +0000
741+++ src/display/Makefile_insert 2014-09-23 18:22:24 +0000
742@@ -15,6 +15,8 @@
743 display/canvas-bpath.h \
744 display/canvas-grid.cpp \
745 display/canvas-grid.h \
746+ display/canvas-guide.cpp \
747+ display/canvas-guide.h \
748 display/canvas-temporary-item.cpp \
749 display/canvas-temporary-item.h \
750 display/canvas-temporary-item-list.cpp \
751
752=== modified file 'src/display/canvas-axonomgrid.cpp'
753--- src/display/canvas-axonomgrid.cpp 2014-08-17 00:23:01 +0000
754+++ src/display/canvas-axonomgrid.cpp 2014-09-23 18:22:24 +0000
755@@ -634,6 +634,8 @@
756 return s;
757 }
758
759+// Geom::Point spacing_dt = _snapmanager->getDesktop()->doc2dt(grid->spacing);
760+ Geom::Point origin_dt = _snapmanager->getDesktop()->doc2dt(grid->origin);
761 double spacing_h;
762 double spacing_v;
763
764@@ -661,16 +663,16 @@
765 // - 2 angled x grid lines, one above and one below the point
766
767 // Calculate the x coordinate of the vertical grid lines
768- Geom::Coord x_max = Inkscape::Util::round_to_upper_multiple_plus(p[Geom::X], spacing_h, grid->origin[Geom::X]);
769- Geom::Coord x_min = Inkscape::Util::round_to_lower_multiple_plus(p[Geom::X], spacing_h, grid->origin[Geom::X]);
770+ Geom::Coord x_max = Inkscape::Util::round_to_upper_multiple_plus(p[Geom::X], spacing_h, origin_dt[Geom::X]);
771+ Geom::Coord x_min = Inkscape::Util::round_to_lower_multiple_plus(p[Geom::X], spacing_h, origin_dt[Geom::X]);
772
773 // Calculate the y coordinate of the intersection of the angled grid lines with the y-axis
774- double y_proj_along_z = p[Geom::Y] - grid->tan_angle[Z]*(p[Geom::X] - grid->origin[Geom::X]);
775- double y_proj_along_x = p[Geom::Y] + grid->tan_angle[X]*(p[Geom::X] - grid->origin[Geom::X]);
776- double y_proj_along_z_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_z, spacing_v, grid->origin[Geom::Y]);
777- double y_proj_along_z_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_z, spacing_v, grid->origin[Geom::Y]);
778- double y_proj_along_x_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_x, spacing_v, grid->origin[Geom::Y]);
779- double y_proj_along_x_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_x, spacing_v, grid->origin[Geom::Y]);
780+ double y_proj_along_z = p[Geom::Y] - grid->tan_angle[Z]*(p[Geom::X] - origin_dt[Geom::X]);
781+ double y_proj_along_x = p[Geom::Y] + grid->tan_angle[X]*(p[Geom::X] - origin_dt[Geom::X]);
782+ double y_proj_along_z_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_z, spacing_v, origin_dt[Geom::Y]);
783+ double y_proj_along_z_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_z, spacing_v, origin_dt[Geom::Y]);
784+ double y_proj_along_x_max = Inkscape::Util::round_to_upper_multiple_plus(y_proj_along_x, spacing_v, origin_dt[Geom::Y]);
785+ double y_proj_along_x_min = Inkscape::Util::round_to_lower_multiple_plus(y_proj_along_x, spacing_v, origin_dt[Geom::Y]);
786
787 // Calculate the versor for the angled grid lines
788 Geom::Point vers_x = Geom::Point(1, -grid->tan_angle[X]);
789@@ -709,21 +711,21 @@
790
791 if (inters) {
792 Geom::Point inters_pt = line_x.pointAt((*inters).ta);
793- use_left_half = (p[Geom::X] - grid->origin[Geom::X]) < inters_pt[Geom::X];
794+ use_left_half = (p[Geom::X] - origin_dt[Geom::X]) < inters_pt[Geom::X];
795 use_right_half = !use_left_half;
796 }
797
798 // Return the three grid lines which define the triangle that encloses our point
799 // If we didn't find an intersection above, all 6 grid lines will be returned
800 if (use_left_half) {
801- s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_max)));
802- s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_min)));
803+ s.push_back(std::make_pair(norm_z, Geom::Point(origin_dt[Geom::X], y_proj_along_z_max)));
804+ s.push_back(std::make_pair(norm_x, Geom::Point(origin_dt[Geom::X], y_proj_along_x_min)));
805 s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_max, 0)));
806 }
807
808 if (use_right_half) {
809- s.push_back(std::make_pair(norm_z, Geom::Point(grid->origin[Geom::X], y_proj_along_z_min)));
810- s.push_back(std::make_pair(norm_x, Geom::Point(grid->origin[Geom::X], y_proj_along_x_max)));
811+ s.push_back(std::make_pair(norm_z, Geom::Point(origin_dt[Geom::X], y_proj_along_z_min)));
812+ s.push_back(std::make_pair(norm_x, Geom::Point(origin_dt[Geom::X], y_proj_along_x_max)));
813 s.push_back(std::make_pair(Geom::Point(1, 0), Geom::Point(x_min, 0)));
814 }
815
816
817=== modified file 'src/display/canvas-axonomgrid.h'
818--- src/display/canvas-axonomgrid.h 2014-03-27 01:33:44 +0000
819+++ src/display/canvas-axonomgrid.h 2014-09-23 18:22:24 +0000
820@@ -85,5 +85,15 @@
821
822
823 #endif
824+/*
825+ Local Variables:
826+ mode:c++
827+ c-file-style:"stroustrup"
828+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
829+ indent-tabs-mode:nil
830+ fill-column:99
831+ End:
832+*/
833+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
834
835
836
837=== modified file 'src/display/canvas-grid.cpp'
838--- src/display/canvas-grid.cpp 2014-03-30 21:43:02 +0000
839+++ src/display/canvas-grid.cpp 2014-09-23 18:22:24 +0000
840@@ -996,6 +996,9 @@
841 return s;
842 }
843
844+ Geom::Point spacing_dt = _snapmanager->getDesktop()->doc2dt(grid->spacing);
845+ Geom::Point origin_dt = _snapmanager->getDesktop()->doc2dt(grid->origin);
846+
847 for (unsigned int i = 0; i < 2; ++i) {
848
849 double spacing;
850@@ -1011,21 +1014,22 @@
851 }
852 } else {
853 // Snapping to any grid line, whether it's visible or not
854- spacing = grid->spacing[i];
855+ spacing = spacing_dt[i];
856 }
857
858- Geom::Coord rounded;
859- Geom::Point point_on_line;
860 Geom::Point cvec(0.,0.);
861 cvec[i] = 1.;
862
863- rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], spacing, grid->origin[i]);
864- point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
865- s.push_back(std::make_pair(cvec, point_on_line));
866-
867- rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], spacing, grid->origin[i]);
868- point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
869- s.push_back(std::make_pair(cvec, point_on_line));
870+ { // upper
871+ Geom::Coord rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], spacing, origin_dt[i]);
872+ Geom::Point point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
873+ s.push_back(std::make_pair(cvec, point_on_line));
874+ }
875+ { // lower
876+ Geom::Coord rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], spacing, origin_dt[i]);
877+ Geom::Point point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0);
878+ s.push_back(std::make_pair(cvec, point_on_line));
879+ }
880 }
881
882 return s;
883
884=== added file 'src/display/canvas-guide.cpp'
885--- src/display/canvas-guide.cpp 1970-01-01 00:00:00 +0000
886+++ src/display/canvas-guide.cpp 2014-09-23 18:22:24 +0000
887@@ -0,0 +1,549 @@
888+/*
889+ * Inkscape guideline implementation
890+ *
891+ * Authors:
892+ * Lauris Kaplinski <lauris@kaplinski.com>
893+ * Peter Moulder <pmoulder@mail.csse.monash.edu.au>
894+ * Johan Engelen
895+ * Jon A. Cruz <jon@joncruz.org>
896+ * Abhishek Sharma
897+ *
898+ * Copyright (C) 2000-2002 authors
899+ * Copyright (C) 2004 Monash University
900+ * Copyright (C) 2007 Johan Engelen
901+ *
902+ * Released under GNU GPL, read the file 'COPYING' for more information
903+ */
904+
905+#ifdef HAVE_CONFIG_H
906+# include <config.h>
907+#endif
908+
909+#include <algorithm>
910+#include <cstring>
911+#include <string>
912+#include "desktop-handles.h"
913+#include "display/sp-canvas.h"
914+#include "display/guideline.h"
915+#include "svg/svg.h"
916+#include "svg/stringstream.h"
917+#include "attributes.h"
918+#include "canvas-guide.h"
919+#include <sp-item-notify-moveto.h>
920+#include <sp-item.h>
921+#include <sp-guide-constraint.h>
922+#include <glibmm/i18n.h>
923+#include <xml/repr.h>
924+#include <remove-last.h>
925+// #include "sp-metrics.h"
926+#include "inkscape.h"
927+#include "desktop.h"
928+#include "sp-namedview.h"
929+#include <2geom/angle.h>
930+#include "document.h"
931+#include "document-undo.h"
932+#include "verbs.h"
933+
934+using Inkscape::DocumentUndo;
935+using std::vector;
936+
937+//enum {
938+// PROP_0,
939+// PROP_COLOR,
940+// PROP_HICOLOR
941+//};
942+//
943+//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
944+//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
945+
946+#include "sp-factory.h"
947+
948+namespace {
949+ SPObject* createGuide() {
950+ return new SPGuide();
951+ }
952+
953+ bool guideRegistered = SPFactory::instance().registerObject("inkscape:guide", createGuide);
954+}
955+
956+SPGuide::SPGuide() : SPObject() {
957+ this->label = NULL;
958+ this->views = NULL;
959+
960+ this->normal_to_line = Geom::Point(0.,1.);
961+ this->point_on_line = Geom::Point(0.,0.);
962+ this->color = 0x0000ff7f;
963+ this->hicolor = 0xff00007f;
964+ // this->enable = true;
965+ // this->group = g_strdup("default");
966+}
967+
968+SPGuide::~SPGuide() {
969+}
970+
971+guint32 SPGuide::getColor() const {
972+ return color;
973+}
974+
975+guint32 SPGuide::getHiColor() const {
976+ return hicolor;
977+}
978+
979+void SPGuide::setColor(guint32 c) {
980+ color = c;
981+
982+ for (GSList *l = this->views; l != NULL; l = l->next) {
983+ sp_guideline_set_color(SP_GUIDELINE(l->data), this->color);
984+ }
985+}
986+
987+void SPGuide::setHiColor(guint32 h) {
988+ this->hicolor = h;
989+}
990+
991+//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/)
992+//{
993+// SPGuide &guide = *SP_GUIDE(object);
994+//
995+// switch (prop_id) {
996+// case PROP_COLOR:
997+// guide.color = g_value_get_uint(value);
998+// for (GSList *l = guide.views; l != NULL; l = l->next) {
999+// sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color);
1000+// }
1001+// break;
1002+//
1003+// case PROP_HICOLOR:
1004+// guide.hicolor = g_value_get_uint(value);
1005+// break;
1006+// }
1007+//}
1008+//
1009+//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/)
1010+//{
1011+// SPGuide const &guide = *SP_GUIDE(object);
1012+//
1013+// switch (prop_id) {
1014+// case PROP_COLOR:
1015+// g_value_set_uint(value, guide.color);
1016+// break;
1017+// case PROP_HICOLOR:
1018+// g_value_set_uint(value, guide.hicolor);
1019+// break;
1020+// }
1021+//}
1022+
1023+void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) {
1024+ SPObject::build(document, repr);
1025+
1026+ this->readAttr( "inkscape:label" );
1027+ this->readAttr( "orientation" );
1028+ this->readAttr( "position" );
1029+ // FIXME: Samuel Chase
1030+ // this->readAttr( "enable" );
1031+ // this->readAttr( "group" );
1032+
1033+ /* Register */
1034+ document->addResource("guide", this);
1035+}
1036+
1037+void SPGuide::release() {
1038+ while (this->views) {
1039+ sp_guideline_delete(SP_GUIDELINE(this->views->data));
1040+ this->views = g_slist_remove(this->views, this->views->data);
1041+ }
1042+
1043+ if (this->document) {
1044+ // Unregister ourselves
1045+ this->document->removeResource("guide", this);
1046+ }
1047+
1048+ SPObject::release();
1049+}
1050+
1051+void SPGuide::set(unsigned int key, const gchar *value) {
1052+ switch (key) {
1053+ case SP_ATTR_INKSCAPE_LABEL:
1054+ if (value) {
1055+ this->label = g_strdup(value);
1056+ } else {
1057+ this->label = NULL;
1058+ }
1059+
1060+ sp_guide_set_label(*this, this->label, false);
1061+ break;
1062+ case SP_ATTR_ORIENTATION:
1063+ {
1064+ if (value && !strcmp(value, "horizontal")) {
1065+ /* Visual representation of a horizontal line, constrain vertically (y coordinate). */
1066+ this->normal_to_line = Geom::Point(0., 1.);
1067+ } else if (value && !strcmp(value, "vertical")) {
1068+ this->normal_to_line = Geom::Point(1., 0.);
1069+ } else if (value) {
1070+ gchar ** strarray = g_strsplit(value, ",", 2);
1071+ double newx, newy;
1072+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
1073+ success += sp_svg_number_read_d(strarray[1], &newy);
1074+ g_strfreev (strarray);
1075+ if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) {
1076+ Geom::Point direction(newx, newy);
1077+ direction.normalize();
1078+ this->normal_to_line = direction;
1079+ } else {
1080+ // default to vertical line for bad arguments
1081+ this->normal_to_line = Geom::Point(1., 0.);
1082+ }
1083+ } else {
1084+ // default to vertical line for bad arguments
1085+ this->normal_to_line = Geom::Point(1., 0.);
1086+ }
1087+ sp_guide_set_normal(*this, this->normal_to_line, false);
1088+ }
1089+ break;
1090+ case SP_ATTR_POSITION:
1091+ {
1092+ if (value) {
1093+ gchar ** strarray = g_strsplit(value, ",", 2);
1094+ double newx, newy;
1095+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
1096+ success += sp_svg_number_read_d(strarray[1], &newy);
1097+ g_strfreev (strarray);
1098+ if (success == 2) {
1099+ this->point_on_line = Geom::Point(newx, newy);
1100+ } else if (success == 1) {
1101+ // before 0.46 style guideline definition.
1102+ const gchar *attr = this->getRepr()->attribute("orientation");
1103+ if (attr && !strcmp(attr, "horizontal")) {
1104+ this->point_on_line = Geom::Point(0, newx);
1105+ } else {
1106+ this->point_on_line = Geom::Point(newx, 0);
1107+ }
1108+ }
1109+ } else {
1110+ // default to (0,0) for bad arguments
1111+ this->point_on_line = Geom::Point(0,0);
1112+ }
1113+ // update position in non-committing way
1114+ // fixme: perhaps we need to add an update method instead, and request_update here
1115+ sp_guide_moveto(*this, this->point_on_line, false);
1116+ }
1117+ break;
1118+
1119+ case SP_ATTR_ENABLE:
1120+ {
1121+
1122+ // if (value) {
1123+ // const gchar *attr = object->getRepr()->attribute("enable");
1124+ // if (attr && !strcmp(attr, "true")) {
1125+ // guide->enable = true;
1126+ // } else if (attr && !strcmp(attr, "false")) {
1127+ // guide->enable = false;
1128+ // }
1129+ // }
1130+ }
1131+ break;
1132+
1133+ case SP_ATTR_GROUP:
1134+ {
1135+
1136+ }
1137+ break;
1138+
1139+ default:
1140+ SPObject::set(key, value);
1141+ break;
1142+ }
1143+}
1144+
1145+SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2)
1146+{
1147+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
1148+
1149+ Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:guide");
1150+
1151+ Geom::Point n = Geom::rot90(pt2 - pt1);
1152+
1153+ sp_repr_set_point(repr, "position", pt1);
1154+ sp_repr_set_point(repr, "orientation", n);
1155+ sp_repr_set_boolean(repr, "enable", false);
1156+
1157+ SPNamedView *namedview = sp_document_namedview(doc, NULL);
1158+ if (namedview) {
1159+ namedview->appendChild(repr);
1160+ }
1161+ Inkscape::GC::release(repr);
1162+
1163+ SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr));
1164+ return guide;
1165+}
1166+
1167+void
1168+sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts) {
1169+ for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) {
1170+ SPGuide::createSPGuide(doc, (*i).first, (*i).second);
1171+ }
1172+}
1173+
1174+void
1175+sp_guide_create_guides_around_page(SPDesktop *dt) {
1176+ SPDocument *doc=sp_desktop_document(dt);
1177+ std::list<std::pair<Geom::Point, Geom::Point> > pts;
1178+
1179+ Geom::Point A(0, 0);
1180+ Geom::Point C(doc->getWidth().value("px"), doc->getHeight().value("px"));
1181+ Geom::Point B(C[Geom::X], 0);
1182+ Geom::Point D(0, C[Geom::Y]);
1183+
1184+ pts.push_back(std::make_pair<Geom::Point, Geom::Point>(A, B));
1185+ pts.push_back(std::make_pair<Geom::Point, Geom::Point>(B, C));
1186+ pts.push_back(std::make_pair<Geom::Point, Geom::Point>(C, D));
1187+ pts.push_back(std::make_pair<Geom::Point, Geom::Point>(D, A));
1188+
1189+ sp_guide_pt_pairs_to_guides(doc, pts);
1190+
1191+ DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page"));
1192+}
1193+
1194+void
1195+sp_guide_delete_all_guides(SPDesktop *dt) {
1196+ SPDocument *doc=sp_desktop_document(dt);
1197+ const GSList *current;
1198+ while ( (current = doc->getResourceList("guide")) ) {
1199+ SPGuide* guide = SP_GUIDE(current->data);
1200+ sp_guide_remove(guide);
1201+ }
1202+
1203+ DocumentUndo::done(doc, SP_VERB_NONE, _("Delete All Guides"));
1204+}
1205+
1206+void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler)
1207+{
1208+ SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line);
1209+ sp_guideline_set_color(SP_GUIDELINE(item), color);
1210+
1211+ // FIXME: sp_guideline_set_enable(SP_GUIDELINE(item), enable);
1212+
1213+ // for (GSList *l = views; l != NULL; l = l->next) {
1214+ // g_message("showSPGuide: Enable: %d", enable);
1215+ // sp_guideline_set_enable(SP_GUIDELINE(l->data), enable);
1216+ // }
1217+
1218+ g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this);
1219+
1220+ views = g_slist_prepend(views, item);
1221+}
1222+
1223+void SPGuide::hideSPGuide(SPCanvas *canvas)
1224+{
1225+ g_assert(canvas != NULL);
1226+ g_assert(SP_IS_CANVAS(canvas));
1227+
1228+ for (GSList *l = views; l != NULL; l = l->next) {
1229+ if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
1230+ sp_guideline_delete(SP_GUIDELINE(l->data));
1231+ views = g_slist_remove(views, l->data);
1232+ return;
1233+ }
1234+ }
1235+
1236+ g_assert_not_reached();
1237+}
1238+
1239+void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive)
1240+{
1241+ g_assert(canvas != NULL);
1242+ g_assert(SP_IS_CANVAS(canvas));
1243+
1244+ for (GSList *l = views; l != NULL; l = l->next) {
1245+ if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
1246+ sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive);
1247+ return;
1248+ }
1249+ }
1250+
1251+ g_assert_not_reached();
1252+}
1253+
1254+Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const
1255+{
1256+ return -(pt - point_on_line);
1257+}
1258+
1259+double SPGuide::getDistanceFrom(Geom::Point const &pt) const
1260+{
1261+ return Geom::dot(pt - point_on_line, normal_to_line);
1262+}
1263+
1264+/**
1265+ * \arg commit False indicates temporary moveto in response to motion event while dragging,
1266+ * true indicates a "committing" version: in response to button release event after
1267+ * dragging a guideline, or clicking OK in guide editing dialog.
1268+ */
1269+void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit)
1270+{
1271+ g_assert(SP_IS_GUIDE(&guide));
1272+
1273+ for (GSList *l = guide.views; l != NULL; l = l->next) {
1274+ sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line);
1275+ }
1276+
1277+ /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit
1278+ case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
1279+ if (commit) {
1280+ //XML Tree being used here directly while it shouldn't be.
1281+ sp_repr_set_point(guide.getRepr(), "position", point_on_line);
1282+ }
1283+
1284+/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
1285+ for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
1286+ iEnd(guide.attached_items.end());
1287+ i != iEnd; ++i)
1288+ {
1289+ SPGuideAttachment const &att = *i;
1290+ sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
1291+ }
1292+*/
1293+}
1294+
1295+/**
1296+ * \arg commit False indicates temporary moveto in response to motion event while dragging,
1297+ * true indicates a "committing" version: in response to button release event after
1298+ * dragging a guideline, or clicking OK in guide editing dialog.
1299+ */
1300+void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit)
1301+{
1302+ g_assert(SP_IS_GUIDE(&guide));
1303+
1304+ for (GSList *l = guide.views; l != NULL; l = l->next) {
1305+ sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line);
1306+ }
1307+
1308+ /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
1309+ case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
1310+ if (commit) {
1311+ //XML Tree being used directly while it shouldn't be
1312+ sp_repr_set_point(guide.getRepr(), "orientation", normal_to_line);
1313+ }
1314+
1315+/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
1316+ for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
1317+ iEnd(guide.attached_items.end());
1318+ i != iEnd; ++i)
1319+ {
1320+ SPGuideAttachment const &att = *i;
1321+ sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
1322+ }
1323+*/
1324+}
1325+
1326+void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit)
1327+{
1328+ g_assert(SP_IS_GUIDE(&guide));
1329+ guide.color = (r << 24) | (g << 16) | (b << 8) | 0x7f;
1330+
1331+ if (guide.views) {
1332+ sp_guideline_set_color(SP_GUIDELINE(guide.views->data), guide.color);
1333+ }
1334+
1335+ if (commit) {
1336+ std::ostringstream os;
1337+ os << "rgb(" << r << "," << g << "," << b << ")";
1338+ //XML Tree being used directly while it shouldn't be
1339+ guide.getRepr()->setAttribute("inkscape:color", os.str().c_str());
1340+ }
1341+}
1342+
1343+void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit)
1344+{
1345+ g_assert(SP_IS_GUIDE(&guide));
1346+
1347+ if (guide.views) {
1348+ sp_guideline_set_label(SP_GUIDELINE(guide.views->data), label);
1349+ }
1350+
1351+ if (commit) {
1352+ //XML Tree being used directly while it shouldn't be
1353+ guide.getRepr()->setAttribute("inkscape:label", label);
1354+ }
1355+}
1356+
1357+/**
1358+ * Returns a human-readable description of the guideline for use in dialog boxes and status bar.
1359+ * If verbose is false, only positioning information is included (useful for dialogs).
1360+ *
1361+ * The caller is responsible for freeing the string.
1362+ */
1363+char *sp_guide_description(SPGuide const *guide, const bool verbose)
1364+{
1365+ using Geom::X;
1366+ using Geom::Y;
1367+
1368+ char *descr = 0;
1369+ if ( !guide->document ) {
1370+ // Guide has probably been deleted and no longer has an attached namedview.
1371+ descr = g_strdup_printf("%s", _("Deleted"));
1372+ } else {
1373+ SPNamedView *namedview = sp_document_namedview(guide->document, NULL);
1374+
1375+ Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(guide->point_on_line[X], "px");
1376+ Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(guide->point_on_line[Y], "px");
1377+ GString *position_string_x = g_string_new(x_q.string(namedview->doc_units).c_str());
1378+ GString *position_string_y = g_string_new(y_q.string(namedview->doc_units).c_str());
1379+
1380+ gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete"));
1381+
1382+ if ( are_near(guide->normal_to_line, Geom::Point(1., 0.)) ||
1383+ are_near(guide->normal_to_line, -Geom::Point(1., 0.)) ) {
1384+ descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str);
1385+ } else if ( are_near(guide->normal_to_line, Geom::Point(0., 1.)) ||
1386+ are_near(guide->normal_to_line, -Geom::Point(0., 1.)) ) {
1387+ descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str);
1388+ } else {
1389+ double const radians = guide->angle();
1390+ double const degrees = Geom::rad_to_deg(radians);
1391+ int const degrees_int = (int) round(degrees);
1392+ descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"),
1393+ degrees_int, position_string_x->str, position_string_y->str);
1394+ }
1395+
1396+ g_string_free(position_string_x, TRUE);
1397+ g_string_free(position_string_y, TRUE);
1398+
1399+ if (verbose) {
1400+ gchar *oldDescr = descr;
1401+ descr = g_strconcat(oldDescr, shortcuts, NULL);
1402+ g_free(oldDescr);
1403+ }
1404+ g_free(shortcuts);
1405+ }
1406+
1407+ return descr;
1408+}
1409+
1410+void sp_guide_remove(SPGuide *guide)
1411+{
1412+ g_assert(SP_IS_GUIDE(guide));
1413+
1414+ for (vector<SPGuideAttachment>::const_iterator i(guide->attached_items.begin()),
1415+ iEnd(guide->attached_items.end());
1416+ i != iEnd; ++i)
1417+ {
1418+ SPGuideAttachment const &att = *i;
1419+ remove_last(att.item->constraints, SPGuideConstraint(guide, att.snappoint_ix));
1420+ }
1421+ guide->attached_items.clear();
1422+
1423+ //XML Tree being used directly while it shouldn't be.
1424+ sp_repr_unparent(guide->getRepr());
1425+}
1426+
1427+/*
1428+ Local Variables:
1429+ mode:c++
1430+ c-file-style:"stroustrup"
1431+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1432+ indent-tabs-mode:nil
1433+ fill-column:99
1434+ End:
1435+*/
1436+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
1437
1438=== added file 'src/display/canvas-guide.h'
1439--- src/display/canvas-guide.h 1970-01-01 00:00:00 +0000
1440+++ src/display/canvas-guide.h 2014-09-23 18:22:24 +0000
1441@@ -0,0 +1,92 @@
1442+#ifndef SEEN_SP_GUIDE_H
1443+#define SEEN_SP_GUIDE_H
1444+
1445+/*
1446+ * SPGuide
1447+ *
1448+ * A guideline
1449+ *
1450+ * Copyright (C) Lauris Kaplinski 2000
1451+ * Copyright (C) Johan Engelen 2007
1452+ * Abhishek Sharma
1453+ * Jon A. Cruz <jon@joncruz.org>
1454+ *
1455+ */
1456+
1457+#include <vector>
1458+
1459+#include <2geom/point.h>
1460+#include "sp-object.h"
1461+#include "sp-guide-attachment.h"
1462+
1463+struct SPCanvas;
1464+struct SPCanvasGroup;
1465+class SPDesktop;
1466+
1467+#define SP_GUIDE(obj) (dynamic_cast<SPGuide*>((SPObject*)obj))
1468+#define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj) != NULL)
1469+
1470+/* Represents the constraint on p that dot(g.direction, p) == g.position. */
1471+class SPGuide : public SPObject {
1472+public:
1473+ SPGuide();
1474+ virtual ~SPGuide();
1475+
1476+ char* label;
1477+ char* group;
1478+ bool enable;
1479+
1480+ Geom::Point normal_to_line;
1481+ Geom::Point point_on_line;
1482+
1483+ guint32 color;
1484+ guint32 hicolor;
1485+ GSList *views;
1486+ std::vector<SPGuideAttachment> attached_items;
1487+
1488+ guint32 getColor() const;
1489+ guint32 getHiColor() const;
1490+ void setColor(guint32 c);
1491+ void setHiColor(guint32 h);
1492+ inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); };
1493+ inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); };
1494+ inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
1495+ static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2);
1496+ void showSPGuide(SPCanvasGroup *group, GCallback handler);
1497+ void hideSPGuide(SPCanvas *canvas);
1498+ void sensitize(SPCanvas *canvas, gboolean sensitive);
1499+ Geom::Point getPositionFrom(Geom::Point const &pt) const;
1500+ double getDistanceFrom(Geom::Point const &pt) const;
1501+
1502+protected:
1503+ virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
1504+ virtual void release();
1505+ virtual void set(unsigned int key, const gchar* value);
1506+};
1507+
1508+void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
1509+void sp_guide_create_guides_around_page(SPDesktop *dt);
1510+void sp_guide_delete_all_guides(SPDesktop *dt);
1511+
1512+void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit);
1513+void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit);
1514+void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit);
1515+void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit);
1516+void sp_guide_set_enable(SPGuide &guide, bool const enable_flag, bool const commit);
1517+
1518+void sp_guide_remove(SPGuide *guide);
1519+
1520+char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
1521+
1522+#endif // SEEN_SP_GUIDE_H
1523+
1524+/*
1525+ Local Variables:
1526+ mode:c++
1527+ c-file-style:"stroustrup"
1528+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1529+ indent-tabs-mode:nil
1530+ fill-column:99
1531+ End:
1532+*/
1533+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
1534
1535=== modified file 'src/display/guideline.cpp'
1536--- src/display/guideline.cpp 2014-03-27 01:33:44 +0000
1537+++ src/display/guideline.cpp 2014-09-23 18:22:24 +0000
1538@@ -1,5 +1,5 @@
1539 /*
1540- * Horizontal/vertical but can also be angled line
1541+ * Guides can be horizontal, vertical or angled.
1542 *
1543 * Authors:
1544 * Lauris Kaplinski <lauris@kaplinski.com>
1545@@ -16,6 +16,7 @@
1546
1547 #include <2geom/coord.h>
1548 #include <2geom/transforms.h>
1549+#include <helper/geom.h>
1550 #include "sp-canvas-util.h"
1551 #include "sp-ctrlpoint.h"
1552 #include "guideline.h"
1553@@ -84,6 +85,9 @@
1554 gl->point_on_line = Geom::Point(0,0);
1555 gl->sensitive = 0;
1556
1557+ gl->group = g_strdup("default");
1558+ gl->enable = true;
1559+
1560 gl->origin = NULL;
1561 gl->label = NULL;
1562 }
1563@@ -113,10 +117,13 @@
1564
1565 static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf)
1566 {
1567- //TODO: the routine that renders the label of a specific guideline sometimes
1568+ // TODO: the routine that renders the label of a specific guideline sometimes
1569 // ends up erasing the labels of the other guidelines.
1570 // Maybe we should render all labels everytime.
1571
1572+ static const double dash[] = {4.0, 4.0};
1573+ static int len = sizeof(dash) / sizeof(dash[0]);
1574+
1575 SPGuideLine const *gl = SP_GUIDELINE (item);
1576
1577 cairo_save(buf->ct);
1578@@ -126,7 +133,13 @@
1579 cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE);
1580 cairo_set_font_size(buf->ct, 10);
1581
1582- Geom::Point normal_dt = /*unit_vector*/(gl->normal_to_line * gl->affine.withoutTranslation()); // note that normal_dt does not have unit length
1583+ //g_message("Enable: %d", gl->enable);
1584+
1585+ if (!gl->enable) {
1586+ cairo_set_dash(buf->ct, dash, len, 1);
1587+ }
1588+
1589+ Geom::Point normal_dt = transform_normal(gl->normal_to_line, gl->affine); // note that normal_dt does not have unit length
1590 Geom::Point point_on_line_dt = gl->point_on_line * gl->affine;
1591
1592 if (gl->label) {
1593@@ -228,7 +241,7 @@
1594
1595 *actual_item = item;
1596
1597- Geom::Point vec = gl->normal_to_line * gl->affine.withoutTranslation();
1598+ Geom::Point vec = transform_normal(gl->normal_to_line, gl->affine);
1599 double distance = Geom::dot((p - gl->point_on_line * gl->affine), unit_vector(vec));
1600 return MAX(fabs(distance)-1, 0);
1601 }
1602@@ -238,7 +251,7 @@
1603 SPCanvasItem *item = sp_canvas_item_new(parent, SP_TYPE_GUIDELINE, NULL);
1604 SPCanvasItem *origin = ControlManager::getManager().createControl(parent, Inkscape::CTRL_TYPE_ORIGIN);
1605 ControlManager::getManager().track(origin);
1606-
1607+
1608 SPGuideLine *gl = SP_GUIDELINE(item);
1609 SPCtrlPoint *cp = SP_CTRLPOINT(origin);
1610 gl->origin = cp;
1611@@ -247,6 +260,8 @@
1612 gl->label = label;
1613 gl->normal_to_line = normal;
1614 gl->angle = tan( -gl->normal_to_line[Geom::X] / gl->normal_to_line[Geom::Y]);
1615+ gl->group = g_strdup("default");
1616+ //gl->enable = true;
1617 sp_guideline_set_position(gl, point_on_line);
1618
1619 sp_ctrlpoint_set_coords(cp, point_on_line);
1620@@ -254,13 +269,30 @@
1621 return item;
1622 }
1623
1624+void sp_guideline_set_group(SPGuideLine *gl, const char* group)
1625+{
1626+ if (gl->group) {
1627+ g_free(gl->group);
1628+ }
1629+ gl->group = g_strdup(group);
1630+
1631+ sp_canvas_item_request_update(SP_CANVAS_ITEM (gl));
1632+}
1633+
1634+void sp_guideline_set_enable(SPGuideLine *gl, bool enable_flag)
1635+{
1636+ gl->enable = enable_flag;
1637+ sp_canvas_item_request_update(SP_CANVAS_ITEM (gl));
1638+}
1639+
1640 void sp_guideline_set_label(SPGuideLine *gl, const char* label)
1641 {
1642+
1643 if (gl->label) {
1644 g_free(gl->label);
1645 }
1646+
1647 gl->label = g_strdup(label);
1648-
1649 sp_canvas_item_request_update(SP_CANVAS_ITEM (gl));
1650 }
1651
1652
1653=== modified file 'src/display/guideline.h'
1654--- src/display/guideline.h 2014-03-27 01:33:44 +0000
1655+++ src/display/guideline.h 2014-09-23 18:22:24 +0000
1656@@ -32,9 +32,11 @@
1657 guint32 rgba;
1658
1659 char* label;
1660+ char* group;
1661 Geom::Point normal_to_line;
1662 Geom::Point point_on_line;
1663 double angle;
1664+ bool enable;
1665
1666 unsigned int sensitive : 1;
1667
1668@@ -55,6 +57,8 @@
1669 void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line);
1670 void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba);
1671 void sp_guideline_set_sensitive(SPGuideLine *gl, int sensitive);
1672+void sp_guideline_set_group(SPGuideLine *gl, char* group);
1673+void sp_guideline_set_enable(SPGuideLine *gl, bool enable_flag);
1674 void sp_guideline_delete(SPGuideLine *gl);
1675
1676 #endif // SEEN_SP_GUIDELINE_H
1677
1678=== modified file 'src/document-undo.cpp'
1679--- src/document-undo.cpp 2014-08-06 17:56:59 +0000
1680+++ src/document-undo.cpp 2014-09-23 18:22:24 +0000
1681@@ -22,8 +22,8 @@
1682 * stack. Two methods exist to indicate that the given action is completed:
1683 *
1684 * \verbatim
1685- void sp_document_done( SPDocument *document );
1686- void sp_document_maybe_done( SPDocument *document, const unsigned char *key ) \endverbatim
1687+ * void sp_document_done( SPDocument *document );
1688+ * void sp_document_maybe_done( SPDocument *document, const unsigned char *key ) \endverbatim
1689 *
1690 * Both move the recent action list into the undo stack and clear the
1691 * list afterwards. While the first method does an unconditional push,
1692@@ -150,17 +150,19 @@
1693
1694 }
1695
1696-void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const unsigned int event_type,
1697+void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key,
1698+ const unsigned int event_type,
1699 Glib::ustring const &event_description)
1700 {
1701 g_assert (doc != NULL);
1702 g_assert (doc->priv != NULL);
1703- g_assert (doc->priv->sensitive);
1704- if ( key && !*key ) {
1705- g_warning("Blank undo key specified.");
1706- }
1707-
1708- Inkscape::Debug::EventTracker<CommitEvent> tracker(doc, key, event_type);
1709+ g_assert (doc->priv->sensitive);
1710+
1711+ if ( key && !*key ) {
1712+ g_warning("Blank undo key specified.");
1713+ }
1714+
1715+ Inkscape::Debug::EventTracker<CommitEvent> tracker(doc, key, event_type);
1716
1717 doc->collectOrphans();
1718
1719@@ -168,11 +170,12 @@
1720
1721 DocumentUndo::clearRedo(doc);
1722
1723- Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc));
1724+ Inkscape::XML::Event *log = sp_repr_coalesce_log(doc->priv->partial,
1725+ sp_repr_commit_undoable(doc->rdoc));
1726 doc->priv->partial = NULL;
1727
1728 if (!log) {
1729- sp_repr_begin_transaction (doc->rdoc);
1730+ sp_repr_begin_transaction(doc->rdoc);
1731 return;
1732 }
1733
1734@@ -180,24 +183,25 @@
1735 ((Inkscape::Event *)doc->priv->undo->data)->event =
1736 sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log);
1737 } else {
1738- Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description);
1739- doc->priv->undo = g_slist_prepend (doc->priv->undo, event);
1740+ Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description);
1741+ doc->priv->undo = g_slist_prepend(doc->priv->undo, event);
1742 doc->priv->history_size++;
1743 doc->priv->undoStackObservers.notifyUndoCommitEvent(event);
1744 }
1745
1746- if ( key ) {
1747- doc->actionkey = key;
1748- } else {
1749- doc->actionkey.clear();
1750- }
1751+ if (key) {
1752+ doc->actionkey = key;
1753+ }
1754+ else {
1755+ doc->actionkey.clear();
1756+ }
1757
1758 doc->virgin = FALSE;
1759- doc->setModifiedSinceSave();
1760+ doc->setModifiedSinceSave();
1761
1762 sp_repr_begin_transaction (doc->rdoc);
1763
1764- doc->priv->commit_signal.emit();
1765+ doc->priv->commit_signal.emit();
1766 }
1767
1768 void Inkscape::DocumentUndo::cancel(SPDocument *doc)
1769
1770=== modified file 'src/document.cpp'
1771--- src/document.cpp 2014-09-02 23:51:04 +0000
1772+++ src/document.cpp 2014-09-23 18:22:24 +0000
1773@@ -747,11 +747,11 @@
1774 root->translateChildItems(tr);
1775
1776 if(nv) {
1777+ nv->translateGuides(Geom::Translate(tr[0],-tr[1]));
1778+ nv->translateGrids (Geom::Translate(tr[0],-tr[1]));
1779+
1780+ // update the viewport so the drawing appears to stay where it was
1781 Geom::Translate tr2(-rect_with_margins.min());
1782- nv->translateGuides(tr2);
1783- nv->translateGrids(tr2);
1784-
1785- // update the viewport so the drawing appears to stay where it was
1786 nv->scrollAllDesktops(-tr2[0], tr2[1], false);
1787 }
1788 }
1789
1790=== modified file 'src/file.cpp'
1791--- src/file.cpp 2014-08-19 21:24:08 +0000
1792+++ src/file.cpp 2014-09-23 18:22:24 +0000
1793@@ -59,6 +59,7 @@
1794 #include "selection.h"
1795 #include "sp-namedview.h"
1796 #include "style.h"
1797+#include "2geom/transforms.h"
1798 #include "ui/view/view-widget.h"
1799 #include "uri.h"
1800 #include "xml/rebase-hrefs.h"
1801@@ -67,6 +68,9 @@
1802 #include "event-log.h"
1803 #include "ui/dialog/font-substitution.h"
1804
1805+#include "svg/stringstream.h"
1806+#include "svg/svg.h"
1807+
1808 #include <gtk/gtk.h>
1809 #include <gtkmm/main.h>
1810
1811@@ -249,12 +253,106 @@
1812 }
1813 }
1814
1815-
1816 /*######################
1817 ## O P E N
1818 ######################*/
1819
1820 /**
1821+ * Convert old-style guides (pre-0.50, "sodipodi:guide") to new-style (0.50, "inkscape-guide")
1822+ * \return true if there was anything changed
1823+ */
1824+static
1825+bool sp_file_backwcompat_guides(SPDocument *doc)
1826+{
1827+ SPNamedView *namedview = sp_document_namedview(doc, NULL);
1828+ if (!namedview) return false;
1829+ Inkscape::XML::Document *document = doc->getReprDoc();
1830+ if (!document) return false;
1831+ Inkscape::XML::Node *nv_root = namedview->getRepr();
1832+ if (!nv_root) return false;
1833+ Inkscape::XML::Node *node = nv_root->firstChild();
1834+ std::vector<Inkscape::XML::Node * > nodes_to_be_removed;
1835+
1836+ while (node) {
1837+ if (!strcmp(node->name(), "sodipodi:guide")) {
1838+ gchar const *position = node->attribute("position");
1839+ gchar const *orientation = node->attribute("orientation");
1840+
1841+ Geom::Point normal = Geom::Point(1.,0.); // default value if reading from SVG fails
1842+ Geom::Point point_on_line = Geom::Point(0.,0.); // default value if reading from SVG fails
1843+
1844+ // the value string of "position" is of the form:
1845+ // <x-coord double>,<y-coord double>. e.g. 123.243434,355.438534
1846+
1847+ if (position) {
1848+ double pos_x, pos_y;
1849+ gchar **attr_val = g_strsplit(position, ",", 2);
1850+ unsigned int success = sp_svg_number_read_d(attr_val[0], &pos_x);
1851+ success += sp_svg_number_read_d(attr_val[1], &pos_y);
1852+ g_strfreev(attr_val);
1853+ if (success == 2) {
1854+ point_on_line = Geom::Point(pos_x, pos_y);
1855+ }
1856+ else if (success == 1) {
1857+ if (orientation && !strcmp(orientation, "horizontal")) {
1858+ point_on_line = Geom::Point(0, pos_x);
1859+ } else {
1860+ point_on_line = Geom::Point(pos_x, 0);
1861+ }
1862+ }
1863+ }
1864+
1865+ if (orientation) {
1866+ if ( !strcmp(orientation, "horizontal") ) {
1867+ normal = Geom::Point(0., 1.);
1868+ }
1869+ else if ( !strcmp(orientation, "vertical") ) {
1870+ normal = Geom::Point(1., 0.);
1871+ } else {
1872+ double ort_x, ort_y;
1873+ gchar **attr_val = g_strsplit(orientation, ",", 2);
1874+ unsigned int success = sp_svg_number_read_d(attr_val[0], &ort_x);
1875+ success += sp_svg_number_read_d(attr_val[1], &ort_y);
1876+ g_strfreev(attr_val);
1877+ if (success == 2 && (fabs(ort_x) > 1e-6 || fabs(ort_y) > 1e-6)) {
1878+ normal = Geom::Point(ort_x, ort_y);
1879+ normal.normalize();
1880+ }
1881+ }
1882+ }
1883+
1884+ double height = doc->getHeight().value("px");
1885+
1886+ Geom::Point point_on_line_doc = Geom::Point(point_on_line[0], -point_on_line[1] + height);
1887+ Geom::Point normal_doc = Geom::Point(normal[0], -normal[1]);
1888+
1889+ Inkscape::SVGOStringStream pos, ort;
1890+ pos << point_on_line_doc;
1891+ ort << normal_doc;
1892+
1893+ Inkscape::XML::Node *new_node = document->createElement("inkscape:guide");
1894+ new_node->setAttribute("id", node->attribute("id"));
1895+ new_node->setAttribute("label", node->attribute("label"));
1896+ new_node->setAttribute("color", node->attribute("color"));
1897+ new_node->setAttribute("position", pos.str().c_str());
1898+ new_node->setAttribute("orientation", ort.str().c_str());
1899+
1900+ nv_root->appendChild(new_node);
1901+ Inkscape::GC::release(new_node);
1902+
1903+ nodes_to_be_removed.push_back(node);
1904+ }
1905+ node = node->next();
1906+ } // end while
1907+
1908+ for (std::vector<Inkscape::XML::Node * >::iterator itr = nodes_to_be_removed.begin(); itr != nodes_to_be_removed.end(); ++itr) {
1909+ nv_root->removeChild(*itr);
1910+ }
1911+
1912+ return ( !nodes_to_be_removed.empty() );
1913+}
1914+
1915+/**
1916 * Open a file, add the document to the desktop
1917 *
1918 * \param replace_empty if true, and the current desktop is empty, this document
1919@@ -291,6 +389,10 @@
1920
1921 SPDocument *existing = desktop ? sp_desktop_document(desktop) : NULL;
1922
1923+ // backwards compatibility: updating old-style files to new-style files
1924+ bool changed = sp_file_backwcompat_guides(doc);
1925+ /// \todo report the change to the user, and perhaps find better place to do such things
1926+
1927 if (existing && existing->virgin && replace_empty) {
1928 // If the current desktop is empty, open the document there
1929 doc->ensureUpToDate(); // TODO this will trigger broken link warnings, etc.
1930@@ -298,7 +400,21 @@
1931 doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px"));
1932 } else {
1933 // create a whole new desktop and window
1934+
1935+ // Ipnkscape::XML::Document *xml_doc = doc->getReprDoc();
1936+ // SPViewWidget *dtw;
1937+ // // find if old-style guides are being used.
1938+ // if (sp_repr_lookup_name(xml_doc->root(), "sodipodi:guide")) {
1939+ // SPNamedView *nv = sp_document_namedview(doc, NULL);
1940+ // g_message("hi");
1941+ // Geom::Affine dt2doc = desktop->dt2doc();
1942+ // //nv->transformGuides(dt2doc);
1943+ // //dtw = sp_desktop_widget_new(nv);
1944+ // }
1945+ // else {
1946 SPViewWidget *dtw = sp_desktop_widget_new(sp_document_namedview(doc, NULL)); // TODO this will trigger broken link warnings, etc.
1947+ // }
1948+
1949 sp_create_window(dtw, TRUE);
1950 desktop = static_cast<SPDesktop*>(dtw->view);
1951 }
1952
1953=== added file 'src/guide-manager.cpp'
1954--- src/guide-manager.cpp 1970-01-01 00:00:00 +0000
1955+++ src/guide-manager.cpp 2014-09-23 18:22:24 +0000
1956@@ -0,0 +1,154 @@
1957+/*
1958+
1959+ #include "guide-manager.h"
1960+
1961+ namespace Inkscape {
1962+
1963+ class GuideManager::GuideWatcher {
1964+ public:
1965+ };
1966+
1967+ GuideManager::GuideManager(SPDesktop *desktop) : _desktop(desktop)
1968+ {
1969+
1970+ }
1971+
1972+
1973+
1974+ } // end of namespace Inkscape
1975+
1976+*/
1977+
1978+/*
1979+ * Inkscape::GuideManager
1980+ * Released under GNU GPL, read the file 'COPYING' for more information
1981+ */
1982+
1983+#include <set>
1984+#include <sigc++/functors/mem_fun.h>
1985+#include <sigc++/adaptors/hide.h>
1986+#include "gc-managed.h"
1987+#include "gc-finalized.h"
1988+#include "document.h"
1989+#include "desktop.h"
1990+#include "desktop-handles.h"
1991+#include "guide-manager.h"
1992+#include "preferences.h"
1993+#include "ui/view/view.h"
1994+#include "selection.h"
1995+#include "sp-object.h"
1996+#include "sp-namedview.h"
1997+#include "sp-item-group.h"
1998+#include "xml/node.h"
1999+#include "xml/node-observer.h"
2000+#include "util/format.h"
2001+// #include "debug/event-tracker.h"
2002+// #include "debug/simple-event.h"
2003+
2004+namespace Inkscape {
2005+
2006+// class GuideManager::GuideWatcher {
2007+// public:
2008+// };
2009+
2010+GuideManager::GuideManager(SPDesktop *desktop) : _desktop(desktop)
2011+{
2012+ _namedview_connection = desktop->namedview->connectModified(sigc::mem_fun(*this, &GuideManager::_namedview_changed));
2013+}
2014+
2015+using Inkscape::XML::Node;
2016+
2017+class GuideManager::GuideWatcher : public Inkscape::XML::NodeObserver {
2018+public:
2019+ GuideWatcher(GuideManager* mgr, SPObject* obj, sigc::connection c) :
2020+ _mgr(mgr),
2021+ _obj(obj),
2022+ _connection(c)
2023+ {}
2024+
2025+ virtual void notifyChildAdded( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
2026+ virtual void notifyChildRemoved( Node &/*node*/, Node &/*child*/, Node */*prev*/ ) {}
2027+ virtual void notifyChildOrderChanged( Node &/*node*/, Node &/*child*/, Node */*old_prev*/, Node */*new_prev*/ ) {}
2028+ virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared<char> /*old_content*/, Util::ptr_shared<char> /*new_content*/ ) {}
2029+
2030+ virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared<char> /*old_value*/, Util::ptr_shared<char> /*new_value*/ ) {
2031+ if ( _mgr && _obj ) {
2032+ _mgr->_objectModified( _obj, 0 );
2033+ }
2034+ }
2035+
2036+ GuideManager* _mgr;
2037+ SPObject* _obj;
2038+ sigc::connection _connection;
2039+};
2040+
2041+GuideManager::~GuideManager()
2042+{
2043+ _namedview_connection.disconnect();
2044+ _resource_connection.disconnect();
2045+ //_document = 0;
2046+}
2047+
2048+// void LayerManager::_setDocument(SPDocument *document) {
2049+// if (_document) {
2050+// _resource_connection.disconnect();
2051+// }
2052+// _document = document;
2053+// if (document) {
2054+// _resource_connection = document->connectResourcesChanged("layer", sigc::mem_fun(*this, &LayerManager::_rebuild));
2055+// }
2056+// _rebuild();
2057+// }
2058+
2059+void GuideManager::_objectModified(SPObject* obj, guint /*flags*/ )
2060+{
2061+ _details_changed_signal.emit(obj);
2062+}
2063+
2064+void GuideManager::_rebuild() {
2065+
2066+ while ( !_watchers.empty() ) {
2067+ GuideWatcher* one = _watchers.back();
2068+ _watchers.pop_back();
2069+ if ( one->_obj ) {
2070+ Node* node = one->_obj->getRepr();
2071+ if ( node ) {
2072+ node->removeObserver(*one);
2073+ }
2074+ one->_connection.disconnect();
2075+ }
2076+ }
2077+
2078+ _clear();
2079+
2080+ GSList const *guides = _desktop->namedview->guides;
2081+
2082+ for (GSList const *iter = guides; iter; iter = iter->next) {
2083+
2084+ SPObject *guide = SP_OBJECT(iter);
2085+ sigc::connection connection = guide->connectModified(sigc::mem_fun(*this, &GuideManager::_objectModified));
2086+ GuideWatcher *eye = new GuideWatcher(this, guide, connection);
2087+
2088+ _watchers.push_back(eye);
2089+ guide->getRepr()->addObserver(*eye);
2090+ _addOne(guide);
2091+ }
2092+}
2093+
2094+void GuideManager::_namedview_changed(SPObject *guide, guint /*flags*/)
2095+{
2096+ _namedview_changed_signal.emit(guide);
2097+}
2098+
2099+} //namespace
2100+
2101+/*
2102+ Local Variables:
2103+ mode:c++
2104+ c-file-style:"stroustrup"
2105+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2106+ indent-tabs-mode:nil
2107+ fill-column:99
2108+ End:
2109+*/
2110+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
2111
2112=== added file 'src/guide-manager.h'
2113--- src/guide-manager.h 1970-01-01 00:00:00 +0000
2114+++ src/guide-manager.h 2014-09-23 18:22:24 +0000
2115@@ -0,0 +1,65 @@
2116+/*
2117+ * Inkscape::GuideManager
2118+ *
2119+ * Released under GNU GPL, read the file 'COPYING' for more information
2120+ *
2121+ */
2122+
2123+#ifndef SEEN_INKSCAPE_GUIDE_MANAGER_H
2124+#define SEEN_INKSCAPE_GUIDE_MANAGER_H
2125+
2126+#include "document-subset.h"
2127+#include "gc-finalized.h"
2128+#include "gc-soft-ptr.h"
2129+#include <vector>
2130+#include <map>
2131+
2132+class SPDesktop;
2133+class SPDocument;
2134+
2135+namespace Inkscape {
2136+
2137+class GuideManager : public DocumentSubset,
2138+ public GC::Finalized
2139+
2140+{
2141+
2142+public:
2143+ GuideManager(SPDesktop *desktop);
2144+ ~GuideManager();
2145+
2146+private:
2147+ friend class GuideWatcher;
2148+ class GuideWatcher;
2149+
2150+ void _objectModified(SPObject* obj, guint flags);
2151+ void _setDocument(SPDocument *document);
2152+ void _rebuild();
2153+ void _namedview_changed(SPObject *guide, guint);
2154+
2155+ sigc::connection _namedview_connection;
2156+ sigc::connection _resource_connection;
2157+
2158+ GC::soft_ptr<SPDesktop> _desktop;
2159+
2160+ std::vector<GuideWatcher*> _watchers;
2161+
2162+ sigc::signal<void, SPObject *> _namedview_changed_signal;
2163+ sigc::signal<void, SPObject *> _details_changed_signal;
2164+
2165+};
2166+
2167+} // namespace
2168+
2169+#endif
2170+
2171+/*
2172+ Local Variables:
2173+ mode:c++
2174+ c-file-style:"stroustrup"
2175+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2176+ indent-tabs-mode:nil
2177+ fill-column:99
2178+ End:
2179+*/
2180+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
2181
2182=== modified file 'src/guide-snapper.cpp'
2183--- src/guide-snapper.cpp 2014-03-27 01:33:44 +0000
2184+++ src/guide-snapper.cpp 2014-09-23 18:22:24 +0000
2185@@ -13,7 +13,8 @@
2186
2187 #include "sp-namedview.h"
2188 #include "desktop.h"
2189-#include "sp-guide.h"
2190+#include "display/canvas-guide.h"
2191+#include "helper/geom.h"
2192
2193 Inkscape::GuideSnapper::GuideSnapper(SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d)
2194 {
2195@@ -47,8 +48,8 @@
2196
2197 for (GSList const *l = _snapmanager->getNamedView()->guides; l != NULL; l = l->next) {
2198 SPGuide const *g = SP_GUIDE(l->data);
2199- if (g != guide_to_ignore) {
2200- s.push_back(std::make_pair(g->normal_to_line, g->point_on_line));
2201+ if (g != guide_to_ignore && g->enable == true) {
2202+ s.push_back(std::make_pair(transform_normal(g->normal_to_line, _snapmanager->getDesktop()->doc2dt()), _snapmanager->getDesktop()->doc2dt(g->point_on_line)));
2203 }
2204 }
2205
2206@@ -70,7 +71,7 @@
2207 void Inkscape::GuideSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, Geom::Point const &point_on_line) const
2208 {
2209 SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GUIDE, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
2210- isr.guide_lines.push_back(dummy);
2211+ isr.guide_lines.push_back(dummy);
2212 }
2213
2214 void Inkscape::GuideSnapper::_addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const &origin, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
2215
2216=== modified file 'src/helper/geom.cpp'
2217--- src/helper/geom.cpp 2014-03-27 01:33:44 +0000
2218+++ src/helper/geom.cpp 2014-09-23 18:22:24 +0000
2219@@ -812,7 +812,21 @@
2220 rect = Geom::Rect(ints[0], ints[1]);
2221 }
2222
2223-
2224+Geom::Point transform_normal(Geom::Point normal, Geom::Affine affine) {
2225+
2226+/* Function that transforms normals. Ensures that the normal still has a magnitude of 1 */
2227+
2228+ normal = normal.ccw(); // normal is now parallel to the line.
2229+ normal = normal * affine.withoutTranslation(); // apply the transform
2230+ normal = normal.ccw(); // rotate in the opposite direction to make it perpendicular again.
2231+
2232+ if (!normal.isNormalized()) {
2233+ normal.normalize();
2234+ }
2235+
2236+ return normal;
2237+}
2238+
2239 namespace Geom {
2240
2241 bool transform_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon) {
2242
2243=== modified file 'src/helper/geom.h'
2244--- src/helper/geom.h 2014-03-27 01:33:44 +0000
2245+++ src/helper/geom.h 2014-09-23 18:22:24 +0000
2246@@ -34,6 +34,9 @@
2247
2248 void round_rectangle_outwards(Geom::Rect & rect);
2249
2250+Geom::Point transform_normal(Geom::Point normal, Geom::Affine affine);
2251+
2252+
2253 namespace Geom{
2254 bool transform_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon);
2255 bool translate_equalp(Geom::Affine const &m0, Geom::Affine const &m1, Geom::Coord const epsilon);
2256
2257=== modified file 'src/line-snapper.cpp'
2258--- src/line-snapper.cpp 2014-03-27 01:33:44 +0000
2259+++ src/line-snapper.cpp 2014-09-23 18:22:24 +0000
2260@@ -32,7 +32,7 @@
2261
2262 /* Get the lines that we will try to snap to */
2263 const LineList lines = _getSnapLines(p.getPoint());
2264-
2265+
2266 for (LineList::const_iterator i = lines.begin(); i != lines.end(); ++i) {
2267 Geom::Point const p1 = i->second; // point at guide/grid line
2268 Geom::Point const p2 = p1 + Geom::rot90(i->first); // 2nd point at guide/grid line
2269
2270=== modified file 'src/main.cpp'
2271--- src/main.cpp 2014-06-03 17:50:49 +0000
2272+++ src/main.cpp 2014-09-23 18:22:24 +0000
2273@@ -78,7 +78,8 @@
2274 #include "inkscape-version.h"
2275
2276 #include "sp-namedview.h"
2277-#include "sp-guide.h"
2278+#include "display/canvas-guide.h"
2279+// #include "sp-object-repr.h"
2280 #include "xml/repr.h"
2281
2282 #include "io/sys.h"
2283
2284=== modified file 'src/satisfied-guide-cns.cpp'
2285--- src/satisfied-guide-cns.cpp 2014-03-27 01:33:44 +0000
2286+++ src/satisfied-guide-cns.cpp 2014-09-23 18:22:24 +0000
2287@@ -1,6 +1,6 @@
2288 #include <2geom/coord.h>
2289 #include "desktop-handles.h"
2290-#include "sp-guide.h"
2291+#include "display/canvas-guide.h"
2292 #include "sp-guide-constraint.h"
2293 #include "sp-namedview.h"
2294 #include "satisfied-guide-cns.h"
2295
2296=== modified file 'src/snap.cpp'
2297--- src/snap.cpp 2014-08-17 18:31:38 +0000
2298+++ src/snap.cpp 2014-09-23 18:22:24 +0000
2299@@ -30,7 +30,7 @@
2300 #include "inkscape.h"
2301 #include "desktop.h"
2302 #include "selection.h"
2303-#include "sp-guide.h"
2304+#include "display/canvas-guide.h"
2305 #include "preferences.h"
2306 #include "ui/tools/tool-base.h"
2307 #include "util/mathfns.h"
2308@@ -179,7 +179,8 @@
2309 // will use the grid snapper. Simply snapping the value t to the grid will do, but
2310 // only if the origin of the grid is at (0,0). If it's not then compensate for this
2311 // in the translation t
2312- Geom::Point const t_offset = t + grid->origin;
2313+ Geom::Point origin_dt = getDesktop()->doc2dt(grid->origin); // remember snapping is done in desktop-coords
2314+ Geom::Point const t_offset = t + origin_dt;
2315 IntermSnapResults isr;
2316 // Only the first three parameters are being used for grid snappers
2317 snapper->freeSnap(isr, Inkscape::SnapCandidatePoint(t_offset, Inkscape::SNAPSOURCE_GRID_PITCH),Geom::OptRect(), NULL, NULL);
2318@@ -192,7 +193,7 @@
2319 // use getSnapDistance() instead of getWeightedDistance() here because the pointer's position
2320 // doesn't tell us anything about which node to snap
2321 success = true;
2322- nearest_multiple = s.getPoint() - grid->origin;
2323+ nearest_multiple = s.getPoint() - origin_dt;
2324 nearest_distance = s.getSnapDistance();
2325 bestSnappedPoint = s;
2326 }
2327@@ -384,7 +385,7 @@
2328 return sp;
2329 }
2330
2331-void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point &origin_or_vector, bool origin, bool freeze_angle) const
2332+void SnapManager::guideFreeSnap(Geom::Point &point_dt, Geom::Point &origin_or_vector, bool origin, bool freeze_angle) const
2333 {
2334 if (freeze_angle && origin) {
2335 g_warning("Dear developer, when snapping guides you shouldn't ask me to freeze the guide's vector when you haven't specified one");
2336@@ -395,11 +396,11 @@
2337 return;
2338 }
2339
2340- Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE);
2341+ Inkscape::SnapCandidatePoint candidate(point_dt, Inkscape::SNAPSOURCE_GUIDE);
2342 if (origin) {
2343 candidate.addOrigin(origin_or_vector);
2344 } else {
2345- candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN);
2346+ candidate = Inkscape::SnapCandidatePoint(point_dt, Inkscape::SNAPSOURCE_GUIDE_ORIGIN);
2347 candidate.addVector(Geom::rot90(origin_or_vector));
2348 }
2349
2350@@ -411,7 +412,7 @@
2351
2352 Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false);
2353
2354- s.getPointIfSnapped(p);
2355+ s.getPointIfSnapped(point_dt);
2356
2357 if (!freeze_angle && s.getSnapped()) {
2358 if (!Geom::are_near(s.getTangent(), Geom::Point(0,0))) { // If the tangent has been set ...
2359@@ -421,13 +422,13 @@
2360 }
2361 }
2362
2363-void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const
2364+void SnapManager::guideConstrainedSnap(Geom::Point &point_dt, SPGuide const &guideline) const
2365 {
2366 if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) {
2367 return;
2368 }
2369
2370- Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED);
2371+ Inkscape::SnapCandidatePoint candidate(point_dt, Inkscape::SNAPSOURCE_GUIDE_ORIGIN, Inkscape::SNAPTARGET_UNDEFINED);
2372
2373 IntermSnapResults isr;
2374 Inkscape::Snapper::SnapConstraint cl(guideline.point_on_line, Geom::rot90(guideline.normal_to_line));
2375@@ -438,7 +439,7 @@
2376 }
2377
2378 Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false);
2379- s.getPointIfSnapped(p);
2380+ s.getPointIfSnapped(point_dt);
2381 }
2382
2383 Inkscape::SnappedPoint SnapManager::_snapTransformed(
2384
2385=== removed file 'src/sp-guide.cpp'
2386--- src/sp-guide.cpp 2014-03-28 21:16:35 +0000
2387+++ src/sp-guide.cpp 1970-01-01 00:00:00 +0000
2388@@ -1,540 +0,0 @@
2389-/*
2390- * Inkscape guideline implementation
2391- *
2392- * Authors:
2393- * Lauris Kaplinski <lauris@kaplinski.com>
2394- * Peter Moulder <pmoulder@mail.csse.monash.edu.au>
2395- * Johan Engelen
2396- * Jon A. Cruz <jon@joncruz.org>
2397- * Abhishek Sharma
2398- *
2399- * Copyright (C) 2000-2002 authors
2400- * Copyright (C) 2004 Monash University
2401- * Copyright (C) 2007 Johan Engelen
2402- *
2403- * Released under GNU GPL, read the file 'COPYING' for more information
2404- */
2405-
2406-#ifdef HAVE_CONFIG_H
2407-# include <config.h>
2408-#endif
2409-
2410-#include <algorithm>
2411-#include <cstring>
2412-#include <string>
2413-#include "desktop-handles.h"
2414-#include "display/sp-canvas.h"
2415-#include "display/guideline.h"
2416-#include "svg/svg.h"
2417-#include "svg/stringstream.h"
2418-#include "attributes.h"
2419-#include "sp-guide.h"
2420-#include <sp-item-notify-moveto.h>
2421-#include <sp-item.h>
2422-#include <sp-guide-constraint.h>
2423-#include <glibmm/i18n.h>
2424-#include <xml/repr.h>
2425-#include <remove-last.h>
2426-#include "inkscape.h"
2427-#include "desktop.h"
2428-#include "sp-namedview.h"
2429-#include <2geom/angle.h>
2430-#include "document.h"
2431-#include "document-undo.h"
2432-#include "verbs.h"
2433-
2434-using Inkscape::DocumentUndo;
2435-using std::vector;
2436-
2437-//enum {
2438-// PROP_0,
2439-// PROP_COLOR,
2440-// PROP_HICOLOR
2441-//};
2442-//
2443-//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
2444-//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
2445-
2446-#include "sp-factory.h"
2447-
2448-namespace {
2449- SPObject* createGuide() {
2450- return new SPGuide();
2451- }
2452-
2453- bool guideRegistered = SPFactory::instance().registerObject("sodipodi:guide", createGuide);
2454-}
2455-
2456-//static void sp_guide_class_init(SPGuideClass *gc)
2457-//{
2458-// GObjectClass *gobject_class = (GObjectClass *) gc;
2459-//
2460-// gobject_class->set_property = sp_guide_set_property;
2461-// gobject_class->get_property = sp_guide_get_property;
2462-//
2463-// g_object_class_install_property(gobject_class,
2464-// PROP_COLOR,
2465-// g_param_spec_uint("color", "Color", "Color",
2466-// 0,
2467-// 0xffffffff,
2468-// 0xff000000,
2469-// (GParamFlags) G_PARAM_READWRITE));
2470-//
2471-// g_object_class_install_property(gobject_class,
2472-// PROP_HICOLOR,
2473-// g_param_spec_uint("hicolor", "HiColor", "HiColor",
2474-// 0,
2475-// 0xffffffff,
2476-// 0xff000000,
2477-// (GParamFlags) G_PARAM_READWRITE));
2478-//}
2479-// CPPIFY: properties!
2480-
2481-SPGuide::SPGuide() : SPObject() {
2482- this->label = NULL;
2483- this->views = NULL;
2484-
2485- this->normal_to_line = Geom::Point(0.,1.);
2486- this->point_on_line = Geom::Point(0.,0.);
2487- this->color = 0x0000ff7f;
2488- this->hicolor = 0xff00007f;
2489-}
2490-
2491-SPGuide::~SPGuide() {
2492-}
2493-
2494-guint32 SPGuide::getColor() const {
2495- return color;
2496-}
2497-
2498-guint32 SPGuide::getHiColor() const {
2499- return hicolor;
2500-}
2501-
2502-void SPGuide::setColor(guint32 c) {
2503- color = c;
2504-
2505- for (GSList *l = this->views; l != NULL; l = l->next) {
2506- sp_guideline_set_color(SP_GUIDELINE(l->data), this->color);
2507- }
2508-}
2509-
2510-void SPGuide::setHiColor(guint32 h) {
2511- this->hicolor = h;
2512-}
2513-
2514-//static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/)
2515-//{
2516-// SPGuide &guide = *SP_GUIDE(object);
2517-//
2518-// switch (prop_id) {
2519-// case PROP_COLOR:
2520-// guide.color = g_value_get_uint(value);
2521-// for (GSList *l = guide.views; l != NULL; l = l->next) {
2522-// sp_guideline_set_color(SP_GUIDELINE(l->data), guide.color);
2523-// }
2524-// break;
2525-//
2526-// case PROP_HICOLOR:
2527-// guide.hicolor = g_value_get_uint(value);
2528-// break;
2529-// }
2530-//}
2531-//
2532-//static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec */*pspec*/)
2533-//{
2534-// SPGuide const &guide = *SP_GUIDE(object);
2535-//
2536-// switch (prop_id) {
2537-// case PROP_COLOR:
2538-// g_value_set_uint(value, guide.color);
2539-// break;
2540-// case PROP_HICOLOR:
2541-// g_value_set_uint(value, guide.hicolor);
2542-// break;
2543-// }
2544-//}
2545-
2546-void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) {
2547- SPObject::build(document, repr);
2548-
2549- this->readAttr( "inkscape:label" );
2550- this->readAttr( "orientation" );
2551- this->readAttr( "position" );
2552-
2553- /* Register */
2554- document->addResource("guide", this);
2555-}
2556-
2557-void SPGuide::release() {
2558- while (this->views) {
2559- sp_guideline_delete(SP_GUIDELINE(this->views->data));
2560- this->views = g_slist_remove(this->views, this->views->data);
2561- }
2562-
2563- if (this->document) {
2564- // Unregister ourselves
2565- this->document->removeResource("guide", this);
2566- }
2567-
2568- SPObject::release();
2569-}
2570-
2571-void SPGuide::set(unsigned int key, const gchar *value) {
2572- switch (key) {
2573- case SP_ATTR_INKSCAPE_LABEL:
2574- if (this->label) g_free(this->label);
2575-
2576- if (value) {
2577- this->label = g_strdup(value);
2578- } else {
2579- this->label = NULL;
2580- }
2581-
2582- sp_guide_set_label(*this, this->label, false);
2583- break;
2584- case SP_ATTR_ORIENTATION:
2585- {
2586- if (value && !strcmp(value, "horizontal")) {
2587- /* Visual representation of a horizontal line, constrain vertically (y coordinate). */
2588- this->normal_to_line = Geom::Point(0., 1.);
2589- } else if (value && !strcmp(value, "vertical")) {
2590- this->normal_to_line = Geom::Point(1., 0.);
2591- } else if (value) {
2592- gchar ** strarray = g_strsplit(value, ",", 2);
2593- double newx, newy;
2594- unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
2595- success += sp_svg_number_read_d(strarray[1], &newy);
2596- g_strfreev (strarray);
2597- if (success == 2 && (fabs(newx) > 1e-6 || fabs(newy) > 1e-6)) {
2598- Geom::Point direction(newx, newy);
2599- direction.normalize();
2600- this->normal_to_line = direction;
2601- } else {
2602- // default to vertical line for bad arguments
2603- this->normal_to_line = Geom::Point(1., 0.);
2604- }
2605- } else {
2606- // default to vertical line for bad arguments
2607- this->normal_to_line = Geom::Point(1., 0.);
2608- }
2609- sp_guide_set_normal(*this, this->normal_to_line, false);
2610- }
2611- break;
2612- case SP_ATTR_POSITION:
2613- {
2614- if (value) {
2615- gchar ** strarray = g_strsplit(value, ",", 2);
2616- double newx, newy;
2617- unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
2618- success += sp_svg_number_read_d(strarray[1], &newy);
2619- g_strfreev (strarray);
2620- if (success == 2) {
2621- this->point_on_line = Geom::Point(newx, newy);
2622- } else if (success == 1) {
2623- // before 0.46 style guideline definition.
2624- const gchar *attr = this->getRepr()->attribute("orientation");
2625- if (attr && !strcmp(attr, "horizontal")) {
2626- this->point_on_line = Geom::Point(0, newx);
2627- } else {
2628- this->point_on_line = Geom::Point(newx, 0);
2629- }
2630- }
2631- } else {
2632- // default to (0,0) for bad arguments
2633- this->point_on_line = Geom::Point(0,0);
2634- }
2635- // update position in non-committing way
2636- // fixme: perhaps we need to add an update method instead, and request_update here
2637- sp_guide_moveto(*this, this->point_on_line, false);
2638- }
2639- break;
2640- default:
2641- SPObject::set(key, value);
2642- break;
2643- }
2644-}
2645-
2646-SPGuide *SPGuide::createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2)
2647-{
2648- Inkscape::XML::Document *xml_doc = doc->getReprDoc();
2649-
2650- Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide");
2651-
2652- Geom::Point n = Geom::rot90(pt2 - pt1);
2653-
2654- sp_repr_set_point(repr, "position", pt1);
2655- sp_repr_set_point(repr, "orientation", n);
2656-
2657- SPNamedView *namedview = sp_document_namedview(doc, NULL);
2658- if (namedview) {
2659- namedview->appendChild(repr);
2660- }
2661- Inkscape::GC::release(repr);
2662-
2663- SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr));
2664- return guide;
2665-}
2666-
2667-void
2668-sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts) {
2669- for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) {
2670- SPGuide::createSPGuide(doc, (*i).first, (*i).second);
2671- }
2672-}
2673-
2674-void
2675-sp_guide_create_guides_around_page(SPDesktop *dt) {
2676- SPDocument *doc=sp_desktop_document(dt);
2677- std::list<std::pair<Geom::Point, Geom::Point> > pts;
2678-
2679- Geom::Point A(0, 0);
2680- Geom::Point C(doc->getWidth().value("px"), doc->getHeight().value("px"));
2681- Geom::Point B(C[Geom::X], 0);
2682- Geom::Point D(0, C[Geom::Y]);
2683-
2684- pts.push_back(std::pair<Geom::Point, Geom::Point>(A, B));
2685- pts.push_back(std::pair<Geom::Point, Geom::Point>(B, C));
2686- pts.push_back(std::pair<Geom::Point, Geom::Point>(C, D));
2687- pts.push_back(std::pair<Geom::Point, Geom::Point>(D, A));
2688-
2689- sp_guide_pt_pairs_to_guides(doc, pts);
2690-
2691- DocumentUndo::done(doc, SP_VERB_NONE, _("Create Guides Around the Page"));
2692-}
2693-
2694-void
2695-sp_guide_delete_all_guides(SPDesktop *dt) {
2696- SPDocument *doc=sp_desktop_document(dt);
2697- const GSList *current;
2698- while ( (current = doc->getResourceList("guide")) ) {
2699- SPGuide* guide = SP_GUIDE(current->data);
2700- sp_guide_remove(guide);
2701- }
2702-
2703- DocumentUndo::done(doc, SP_VERB_NONE, _("Delete All Guides"));
2704-}
2705-
2706-void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler)
2707-{
2708- SPCanvasItem *item = sp_guideline_new(group, label, point_on_line, normal_to_line);
2709- sp_guideline_set_color(SP_GUIDELINE(item), color);
2710-
2711- g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this);
2712-
2713- views = g_slist_prepend(views, item);
2714-}
2715-
2716-void SPGuide::hideSPGuide(SPCanvas *canvas)
2717-{
2718- g_assert(canvas != NULL);
2719- g_assert(SP_IS_CANVAS(canvas));
2720-
2721- for (GSList *l = views; l != NULL; l = l->next) {
2722- if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
2723- sp_guideline_delete(SP_GUIDELINE(l->data));
2724- views = g_slist_remove(views, l->data);
2725- return;
2726- }
2727- }
2728-
2729- g_assert_not_reached();
2730-}
2731-
2732-void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive)
2733-{
2734- g_assert(canvas != NULL);
2735- g_assert(SP_IS_CANVAS(canvas));
2736-
2737- for (GSList *l = views; l != NULL; l = l->next) {
2738- if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
2739- sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive);
2740- return;
2741- }
2742- }
2743-
2744- g_assert_not_reached();
2745-}
2746-
2747-Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const
2748-{
2749- return -(pt - point_on_line);
2750-}
2751-
2752-double SPGuide::getDistanceFrom(Geom::Point const &pt) const
2753-{
2754- return Geom::dot(pt - point_on_line, normal_to_line);
2755-}
2756-
2757-/**
2758- * \arg commit False indicates temporary moveto in response to motion event while dragging,
2759- * true indicates a "committing" version: in response to button release event after
2760- * dragging a guideline, or clicking OK in guide editing dialog.
2761- */
2762-void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit)
2763-{
2764- g_assert(SP_IS_GUIDE(&guide));
2765-
2766- for (GSList *l = guide.views; l != NULL; l = l->next) {
2767- sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line);
2768- }
2769-
2770- /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit
2771- case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
2772- if (commit) {
2773- //XML Tree being used here directly while it shouldn't be.
2774- sp_repr_set_point(guide.getRepr(), "position", point_on_line);
2775- }
2776-
2777-/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
2778- for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
2779- iEnd(guide.attached_items.end());
2780- i != iEnd; ++i)
2781- {
2782- SPGuideAttachment const &att = *i;
2783- sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
2784- }
2785-*/
2786-}
2787-
2788-/**
2789- * \arg commit False indicates temporary moveto in response to motion event while dragging,
2790- * true indicates a "committing" version: in response to button release event after
2791- * dragging a guideline, or clicking OK in guide editing dialog.
2792- */
2793-void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit)
2794-{
2795- g_assert(SP_IS_GUIDE(&guide));
2796-
2797- for (GSList *l = guide.views; l != NULL; l = l->next) {
2798- sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line);
2799- }
2800-
2801- /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
2802- case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
2803- if (commit) {
2804- //XML Tree being used directly while it shouldn't be
2805- sp_repr_set_point(guide.getRepr(), "orientation", normal_to_line);
2806- }
2807-
2808-/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
2809- for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
2810- iEnd(guide.attached_items.end());
2811- i != iEnd; ++i)
2812- {
2813- SPGuideAttachment const &att = *i;
2814- sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
2815- }
2816-*/
2817-}
2818-
2819-void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit)
2820-{
2821- g_assert(SP_IS_GUIDE(&guide));
2822- guide.color = (r << 24) | (g << 16) | (b << 8) | 0x7f;
2823-
2824- if (guide.views){
2825- sp_guideline_set_color(SP_GUIDELINE(guide.views->data), guide.color);
2826- }
2827-
2828- if (commit){
2829- std::ostringstream os;
2830- os << "rgb(" << r << "," << g << "," << b << ")";
2831- //XML Tree being used directly while it shouldn't be
2832- guide.getRepr()->setAttribute("inkscape:color", os.str().c_str());
2833- }
2834-}
2835-
2836-void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit)
2837-{
2838- g_assert(SP_IS_GUIDE(&guide));
2839- if (guide.views){
2840- sp_guideline_set_label(SP_GUIDELINE(guide.views->data), label);
2841- }
2842-
2843- if (commit){
2844- //XML Tree being used directly while it shouldn't be
2845- guide.getRepr()->setAttribute("inkscape:label", label);
2846- }
2847-}
2848-
2849-/**
2850- * Returns a human-readable description of the guideline for use in dialog boxes and status bar.
2851- * If verbose is false, only positioning information is included (useful for dialogs).
2852- *
2853- * The caller is responsible for freeing the string.
2854- */
2855-char *sp_guide_description(SPGuide const *guide, const bool verbose)
2856-{
2857- using Geom::X;
2858- using Geom::Y;
2859-
2860- char *descr = 0;
2861- if ( !guide->document ) {
2862- // Guide has probably been deleted and no longer has an attached namedview.
2863- descr = g_strdup_printf("%s", _("Deleted"));
2864- } else {
2865- SPNamedView *namedview = sp_document_namedview(guide->document, NULL);
2866-
2867- Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(guide->point_on_line[X], "px");
2868- Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(guide->point_on_line[Y], "px");
2869- GString *position_string_x = g_string_new(x_q.string(namedview->doc_units).c_str());
2870- GString *position_string_y = g_string_new(y_q.string(namedview->doc_units).c_str());
2871-
2872- gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete"));
2873-
2874- if ( are_near(guide->normal_to_line, Geom::Point(1., 0.)) ||
2875- are_near(guide->normal_to_line, -Geom::Point(1., 0.)) ) {
2876- descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str);
2877- } else if ( are_near(guide->normal_to_line, Geom::Point(0., 1.)) ||
2878- are_near(guide->normal_to_line, -Geom::Point(0., 1.)) ) {
2879- descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str);
2880- } else {
2881- double const radians = guide->angle();
2882- double const degrees = Geom::rad_to_deg(radians);
2883- int const degrees_int = (int) round(degrees);
2884- descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"),
2885- degrees_int, position_string_x->str, position_string_y->str);
2886- }
2887-
2888- g_string_free(position_string_x, TRUE);
2889- g_string_free(position_string_y, TRUE);
2890-
2891- if (verbose) {
2892- gchar *oldDescr = descr;
2893- descr = g_strconcat(oldDescr, shortcuts, NULL);
2894- g_free(oldDescr);
2895- }
2896- g_free(shortcuts);
2897- }
2898-
2899- return descr;
2900-}
2901-
2902-void sp_guide_remove(SPGuide *guide)
2903-{
2904- g_assert(SP_IS_GUIDE(guide));
2905-
2906- for (vector<SPGuideAttachment>::const_iterator i(guide->attached_items.begin()),
2907- iEnd(guide->attached_items.end());
2908- i != iEnd; ++i)
2909- {
2910- SPGuideAttachment const &att = *i;
2911- remove_last(att.item->constraints, SPGuideConstraint(guide, att.snappoint_ix));
2912- }
2913- guide->attached_items.clear();
2914-
2915- //XML Tree being used directly while it shouldn't be.
2916- sp_repr_unparent(guide->getRepr());
2917-}
2918-
2919-/*
2920- Local Variables:
2921- mode:c++
2922- c-file-style:"stroustrup"
2923- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
2924- indent-tabs-mode:nil
2925- fill-column:99
2926- End:
2927-*/
2928-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
2929
2930=== removed file 'src/sp-guide.h'
2931--- src/sp-guide.h 2014-03-27 01:33:44 +0000
2932+++ src/sp-guide.h 1970-01-01 00:00:00 +0000
2933@@ -1,88 +0,0 @@
2934-#ifndef SEEN_SP_GUIDE_H
2935-#define SEEN_SP_GUIDE_H
2936-
2937-/*
2938- * SPGuide
2939- *
2940- * A guideline
2941- *
2942- * Copyright (C) Lauris Kaplinski 2000
2943- * Copyright (C) Johan Engelen 2007
2944- * Abhishek Sharma
2945- * Jon A. Cruz <jon@joncruz.org>
2946- *
2947- */
2948-
2949-#include <vector>
2950-
2951-#include <2geom/point.h>
2952-#include "sp-object.h"
2953-#include "sp-guide-attachment.h"
2954-
2955-struct SPCanvas;
2956-struct SPCanvasGroup;
2957-class SPDesktop;
2958-
2959-#define SP_GUIDE(obj) (dynamic_cast<SPGuide*>((SPObject*)obj))
2960-#define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj) != NULL)
2961-
2962-/* Represents the constraint on p that dot(g.direction, p) == g.position. */
2963-class SPGuide : public SPObject {
2964-public:
2965- SPGuide();
2966- virtual ~SPGuide();
2967-
2968- char* label;
2969- Geom::Point normal_to_line;
2970- Geom::Point point_on_line;
2971-
2972- guint32 color;
2973- guint32 hicolor;
2974- GSList *views;
2975- std::vector<SPGuideAttachment> attached_items;
2976-
2977- guint32 getColor() const;
2978- guint32 getHiColor() const;
2979- void setColor(guint32 c);
2980- void setHiColor(guint32 h);
2981-
2982- inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); };
2983- inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); };
2984- inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
2985- static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2);
2986- void showSPGuide(SPCanvasGroup *group, GCallback handler);
2987- void hideSPGuide(SPCanvas *canvas);
2988- void sensitize(SPCanvas *canvas, gboolean sensitive);
2989- Geom::Point getPositionFrom(Geom::Point const &pt) const;
2990- double getDistanceFrom(Geom::Point const &pt) const;
2991-
2992-protected:
2993- virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
2994- virtual void release();
2995- virtual void set(unsigned int key, const gchar* value);
2996-};
2997-
2998-void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
2999-void sp_guide_create_guides_around_page(SPDesktop *dt);
3000-void sp_guide_delete_all_guides(SPDesktop *dt);
3001-
3002-void sp_guide_moveto(SPGuide &guide, Geom::Point const point_on_line, bool const commit);
3003-void sp_guide_set_normal(SPGuide &guide, Geom::Point const normal_to_line, bool const commit);
3004-void sp_guide_set_label(SPGuide &guide, const char* label, bool const commit);
3005-void sp_guide_set_color(SPGuide &guide, const unsigned r, const unsigned g, const unsigned b, bool const commit);
3006-void sp_guide_remove(SPGuide *guide);
3007-
3008-char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
3009-
3010-#endif // SEEN_SP_GUIDE_H
3011-
3012-/*
3013- Local Variables:
3014- mode:c++
3015- c-file-style:"stroustrup"
3016- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
3017- indent-tabs-mode:nil
3018- fill-column:99
3019- End:
3020-*/
3021-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
3022
3023=== modified file 'src/sp-item-notify-moveto.cpp'
3024--- src/sp-item-notify-moveto.cpp 2014-03-27 01:33:44 +0000
3025+++ src/sp-item-notify-moveto.cpp 2014-09-23 18:22:24 +0000
3026@@ -4,7 +4,7 @@
3027
3028 #include <sp-item.h>
3029 #include <2geom/transforms.h>
3030-#include <sp-guide.h>
3031+#include <display/canvas-guide.h>
3032 #include <sp-item-rm-unsatisfied-cns.h>
3033 #include <sp-item-notify-moveto.h>
3034 using std::vector;
3035
3036=== modified file 'src/sp-item-rm-unsatisfied-cns.cpp'
3037--- src/sp-item-rm-unsatisfied-cns.cpp 2014-03-27 01:33:44 +0000
3038+++ src/sp-item-rm-unsatisfied-cns.cpp 2014-09-23 18:22:24 +0000
3039@@ -3,7 +3,7 @@
3040 #include <2geom/coord.h>
3041
3042 #include "remove-last.h"
3043-#include "sp-guide.h"
3044+#include "display/canvas-guide.h"
3045 #include "sp-guide-constraint.h"
3046 #include "sp-item.h"
3047 #include "sp-item-rm-unsatisfied-cns.h"
3048
3049=== modified file 'src/sp-item-update-cns.cpp'
3050--- src/sp-item-update-cns.cpp 2014-03-27 01:33:44 +0000
3051+++ src/sp-item-update-cns.cpp 2014-09-23 18:22:24 +0000
3052@@ -1,9 +1,8 @@
3053-
3054 #include "satisfied-guide-cns.h"
3055 #include "sp-guide-constraint.h"
3056+#include "display/canvas-guide.h"
3057+#include "sp-item.h"
3058 #include "sp-item-update-cns.h"
3059-#include "sp-guide.h"
3060-#include "sp-item.h"
3061 #include <algorithm>
3062 using std::find;
3063 using std::vector;
3064
3065=== modified file 'src/sp-item.cpp'
3066--- src/sp-item.cpp 2014-08-26 20:38:14 +0000
3067+++ src/sp-item.cpp 2014-09-23 18:22:24 +0000
3068@@ -55,7 +55,7 @@
3069 #include "conditions.h"
3070 #include "sp-filter-reference.h"
3071 #include "filter-chemistry.h"
3072-#include "sp-guide.h"
3073+#include "display/canvas-guide.h"
3074 #include "sp-title.h"
3075 #include "sp-desc.h"
3076
3077@@ -1638,7 +1638,7 @@
3078 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
3079 int prefs_bbox = prefs->getInt("/tools/bounding_box", 0);
3080
3081- Geom::OptRect bbox = (prefs_bbox == 0) ? desktopVisualBounds() : desktopGeometricBounds();
3082+ Geom::OptRect bbox = (prefs_bbox == 0) ? documentVisualBounds() : documentGeometricBounds();
3083 if (!bbox) {
3084 g_warning ("Cannot determine item's bounding box during conversion to guides.\n");
3085 return;
3086
3087=== modified file 'src/sp-line.cpp'
3088--- src/sp-line.cpp 2014-03-27 01:33:44 +0000
3089+++ src/sp-line.cpp 2014-09-23 18:22:24 +0000
3090@@ -17,7 +17,7 @@
3091 #include "attributes.h"
3092 #include "style.h"
3093 #include "sp-line.h"
3094-#include "sp-guide.h"
3095+#include "display/canvas-guide.h"
3096 #include "display/curve.h"
3097 #include <glibmm/i18n.h>
3098 #include "xml/repr.h"
3099@@ -128,10 +128,11 @@
3100
3101 void SPLine::convert_to_guides() const {
3102 Geom::Point points[2];
3103- Geom::Affine const i2dt(this->i2dt_affine());
3104-
3105- points[0] = Geom::Point(this->x1.computed, this->y1.computed)*i2dt;
3106- points[1] = Geom::Point(this->x2.computed, this->y2.computed)*i2dt;
3107+
3108+ Geom::Affine const i2doc(this->i2doc_affine());
3109+
3110+ points[0] = Geom::Point(this->x1.computed, this->y1.computed)*i2doc;
3111+ points[1] = Geom::Point(this->x2.computed, this->y2.computed)*i2doc;
3112
3113 SPGuide::createSPGuide(this->document, points[0], points[1]);
3114 }
3115
3116=== modified file 'src/sp-namedview.cpp'
3117--- src/sp-namedview.cpp 2014-03-27 01:33:44 +0000
3118+++ src/sp-namedview.cpp 2014-09-23 18:22:24 +0000
3119@@ -14,14 +14,19 @@
3120 * Released under GNU GPL, read the file 'COPYING' for more information
3121 */
3122
3123+#ifdef HAVE_CONFIG_H
3124 #include "config.h"
3125+#endif
3126+
3127 #include <cstring>
3128 #include <string>
3129 #include "event-log.h"
3130 #include <2geom/transforms.h>
3131
3132+#include "display/guideline.h"
3133 #include "display/canvas-grid.h"
3134-#include "display/guideline.h"
3135+#include "display/canvas-guide.h"
3136+
3137 #include "util/units.h"
3138 #include "svg/svg-color.h"
3139 #include "xml/repr.h"
3140@@ -30,7 +35,6 @@
3141 #include "document-undo.h"
3142 #include "desktop-events.h"
3143 #include "desktop-handles.h"
3144-#include "sp-guide.h"
3145 #include "sp-item-group.h"
3146 #include "sp-namedview.h"
3147 #include "preferences.h"
3148@@ -38,6 +42,8 @@
3149 #include "conn-avoid-ref.h" // for defaultConnSpacing.
3150 #include "sp-root.h"
3151 #include <gtkmm/window.h>
3152+#include "guide-manager.h"
3153+
3154
3155 using Inkscape::DocumentUndo;
3156 using Inkscape::Util::unit_table;
3157@@ -1162,6 +1168,24 @@
3158 }
3159 }
3160
3161+// void SPNamedView::transformGuides(Geom::Affine const affine) {
3162+
3163+// for (GSList *l = guides; l != NULL; l = l->next) {
3164+// SPGuide &guide = *SP_GUIDE(l->data);
3165+
3166+// Geom::Point point_on_line = guide.point_on_line;
3167+// Geom::Point normal = guide.normal_to_line;
3168+
3169+// point_on_line *= affine;
3170+// normal = transform_normal(normal, affine);
3171+
3172+// sp_guide_moveto(guide, point_on_line, true);
3173+// sp_guide_set_normal(guide, normal, true);
3174+
3175+// // TODO attribute names should be changed as well.
3176+// }
3177+// }
3178+
3179 void SPNamedView::translateGrids(Geom::Translate const &tr) {
3180 for (GSList *l = grids; l != NULL; l = l->next) {
3181 Inkscape::CanvasGrid* g = reinterpret_cast<Inkscape::CanvasGrid*>(l->data);
3182@@ -1172,10 +1196,10 @@
3183 }
3184
3185 void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) {
3186- for(GSList *l = views; l; l = l->next) {
3187- SPDesktop *desktop = static_cast<SPDesktop *>(l->data);
3188- desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling);
3189- }
3190+ for (GSList *l = views; l; l = l->next) {
3191+ SPDesktop *desktop = static_cast<SPDesktop *>(l->data);
3192+ desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling);
3193+ }
3194 }
3195
3196
3197
3198=== modified file 'src/sp-namedview.h'
3199--- src/sp-namedview.h 2014-03-27 01:33:44 +0000
3200+++ src/sp-namedview.h 2014-09-23 18:22:24 +0000
3201@@ -22,11 +22,13 @@
3202 #include "document.h"
3203 #include "util/units.h"
3204
3205+
3206 namespace Inkscape {
3207- class CanvasGrid;
3208+class CanvasGrid;
3209 namespace Util {
3210 class Unit;
3211 }
3212+ class GuideManager;
3213 }
3214
3215 enum {
3216@@ -55,6 +57,7 @@
3217 gint window_maximized;
3218
3219 SnapManager snap_manager;
3220+ Inkscape::GuideManager *guide_manager;
3221 GSList * grids;
3222 bool grids_visible;
3223
3224@@ -86,6 +89,7 @@
3225
3226 void translateGuides(Geom::Translate const &translation);
3227 void translateGrids(Geom::Translate const &translation);
3228+ // void transformGuides(Geom::Affine const affine);
3229 void scrollAllDesktops(double dx, double dy, bool is_scrolling);
3230 void writeNewGrid(SPDocument *document,int gridtype);
3231 bool getSnapGlobal() const;
3232@@ -116,8 +120,9 @@
3233 void sp_namedview_document_from_window(SPDesktop *desktop);
3234 void sp_namedview_update_layers_from_document (SPDesktop *desktop);
3235
3236+void sp_namedview_show_grids(SPNamedView *namedview, bool show, bool dirty_document);
3237 void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr);
3238-void sp_namedview_show_grids(SPNamedView *namedview, bool show, bool dirty_document);
3239+void sp_namedview_convert_old_guides(SPNamedView * /*nv*/, SPDocument *document, Inkscape::XML::Node *repr);
3240 Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedview);
3241
3242
3243
3244=== modified file 'src/sp-path.cpp'
3245--- src/sp-path.cpp 2014-07-28 21:44:54 +0000
3246+++ src/sp-path.cpp 2014-09-23 18:22:24 +0000
3247@@ -37,7 +37,7 @@
3248 #include "attributes.h"
3249
3250 #include "sp-path.h"
3251-#include "sp-guide.h"
3252+#include "display/canvas-guide.h"
3253
3254 #include "document.h"
3255 #include "desktop.h"
3256@@ -107,7 +107,7 @@
3257
3258 std::list<std::pair<Geom::Point, Geom::Point> > pts;
3259
3260- Geom::Affine const i2dt(this->i2dt_affine());
3261+ Geom::Affine const i2doc(this->i2doc_affine());
3262 Geom::PathVector const & pv = this->_curve->get_pathvector();
3263
3264 for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
3265@@ -115,7 +115,7 @@
3266 // only add curves for straight line segments
3267 if( is_straight_curve(*cit) )
3268 {
3269- pts.push_back(std::make_pair(cit->initialPoint() * i2dt, cit->finalPoint() * i2dt));
3270+ pts.push_back(std::make_pair(cit->initialPoint() * i2doc, cit->finalPoint() * i2doc));
3271 }
3272 }
3273 }
3274
3275=== modified file 'src/sp-rect.cpp'
3276--- src/sp-rect.cpp 2014-03-27 01:33:44 +0000
3277+++ src/sp-rect.cpp 2014-09-23 18:22:24 +0000
3278@@ -26,7 +26,7 @@
3279 #include "sp-rect.h"
3280 #include <glibmm/i18n.h>
3281 #include "xml/repr.h"
3282-#include "sp-guide.h"
3283+#include "display/canvas-guide.h"
3284 #include "preferences.h"
3285
3286 #define noRECT_VERBOSE
3287@@ -529,12 +529,12 @@
3288
3289 std::list<std::pair<Geom::Point, Geom::Point> > pts;
3290
3291- Geom::Affine const i2dt(this->i2dt_affine());
3292+ Geom::Affine const i2doc(this->i2doc_affine());
3293
3294- Geom::Point A1(Geom::Point(this->x.computed, this->y.computed) * i2dt);
3295- Geom::Point A2(Geom::Point(this->x.computed, this->y.computed + this->height.computed) * i2dt);
3296- Geom::Point A3(Geom::Point(this->x.computed + this->width.computed, this->y.computed + this->height.computed) * i2dt);
3297- Geom::Point A4(Geom::Point(this->x.computed + this->width.computed, this->y.computed) * i2dt);
3298+ Geom::Point A1(Geom::Point(this->x.computed, this->y.computed) * i2doc);
3299+ Geom::Point A2(Geom::Point(this->x.computed, this->y.computed + this->height.computed) * i2doc);
3300+ Geom::Point A3(Geom::Point(this->x.computed + this->width.computed, this->y.computed + this->height.computed) * i2doc);
3301+ Geom::Point A4(Geom::Point(this->x.computed + this->width.computed, this->y.computed) * i2doc);
3302
3303 pts.push_back(std::make_pair(A1, A2));
3304 pts.push_back(std::make_pair(A2, A3));
3305
3306=== modified file 'src/ui/dialog/document-properties.cpp'
3307--- src/ui/dialog/document-properties.cpp 2014-09-08 17:13:03 +0000
3308+++ src/ui/dialog/document-properties.cpp 2014-09-23 18:22:24 +0000
3309@@ -19,13 +19,15 @@
3310 */
3311
3312 #ifdef HAVE_CONFIG_H
3313-# include <config.h>
3314+#include <config.h>
3315 #endif
3316
3317 #include "ui/widget/notebook-page.h"
3318 #include "document-properties.h"
3319 #include "display/canvas-grid.h"
3320+#include "display/canvas-guide.h"
3321 #include "document.h"
3322+#include "document-undo.h"
3323 #include "desktop-handles.h"
3324 #include "desktop.h"
3325 #include "inkscape.h"
3326@@ -43,8 +45,10 @@
3327 #include "ui/dialog/filedialog.h"
3328 #include "verbs.h"
3329 #include "widgets/icon.h"
3330+#include "ui/icon-names.h"
3331 #include "xml/node-event-vector.h"
3332 #include "xml/repr.h"
3333+#include "ui/widget/imagetoggler.h"
3334 #include <algorithm> // std::min
3335
3336 #include "rdf.h"
3337@@ -75,20 +79,20 @@
3338
3339 //---------------------------------------------------
3340
3341-static void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
3342-static void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
3343-static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
3344-
3345-static Inkscape::XML::NodeEventVector const _repr_events = {
3346- on_child_added, // child_added
3347- on_child_removed, // child_removed
3348- on_repr_attr_changed,
3349- NULL, // content_changed
3350- NULL // order_changed
3351+static void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void *data);
3352+
3353+static void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref,
3354+ void *data);
3355+
3356+static void on_repr_attr_changed(Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
3357+
3358+static Inkscape::XML::NodeEventVector const _repr_events = { on_child_added, // child_added
3359+ on_child_removed, // child_removed
3360+ on_repr_attr_changed, NULL, // content_changed
3361+ NULL // order_changed
3362 };
3363
3364-
3365-DocumentProperties& DocumentProperties::getInstance()
3366+DocumentProperties &DocumentProperties::getInstance()
3367 {
3368 DocumentProperties &instance = *new DocumentProperties();
3369 instance.init();
3370@@ -96,70 +100,112 @@
3371 return instance;
3372 }
3373
3374-DocumentProperties::DocumentProperties()
3375- : UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
3376- _page_page(Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))),
3377- _page_guides(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3378- _page_snap(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3379- _page_cms(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3380- _page_scripting(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3381- _page_external_scripts(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3382- _page_embedded_scripts(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3383- _page_metadata1(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3384- _page_metadata2(Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3385- //---------------------------------------------------------------
3386- _rcb_antialias(_("Use antialiasing"), _("If unset, no antialiasing will be done on the drawing"), "shape-rendering", _wr, false, NULL, NULL, NULL, "crispEdges"),
3387- _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false),
3388- _rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false),
3389- _rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false),
3390- _rcp_bg(_("Back_ground color:"), _("Background color"), _("Color of the page background. Note: transparency setting ignored while editing but used when exporting to bitmap."), "pagecolor", "inkscape:pageopacity", _wr),
3391- _rcp_bord(_("Border _color:"), _("Page border color"), _("Color of the page border"), "bordercolor", "borderopacity", _wr),
3392- _rum_deflt(_("Default _units:"), "inkscape:document-units", _wr),
3393- _page_sizer(_wr),
3394- //---------------------------------------------------------------
3395- //General snap options
3396- _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr),
3397- _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr),
3398- _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr),
3399- //---------------------------------------------------------------
3400- _rsu_sno(_("Snap _distance"), _("Snap only when _closer than:"), _("Always snap"),
3401- _("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"),
3402- _("If set, objects only snap to another object when it's within the range specified below"),
3403- "objecttolerance", _wr),
3404- //Options for snapping to grids
3405+DocumentProperties::DocumentProperties() :
3406+ UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
3407+ _page_page (Gtk::manage(new UI::Widget::NotebookPage(1, 1, true, true))),
3408+ _page_guides (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3409+ _page_snap (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3410+ _page_cms (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3411+ _page_scripting (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3412+ _page_external_scripts (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3413+ _page_embedded_scripts (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3414+ _page_metadata1 (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3415+ _page_metadata2 (Gtk::manage(new UI::Widget::NotebookPage(1, 1))),
3416+//---------------------------------------------------------------
3417+ _rcb_antialias(_("Use antialiasing"),
3418+ _("If unset, no antialiasing will be done on the drawing"),
3419+ "shape-rendering", _wr, false, NULL, NULL, NULL, "crispEdges"),
3420+
3421+ _rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"),
3422+ "showborder", _wr, false),
3423+
3424+ _rcb_bord(_("Border on _top of drawing"),
3425+ _("If set, border is always on top of the drawing"),
3426+ "borderlayer", _wr, false),
3427+
3428+ _rcb_shad(_("_Show border shadow"),
3429+ _("If set, page border shows a shadow on its right and lower side"),
3430+ "inkscape:showpageshadow", _wr, false),
3431+
3432+ _rcp_bg(_("Back_ground color:"), _("Background color"),
3433+ _("Color of the page background. Note: transparency setting ignored"
3434+ "while editing but used when exporting to bitmap."),
3435+ "pagecolor", "inkscape:pageopacity", _wr),
3436+
3437+ _rcp_bord(_("Border _color:"), _("Page border color"),
3438+ _("Color of the page border"), "bordercolor", "borderopacity", _wr),
3439+
3440+ _rum_deflt(_("Default _units:"), "inkscape:document-units", _wr),
3441+
3442+ _page_sizer(_wr),
3443+
3444+//---------------------------------------------------------------
3445+// General snap options
3446+// TODO: might have to clean these up, as might not used anymore.
3447+
3448+ _rcb_sgui(_("Show _guides"), _("Show or hide guides"), "showguides", _wr),
3449+
3450+ _rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"),
3451+ "guidecolor", "guideopacity", _wr),
3452+
3453+ _rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"),
3454+ _("Color of a guideline when it is under mouse"),
3455+ "guidehicolor", "guidehiopacity", _wr),
3456+//---------------------------------------------------------------
3457+ _rsu_sno(_("Snap _distance"), _("Snap only when _closer than:"),
3458+ _("Always snap"),
3459+ _("Snapping distance, in screen pixels, for snapping to objects"),
3460+ _("Always snap to objects, regardless of their distance"),
3461+ _("If set, objects only snap to another object when it's within the range specified below"),
3462+ "objecttolerance", _wr),
3463+// Options for snapping to grids
3464 _rsu_sn(_("Snap d_istance"), _("Snap only when c_loser than:"), _("Always snap"),
3465- _("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"),
3466- _("If set, objects only snap to a grid line when it's within the range specified below"),
3467- "gridtolerance", _wr),
3468- //Options for snapping to guides
3469+ _("Snapping distance, in screen pixels, for snapping to grid"),
3470+ _("Always snap to grids, regardless of the distance"),
3471+ _("If set, objects only snap to a grid line when it's within the range specified below"),
3472+ "gridtolerance", _wr),
3473+
3474+// Options for snapping to guides
3475 _rsu_gusn(_("Snap dist_ance"), _("Snap only when close_r than:"), _("Always snap"),
3476- _("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"),
3477- _("If set, objects only snap to a guide when it's within the range specified below"),
3478- "guidetolerance", _wr),
3479- //---------------------------------------------------------------
3480- _rcb_snclp(_("Snap to clip paths"), _("When snapping to paths, then also try snapping to clip paths"), "inkscape:snap-path-clip", _wr),
3481- _rcb_snmsk(_("Snap to mask paths"), _("When snapping to paths, then also try snapping to mask paths"), "inkscape:snap-path-mask", _wr),
3482- _rcb_perp(_("Snap perpendicularly"), _("When snapping to paths or guides, then also try snapping perpendicularly"), "inkscape:snap-perpendicular", _wr),
3483- _rcb_tang(_("Snap tangentially"), _("When snapping to paths or guides, then also try snapping tangentially"), "inkscape:snap-tangential", _wr),
3484- //---------------------------------------------------------------
3485- _grids_label_crea("", Gtk::ALIGN_START),
3486- _grids_button_new(C_("Grid", "_New"), _("Create new grid.")),
3487- _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")),
3488- _grids_label_def("", Gtk::ALIGN_START)
3489+ _("Snapping distance, in screen pixels, for snapping to guides"),
3490+ _("Always snap to guides, regardless of the distance"),
3491+ _("If set, objects only snap to a guide when it's within the range specified below"),
3492+ "guidetolerance", _wr),
3493+//---------------------------------------------------------------
3494+ _rcb_snclp(_("Snap to clip paths"),
3495+ _("When snapping to paths, then also try snapping to clip paths"),
3496+ "inkscape:snap-path-clip", _wr),
3497+
3498+ _rcb_snmsk(_("Snap to mask paths"),
3499+ _("When snapping to paths, then also try snapping to mask paths"),
3500+ "inkscape:snap-path-mask", _wr),
3501+
3502+ _rcb_perp(_("Snap perpendicularly"),
3503+ _("When snapping to paths or guides, then also try snapping perpendicularly"),
3504+ "inkscape:snap-perpendicular", _wr),
3505+
3506+ _rcb_tang(_("Snap tangentially"),
3507+ _("When snapping to paths or guides, then also try snapping tangentially"),
3508+ "inkscape:snap-tangential", _wr),
3509+//---------------------------------------------------------------
3510+ _grids_label_crea("", Gtk::ALIGN_START),
3511+ _grids_button_new(C_("Grid", "_New"), _("Create new grid.")),
3512+ _grids_button_remove(C_("Grid", "_Remove"), _("Remove selected grid.")),
3513+ _grids_label_def("", Gtk::ALIGN_START)
3514 {
3515- _getContents()->set_spacing (4);
3516+ _getContents()->set_spacing(4);
3517 _getContents()->pack_start(_notebook, true, true);
3518
3519- _notebook.append_page(*_page_page, _("Page"));
3520- _notebook.append_page(*_page_guides, _("Guides"));
3521- _notebook.append_page(_grids_vbox, _("Grids"));
3522- _notebook.append_page(*_page_snap, _("Snap"));
3523+ _notebook.append_page(*_page_page, _("Page"));
3524+ _notebook.append_page(*_page_guides, _("Guides"));
3525+ _notebook.append_page(_grids_vbox, _("Grids"));
3526+ _notebook.append_page(*_page_snap, _("Snap"));
3527 _notebook.append_page(*_page_cms, _("Color"));
3528 _notebook.append_page(*_page_scripting, _("Scripting"));
3529 _notebook.append_page(*_page_metadata1, _("Metadata"));
3530 _notebook.append_page(*_page_metadata2, _("License"));
3531
3532- _wr.setUpdating (true);
3533+ _wr.setUpdating(true);
3534 build_page();
3535 build_guides();
3536 build_gridspage();
3537@@ -169,7 +215,9 @@
3538 #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
3539 build_scripting();
3540 build_metadata();
3541- _wr.setUpdating (false);
3542+ _wr.setUpdating(false);
3543+
3544+ _refresh_guidelist_button.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::populate_guides_list));
3545
3546 _grids_button_new.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onNewGrid));
3547 _grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
3548@@ -187,126 +235,138 @@
3549 update();
3550
3551 Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
3552- repr->addListener (&_repr_events, this);
3553+ repr->addListener(&_repr_events, this);
3554 Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr();
3555- root->addListener (&_repr_events, this);
3556+ root->addListener(&_repr_events, this);
3557
3558 show_all_children();
3559 _grids_button_remove.hide();
3560+ _guidelist.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
3561 }
3562
3563 DocumentProperties::~DocumentProperties()
3564 {
3565 Inkscape::XML::Node *repr = sp_desktop_namedview(getDesktop())->getRepr();
3566- repr->removeListenerByData (this);
3567+ repr->removeListenerByData(this);
3568 Inkscape::XML::Node *root = sp_desktop_document(getDesktop())->getRoot()->getRepr();
3569- root->removeListenerByData (this);
3570+ root->removeListenerByData(this);
3571
3572- for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it)
3573+ for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); ++it) {
3574 delete (*it);
3575+ }
3576 }
3577
3578 //========================================================================
3579
3580 /**
3581- * Helper function that attaches widgets in a 3xn table. The widgets come in an
3582- * array that has two entries per table row. The two entries code for four
3583- * possible cases: (0,0) means insert space in first column; (0, non-0) means
3584- * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
3585+ * Helper function that attaches widgets in a 3xn table. The widgets come in an array that has two
3586+ * entries per table row.
3587+ *
3588+ * The two entries describe the four possible cases:
3589+ *
3590+ * (0, 0) means insert space in first column.
3591+ *
3592+ * (0, non-0) means widget in columns 2-3.
3593+ *
3594+ * (non-0, 0) means label in columns 1-3.
3595+ *
3596 * (non-0, non-0) means two widgets in columns 2 and 3.
3597+ *
3598 */
3599 #if WITH_GTKMM_3_0
3600-inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0)
3601+inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0,
3602+ int docum_prop_flag = 0)
3603 #else
3604-inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0)
3605+inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0,
3606+ int docum_prop_flag = 0)
3607 #endif
3608 {
3609 for (unsigned i = 0, r = start; i < n; i += 2) {
3610- if (arr[i] && arr[i+1]) {
3611+ if (arr[i] && arr[i + 1]) {
3612 #if WITH_GTKMM_3_0
3613 arr[i]->set_hexpand();
3614- arr[i+1]->set_hexpand();
3615+ arr[i + 1]->set_hexpand();
3616 arr[i]->set_valign(Gtk::ALIGN_CENTER);
3617- arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
3618- table.attach(*arr[i], 1, r, 1, 1);
3619- table.attach(*arr[i+1], 2, r, 1, 1);
3620+ arr[i + 1]->set_valign(Gtk::ALIGN_CENTER);
3621+ table.attach(*arr[i], 1, r, 1, 1);
3622+ table.attach(*arr[i + 1], 2, r, 1, 1);
3623 #else
3624- table.attach(*arr[i], 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
3625- table.attach(*arr[i+1], 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
3626+ table.attach(*arr[i], 1, 2, r, r + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
3627+ table.attach(*arr[i + 1], 2, 3, r, r + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
3628 #endif
3629 } else {
3630- if (arr[i+1]) {
3631+ if (arr[i + 1]) {
3632 Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0;
3633- if (dynamic_cast<Inkscape::UI::Widget::PageSizer*>(arr[i+1])) {
3634+ if (dynamic_cast<Inkscape::UI::Widget::PageSizer *>(arr[i + 1])) {
3635 // only the PageSizer in Document Properties|Page should be stretched vertically
3636- yoptions = Gtk::FILL|Gtk::EXPAND;
3637+ yoptions = Gtk::FILL | Gtk::EXPAND;
3638 }
3639 if (docum_prop_flag) {
3640 // this sets the padding for subordinate widgets on the "Page" page
3641- if( i==(n-8) || i==(n-10) ) {
3642+ if (i == (n - 8) || i == (n - 10)) {
3643 #if WITH_GTKMM_3_0
3644- arr[i+1]->set_hexpand();
3645- arr[i+1]->set_margin_left(20);
3646- arr[i+1]->set_margin_right(20);
3647+ arr[i + 1]->set_hexpand();
3648+ arr[i + 1]->set_margin_left(20);
3649+ arr[i + 1]->set_margin_right(20);
3650
3651 if (yoptions & Gtk::EXPAND)
3652- arr[i+1]->set_vexpand();
3653+ arr[i + 1]->set_vexpand();
3654 else
3655- arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
3656+ arr[i + 1]->set_valign(Gtk::ALIGN_CENTER);
3657
3658- table.attach(*arr[i+1], 1, r, 2, 1);
3659+ table.attach(*arr[i + 1], 1, r, 2, 1);
3660 #else
3661- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0);
3662+ table.attach(*arr[i + 1], 1, 3, r, r + 1, Gtk::FILL | Gtk::EXPAND, yoptions, 20, 0);
3663 #endif
3664 } else {
3665 #if WITH_GTKMM_3_0
3666- arr[i+1]->set_hexpand();
3667+ arr[i + 1]->set_hexpand();
3668
3669 if (yoptions & Gtk::EXPAND)
3670- arr[i+1]->set_vexpand();
3671+ arr[i + 1]->set_vexpand();
3672 else
3673- arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
3674+ arr[i + 1]->set_valign(Gtk::ALIGN_CENTER);
3675
3676- table.attach(*arr[i+1], 1, r, 2, 1);
3677+ table.attach(*arr[i + 1], 1, r, 2, 1);
3678 #else
3679- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
3680+ table.attach(*arr[i + 1], 1, 3, r, r + 1, Gtk::FILL | Gtk::EXPAND, yoptions, 0, 0);
3681 #endif
3682 }
3683 } else {
3684 #if WITH_GTKMM_3_0
3685- arr[i+1]->set_hexpand();
3686-
3687+ arr[i + 1]->set_hexpand();
3688+
3689 if (yoptions & Gtk::EXPAND)
3690- arr[i+1]->set_vexpand();
3691+ arr[i + 1]->set_vexpand();
3692 else
3693- arr[i+1]->set_valign(Gtk::ALIGN_CENTER);
3694+ arr[i + 1]->set_valign(Gtk::ALIGN_CENTER);
3695
3696- table.attach(*arr[i+1], 1, r, 2, 1);
3697+ table.attach(*arr[i + 1], 1, r, 2, 1);
3698 #else
3699- table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0);
3700+ table.attach(*arr[i + 1], 1, 3, r, r + 1, Gtk::FILL | Gtk::EXPAND, yoptions, 0, 0);
3701 #endif
3702 }
3703 } else if (arr[i]) {
3704- Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]);
3705- label.set_alignment (0.0);
3706+ Gtk::Label &label = reinterpret_cast<Gtk::Label &>(*arr[i]);
3707+ label.set_alignment(0.0);
3708
3709 #if WITH_GTKMM_3_0
3710 label.set_hexpand();
3711 label.set_valign(Gtk::ALIGN_CENTER);
3712 table.attach(label, 0, r, 3, 1);
3713 #else
3714- table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
3715+ table.attach(label, 0, 3, r, r + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
3716 #endif
3717 } else {
3718- Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
3719- space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
3720+ Gtk::HBox *space = Gtk::manage(new Gtk::HBox);
3721+ space->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
3722
3723 #if WITH_GTKMM_3_0
3724 space->set_halign(Gtk::ALIGN_CENTER);
3725 space->set_valign(Gtk::ALIGN_CENTER);
3726 table.attach(*space, 0, r, 1, 1);
3727 #else
3728- table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
3729+ table.attach(*space, 0, 1, r, r + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0);
3730 #endif
3731 }
3732 }
3733@@ -318,20 +378,20 @@
3734 {
3735 _page_page->show();
3736
3737- Gtk::Label* label_gen = Gtk::manage (new Gtk::Label);
3738- label_gen->set_markup (_("<b>General</b>"));
3739- Gtk::Label *label_for = Gtk::manage (new Gtk::Label);
3740- label_for->set_markup (_("<b>Page Size</b>"));
3741- Gtk::Label* label_dsp = Gtk::manage (new Gtk::Label);
3742- label_dsp->set_markup (_("<b>Display</b>"));
3743+ Gtk::Label *label_gen = Gtk::manage(new Gtk::Label);
3744+ label_gen->set_markup(_("<b>General</b>"));
3745+ Gtk::Label *label_for = Gtk::manage(new Gtk::Label);
3746+ label_for->set_markup(_("<b>Page Size</b>"));
3747+ Gtk::Label *label_dsp = Gtk::manage(new Gtk::Label);
3748+ label_dsp->set_markup(_("<b>Display</b>"));
3749 _page_sizer.init();
3750
3751 Gtk::Widget *const widget_array[] =
3752 {
3753 label_gen, 0,
3754 0, &_rum_deflt,
3755- //label_col, 0,
3756- //_rcp_bg._label, &_rcp_bg,
3757+ // label_col, 0,
3758+ // _rcp_bg._label, &_rcp_bg,
3759 0, 0,
3760 label_for, 0,
3761 0, &_page_sizer,
3762@@ -345,76 +405,225 @@
3763 _rcp_bord._label, &_rcp_bord,
3764 };
3765
3766- std::list<Gtk::Widget*> _slaveList;
3767+ std::list<Gtk::Widget *> _slaveList;
3768 _slaveList.push_back(&_rcb_bord);
3769 _slaveList.push_back(&_rcb_shad);
3770 _rcb_canb.setSlaveWidgets(_slaveList);
3771
3772- attach_all(_page_page->table(), widget_array, G_N_ELEMENTS(widget_array),0,1);
3773+ attach_all(_page_page->table(), widget_array, G_N_ELEMENTS(widget_array), 0, 1);
3774+}
3775+
3776+void DocumentProperties::guides_page_config_buttons()
3777+{
3778+ _delete_guide_button.set_label(_("Delete"));
3779+ _delete_guide_button.set_image(*Gtk::manage(new Gtk::Image(Gtk::Stock::REMOVE, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
3780+ _delete_guide_button.set_tooltip_text(_("Delete guide"));
3781+ _delete_guide_button.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::delete_selected_guides));
3782+ _delete_guide_button.set_alignment(0.0, 0.0);
3783+
3784+ _refresh_guidelist_button.set_image(
3785+ *Gtk::manage(new Gtk::Image(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
3786+ _refresh_guidelist_button.set_tooltip_text(_("Refresh guide list"));
3787+ _refresh_guidelist_button.set_label(_("Refresh"));
3788+}
3789+
3790+void DocumentProperties::guides_page_attach_widgets()
3791+{
3792+#if WITH_GTKMM_3_0
3793+ // _page_guides->table().attach(*label_guidelist, 0, row++, 1, 1);
3794+ // _page_guides->table().attach(_guidelist_ListScroller, 0, row++, 1, 1);
3795+ // _page_guides->table().attach(_delete_guide_button, 0, row++, 1, 1);
3796+ // _page_guides->table().attach(_refresh_guidelist_button, 0, row, 1, 1);
3797+#else
3798+ Gtk::Label *label_gui = Gtk::manage(new Gtk::Label);
3799+ label_gui->set_markup(_("<b>Guides</b>"));
3800+
3801+ Gtk::Widget *const widget_array[] =
3802+ {
3803+ label_gui, 0,
3804+ 0, &_rcb_sgui,
3805+ _rcp_gui._label, &_rcp_gui,
3806+ _rcp_hgui._label, &_rcp_hgui
3807+ };
3808+
3809+ attach_all(_page_guides->table(), widget_array, G_N_ELEMENTS(widget_array));
3810+
3811+ Gtk::Label *label_guidelist = manage(new Gtk::Label("", Gtk::ALIGN_START));
3812+ label_guidelist->set_markup(_("<b>Guide list:</b>"));
3813+ label_guidelist->set_alignment(0.0);
3814+
3815+ Gtk::HBox *spacer = Gtk::manage(new Gtk::HBox());
3816+ spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
3817+
3818+ _page_guides->set_spacing(4);
3819+
3820+ gint row = 4;
3821+
3822+ _page_guides->table().attach(*label_guidelist, 0, 1, row, row + 1,
3823+ Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions) 0,
3824+ 0, 1);
3825+ row++;
3826+
3827+ _page_guides->table().attach(_guidelist_ListScroller, 0, 1, row, row + 1,
3828+ Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions) 0,
3829+ 0, 0);
3830+ row++;
3831+
3832+ _page_guides->table().attach(_delete_guide_button, 0, 1, row, row + 1,
3833+ (Gtk::AttachOptions) 0, (Gtk::AttachOptions) 0,
3834+ 0, 0);
3835+ row++;
3836+
3837+ _page_guides->table().attach(_refresh_guidelist_button, 0, 1, row, row + 1,
3838+ (Gtk::AttachOptions) 0, (Gtk::AttachOptions) 0,
3839+ 0, 0);
3840+#endif
3841+}
3842+
3843+void DocumentProperties::guides_page_config_guidelist()
3844+{
3845+ using Inkscape::UI::Widget::ImageToggler;
3846+
3847+ ImageToggler *visiblity_toggler =
3848+ Gtk::manage(new ImageToggler(INKSCAPE_ICON("object-visible"),
3849+ INKSCAPE_ICON("object-hidden")));
3850+
3851+ ImageToggler *lock_toggler =
3852+ Gtk::manage(new ImageToggler(INKSCAPE_ICON("object-locked"),
3853+ INKSCAPE_ICON("object-unlocked")));
3854+
3855+ _guidelist_ListStore = Gtk::ListStore::create(_guidelist_columns);
3856+ _guidelist.set_model(_guidelist_ListStore);
3857+ _guidelist.append_column("", *visiblity_toggler);
3858+ _guidelist.append_column("", *lock_toggler);
3859+ _guidelist.append_column(_("Guide id"), _guidelist_columns.guide_name_column);
3860+ _guidelist.set_headers_visible(false);
3861+
3862+ _guidelist_ListScroller.add(_guidelist);
3863+ _guidelist_ListScroller.set_shadow_type(Gtk::SHADOW_IN);
3864+ _guidelist_ListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
3865+ _guidelist_ListScroller.set_size_request(-1, 90);
3866 }
3867
3868 void DocumentProperties::build_guides()
3869 {
3870 _page_guides->show();
3871-
3872- Gtk::Label *label_gui = Gtk::manage (new Gtk::Label);
3873- label_gui->set_markup (_("<b>Guides</b>"));
3874-
3875- Gtk::Widget *const widget_array[] =
3876- {
3877- label_gui, 0,
3878- 0, &_rcb_sgui,
3879- _rcp_gui._label, &_rcp_gui,
3880- _rcp_hgui._label, &_rcp_hgui
3881- };
3882-
3883- attach_all(_page_guides->table(), widget_array, G_N_ELEMENTS(widget_array));
3884+ guides_page_config_buttons();
3885+ guides_page_attach_widgets();
3886+ guides_page_config_guidelist();
3887+ populate_guides_list();
3888+}
3889+
3890+void DocumentProperties::delete_guide_in_treeview_row(const Gtk::TreeModel::iterator &iter)
3891+{
3892+ SPDesktop *desktop = getDesktop();
3893+
3894+ if (!desktop) {
3895+ return;
3896+ }
3897+
3898+ SPDocument *document = sp_desktop_document(desktop);
3899+
3900+ if (!document) {
3901+ return;
3902+ }
3903+
3904+ Glib::ustring guide_id = (*iter)[_guidelist_columns.guide_id_column];
3905+
3906+ SPObject *guide = document->getObjectById(guide_id.c_str());
3907+
3908+ if (!SP_IS_GUIDE(guide)) {
3909+ return;
3910+ }
3911+ else {
3912+ sp_guide_remove((SPGuide *) guide);
3913+ DocumentUndo::maybeDone(document, "guide:delete",
3914+ SP_VERB_NONE, _("Delete selected guides."));
3915+ }
3916+}
3917+
3918+void DocumentProperties::delete_selected_guides()
3919+{
3920+ _guidelist.get_selection()->selected_foreach_iter
3921+ (sigc::mem_fun(*this, &DocumentProperties::delete_guide_in_treeview_row));
3922+
3923+ populate_guides_list();
3924+}
3925+
3926+void DocumentProperties::populate_guides_list()
3927+{
3928+ SPDesktop *desktop = getDesktop();
3929+
3930+ if (!desktop) {
3931+ return;
3932+ }
3933+
3934+ SPNamedView *named_view = sp_desktop_namedview(desktop);
3935+
3936+ if (!named_view) {
3937+ return;
3938+ }
3939+
3940+ _guidelist_ListStore->clear();
3941+
3942+ for (SPObject *object = named_view->firstChild(); object; object = object->getNext()) {
3943+
3944+ if (SP_IS_GUIDE(object)) {
3945+
3946+ SPGuide *guide = SP_GUIDE(object);
3947+ Gtk::TreeModel::Row row = *(_guidelist_ListStore->append());
3948+
3949+ const gchar *guide_id = guide->getAttribute("id");
3950+
3951+ if (guide_id) {
3952+
3953+ if (guide->label != NULL) {
3954+ row[_guidelist_columns.guide_name_column] = guide->label;
3955+ }
3956+ else {
3957+ row[_guidelist_columns.guide_name_column] = guide_id;
3958+ }
3959+
3960+ row[_guidelist_columns.guide_id_column] = guide_id;
3961+ }
3962+ }
3963+ }
3964 }
3965
3966 void DocumentProperties::build_snap()
3967 {
3968 _page_snap->show();
3969
3970- Gtk::Label *label_o = Gtk::manage (new Gtk::Label);
3971- label_o->set_markup (_("<b>Snap to objects</b>"));
3972- Gtk::Label *label_gr = Gtk::manage (new Gtk::Label);
3973- label_gr->set_markup (_("<b>Snap to grids</b>"));
3974- Gtk::Label *label_gu = Gtk::manage (new Gtk::Label);
3975- label_gu->set_markup (_("<b>Snap to guides</b>"));
3976- Gtk::Label *label_m = Gtk::manage (new Gtk::Label);
3977- label_m->set_markup (_("<b>Miscellaneous</b>"));
3978+ Gtk::Label *label_o = Gtk::manage(new Gtk::Label);
3979+ label_o->set_markup(_("<b>Snap to objects</b>"));
3980+ Gtk::Label *label_gr = Gtk::manage(new Gtk::Label);
3981+ label_gr->set_markup(_("<b>Snap to grids</b>"));
3982+ Gtk::Label *label_gu = Gtk::manage(new Gtk::Label);
3983+ label_gu->set_markup(_("<b>Snap to guides</b>"));
3984+ Gtk::Label *label_m = Gtk::manage(new Gtk::Label);
3985+ label_m->set_markup(_("<b>Miscellaneous</b>"));
3986
3987- Gtk::Widget *const array[] =
3988- {
3989- label_o, 0,
3990- 0, _rsu_sno._vbox,
3991- 0, &_rcb_snclp,
3992- 0, &_rcb_snmsk,
3993- 0, 0,
3994- label_gr, 0,
3995- 0, _rsu_sn._vbox,
3996- 0, 0,
3997- label_gu, 0,
3998- 0, _rsu_gusn._vbox,
3999- 0, 0,
4000- label_m, 0,
4001- 0, &_rcb_perp,
4002- 0, &_rcb_tang
4003- };
4004+ Gtk::Widget *const array[] = { label_o, 0, 0, _rsu_sno._vbox, 0, &_rcb_snclp,
4005+ 0, &_rcb_snmsk, 0, 0, label_gr, 0,
4006+ 0, _rsu_sn._vbox, 0, 0, label_gu, 0,
4007+ 0, _rsu_gusn._vbox, 0, 0, label_m, 0,
4008+ 0, &_rcb_perp, 0, &_rcb_tang };
4009
4010 attach_all(_page_snap->table(), array, G_N_ELEMENTS(array));
4011- }
4012+}
4013
4014 #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
4015 /// Populates the available color profiles combo box
4016-void DocumentProperties::populate_available_profiles(){
4017+void DocumentProperties::populate_available_profiles()
4018+{
4019 _combo_avail.remove_all(); // Clear any existing items in the combo box
4020
4021 // Iterate through the list of profiles and add the name to the combo box.
4022 std::vector<std::pair<Glib::ustring, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames();
4023- for ( std::vector<std::pair<Glib::ustring, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end(); ++it ) {
4024+ for (std::vector<std::pair<Glib::ustring, Glib::ustring> >::const_iterator it = pairs.begin(); it != pairs.end();
4025+ ++it) {
4026 Glib::ustring name = it->second;
4027- _combo_avail.append(name);
4028+ _combo_avail.append(name);
4029 }
4030 }
4031
4032@@ -422,29 +631,21 @@
4033 * Cleans up name to remove disallowed characters.
4034 * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj
4035 * Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z'
4036- * Allowed ASCII remaining chars add: '-', '.', '0'-'9',
4037+ * Allowed ASCII remaining chars add: '-', '.', '0'-'9',
4038 *
4039 * @param str the string to clean up.
4040 */
4041-static void sanitizeName( Glib::ustring& str )
4042+static void sanitizeName(Glib::ustring &str)
4043 {
4044 if (str.size() > 1) {
4045 char val = str.at(0);
4046- if (((val < 'A') || (val > 'Z'))
4047- && ((val < 'a') || (val > 'z'))
4048- && (val != '_')
4049- && (val != ':')) {
4050+ if (((val < 'A') || (val > 'Z')) && ((val < 'a') || (val > 'z')) && (val != '_') && (val != ':')) {
4051 str.replace(0, 1, "-");
4052 }
4053 for (Glib::ustring::size_type i = 1; i < str.size(); i++) {
4054 char val = str.at(i);
4055- if (((val < 'A') || (val > 'Z'))
4056- && ((val < 'a') || (val > 'z'))
4057- && ((val < '0') || (val > '9'))
4058- && (val != '_')
4059- && (val != ':')
4060- && (val != '-')
4061- && (val != '.')) {
4062+ if (((val < 'A') || (val > 'Z')) && ((val < 'a') || (val > 'z')) && ((val < '0') || (val > '9')) &&
4063+ (val != '_') && (val != ':') && (val != '-') && (val != '.')) {
4064 str.replace(i, 1, "-");
4065 }
4066 }
4067@@ -454,36 +655,36 @@
4068 /// Links the selected color profile in the combo box to the document
4069 void DocumentProperties::linkSelectedProfile()
4070 {
4071-//store this profile in the SVG document (create <color-profile> element in the XML)
4072+ // store this profile in the SVG document (create <color-profile> element in the XML)
4073 // TODO remove use of 'active' desktop
4074 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
4075- if (!desktop){
4076+ if (!desktop) {
4077 g_warning("No active desktop");
4078 } else {
4079- // Find the index of the currently-selected row in the color profiles combobox
4080- int row = _combo_avail.get_active_row_number();
4081+ // Find the index of the currently-selected row in the color profiles combobox
4082+ int row = _combo_avail.get_active_row_number();
4083
4084- if (row == -1){
4085+ if (row == -1) {
4086 g_warning("No color profile available.");
4087 return;
4088 }
4089-
4090- // Read the filename and description from the list of available profiles
4091- std::vector<std::pair<Glib::ustring, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames();
4092+
4093+ // Read the filename and description from the list of available profiles
4094+ std::vector<std::pair<Glib::ustring, Glib::ustring> > pairs = ColorProfile::getProfileFilesWithNames();
4095 Glib::ustring file = pairs[row].first;
4096 Glib::ustring name = pairs[row].second;
4097
4098 Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
4099 Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile");
4100- gchar* tmp = g_strdup(name.c_str());
4101+ gchar *tmp = g_strdup(name.c_str());
4102 Glib::ustring nameStr = tmp ? tmp : "profile"; // TODO add some auto-numbering to avoid collisions
4103 sanitizeName(nameStr);
4104 cprofRepr->setAttribute("name", nameStr.c_str());
4105- cprofRepr->setAttribute("xlink:href", (gchar*) file.c_str());
4106+ cprofRepr->setAttribute("xlink:href", (gchar *)file.c_str());
4107
4108 // Checks whether there is a defs element. Creates it when needed
4109 Inkscape::XML::Node *defsRepr = sp_repr_lookup_name(xml_doc, "svg:defs");
4110- if (!defsRepr){
4111+ if (!defsRepr) {
4112 defsRepr = xml_doc->createElement("svg:defs");
4113 xml_doc->root()->addChild(defsRepr, NULL);
4114 }
4115@@ -492,7 +693,7 @@
4116 defsRepr->addChild(cprofRepr, NULL);
4117
4118 // TODO check if this next line was sometimes needed. It being there caused an assertion.
4119- //Inkscape::GC::release(defsRepr);
4120+ // Inkscape::GC::release(defsRepr);
4121
4122 // inform the document, so we can undo
4123 DocumentUndo::done(desktop->doc(), SP_VERB_EDIT_LINK_COLOR_PROFILE, _("Link Color Profile"));
4124@@ -504,44 +705,44 @@
4125 void DocumentProperties::populate_linked_profiles_box()
4126 {
4127 _LinkedProfilesListStore->clear();
4128- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" );
4129+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile");
4130 if (current) {
4131 _emb_profiles_observer.set(SP_OBJECT(current->data)->parent);
4132 }
4133- while ( current ) {
4134- SPObject* obj = SP_OBJECT(current->data);
4135- Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
4136+ while (current) {
4137+ SPObject *obj = SP_OBJECT(current->data);
4138+ Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj);
4139 Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append());
4140 row[_LinkedProfilesListColumns.nameColumn] = prof->name;
4141-// row[_LinkedProfilesListColumns.previewColumn] = "Color Preview";
4142+ // row[_LinkedProfilesListColumns.previewColumn] = "Color Preview";
4143 current = g_slist_next(current);
4144 }
4145 }
4146
4147-void DocumentProperties::external_scripts_list_button_release(GdkEventButton* event)
4148+void DocumentProperties::external_scripts_list_button_release(GdkEventButton *event)
4149 {
4150- if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4151+ if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4152 _ExternalScriptsContextMenu.popup(event->button, event->time);
4153 }
4154 }
4155
4156-void DocumentProperties::embedded_scripts_list_button_release(GdkEventButton* event)
4157+void DocumentProperties::embedded_scripts_list_button_release(GdkEventButton *event)
4158 {
4159- if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4160+ if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4161 _EmbeddedScriptsContextMenu.popup(event->button, event->time);
4162 }
4163 }
4164
4165-void DocumentProperties::linked_profiles_list_button_release(GdkEventButton* event)
4166+void DocumentProperties::linked_profiles_list_button_release(GdkEventButton *event)
4167 {
4168- if((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4169+ if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 3)) {
4170 _EmbProfContextMenu.popup(event->button, event->time);
4171 }
4172 }
4173
4174-void DocumentProperties::cms_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
4175+void DocumentProperties::cms_create_popup_menu(Gtk::Widget &parent, sigc::slot<void> rem)
4176 {
4177- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4178+ Gtk::MenuItem *mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4179 _EmbProfContextMenu.append(*mi);
4180 mi->signal_activate().connect(rem);
4181 mi->show();
4182@@ -549,18 +750,18 @@
4183 }
4184
4185
4186-void DocumentProperties::external_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
4187+void DocumentProperties::external_create_popup_menu(Gtk::Widget &parent, sigc::slot<void> rem)
4188 {
4189- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4190+ Gtk::MenuItem *mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4191 _ExternalScriptsContextMenu.append(*mi);
4192 mi->signal_activate().connect(rem);
4193 mi->show();
4194 _ExternalScriptsContextMenu.accelerate(parent);
4195 }
4196
4197-void DocumentProperties::embedded_create_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem)
4198+void DocumentProperties::embedded_create_popup_menu(Gtk::Widget &parent, sigc::slot<void> rem)
4199 {
4200- Gtk::MenuItem* mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4201+ Gtk::MenuItem *mi = Gtk::manage(new Gtk::ImageMenuItem(Gtk::Stock::REMOVE));
4202 _EmbeddedScriptsContextMenu.append(*mi);
4203 mi->signal_activate().connect(rem);
4204 mi->show();
4205@@ -571,30 +772,31 @@
4206 {
4207 Glib::RefPtr<Gtk::TreeSelection> sel = _LinkedProfilesList.get_selection();
4208 if (sel) {
4209- _unlink_btn.set_sensitive(sel->count_selected_rows () > 0);
4210+ _unlink_btn.set_sensitive(sel->count_selected_rows() > 0);
4211 }
4212 }
4213
4214
4215-void DocumentProperties::removeSelectedProfile(){
4216+void DocumentProperties::removeSelectedProfile()
4217+{
4218 Glib::ustring name;
4219- if(_LinkedProfilesList.get_selection()) {
4220+ if (_LinkedProfilesList.get_selection()) {
4221 Gtk::TreeModel::iterator i = _LinkedProfilesList.get_selection()->get_selected();
4222
4223- if(i){
4224+ if (i) {
4225 name = (*i)[_LinkedProfilesListColumns.nameColumn];
4226 } else {
4227 return;
4228 }
4229 }
4230
4231- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" );
4232- while ( current ) {
4233- SPObject* obj = SP_OBJECT(current->data);
4234- Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
4235- if (!name.compare(prof->name)){
4236+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile");
4237+ while (current) {
4238+ SPObject *obj = SP_OBJECT(current->data);
4239+ Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj);
4240+ if (!name.compare(prof->name)) {
4241
4242- //XML Tree being used directly here while it shouldn't be.
4243+ // XML Tree being used directly here while it shouldn't be.
4244 sp_repr_unparent(obj->getRepr());
4245 DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile"));
4246 break; // removing the color profile likely invalidates part of the traversed list, stop traversing here.
4247@@ -609,10 +811,10 @@
4248 void DocumentProperties::build_cms()
4249 {
4250 _page_cms->show();
4251- Gtk::Label *label_link= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START));
4252- label_link->set_markup (_("<b>Linked Color Profiles:</b>"));
4253- Gtk::Label *label_avail = Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START));
4254- label_avail->set_markup (_("<b>Available Color Profiles:</b>"));
4255+ Gtk::Label *label_link = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
4256+ label_link->set_markup(_("<b>Linked Color Profiles:</b>"));
4257+ Gtk::Label *label_avail = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
4258+ label_avail->set_markup(_("<b>Available Color Profiles:</b>"));
4259
4260 _link_btn.set_tooltip_text(_("Link Profile"));
4261 #if WITH_GTKMM_3_10
4262@@ -642,7 +844,7 @@
4263 label_link->set_valign(Gtk::ALIGN_CENTER);
4264 _page_cms->table().attach(*label_link, 0, row, 3, 1);
4265 #else
4266- _page_cms->table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4267+ _page_cms->table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4268 #endif
4269
4270 row++;
4271@@ -652,12 +854,13 @@
4272 _LinkedProfilesListScroller.set_valign(Gtk::ALIGN_CENTER);
4273 _page_cms->table().attach(_LinkedProfilesListScroller, 0, row, 3, 1);
4274 #else
4275- _page_cms->table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4276+ _page_cms->table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4277+ (Gtk::AttachOptions)0, 0, 0);
4278 #endif
4279
4280 row++;
4281
4282- Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox());
4283+ Gtk::HBox *spacer = Gtk::manage(new Gtk::HBox());
4284 spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
4285
4286 #if WITH_GTKMM_3_0
4287@@ -665,7 +868,7 @@
4288 spacer->set_valign(Gtk::ALIGN_CENTER);
4289 _page_cms->table().attach(*spacer, 0, row, 3, 1);
4290 #else
4291- _page_cms->table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4292+ _page_cms->table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4293 #endif
4294
4295 row++;
4296@@ -677,7 +880,7 @@
4297 label_avail->set_valign(Gtk::ALIGN_CENTER);
4298 _page_cms->table().attach(*label_avail, 0, row, 3, 1);
4299 #else
4300- _page_cms->table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4301+ _page_cms->table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4302 #endif
4303
4304 row++;
4305@@ -697,7 +900,7 @@
4306 _unlink_btn.set_valign(Gtk::ALIGN_CENTER);
4307 _page_cms->table().attach(_unlink_btn, 2, row, 1, 1);
4308 #else
4309- _page_cms->table().attach(_combo_avail, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4310+ _page_cms->table().attach(_combo_avail, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4311 _page_cms->table().attach(_link_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0);
4312 _page_cms->table().attach(_unlink_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0);
4313 #endif
4314@@ -708,9 +911,9 @@
4315 _LinkedProfilesListStore = Gtk::ListStore::create(_LinkedProfilesListColumns);
4316 _LinkedProfilesList.set_model(_LinkedProfilesListStore);
4317 _LinkedProfilesList.append_column(_("Profile Name"), _LinkedProfilesListColumns.nameColumn);
4318-// _LinkedProfilesList.append_column(_("Color Preview"), _LinkedProfilesListColumns.previewColumn);
4319+ // _LinkedProfilesList.append_column(_("Color Preview"), _LinkedProfilesListColumns.previewColumn);
4320 _LinkedProfilesList.set_headers_visible(false);
4321-// TODO restore? _LinkedProfilesList.set_fixed_height_mode(true);
4322+ // TODO restore? _LinkedProfilesList.set_fixed_height_mode(true);
4323
4324 populate_linked_profiles_box();
4325
4326@@ -722,16 +925,19 @@
4327 _link_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::linkSelectedProfile));
4328 _unlink_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
4329
4330- _LinkedProfilesList.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &DocumentProperties::onColorProfileSelectRow) );
4331+ _LinkedProfilesList.get_selection()->signal_changed().connect(
4332+ sigc::mem_fun(*this, &DocumentProperties::onColorProfileSelectRow));
4333
4334- _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release));
4335+ _LinkedProfilesList.signal_button_release_event().connect_notify(
4336+ sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release));
4337 cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
4338
4339- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" );
4340+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("defs");
4341 if (current) {
4342 _emb_profiles_observer.set(SP_OBJECT(current->data)->parent);
4343 }
4344- _emb_profiles_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box));
4345+ _emb_profiles_observer.signal_changed().connect(
4346+ sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box));
4347 onColorProfileSelectRow();
4348 }
4349 #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
4350@@ -740,7 +946,7 @@
4351 {
4352 _page_scripting->show();
4353
4354- _page_scripting->set_spacing (4);
4355+ _page_scripting->set_spacing(4);
4356 _page_scripting->pack_start(_scripting_notebook, true, true);
4357
4358 _scripting_notebook.append_page(*_page_external_scripts, _("External scripts"));
4359@@ -748,8 +954,8 @@
4360
4361 //# External scripts tab
4362 _page_external_scripts->show();
4363- Gtk::Label *label_external= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START));
4364- label_external->set_markup (_("<b>External script files:</b>"));
4365+ Gtk::Label *label_external = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
4366+ label_external->set_markup(_("<b>External script files:</b>"));
4367
4368 _external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file"));
4369 #if WITH_GTKMM_3_10
4370@@ -779,7 +985,8 @@
4371 label_external->set_valign(Gtk::ALIGN_CENTER);
4372 _page_external_scripts->table().attach(*label_external, 0, row, 3, 1);
4373 #else
4374- _page_external_scripts->table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4375+ _page_external_scripts->table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4376+ (Gtk::AttachOptions)0, 0, 0);
4377 #endif
4378
4379 row++;
4380@@ -789,12 +996,13 @@
4381 _ExternalScriptsListScroller.set_valign(Gtk::ALIGN_CENTER);
4382 _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, row, 3, 1);
4383 #else
4384- _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4385+ _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4386+ (Gtk::AttachOptions)0, 0, 0);
4387 #endif
4388
4389 row++;
4390
4391- Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox());
4392+ Gtk::HBox *spacer_external = Gtk::manage(new Gtk::HBox());
4393 spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
4394
4395 #if WITH_GTKMM_3_0
4396@@ -802,7 +1010,8 @@
4397 spacer_external->set_valign(Gtk::ALIGN_CENTER);
4398 _page_external_scripts->table().attach(*spacer_external, 0, row, 3, 1);
4399 #else
4400- _page_external_scripts->table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4401+ _page_external_scripts->table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4402+ (Gtk::AttachOptions)0, 0, 0);
4403 #endif
4404
4405 row++;
4406@@ -822,9 +1031,12 @@
4407 _external_remove_btn.set_valign(Gtk::ALIGN_CENTER);
4408 _page_external_scripts->table().attach(_external_remove_btn, 2, row, 1, 1);
4409 #else
4410- _page_external_scripts->table().attach(_script_entry, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4411- _page_external_scripts->table().attach(_external_add_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0);
4412- _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0);
4413+ _page_external_scripts->table().attach(_script_entry, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4414+ (Gtk::AttachOptions)0, 0, 0);
4415+ _page_external_scripts->table().attach(_external_add_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0,
4416+ (Gtk::AttachOptions)0, 2, 0);
4417+ _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0,
4418+ (Gtk::AttachOptions)0, 0, 0);
4419 #endif
4420
4421 //# Set up the External Scripts box
4422@@ -832,13 +1044,13 @@
4423 _ExternalScriptsList.set_model(_ExternalScriptsListStore);
4424 _ExternalScriptsList.append_column(_("Filename"), _ExternalScriptsListColumns.filenameColumn);
4425 _ExternalScriptsList.set_headers_visible(true);
4426-// TODO restore? _ExternalScriptsList.set_fixed_height_mode(true);
4427+ // TODO restore? _ExternalScriptsList.set_fixed_height_mode(true);
4428
4429
4430 //# Embedded scripts tab
4431 _page_embedded_scripts->show();
4432- Gtk::Label *label_embedded= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START));
4433- label_embedded->set_markup (_("<b>Embedded script files:</b>"));
4434+ Gtk::Label *label_embedded = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
4435+ label_embedded->set_markup(_("<b>Embedded script files:</b>"));
4436
4437 _embed_new_btn.set_tooltip_text(_("New"));
4438 #if WITH_GTKMM_3_10
4439@@ -861,10 +1073,10 @@
4440 #if !WITH_GTKMM_3_0
4441 // TODO: This has been removed from Gtkmm 3.0. Check that
4442 // everything still looks OK!
4443- _embed_button_box.set_child_min_width( 16 );
4444- _embed_button_box.set_spacing( 4 );
4445+ _embed_button_box.set_child_min_width(16);
4446+ _embed_button_box.set_spacing(4);
4447 #endif
4448- _embed_button_box.set_layout (Gtk::BUTTONBOX_START);
4449+ _embed_button_box.set_layout(Gtk::BUTTONBOX_START);
4450 _embed_button_box.add(_embed_new_btn);
4451 _embed_button_box.add(_embed_remove_btn);
4452
4453@@ -878,7 +1090,8 @@
4454 label_embedded->set_valign(Gtk::ALIGN_CENTER);
4455 _page_embedded_scripts->table().attach(*label_embedded, 0, row, 3, 1);
4456 #else
4457- _page_embedded_scripts->table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4458+ _page_embedded_scripts->table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4459+ (Gtk::AttachOptions)0, 0, 0);
4460 #endif
4461
4462 row++;
4463@@ -888,7 +1101,8 @@
4464 _EmbeddedScriptsListScroller.set_valign(Gtk::ALIGN_CENTER);
4465 _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, row, 3, 1);
4466 #else
4467- _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4468+ _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4469+ (Gtk::AttachOptions)0, 0, 0);
4470 #endif
4471
4472 row++;
4473@@ -898,12 +1112,13 @@
4474 _embed_button_box.set_valign(Gtk::ALIGN_CENTER);
4475 _page_embedded_scripts->table().attach(_embed_button_box, 0, row, 1, 1);
4476 #else
4477- _page_embedded_scripts->table().attach(_embed_button_box, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4478+ _page_embedded_scripts->table().attach(_embed_button_box, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4479+ (Gtk::AttachOptions)0, 0, 0);
4480 #endif
4481
4482 row++;
4483
4484- Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox());
4485+ Gtk::HBox *spacer_embedded = Gtk::manage(new Gtk::HBox());
4486 spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
4487
4488 #if WITH_GTKMM_3_0
4489@@ -911,7 +1126,8 @@
4490 spacer_embedded->set_valign(Gtk::ALIGN_CENTER);
4491 _page_embedded_scripts->table().attach(*spacer_embedded, 0, row, 3, 1);
4492 #else
4493- _page_embedded_scripts->table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4494+ _page_embedded_scripts->table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4495+ (Gtk::AttachOptions)0, 0, 0);
4496 #endif
4497
4498 row++;
4499@@ -921,11 +1137,11 @@
4500 _EmbeddedScriptsList.set_model(_EmbeddedScriptsListStore);
4501 _EmbeddedScriptsList.append_column(_("Script id"), _EmbeddedScriptsListColumns.idColumn);
4502 _EmbeddedScriptsList.set_headers_visible(true);
4503-// TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true);
4504+ // TODO restore? _EmbeddedScriptsList.set_fixed_height_mode(true);
4505
4506 //# Set up the Embedded Scripts content box
4507- Gtk::Label *label_embedded_content= Gtk::manage (new Gtk::Label("", Gtk::ALIGN_START));
4508- label_embedded_content->set_markup (_("<b>Content:</b>"));
4509+ Gtk::Label *label_embedded_content = Gtk::manage(new Gtk::Label("", Gtk::ALIGN_START));
4510+ label_embedded_content->set_markup(_("<b>Content:</b>"));
4511
4512 label_embedded_content->set_alignment(0.0);
4513
4514@@ -934,7 +1150,8 @@
4515 label_embedded_content->set_valign(Gtk::ALIGN_CENTER);
4516 _page_embedded_scripts->table().attach(*label_embedded_content, 0, row, 3, 1);
4517 #else
4518- _page_embedded_scripts->table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4519+ _page_embedded_scripts->table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4520+ (Gtk::AttachOptions)0, 0, 0);
4521 #endif
4522
4523 row++;
4524@@ -944,7 +1161,8 @@
4525 _EmbeddedContentScroller.set_valign(Gtk::ALIGN_CENTER);
4526 _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, row, 3, 1);
4527 #else
4528- _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
4529+ _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4530+ (Gtk::AttachOptions)0, 0, 0);
4531 #endif
4532
4533 _EmbeddedContentScroller.add(_EmbeddedContent);
4534@@ -952,12 +1170,16 @@
4535 _EmbeddedContentScroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
4536 _EmbeddedContentScroller.set_size_request(-1, 140);
4537
4538- _EmbeddedScriptsList.signal_cursor_changed().connect(sigc::mem_fun(*this, &DocumentProperties::changeEmbeddedScript));
4539- _EmbeddedScriptsList.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &DocumentProperties::onEmbeddedScriptSelectRow) );
4540-
4541- _ExternalScriptsList.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &DocumentProperties::onExternalScriptSelectRow) );
4542-
4543- _EmbeddedContent.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::editEmbeddedScript));
4544+ _EmbeddedScriptsList.signal_cursor_changed().connect(
4545+ sigc::mem_fun(*this, &DocumentProperties::changeEmbeddedScript));
4546+ _EmbeddedScriptsList.get_selection()->signal_changed().connect(
4547+ sigc::mem_fun(*this, &DocumentProperties::onEmbeddedScriptSelectRow));
4548+
4549+ _ExternalScriptsList.get_selection()->signal_changed().connect(
4550+ sigc::mem_fun(*this, &DocumentProperties::onExternalScriptSelectRow));
4551+
4552+ _EmbeddedContent.get_buffer()->signal_changed().connect(
4553+ sigc::mem_fun(*this, &DocumentProperties::editEmbeddedScript));
4554
4555 populate_script_lists();
4556
4557@@ -980,15 +1202,17 @@
4558 _external_remove_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
4559 _embed_remove_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript));
4560
4561- _ExternalScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release));
4562+ _ExternalScriptsList.signal_button_release_event().connect_notify(
4563+ sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release));
4564 external_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
4565
4566- _EmbeddedScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::embedded_scripts_list_button_release));
4567+ _EmbeddedScriptsList.signal_button_release_event().connect_notify(
4568+ sigc::mem_fun(*this, &DocumentProperties::embedded_scripts_list_button_release));
4569 embedded_create_popup_menu(_EmbeddedScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeEmbeddedScript));
4570 #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
4571
4572-//TODO: review this observers code:
4573- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
4574+ // TODO: review this observers code:
4575+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("script");
4576 if (current) {
4577 _scripts_observer.set(SP_OBJECT(current->data)->parent);
4578 }
4579@@ -1003,26 +1227,26 @@
4580
4581 _page_metadata1->show();
4582
4583- Gtk::Label *label = Gtk::manage (new Gtk::Label);
4584- label->set_markup (_("<b>Dublin Core Entities</b>"));
4585- label->set_alignment (0.0);
4586+ Gtk::Label *label = Gtk::manage(new Gtk::Label);
4587+ label->set_markup(_("<b>Dublin Core Entities</b>"));
4588+ label->set_alignment(0.0);
4589
4590 #if WITH_GTKMM_3_0
4591 label->set_valign(Gtk::ALIGN_CENTER);
4592- _page_metadata1->table().attach (*label, 0,0,3,1);
4593+ _page_metadata1->table().attach(*label, 0, 0, 3, 1);
4594 #else
4595- _page_metadata1->table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4596+ _page_metadata1->table().attach(*label, 0, 3, 0, 1, Gtk::FILL, (Gtk::AttachOptions)0, 0, 0);
4597 #endif
4598
4599- /* add generic metadata entry areas */
4600- struct rdf_work_entity_t * entity;
4601+ /* add generic metadata entry areas */
4602+ struct rdf_work_entity_t *entity;
4603 int row = 1;
4604 for (entity = rdf_work_entities; entity && entity->name; entity++, row++) {
4605- if ( entity->editable == RDF_EDIT_GENERIC ) {
4606- EntityEntry *w = EntityEntry::create (entity, _wr);
4607- _rdflist.push_back (w);
4608- Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
4609- space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
4610+ if (entity->editable == RDF_EDIT_GENERIC) {
4611+ EntityEntry *w = EntityEntry::create(entity, _wr);
4612+ _rdflist.push_back(w);
4613+ Gtk::HBox *space = Gtk::manage(new Gtk::HBox);
4614+ space->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
4615
4616 #if WITH_GTKMM_3_0
4617 space->set_valign(Gtk::ALIGN_CENTER);
4618@@ -1035,22 +1259,23 @@
4619 w->_packable->set_valign(Gtk::ALIGN_CENTER);
4620 _page_metadata1->table().attach(*w->_packable, 2, row, 1, 1);
4621 #else
4622- _page_metadata1->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4623- _page_metadata1->table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4624- _page_metadata1->table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
4625+ _page_metadata1->table().attach(*space, 0, 1, row, row + 1, Gtk::FILL, (Gtk::AttachOptions)0, 0, 0);
4626+ _page_metadata1->table().attach(w->_label, 1, 2, row, row + 1, Gtk::FILL, (Gtk::AttachOptions)0, 0, 0);
4627+ _page_metadata1->table().attach(*w->_packable, 2, 3, row, row + 1, Gtk::FILL | Gtk::EXPAND,
4628+ (Gtk::AttachOptions)0, 0, 0);
4629 #endif
4630 }
4631 }
4632
4633- Gtk::Button *button_save = Gtk::manage (new Gtk::Button(_("_Save as default"),1));
4634+ Gtk::Button *button_save = Gtk::manage(new Gtk::Button(_("_Save as default"), 1));
4635 button_save->set_tooltip_text(_("Save this metadata as the default metadata"));
4636- Gtk::Button *button_load = Gtk::manage (new Gtk::Button(_("Use _default"),1));
4637+ Gtk::Button *button_load = Gtk::manage(new Gtk::Button(_("Use _default"), 1));
4638 button_load->set_tooltip_text(_("Use the previously saved default metadata here"));
4639
4640 #if WITH_GTKMM_3_0
4641- Gtk::ButtonBox *box_buttons = Gtk::manage (new Gtk::ButtonBox);
4642+ Gtk::ButtonBox *box_buttons = Gtk::manage(new Gtk::ButtonBox);
4643 #else
4644- Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox);
4645+ Gtk::HButtonBox *box_buttons = Gtk::manage(new Gtk::HButtonBox);
4646 #endif
4647
4648 box_buttons->set_layout(Gtk::BUTTONBOX_END);
4649@@ -1065,22 +1290,22 @@
4650 _page_metadata2->show();
4651
4652 row = 0;
4653- Gtk::Label *llabel = Gtk::manage (new Gtk::Label);
4654- llabel->set_markup (_("<b>License</b>"));
4655- llabel->set_alignment (0.0);
4656+ Gtk::Label *llabel = Gtk::manage(new Gtk::Label);
4657+ llabel->set_markup(_("<b>License</b>"));
4658+ llabel->set_alignment(0.0);
4659
4660 #if WITH_GTKMM_3_0
4661 llabel->set_valign(Gtk::ALIGN_CENTER);
4662 _page_metadata2->table().attach(*llabel, 0, row, 3, 1);
4663 #else
4664- _page_metadata2->table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4665+ _page_metadata2->table().attach(*llabel, 0, 3, row, row + 1, Gtk::FILL, (Gtk::AttachOptions)0, 0, 0);
4666 #endif
4667
4668 /* add license selector pull-down and URI */
4669 ++row;
4670- _licensor.init (_wr);
4671- Gtk::HBox *space = Gtk::manage (new Gtk::HBox);
4672- space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
4673+ _licensor.init(_wr);
4674+ Gtk::HBox *space = Gtk::manage(new Gtk::HBox);
4675+ space->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y);
4676
4677 #if WITH_GTKMM_3_0
4678 space->set_valign(Gtk::ALIGN_CENTER);
4679@@ -1090,12 +1315,14 @@
4680 _licensor.set_valign(Gtk::ALIGN_CENTER);
4681 _page_metadata2->table().attach(_licensor, 1, row, 3, 1);
4682 #else
4683- _page_metadata2->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4684- _page_metadata2->table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0);
4685+ _page_metadata2->table().attach(*space, 0, 1, row, row + 1, Gtk::FILL, (Gtk::AttachOptions)0, 0, 0);
4686+ _page_metadata2->table().attach(_licensor, 1, 3, row, row + 1, Gtk::EXPAND | Gtk::FILL, (Gtk::AttachOptions)0, 0,
4687+ 0);
4688 #endif
4689 }
4690
4691-void DocumentProperties::addExternalScript(){
4692+void DocumentProperties::addExternalScript()
4693+{
4694
4695 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
4696 if (!desktop) {
4697@@ -1103,7 +1330,7 @@
4698 return;
4699 }
4700
4701- if (_script_entry.get_text().empty() ) {
4702+ if (_script_entry.get_text().empty()) {
4703 // Click Add button with no filename, show a Browse dialog
4704 browseExternalScript();
4705 }
4706@@ -1112,7 +1339,7 @@
4707
4708 Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
4709 Inkscape::XML::Node *scriptRepr = xml_doc->createElement("svg:script");
4710- scriptRepr->setAttribute("xlink:href", (gchar*) _script_entry.get_text().c_str());
4711+ scriptRepr->setAttribute("xlink:href", (gchar *)_script_entry.get_text().c_str());
4712 _script_entry.set_text("");
4713
4714 xml_doc->root()->addChild(scriptRepr, NULL);
4715@@ -1122,12 +1349,12 @@
4716
4717 populate_script_lists();
4718 }
4719-
4720 }
4721
4722-static Inkscape::UI::Dialog::FileOpenDialog * selectPrefsFileInstance = NULL;
4723+static Inkscape::UI::Dialog::FileOpenDialog *selectPrefsFileInstance = NULL;
4724
4725-void DocumentProperties::browseExternalScript() {
4726+void DocumentProperties::browseExternalScript()
4727+{
4728
4729 //# Get the current directory for finding files
4730 static Glib::ustring open_path;
4731@@ -1135,16 +1362,15 @@
4732
4733
4734 Glib::ustring attr = prefs->getString(_prefs_path);
4735- if (!attr.empty()) open_path = attr;
4736+ if (!attr.empty())
4737+ open_path = attr;
4738
4739 //# Test if the open_path directory exists
4740- if (!Inkscape::IO::file_test(open_path.c_str(),
4741- (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
4742+ if (!Inkscape::IO::file_test(open_path.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
4743 open_path = "";
4744
4745 //# If no open path, default to our home directory
4746- if (open_path.empty())
4747- {
4748+ if (open_path.empty()) {
4749 open_path = g_get_home_dir();
4750 open_path.append(G_DIR_SEPARATOR_S);
4751 }
4752@@ -1152,12 +1378,8 @@
4753 //# Create a dialog
4754 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
4755 if (!selectPrefsFileInstance) {
4756- selectPrefsFileInstance =
4757- Inkscape::UI::Dialog::FileOpenDialog::create(
4758- *desktop->getToplevel(),
4759- open_path,
4760- Inkscape::UI::Dialog::CUSTOM_TYPE,
4761- _("Select a script to load"));
4762+ selectPrefsFileInstance = Inkscape::UI::Dialog::FileOpenDialog::create(
4763+ *desktop->getToplevel(), open_path, Inkscape::UI::Dialog::CUSTOM_TYPE, _("Select a script to load"));
4764 selectPrefsFileInstance->addFilterMenu("Javascript Files", "*.js");
4765 }
4766
4767@@ -1174,9 +1396,10 @@
4768 _script_entry.set_text(fileName);
4769 }
4770
4771-void DocumentProperties::addEmbeddedScript(){
4772+void DocumentProperties::addEmbeddedScript()
4773+{
4774 SPDesktop *desktop = SP_ACTIVE_DESKTOP;
4775- if (!desktop){
4776+ if (!desktop) {
4777 g_warning("No active desktop");
4778 } else {
4779 Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
4780@@ -1191,32 +1414,34 @@
4781 }
4782 }
4783
4784-void DocumentProperties::removeExternalScript(){
4785+void DocumentProperties::removeExternalScript()
4786+{
4787 Glib::ustring name;
4788- if(_ExternalScriptsList.get_selection()) {
4789+ if (_ExternalScriptsList.get_selection()) {
4790 Gtk::TreeModel::iterator i = _ExternalScriptsList.get_selection()->get_selected();
4791
4792- if(i){
4793+ if (i) {
4794 name = (*i)[_ExternalScriptsListColumns.filenameColumn];
4795 } else {
4796 return;
4797 }
4798 }
4799
4800- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
4801- while ( current ) {
4802+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("script");
4803+ while (current) {
4804 if (current->data && SP_IS_OBJECT(current->data)) {
4805- SPObject* obj = SP_OBJECT(current->data);
4806- SPScript* script = SP_SCRIPT(obj);
4807- if (name == script->xlinkhref){
4808+ SPObject *obj = SP_OBJECT(current->data);
4809+ SPScript *script = SP_SCRIPT(obj);
4810+ if (name == script->xlinkhref) {
4811
4812- //XML Tree being used directly here while it shouldn't be.
4813+ // XML Tree being used directly here while it shouldn't be.
4814 Inkscape::XML::Node *repr = obj->getRepr();
4815- if (repr){
4816+ if (repr) {
4817 sp_repr_unparent(repr);
4818
4819 // inform the document, so we can undo
4820- DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script"));
4821+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT,
4822+ _("Remove external script"));
4823 }
4824 }
4825 }
4826@@ -1226,23 +1451,24 @@
4827 populate_script_lists();
4828 }
4829
4830-void DocumentProperties::removeEmbeddedScript(){
4831+void DocumentProperties::removeEmbeddedScript()
4832+{
4833 Glib::ustring id;
4834- if(_EmbeddedScriptsList.get_selection()) {
4835+ if (_EmbeddedScriptsList.get_selection()) {
4836 Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected();
4837
4838- if(i){
4839+ if (i) {
4840 id = (*i)[_EmbeddedScriptsListColumns.idColumn];
4841 } else {
4842 return;
4843 }
4844 }
4845
4846- SPObject* obj = SP_ACTIVE_DOCUMENT->getObjectById(id);
4847+ SPObject *obj = SP_ACTIVE_DOCUMENT->getObjectById(id);
4848 if (obj) {
4849- //XML Tree being used directly here while it shouldn't be.
4850+ // XML Tree being used directly here while it shouldn't be.
4851 Inkscape::XML::Node *repr = obj->getRepr();
4852- if (repr){
4853+ if (repr) {
4854 sp_repr_unparent(repr);
4855
4856 // inform the document, so we can undo
4857@@ -1257,7 +1483,7 @@
4858 {
4859 Glib::RefPtr<Gtk::TreeSelection> sel = _ExternalScriptsList.get_selection();
4860 if (sel) {
4861- _external_remove_btn.set_sensitive(sel->count_selected_rows () > 0);
4862+ _external_remove_btn.set_sensitive(sel->count_selected_rows() > 0);
4863 }
4864 }
4865
4866@@ -1265,45 +1491,47 @@
4867 {
4868 Glib::RefPtr<Gtk::TreeSelection> sel = _EmbeddedScriptsList.get_selection();
4869 if (sel) {
4870- _embed_remove_btn.set_sensitive(sel->count_selected_rows () > 0);
4871+ _embed_remove_btn.set_sensitive(sel->count_selected_rows() > 0);
4872 }
4873 }
4874
4875-void DocumentProperties::changeEmbeddedScript(){
4876+void DocumentProperties::changeEmbeddedScript()
4877+{
4878 Glib::ustring id;
4879- if(_EmbeddedScriptsList.get_selection()) {
4880+ if (_EmbeddedScriptsList.get_selection()) {
4881 Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected();
4882
4883- if(i){
4884+ if (i) {
4885 id = (*i)[_EmbeddedScriptsListColumns.idColumn];
4886 } else {
4887 return;
4888 }
4889 }
4890
4891- bool voidscript=true;
4892- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
4893- while ( current ) {
4894- SPObject* obj = SP_OBJECT(current->data);
4895- if (id == obj->getId()){
4896+ bool voidscript = true;
4897+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("script");
4898+ while (current) {
4899+ SPObject *obj = SP_OBJECT(current->data);
4900+ if (id == obj->getId()) {
4901
4902- int count=0;
4903- for ( SPObject *child = obj->children ; child; child = child->next )
4904- {
4905+ int count = 0;
4906+ for (SPObject *child = obj->children; child; child = child->next) {
4907 count++;
4908 }
4909
4910- if (count>1)
4911- g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count);
4912-
4913- //XML Tree being used directly here while it shouldn't be.
4914- SPObject* child = obj->firstChild();
4915- //TODO: shouldnt we get all children instead of simply the first child?
4916-
4917- if (child && child->getRepr()){
4918- const gchar* content = child->getRepr()->content();
4919- if (content){
4920- voidscript=false;
4921+ if (count > 1)
4922+ g_warning(
4923+ "TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!",
4924+ count);
4925+
4926+ // XML Tree being used directly here while it shouldn't be.
4927+ SPObject *child = obj->firstChild();
4928+ // TODO: shouldnt we get all children instead of simply the first child?
4929+
4930+ if (child && child->getRepr()) {
4931+ const gchar *content = child->getRepr()->content();
4932+ if (content) {
4933+ voidscript = false;
4934 _EmbeddedContent.get_buffer()->set_text(content);
4935 }
4936 }
4937@@ -1315,12 +1543,13 @@
4938 _EmbeddedContent.get_buffer()->set_text("");
4939 }
4940
4941-void DocumentProperties::editEmbeddedScript(){
4942+void DocumentProperties::editEmbeddedScript()
4943+{
4944 Glib::ustring id;
4945- if(_EmbeddedScriptsList.get_selection()) {
4946+ if (_EmbeddedScriptsList.get_selection()) {
4947 Gtk::TreeModel::iterator i = _EmbeddedScriptsList.get_selection()->get_selected();
4948
4949- if(i){
4950+ if (i) {
4951 id = (*i)[_EmbeddedScriptsListColumns.idColumn];
4952 } else {
4953 return;
4954@@ -1328,19 +1557,20 @@
4955 }
4956
4957 Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc();
4958- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
4959- while ( current ) {
4960- SPObject* obj = SP_OBJECT(current->data);
4961- if (id == obj->getId()){
4962+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("script");
4963+ while (current) {
4964+ SPObject *obj = SP_OBJECT(current->data);
4965+ if (id == obj->getId()) {
4966
4967- //XML Tree being used directly here while it shouldn't be.
4968+ // XML Tree being used directly here while it shouldn't be.
4969 Inkscape::XML::Node *repr = obj->getRepr();
4970- if (repr){
4971+ if (repr) {
4972 SPObject *child;
4973- while (NULL != (child = obj->firstChild())) child->deleteObject();
4974+ while (NULL != (child = obj->firstChild()))
4975+ child->deleteObject();
4976 obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str()));
4977
4978- //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text());
4979+ // TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text());
4980
4981 // inform the document, so we can undo
4982 DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script"));
4983@@ -1350,20 +1580,20 @@
4984 }
4985 }
4986
4987-void DocumentProperties::populate_script_lists(){
4988+void DocumentProperties::populate_script_lists()
4989+{
4990 _ExternalScriptsListStore->clear();
4991 _EmbeddedScriptsListStore->clear();
4992- const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" );
4993- if (current) _scripts_observer.set(SP_OBJECT(current->data)->parent);
4994- while ( current ) {
4995- SPObject* obj = SP_OBJECT(current->data);
4996- SPScript* script = SP_SCRIPT(obj);
4997- if (script->xlinkhref)
4998- {
4999+ const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("script");
5000+ if (current)
The diff has been truncated for viewing.