1
by mental
moving trunk for module inkscape |
1 |
/*
|
2 |
* <sodipodi:namedview> implementation
|
|
3 |
*
|
|
4 |
* Authors:
|
|
5 |
* Lauris Kaplinski <lauris@kaplinski.com>
|
|
6 |
* bulia byak <buliabyak@users.sf.net>
|
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
7 |
* Jon A. Cruz <jon@joncruz.org>
|
8 |
* Abhishek Sharma
|
|
1
by mental
moving trunk for module inkscape |
9 |
*
|
1716
by johanengelen
AXONOMETRIC (3D) GRID! OK, still alot of work to be done. Snapping, diagonal guides, 0-degree angle axes, user-input checking, emphasis lines, optimizing, ... try and find as many bugs as possible :P Or just look at it playing with the angles of the lines, it's pretty cool to look at all by itself :) |
10 |
* Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
|
5600
by dvlierop2
Next steps in implementing the snapping indicator |
11 |
* Copyright (C) 1999-2008 Authors
|
1
by mental
moving trunk for module inkscape |
12 |
* Copyright (C) 2000-2001 Ximian, Inc.
|
13 |
*
|
|
14 |
* Released under GNU GPL, read the file 'COPYING' for more information
|
|
15 |
*/
|
|
16 |
||
17 |
#include "config.h" |
|
4629
by bryce
Applying fixes for gcc 4.3 build issues (closes LP: #169115) |
18 |
#include <cstring> |
19 |
#include <string> |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
20 |
#include <2geom/transforms.h> |
1
by mental
moving trunk for module inkscape |
21 |
|
22 |
#include "display/canvas-grid.h" |
|
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
23 |
#include "display/guideline.h" |
1
by mental
moving trunk for module inkscape |
24 |
#include "helper/units.h" |
232
by pjrm
#include svg/svg-color.h instead of or as well as (as appropriate) svg/svg.h. |
25 |
#include "svg/svg-color.h" |
1
by mental
moving trunk for module inkscape |
26 |
#include "xml/repr.h" |
27 |
#include "attributes.h" |
|
28 |
#include "document.h" |
|
29 |
#include "desktop-events.h" |
|
30 |
#include "desktop-handles.h" |
|
1379
by gustav_b
Added descriptions to Undo/Redo commands in the menus |
31 |
#include "event-log.h" |
1
by mental
moving trunk for module inkscape |
32 |
#include "sp-guide.h" |
33 |
#include "sp-item-group.h" |
|
34 |
#include "sp-namedview.h" |
|
6885
by Ted Gould
From trunk |
35 |
#include "preferences.h" |
1
by mental
moving trunk for module inkscape |
36 |
#include "desktop.h" |
18
by mjwybrow
* src/widgets/toolbox.cpp, src/widgets/desktop-widget.cpp, |
37 |
#include "conn-avoid-ref.h" // for defaultConnSpacing. |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
38 |
#include "sp-root.h" |
39 |
||
40 |
using Inkscape::DocumentUndo; |
|
1
by mental
moving trunk for module inkscape |
41 |
|
42 |
#define DEFAULTGRIDCOLOR 0x3f3fff25
|
|
43 |
#define DEFAULTGRIDEMPCOLOR 0x3f3fff60
|
|
44 |
#define DEFAULTGRIDEMPSPACING 5
|
|
45 |
#define DEFAULTGUIDECOLOR 0x0000ff7f
|
|
46 |
#define DEFAULTGUIDEHICOLOR 0xff00007f
|
|
47 |
#define DEFAULTBORDERCOLOR 0x000000ff
|
|
48 |
#define DEFAULTPAGECOLOR 0xffffff00
|
|
49 |
||
50 |
static void sp_namedview_class_init(SPNamedViewClass *klass); |
|
51 |
static void sp_namedview_init(SPNamedView *namedview); |
|
52 |
||
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
53 |
static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); |
1
by mental
moving trunk for module inkscape |
54 |
static void sp_namedview_release(SPObject *object); |
55 |
static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value); |
|
56 |
static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref); |
|
57 |
static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *child); |
|
5884
by mental
plumb XML::Documents in everywhere |
58 |
static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); |
1
by mental
moving trunk for module inkscape |
59 |
|
60 |
static void sp_namedview_setup_guides(SPNamedView * nv); |
|
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
61 |
static void sp_namedview_show_single_guide(SPGuide* guide, bool show); |
1
by mental
moving trunk for module inkscape |
62 |
|
1637
by kidproto
peeled back the gboolean code as it hit on some complexity theory principles... |
63 |
static gboolean sp_str_to_bool(const gchar *str); |
64 |
static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); |
|
1
by mental
moving trunk for module inkscape |
65 |
|
66 |
static SPObjectGroupClass * parent_class; |
|
67 |
||
68 |
GType
|
|
69 |
sp_namedview_get_type() |
|
70 |
{
|
|
71 |
static GType namedview_type = 0; |
|
72 |
if (!namedview_type) { |
|
73 |
GTypeInfo namedview_info = { |
|
74 |
sizeof(SPNamedViewClass), |
|
4838
by joncruz
Warning and whitespace cleanup |
75 |
NULL, /* base_init */ |
76 |
NULL, /* base_finalize */ |
|
1
by mental
moving trunk for module inkscape |
77 |
(GClassInitFunc) sp_namedview_class_init, |
4838
by joncruz
Warning and whitespace cleanup |
78 |
NULL, /* class_finalize */ |
79 |
NULL, /* class_data */ |
|
1
by mental
moving trunk for module inkscape |
80 |
sizeof(SPNamedView), |
4838
by joncruz
Warning and whitespace cleanup |
81 |
16, /* n_preallocs */ |
1
by mental
moving trunk for module inkscape |
82 |
(GInstanceInitFunc) sp_namedview_init, |
4838
by joncruz
Warning and whitespace cleanup |
83 |
NULL, /* value_table */ |
1
by mental
moving trunk for module inkscape |
84 |
};
|
85 |
namedview_type = g_type_register_static(SP_TYPE_OBJECTGROUP, "SPNamedView", &namedview_info, (GTypeFlags)0); |
|
86 |
}
|
|
87 |
return namedview_type; |
|
88 |
}
|
|
89 |
||
90 |
static void sp_namedview_class_init(SPNamedViewClass * klass) |
|
91 |
{
|
|
92 |
GObjectClass * gobject_class; |
|
93 |
SPObjectClass * sp_object_class; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
94 |
|
1
by mental
moving trunk for module inkscape |
95 |
gobject_class = (GObjectClass *) klass; |
96 |
sp_object_class = (SPObjectClass *) klass; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
97 |
|
1
by mental
moving trunk for module inkscape |
98 |
parent_class = (SPObjectGroupClass*) g_type_class_ref(SP_TYPE_OBJECTGROUP); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
99 |
|
1
by mental
moving trunk for module inkscape |
100 |
sp_object_class->build = sp_namedview_build; |
101 |
sp_object_class->release = sp_namedview_release; |
|
102 |
sp_object_class->set = sp_namedview_set; |
|
103 |
sp_object_class->child_added = sp_namedview_child_added; |
|
104 |
sp_object_class->remove_child = sp_namedview_remove_child; |
|
105 |
sp_object_class->write = sp_namedview_write; |
|
106 |
}
|
|
107 |
||
108 |
static void sp_namedview_init(SPNamedView *nv) |
|
109 |
{
|
|
110 |
nv->editable = TRUE; |
|
111 |
nv->showguides = TRUE; |
|
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
112 |
nv->grids_visible = false; |
1
by mental
moving trunk for module inkscape |
113 |
nv->showborder = TRUE; |
114 |
nv->showpageshadow = TRUE; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
115 |
|
1
by mental
moving trunk for module inkscape |
116 |
nv->guides = NULL; |
117 |
nv->viewcount = 0; |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
118 |
nv->grids = NULL; |
7008
by dvlierop2
1) snap midpoints of line segments (both as source and as target) |
119 |
|
1
by mental
moving trunk for module inkscape |
120 |
nv->default_layer_id = 0; |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
121 |
|
18
by mjwybrow
* src/widgets/toolbox.cpp, src/widgets/desktop-widget.cpp, |
122 |
nv->connector_spacing = defaultConnSpacing; |
727
by cth103
Clean up knutux's fix for the snapper crash. |
123 |
|
124 |
new (&nv->snap_manager) SnapManager(nv); |
|
1
by mental
moving trunk for module inkscape |
125 |
}
|
126 |
||
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
127 |
static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *document, Inkscape::XML::Node *repr) { |
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
128 |
bool old_grid_settings_present = false; |
129 |
||
130 |
// set old settings
|
|
131 |
const char* gridspacingx = "1px"; |
|
132 |
const char* gridspacingy = "1px"; |
|
133 |
const char* gridoriginy = "0px"; |
|
134 |
const char* gridoriginx = "0px"; |
|
135 |
const char* gridempspacing = "5"; |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
136 |
const char* gridcolor = "#3f3fff"; |
137 |
const char* gridempcolor = "#3f3fff"; |
|
138 |
const char* gridopacity = "0.15"; |
|
139 |
const char* gridempopacity = "0.38"; |
|
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
140 |
|
141 |
const char* value = NULL; |
|
142 |
if ((value = repr->attribute("gridoriginx"))) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
143 |
gridoriginx = value; |
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
144 |
old_grid_settings_present = true; |
145 |
}
|
|
146 |
if ((value = repr->attribute("gridoriginy"))) { |
|
147 |
gridoriginy = value; |
|
148 |
old_grid_settings_present = true; |
|
149 |
}
|
|
150 |
if ((value = repr->attribute("gridspacingx"))) { |
|
151 |
gridspacingx = value; |
|
152 |
old_grid_settings_present = true; |
|
153 |
}
|
|
154 |
if ((value = repr->attribute("gridspacingy"))) { |
|
155 |
gridspacingy = value; |
|
156 |
old_grid_settings_present = true; |
|
157 |
}
|
|
158 |
if ((value = repr->attribute("gridcolor"))) { |
|
159 |
gridcolor = value; |
|
160 |
old_grid_settings_present = true; |
|
161 |
}
|
|
162 |
if ((value = repr->attribute("gridempcolor"))) { |
|
163 |
gridempcolor = value; |
|
164 |
old_grid_settings_present = true; |
|
165 |
}
|
|
166 |
if ((value = repr->attribute("gridempspacing"))) { |
|
167 |
gridempspacing = value; |
|
168 |
old_grid_settings_present = true; |
|
169 |
}
|
|
170 |
if ((value = repr->attribute("gridopacity"))) { |
|
171 |
gridopacity = value; |
|
172 |
old_grid_settings_present = true; |
|
173 |
}
|
|
174 |
if ((value = repr->attribute("gridempopacity"))) { |
|
175 |
gridempopacity = value; |
|
176 |
old_grid_settings_present = true; |
|
177 |
}
|
|
178 |
||
179 |
if (old_grid_settings_present) { |
|
180 |
// generate new xy grid with the correct settings
|
|
181 |
// first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete.
|
|
182 |
||
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
183 |
Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
184 |
Inkscape::XML::Node *newnode = xml_doc->createElement("inkscape:grid"); |
185 |
newnode->setAttribute("id", "GridFromPre046Settings"); |
|
186 |
newnode->setAttribute("type", Inkscape::CanvasGrid::getSVGName(Inkscape::GRID_RECTANGULAR)); |
|
187 |
newnode->setAttribute("originx", gridoriginx); |
|
188 |
newnode->setAttribute("originy", gridoriginy); |
|
189 |
newnode->setAttribute("spacingx", gridspacingx); |
|
190 |
newnode->setAttribute("spacingy", gridspacingy); |
|
191 |
newnode->setAttribute("color", gridcolor); |
|
192 |
newnode->setAttribute("empcolor", gridempcolor); |
|
193 |
newnode->setAttribute("opacity", gridopacity); |
|
194 |
newnode->setAttribute("empopacity", gridempopacity); |
|
195 |
newnode->setAttribute("empspacing", gridempspacing); |
|
196 |
||
197 |
repr->appendChild(newnode); |
|
198 |
Inkscape::GC::release(newnode); |
|
199 |
||
200 |
// remove all old settings
|
|
201 |
repr->setAttribute("gridoriginx", NULL); |
|
202 |
repr->setAttribute("gridoriginy", NULL); |
|
203 |
repr->setAttribute("gridspacingx", NULL); |
|
204 |
repr->setAttribute("gridspacingy", NULL); |
|
205 |
repr->setAttribute("gridcolor", NULL); |
|
206 |
repr->setAttribute("gridempcolor", NULL); |
|
207 |
repr->setAttribute("gridopacity", NULL); |
|
208 |
repr->setAttribute("gridempopacity", NULL); |
|
209 |
repr->setAttribute("gridempspacing", NULL); |
|
210 |
||
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
211 |
// SPDocumentUndo::done(doc, SP_VERB_DIALOG_NAMEDVIEW, _("Create new grid from pre0.46 grid settings"));
|
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
212 |
}
|
213 |
}
|
|
214 |
||
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
215 |
static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) |
1
by mental
moving trunk for module inkscape |
216 |
{
|
217 |
SPNamedView *nv = (SPNamedView *) object; |
|
218 |
SPObjectGroup *og = (SPObjectGroup *) object; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
219 |
|
1
by mental
moving trunk for module inkscape |
220 |
if (((SPObjectClass *) (parent_class))->build) { |
221 |
(* ((SPObjectClass *) (parent_class))->build)(object, document, repr); |
|
222 |
}
|
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
223 |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
224 |
object->readAttr( "inkscape:document-units" ); |
225 |
object->readAttr( "units" ); |
|
226 |
object->readAttr( "viewonly" ); |
|
227 |
object->readAttr( "showguides" ); |
|
228 |
object->readAttr( "showgrid" ); |
|
229 |
object->readAttr( "gridtolerance" ); |
|
230 |
object->readAttr( "guidetolerance" ); |
|
231 |
object->readAttr( "objecttolerance" ); |
|
232 |
object->readAttr( "guidecolor" ); |
|
233 |
object->readAttr( "guideopacity" ); |
|
234 |
object->readAttr( "guidehicolor" ); |
|
235 |
object->readAttr( "guidehiopacity" ); |
|
236 |
object->readAttr( "showborder" ); |
|
237 |
object->readAttr( "inkscape:showpageshadow" ); |
|
238 |
object->readAttr( "borderlayer" ); |
|
239 |
object->readAttr( "bordercolor" ); |
|
240 |
object->readAttr( "borderopacity" ); |
|
241 |
object->readAttr( "pagecolor" ); |
|
242 |
object->readAttr( "inkscape:pageopacity" ); |
|
243 |
object->readAttr( "inkscape:pageshadow" ); |
|
244 |
object->readAttr( "inkscape:zoom" ); |
|
245 |
object->readAttr( "inkscape:cx" ); |
|
246 |
object->readAttr( "inkscape:cy" ); |
|
247 |
object->readAttr( "inkscape:window-width" ); |
|
248 |
object->readAttr( "inkscape:window-height" ); |
|
249 |
object->readAttr( "inkscape:window-x" ); |
|
250 |
object->readAttr( "inkscape:window-y" ); |
|
251 |
object->readAttr( "inkscape:window-maximized" ); |
|
252 |
object->readAttr( "inkscape:snap-global" ); |
|
253 |
object->readAttr( "inkscape:snap-bbox" ); |
|
254 |
object->readAttr( "inkscape:snap-nodes" ); |
|
255 |
object->readAttr( "inkscape:snap-others" ); |
|
256 |
object->readAttr( "inkscape:snap-from-guide" ); |
|
257 |
object->readAttr( "inkscape:snap-center" ); |
|
258 |
object->readAttr( "inkscape:snap-smooth-nodes" ); |
|
259 |
object->readAttr( "inkscape:snap-midpoints" ); |
|
260 |
object->readAttr( "inkscape:snap-object-midpoints" ); |
|
261 |
object->readAttr( "inkscape:snap-text-baseline" ); |
|
262 |
object->readAttr( "inkscape:snap-bbox-edge-midpoints" ); |
|
263 |
object->readAttr( "inkscape:snap-bbox-midpoints" ); |
|
264 |
object->readAttr( "inkscape:snap-to-guides" ); |
|
265 |
object->readAttr( "inkscape:snap-grids" ); |
|
266 |
object->readAttr( "inkscape:snap-intersection-paths" ); |
|
267 |
object->readAttr( "inkscape:object-paths" ); |
|
268 |
object->readAttr( "inkscape:object-nodes" ); |
|
269 |
object->readAttr( "inkscape:bbox-paths" ); |
|
270 |
object->readAttr( "inkscape:bbox-nodes" ); |
|
271 |
object->readAttr( "inkscape:snap-page" ); |
|
272 |
object->readAttr( "inkscape:current-layer" ); |
|
273 |
object->readAttr( "inkscape:connector-spacing" ); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
274 |
|
1
by mental
moving trunk for module inkscape |
275 |
/* Construct guideline list */
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
276 |
for (SPObject *o = og->firstChild() ; o; o = o->getNext() ) { |
1
by mental
moving trunk for module inkscape |
277 |
if (SP_IS_GUIDE(o)) { |
278 |
SPGuide * g = SP_GUIDE(o); |
|
279 |
nv->guides = g_slist_prepend(nv->guides, g); |
|
280 |
g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); |
|
281 |
}
|
|
282 |
}
|
|
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
283 |
|
284 |
// backwards compatibility with grid settings (pre 0.46)
|
|
285 |
sp_namedview_generate_old_grid(nv, document, repr); |
|
1
by mental
moving trunk for module inkscape |
286 |
}
|
287 |
||
288 |
static void sp_namedview_release(SPObject *object) |
|
289 |
{
|
|
290 |
SPNamedView *namedview = (SPNamedView *) object; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
291 |
|
1
by mental
moving trunk for module inkscape |
292 |
if (namedview->guides) { |
293 |
g_slist_free(namedview->guides); |
|
294 |
namedview->guides = NULL; |
|
295 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
296 |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
297 |
// delete grids:
|
298 |
while ( namedview->grids ) { |
|
4540
by johanengelen
remove SPDesktop from SPNamedView when it is destroyed. Fixing bug 183621, but another bug is apparently present that causes a bug with similar trigger |
299 |
Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; // get first entry |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
300 |
delete gr; |
4540
by johanengelen
remove SPDesktop from SPNamedView when it is destroyed. Fixing bug 183621, but another bug is apparently present that causes a bug with similar trigger |
301 |
namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
302 |
}
|
2757
by johanengelen
Purging old axonometric grid code: reworked it into the new grid class structure. Still needs alot of work (snapping mostly and code cleansing). |
303 |
|
1
by mental
moving trunk for module inkscape |
304 |
if (((SPObjectClass *) parent_class)->release) { |
305 |
((SPObjectClass *) parent_class)->release(object); |
|
306 |
}
|
|
725
by knutux
Temporary fix for broken snap functionality: as named view constructor is never called, virtual tables of Snapper derived classes are never initialized. Fix - calling constructor/destructor on SPNamedView init/release. |
307 |
|
727
by cth103
Clean up knutux's fix for the snapper crash. |
308 |
namedview->snap_manager.~SnapManager(); |
1
by mental
moving trunk for module inkscape |
309 |
}
|
310 |
||
311 |
static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *value) |
|
312 |
{
|
|
313 |
SPNamedView *nv = SP_NAMEDVIEW(object); |
|
314 |
||
315 |
switch (key) { |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
316 |
case SP_ATTR_VIEWONLY: |
1
by mental
moving trunk for module inkscape |
317 |
nv->editable = (!value); |
318 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
319 |
break; |
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
320 |
case SP_ATTR_SHOWGUIDES: |
1
by mental
moving trunk for module inkscape |
321 |
if (!value) { // show guides if not specified, for backwards compatibility |
322 |
nv->showguides = TRUE; |
|
323 |
} else { |
|
324 |
nv->showguides = sp_str_to_bool(value); |
|
325 |
}
|
|
326 |
sp_namedview_setup_guides(nv); |
|
327 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
328 |
break; |
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
329 |
case SP_ATTR_SHOWGRIDS: |
4334
by johanengelen
Fixed bug #172778, [old] grid settings not respected when reopening document |
330 |
if (!value) { // don't show grids if not specified, for backwards compatibility |
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
331 |
nv->grids_visible = false; |
332 |
} else { |
|
333 |
nv->grids_visible = sp_str_to_bool(value); |
|
334 |
}
|
|
335 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
336 |
break; |
|
337 |
case SP_ATTR_GRIDTOLERANCE: |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
338 |
nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); |
339 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
340 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
341 |
case SP_ATTR_GUIDETOLERANCE: |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
342 |
nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); |
1
by mental
moving trunk for module inkscape |
343 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
344 |
break; |
|
2930
by dvlierop2
Improve readability and remove some unused code |
345 |
case SP_ATTR_OBJECTTOLERANCE: |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
346 |
nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); |
1
by mental
moving trunk for module inkscape |
347 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
348 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
349 |
case SP_ATTR_GUIDECOLOR: |
1
by mental
moving trunk for module inkscape |
350 |
nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); |
351 |
if (value) { |
|
352 |
nv->guidecolor = (nv->guidecolor & 0xff) | sp_svg_read_color(value, nv->guidecolor); |
|
353 |
}
|
|
354 |
for (GSList *l = nv->guides; l != NULL; l = l->next) { |
|
355 |
g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); |
|
356 |
}
|
|
357 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
358 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
359 |
case SP_ATTR_GUIDEOPACITY: |
1
by mental
moving trunk for module inkscape |
360 |
nv->guidecolor = (nv->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); |
361 |
sp_nv_read_opacity(value, &nv->guidecolor); |
|
362 |
for (GSList *l = nv->guides; l != NULL; l = l->next) { |
|
363 |
g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); |
|
364 |
}
|
|
365 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
366 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
367 |
case SP_ATTR_GUIDEHICOLOR: |
1
by mental
moving trunk for module inkscape |
368 |
nv->guidehicolor = (nv->guidehicolor & 0xff) | (DEFAULTGUIDEHICOLOR & 0xffffff00); |
369 |
if (value) { |
|
370 |
nv->guidehicolor = (nv->guidehicolor & 0xff) | sp_svg_read_color(value, nv->guidehicolor); |
|
371 |
}
|
|
372 |
for (GSList *l = nv->guides; l != NULL; l = l->next) { |
|
373 |
g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); |
|
374 |
}
|
|
375 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
376 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
377 |
case SP_ATTR_GUIDEHIOPACITY: |
1
by mental
moving trunk for module inkscape |
378 |
nv->guidehicolor = (nv->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); |
379 |
sp_nv_read_opacity(value, &nv->guidehicolor); |
|
380 |
for (GSList *l = nv->guides; l != NULL; l = l->next) { |
|
381 |
g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); |
|
382 |
}
|
|
383 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
384 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
385 |
case SP_ATTR_SHOWBORDER: |
1
by mental
moving trunk for module inkscape |
386 |
nv->showborder = (value) ? sp_str_to_bool (value) : TRUE; |
387 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
388 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
389 |
case SP_ATTR_BORDERLAYER: |
1
by mental
moving trunk for module inkscape |
390 |
nv->borderlayer = SP_BORDER_LAYER_BOTTOM; |
391 |
if (value && !strcasecmp(value, "true")) nv->borderlayer = SP_BORDER_LAYER_TOP; |
|
392 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
393 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
394 |
case SP_ATTR_BORDERCOLOR: |
1
by mental
moving trunk for module inkscape |
395 |
nv->bordercolor = (nv->bordercolor & 0xff) | (DEFAULTBORDERCOLOR & 0xffffff00); |
396 |
if (value) { |
|
397 |
nv->bordercolor = (nv->bordercolor & 0xff) | sp_svg_read_color (value, nv->bordercolor); |
|
398 |
}
|
|
399 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
400 |
break; |
|
4838
by joncruz
Warning and whitespace cleanup |
401 |
case SP_ATTR_BORDEROPACITY: |
1
by mental
moving trunk for module inkscape |
402 |
nv->bordercolor = (nv->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff); |
403 |
sp_nv_read_opacity(value, &nv->bordercolor); |
|
404 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
405 |
break; |
|
4838
by joncruz
Warning and whitespace cleanup |
406 |
case SP_ATTR_PAGECOLOR: |
1
by mental
moving trunk for module inkscape |
407 |
nv->pagecolor = (nv->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00); |
408 |
if (value) { |
|
409 |
nv->pagecolor = (nv->pagecolor & 0xff) | sp_svg_read_color(value, nv->pagecolor); |
|
410 |
}
|
|
411 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
412 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
413 |
case SP_ATTR_INKSCAPE_PAGEOPACITY: |
1
by mental
moving trunk for module inkscape |
414 |
nv->pagecolor = (nv->pagecolor & 0xffffff00) | (DEFAULTPAGECOLOR & 0xff); |
415 |
sp_nv_read_opacity(value, &nv->pagecolor); |
|
416 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
417 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
418 |
case SP_ATTR_INKSCAPE_PAGESHADOW: |
1
by mental
moving trunk for module inkscape |
419 |
nv->pageshadow = value? atoi(value) : 2; // 2 is the default |
420 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
421 |
break; |
|
2930
by dvlierop2
Improve readability and remove some unused code |
422 |
case SP_ATTR_SHOWPAGESHADOW: |
1
by mental
moving trunk for module inkscape |
423 |
nv->showpageshadow = (value) ? sp_str_to_bool(value) : TRUE; |
424 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
425 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
426 |
case SP_ATTR_INKSCAPE_ZOOM: |
1
by mental
moving trunk for module inkscape |
427 |
nv->zoom = value ? g_ascii_strtod(value, NULL) : 0; // zero means not set |
428 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
429 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
430 |
case SP_ATTR_INKSCAPE_CX: |
1
by mental
moving trunk for module inkscape |
431 |
nv->cx = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set |
432 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
433 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
434 |
case SP_ATTR_INKSCAPE_CY: |
1
by mental
moving trunk for module inkscape |
435 |
nv->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set |
436 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
437 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
438 |
case SP_ATTR_INKSCAPE_WINDOW_WIDTH: |
1
by mental
moving trunk for module inkscape |
439 |
nv->window_width = value? atoi(value) : -1; // -1 means not set |
440 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
441 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
442 |
case SP_ATTR_INKSCAPE_WINDOW_HEIGHT: |
1
by mental
moving trunk for module inkscape |
443 |
nv->window_height = value ? atoi(value) : -1; // -1 means not set |
444 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
445 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
446 |
case SP_ATTR_INKSCAPE_WINDOW_X: |
7924
by dvlierop2
Inkscape should not discard negative window positions. For example, a maximized window on Windows XP is at (-4,-4). When ignoring such values, windows might show up at another location when re-opening the file later on (fixes bug #168422) |
447 |
nv->window_x = value ? atoi(value) : 0; |
1
by mental
moving trunk for module inkscape |
448 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
449 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
450 |
case SP_ATTR_INKSCAPE_WINDOW_Y: |
7924
by dvlierop2
Inkscape should not discard negative window positions. For example, a maximized window on Windows XP is at (-4,-4). When ignoring such values, windows might show up at another location when re-opening the file later on (fixes bug #168422) |
451 |
nv->window_y = value ? atoi(value) : 0; |
1
by mental
moving trunk for module inkscape |
452 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
453 |
break; |
|
7967
by dvlierop2
Store the maximized state in the document (closes bug #168422) |
454 |
case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED: |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
455 |
nv->window_maximized = value ? atoi(value) : 0; |
456 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
457 |
break; |
|
458 |
case SP_ATTR_INKSCAPE_SNAP_GLOBAL: |
|
6885
by Ted Gould
From trunk |
459 |
nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); |
4221
by dvlierop2
Add global snapping toggle |
460 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
461 |
break; |
|
3331
by dvlierop2
1) Changes to snapping preferences dialog |
462 |
case SP_ATTR_INKSCAPE_SNAP_BBOX: |
6885
by Ted Gould
From trunk |
463 |
nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE); |
1
by mental
moving trunk for module inkscape |
464 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
465 |
break; |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
466 |
case SP_ATTR_INKSCAPE_SNAP_NODE: |
6885
by Ted Gould
From trunk |
467 |
nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); |
3361
by dvlierop2
Rearrange snapping preferences, put distinction between paths and nodes back in, and a bit of refactoring |
468 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
469 |
break; |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
470 |
case SP_ATTR_INKSCAPE_SNAP_OTHERS: |
471 |
nv->snap_manager.snapprefs.setSnapModeOthers(value ? sp_str_to_bool(value) : TRUE); |
|
472 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
473 |
break; |
|
474 |
case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: |
|
475 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); |
|
476 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
477 |
break; |
|
478 |
case SP_ATTR_INKSCAPE_SNAP_GRID: |
|
479 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); |
|
480 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
481 |
break; |
|
482 |
case SP_ATTR_INKSCAPE_SNAP_GUIDE: |
|
483 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); |
|
484 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
485 |
break; |
|
486 |
case SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH: |
|
487 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); |
|
488 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
489 |
break; |
|
490 |
case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT: |
|
491 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); |
|
492 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
493 |
break; |
|
494 |
case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT: |
|
495 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); |
|
496 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
497 |
break; |
|
498 |
case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: |
|
499 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); |
|
500 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
501 |
break; |
|
502 |
case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT: |
|
503 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); |
|
504 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
505 |
break; |
|
506 |
case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT: |
|
507 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); |
|
508 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
509 |
break; |
|
510 |
case SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION: |
|
511 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); |
|
512 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
513 |
break; |
|
514 |
case SP_ATTR_INKSCAPE_SNAP_PATH: |
|
515 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); |
|
516 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
517 |
break; |
|
518 |
case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: |
|
519 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); |
|
520 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
521 |
break; |
|
522 |
case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: |
|
523 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); |
|
524 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
525 |
break; |
|
526 |
case SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER: |
|
527 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); |
|
528 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
529 |
break; |
|
530 |
case SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER: |
|
531 |
nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); |
|
5059
by dvlierop2
Snap to page border |
532 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
7008
by dvlierop2
1) snap midpoints of line segments (both as source and as target) |
533 |
break; |
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
534 |
case SP_ATTR_INKSCAPE_CURRENT_LAYER: |
1
by mental
moving trunk for module inkscape |
535 |
nv->default_layer_id = value ? g_quark_from_string(value) : 0; |
536 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
537 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
538 |
case SP_ATTR_INKSCAPE_CONNECTOR_SPACING: |
18
by mjwybrow
* src/widgets/toolbox.cpp, src/widgets/desktop-widget.cpp, |
539 |
nv->connector_spacing = value ? g_ascii_strtod(value, NULL) : |
540 |
defaultConnSpacing; |
|
541 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
542 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
543 |
case SP_ATTR_INKSCAPE_DOCUMENT_UNITS: { |
1
by mental
moving trunk for module inkscape |
544 |
/* The default unit if the document doesn't override this: e.g. for files saved as
|
545 |
* `plain SVG', or non-inkscape files, or files created by an inkscape 0.40 &
|
|
546 |
* earlier.
|
|
547 |
*
|
|
548 |
* Here we choose `px': useful for screen-destined SVGs, and fewer bug reports
|
|
549 |
* about "not the same numbers as what's in the SVG file" (at least for documents
|
|
550 |
* without a viewBox attribute on the root <svg> element). Similarly, it's also
|
|
551 |
* the most reliable unit (i.e. least likely to be wrong in different viewing
|
|
552 |
* conditions) for viewBox-less SVG files given that it's the unit that inkscape
|
|
553 |
* uses for all coordinates.
|
|
554 |
*
|
|
555 |
* For documents that do have a viewBox attribute on the root <svg> element, it
|
|
556 |
* might be better if we used either viewBox coordinates or if we used the unit of
|
|
557 |
* say the width attribute of the root <svg> element. However, these pose problems
|
|
558 |
* in that they aren't in general absolute units as currently required by
|
|
559 |
* doc_units.
|
|
560 |
*/
|
|
561 |
SPUnit const *new_unit = &sp_unit_get_by_id(SP_UNIT_PX); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
562 |
|
1
by mental
moving trunk for module inkscape |
563 |
if (value) { |
564 |
SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); |
|
565 |
if ( req_unit == NULL ) { |
|
566 |
g_warning("Unrecognized unit `%s'", value); |
|
567 |
/* fixme: Document errors should be reported in the status bar or
|
|
568 |
* the like (e.g. as per
|
|
569 |
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
|
|
570 |
* should be only for programmer errors. */
|
|
571 |
} else if ( req_unit->base == SP_UNIT_ABSOLUTE || |
|
572 |
req_unit->base == SP_UNIT_DEVICE ) { |
|
573 |
new_unit = req_unit; |
|
574 |
} else { |
|
575 |
g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", |
|
576 |
value); |
|
577 |
/* fixme: Don't use g_log (see above). */
|
|
578 |
}
|
|
579 |
}
|
|
580 |
nv->doc_units = new_unit; |
|
581 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
582 |
break; |
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
583 |
}
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
584 |
case SP_ATTR_UNITS: { |
585 |
SPUnit const *new_unit = NULL; |
|
586 |
||
587 |
if (value) { |
|
588 |
SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); |
|
589 |
if ( req_unit == NULL ) { |
|
590 |
g_warning("Unrecognized unit `%s'", value); |
|
591 |
/* fixme: Document errors should be reported in the status bar or
|
|
592 |
* the like (e.g. as per
|
|
593 |
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log
|
|
594 |
* should be only for programmer errors. */
|
|
595 |
} else if ( req_unit->base == SP_UNIT_ABSOLUTE || |
|
596 |
req_unit->base == SP_UNIT_DEVICE ) { |
|
597 |
new_unit = req_unit; |
|
598 |
} else { |
|
599 |
g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", |
|
600 |
value); |
|
601 |
/* fixme: Don't use g_log (see above). */
|
|
602 |
}
|
|
603 |
}
|
|
604 |
nv->units = new_unit; |
|
605 |
object->requestModified(SP_OBJECT_MODIFIED_FLAG); |
|
606 |
break; |
|
607 |
}
|
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
608 |
default: |
1
by mental
moving trunk for module inkscape |
609 |
if (((SPObjectClass *) (parent_class))->set) { |
610 |
((SPObjectClass *) (parent_class))->set(object, key, value); |
|
611 |
}
|
|
612 |
break; |
|
613 |
}
|
|
614 |
}
|
|
615 |
||
2873
by johanengelen
New grids are almost ready to fly! |
616 |
/**
|
617 |
* add a grid item from SVG-repr. Check if this namedview already has a gridobject for this one! If desktop=null, add grid-canvasitem to all desktops of this namedview,
|
|
618 |
* otherwise only add it to the specified desktop.
|
|
619 |
*/
|
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
620 |
static Inkscape::CanvasGrid* |
2873
by johanengelen
New grids are almost ready to fly! |
621 |
sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *desktop) { |
622 |
Inkscape::CanvasGrid* grid = NULL; |
|
623 |
//check if namedview already has an object for this grid
|
|
624 |
for (GSList *l = nv->grids; l != NULL; l = l->next) { |
|
625 |
Inkscape::CanvasGrid* g = (Inkscape::CanvasGrid*) l->data; |
|
626 |
if (repr == g->repr) { |
|
627 |
grid = g; |
|
628 |
break; |
|
629 |
}
|
|
630 |
}
|
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
631 |
|
2873
by johanengelen
New grids are almost ready to fly! |
632 |
if (!grid) { |
633 |
//create grid object
|
|
2936
by johanengelen
grid: make grid names translatable. use different gridtype names in SVG that are not translated. |
634 |
Inkscape::GridType gridtype = Inkscape::CanvasGrid::getGridTypeFromSVGName(repr->attribute("type")); |
6885
by Ted Gould
From trunk |
635 |
if (!nv->document) { |
4540
by johanengelen
remove SPDesktop from SPNamedView when it is destroyed. Fixing bug 183621, but another bug is apparently present that causes a bug with similar trigger |
636 |
g_warning("sp_namedview_add_grid - how come doc is null here?!"); |
637 |
return NULL; |
|
638 |
}
|
|
6885
by Ted Gould
From trunk |
639 |
grid = Inkscape::CanvasGrid::NewGrid(nv, repr, nv->document, gridtype); |
2873
by johanengelen
New grids are almost ready to fly! |
640 |
nv->grids = g_slist_append(nv->grids, grid); |
641 |
}
|
|
3958
by johanengelen
remove debug messages, convert tabs to spaces and remove whitespace for sp-namedview.cpp |
642 |
|
2873
by johanengelen
New grids are almost ready to fly! |
643 |
if (!desktop) { |
644 |
//add canvasitem to all desktops
|
|
645 |
for (GSList *l = nv->views; l != NULL; l = l->next) { |
|
646 |
SPDesktop *dt = static_cast<SPDesktop*>(l->data); |
|
647 |
grid->createCanvasItem(dt); |
|
648 |
}
|
|
649 |
} else { |
|
650 |
//add canvasitem only for specified desktop
|
|
651 |
grid->createCanvasItem(desktop); |
|
652 |
}
|
|
653 |
||
654 |
return grid; |
|
655 |
}
|
|
656 |
||
1
by mental
moving trunk for module inkscape |
657 |
static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) |
658 |
{
|
|
659 |
SPNamedView *nv = (SPNamedView *) object; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
660 |
|
1
by mental
moving trunk for module inkscape |
661 |
if (((SPObjectClass *) (parent_class))->child_added) { |
662 |
(* ((SPObjectClass *) (parent_class))->child_added)(object, child, ref); |
|
663 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
664 |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
665 |
if (!strcmp(child->name(), "inkscape:grid")) { |
2873
by johanengelen
New grids are almost ready to fly! |
666 |
sp_namedview_add_grid(nv, child, NULL); |
4173
by johanengelen
Lookup object from repr instead of id to fix redo of undo of guide creation :-) |
667 |
} else { |
668 |
SPObject *no = object->document->getObjectByRepr(child); |
|
4172
by johanengelen
don't crash upon adding strange named XML element to namedview. |
669 |
if ( !SP_IS_OBJECT(no) ) |
670 |
return; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
671 |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
672 |
if (SP_IS_GUIDE(no)) { |
673 |
SPGuide *g = (SPGuide *) no; |
|
674 |
nv->guides = g_slist_prepend(nv->guides, g); |
|
675 |
g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); |
|
676 |
if (nv->editable) { |
|
677 |
for (GSList *l = nv->views; l != NULL; l = l->next) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
678 |
g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event); |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
679 |
if (static_cast<SPDesktop*>(l->data)->guides_active) |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
680 |
g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)), |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
681 |
TRUE); |
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
682 |
sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides); |
1
by mental
moving trunk for module inkscape |
683 |
}
|
684 |
}
|
|
685 |
}
|
|
686 |
}
|
|
687 |
}
|
|
688 |
||
689 |
static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *child) |
|
690 |
{
|
|
691 |
SPNamedView *nv = (SPNamedView *) object; |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
692 |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
693 |
if (!strcmp(child->name(), "inkscape:grid")) { |
694 |
for ( GSList *iter = nv->grids ; iter ; iter = iter->next ) { |
|
695 |
Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)iter->data; |
|
696 |
if ( gr->repr == child ) { |
|
697 |
delete gr; |
|
698 |
nv->grids = g_slist_remove_link(nv->grids, iter); |
|
699 |
break; |
|
700 |
}
|
|
701 |
}
|
|
702 |
} else { |
|
703 |
GSList **ref = &nv->guides; |
|
704 |
for ( GSList *iter = nv->guides ; iter ; iter = iter->next ) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
705 |
if ( reinterpret_cast<SPObject *>(iter->data)->getRepr() == child ) { |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
706 |
*ref = iter->next; |
707 |
iter->next = NULL; |
|
708 |
g_slist_free_1(iter); |
|
709 |
break; |
|
710 |
}
|
|
711 |
ref = &iter->next; |
|
712 |
}
|
|
1
by mental
moving trunk for module inkscape |
713 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
714 |
|
1
by mental
moving trunk for module inkscape |
715 |
if (((SPObjectClass *) (parent_class))->remove_child) { |
716 |
(* ((SPObjectClass *) (parent_class))->remove_child)(object, child); |
|
717 |
}
|
|
718 |
}
|
|
719 |
||
5884
by mental
plumb XML::Documents in everywhere |
720 |
static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) |
1
by mental
moving trunk for module inkscape |
721 |
{
|
722 |
if ( ( flags & SP_OBJECT_WRITE_EXT ) && |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
723 |
repr != object->getRepr() ) |
1
by mental
moving trunk for module inkscape |
724 |
{
|
725 |
if (repr) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
726 |
repr->mergeFrom(object->getRepr(), "id"); |
1
by mental
moving trunk for module inkscape |
727 |
} else { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
728 |
repr = object->getRepr()->duplicate(doc); |
1
by mental
moving trunk for module inkscape |
729 |
}
|
730 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
731 |
|
1
by mental
moving trunk for module inkscape |
732 |
return repr; |
733 |
}
|
|
734 |
||
735 |
void SPNamedView::show(SPDesktop *desktop) |
|
736 |
{
|
|
737 |
for (GSList *l = guides; l != NULL; l = l->next) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
738 |
SP_GUIDE(l->data)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event); |
1
by mental
moving trunk for module inkscape |
739 |
if (desktop->guides_active) { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
740 |
SP_GUIDE(l->data)->sensitize(sp_desktop_canvas(desktop), TRUE); |
1
by mental
moving trunk for module inkscape |
741 |
}
|
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
742 |
sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides); |
1
by mental
moving trunk for module inkscape |
743 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
744 |
|
1
by mental
moving trunk for module inkscape |
745 |
views = g_slist_prepend(views, desktop); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
746 |
|
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
747 |
// generate grids specified in SVG:
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
748 |
Inkscape::XML::Node *repr = this->getRepr(); |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
749 |
if (repr) { |
750 |
for (Inkscape::XML::Node * child = repr->firstChild() ; child != NULL; child = child->next() ) { |
|
751 |
if (!strcmp(child->name(), "inkscape:grid")) { |
|
2873
by johanengelen
New grids are almost ready to fly! |
752 |
sp_namedview_add_grid(this, child, desktop); |
2721
by johanengelen
Monster commit. New grid infrastructure. The old gridmanagement code is still there; this committed for testing purposes. Goal is to delete the old grid code later on. |
753 |
}
|
754 |
}
|
|
755 |
}
|
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
756 |
|
4077
by cilix42
Don't set inkscape:modified on startup when grids are shown/hidden. |
757 |
desktop->showGrids(grids_visible, false); |
1
by mental
moving trunk for module inkscape |
758 |
}
|
759 |
||
2059
by ulferikson
open window ON-screen |
760 |
#define MIN_ONSCREEN_DISTANCE 50
|
761 |
||
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
762 |
void SPNamedView::writeNewGrid(SPDocument *document,int gridtype) |
763 |
{
|
|
764 |
g_assert(this->getRepr() != NULL); |
|
765 |
Inkscape::CanvasGrid::writeNewGridToRepr(this->getRepr(),document,static_cast<Inkscape::GridType>(gridtype)); |
|
766 |
}
|
|
767 |
||
1
by mental
moving trunk for module inkscape |
768 |
/*
|
3075
by buliabyak
patch 1734633: option to save window geometry in prefs |
769 |
* Restores window geometry from the document settings or defaults in prefs
|
1
by mental
moving trunk for module inkscape |
770 |
*/
|
771 |
void sp_namedview_window_from_document(SPDesktop *desktop) |
|
772 |
{
|
|
773 |
SPNamedView *nv = desktop->namedview; |
|
6885
by Ted Gould
From trunk |
774 |
Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
775 |
bool geometry_from_file = prefs->getBool("/options/savewindowgeometry/value"); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
776 |
|
3075
by buliabyak
patch 1734633: option to save window geometry in prefs |
777 |
// restore window size and position stored with the document
|
778 |
if (geometry_from_file) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
779 |
if (nv->window_maximized) { |
780 |
Gtk::Window *win = desktop->getToplevel(); |
|
781 |
if (win){ |
|
782 |
win->maximize(); |
|
783 |
}
|
|
784 |
} else { |
|
785 |
gint w = MIN(gdk_screen_width(), nv->window_width); |
|
786 |
gint h = MIN(gdk_screen_height(), nv->window_height); |
|
787 |
// prevent the window from moving off the screen to the right or to the bottom
|
|
788 |
gint x = MIN(gdk_screen_width() - MIN_ONSCREEN_DISTANCE, nv->window_x); |
|
789 |
gint y = MIN(gdk_screen_height() - MIN_ONSCREEN_DISTANCE, nv->window_y); |
|
790 |
// prevent the window from moving off the screen to the left or to the top
|
|
791 |
x = MAX(MIN_ONSCREEN_DISTANCE - nv->window_width, x); |
|
792 |
y = MAX(MIN_ONSCREEN_DISTANCE - nv->window_height, y); |
|
793 |
if (w>0 && h>0) { |
|
794 |
desktop->setWindowSize(w, h); |
|
795 |
desktop->setWindowPosition(Geom::Point(x, y)); |
|
796 |
}
|
|
797 |
}
|
|
1
by mental
moving trunk for module inkscape |
798 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
799 |
|
1
by mental
moving trunk for module inkscape |
800 |
// restore zoom and view
|
5823
by johanengelen
merge gsoc2008_johan_path2geom into trunk |
801 |
if (nv->zoom != 0 && nv->zoom != HUGE_VAL && !IS_NAN(nv->zoom) |
802 |
&& nv->cx != HUGE_VAL && !IS_NAN(nv->cx) |
|
803 |
&& nv->cy != HUGE_VAL && !IS_NAN(nv->cy)) { |
|
1
by mental
moving trunk for module inkscape |
804 |
desktop->zoom_absolute(nv->cx, nv->cy, nv->zoom); |
532
by mental
Get rid of the SP_DT_* macros which do nothing more than provide additional, confusing, names for other functions. If shorter names are desired, the actual functions should be renamed -- or better, made into member functions. |
805 |
} else if (sp_desktop_document(desktop)) { // document without saved zoom, zoom to its page |
1
by mental
moving trunk for module inkscape |
806 |
desktop->zoom_page(); |
807 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
808 |
|
1
by mental
moving trunk for module inkscape |
809 |
// cancel any history of zooms up to this point
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
810 |
desktop->zooms_past.clear(); |
811 |
}
|
|
812 |
||
813 |
bool SPNamedView::getSnapGlobal() const |
|
814 |
{
|
|
815 |
return this->snap_manager.snapprefs.getSnapEnabledGlobally(); |
|
816 |
}
|
|
817 |
||
818 |
void SPNamedView::setSnapGlobal(bool v) |
|
819 |
{
|
|
820 |
g_assert(this->getRepr() != NULL); |
|
821 |
sp_repr_set_boolean(this->getRepr(), "inkscape:snap-global", v); |
|
1984
by buliabyak
separate updating window from updating layers |
822 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
823 |
|
1984
by buliabyak
separate updating window from updating layers |
824 |
void sp_namedview_update_layers_from_document (SPDesktop *desktop) |
825 |
{
|
|
1
by mental
moving trunk for module inkscape |
826 |
SPObject *layer = NULL; |
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
827 |
SPDocument *document = desktop->doc(); |
1984
by buliabyak
separate updating window from updating layers |
828 |
SPNamedView *nv = desktop->namedview; |
1
by mental
moving trunk for module inkscape |
829 |
if ( nv->default_layer_id != 0 ) { |
830 |
layer = document->getObjectById(g_quark_to_string(nv->default_layer_id)); |
|
831 |
}
|
|
832 |
// don't use that object if it's not at least group
|
|
833 |
if ( !layer || !SP_IS_GROUP(layer) ) { |
|
834 |
layer = NULL; |
|
835 |
}
|
|
836 |
// if that didn't work out, look for the topmost layer
|
|
837 |
if (!layer) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
838 |
for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) { |
1
by mental
moving trunk for module inkscape |
839 |
if (desktop->isLayer(iter)) { |
840 |
layer = iter; |
|
841 |
}
|
|
842 |
}
|
|
843 |
}
|
|
844 |
if (layer) { |
|
845 |
desktop->setCurrentLayer(layer); |
|
846 |
}
|
|
1379
by gustav_b
Added descriptions to Undo/Redo commands in the menus |
847 |
|
848 |
// FIXME: find a better place to do this
|
|
1749
by gustav_b
Moved EventLog from SPDocument to SPDesktop to prevent it from being |
849 |
desktop->event_log->updateUndoVerbs(); |
1
by mental
moving trunk for module inkscape |
850 |
}
|
851 |
||
852 |
void sp_namedview_document_from_window(SPDesktop *desktop) |
|
853 |
{
|
|
6885
by Ted Gould
From trunk |
854 |
Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
855 |
bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0); |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
856 |
Inkscape::XML::Node *view = desktop->namedview->getRepr(); |
6839
by cilix42
Next roud of NR ==> Geom conversion |
857 |
Geom::Rect const r = desktop->get_display_area(); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
858 |
|
1
by mental
moving trunk for module inkscape |
859 |
// saving window geometry is not undoable
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
860 |
bool saved = DocumentUndo::getUndoSensitive(sp_desktop_document(desktop)); |
861 |
DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), false); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
862 |
|
1
by mental
moving trunk for module inkscape |
863 |
sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom()); |
6839
by cilix42
Next roud of NR ==> Geom conversion |
864 |
sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]); |
865 |
sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
866 |
|
3075
by buliabyak
patch 1734633: option to save window geometry in prefs |
867 |
if (save_geometry_in_file) { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
868 |
gint w, h, x, y; |
1
by mental
moving trunk for module inkscape |
869 |
desktop->getWindowGeometry(x, y, w, h); |
870 |
sp_repr_set_int(view, "inkscape:window-width", w); |
|
871 |
sp_repr_set_int(view, "inkscape:window-height", h); |
|
872 |
sp_repr_set_int(view, "inkscape:window-x", x); |
|
873 |
sp_repr_set_int(view, "inkscape:window-y", y); |
|
7967
by dvlierop2
Store the maximized state in the document (closes bug #168422) |
874 |
sp_repr_set_int(view, "inkscape:window-maximized", desktop->is_maximized()); |
1
by mental
moving trunk for module inkscape |
875 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
876 |
|
9012.1.115
by Jon A. Cruz
Cleanup on id access. |
877 |
view->setAttribute("inkscape:current-layer", desktop->currentLayer()->getId()); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
878 |
|
1
by mental
moving trunk for module inkscape |
879 |
// restore undoability
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
880 |
DocumentUndo::setUndoSensitive(sp_desktop_document(desktop), saved); |
1
by mental
moving trunk for module inkscape |
881 |
}
|
882 |
||
883 |
void SPNamedView::hide(SPDesktop const *desktop) |
|
884 |
{
|
|
885 |
g_assert(desktop != NULL); |
|
886 |
g_assert(g_slist_find(views, desktop)); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
887 |
|
1
by mental
moving trunk for module inkscape |
888 |
for (GSList *l = guides; l != NULL; l = l->next) { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
889 |
SP_GUIDE(l->data)->hideSPGuide(sp_desktop_canvas(desktop)); |
1
by mental
moving trunk for module inkscape |
890 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
891 |
|
1
by mental
moving trunk for module inkscape |
892 |
views = g_slist_remove(views, desktop); |
893 |
}
|
|
894 |
||
1637
by kidproto
peeled back the gboolean code as it hit on some complexity theory principles... |
895 |
void SPNamedView::activateGuides(gpointer desktop, gboolean active) |
1
by mental
moving trunk for module inkscape |
896 |
{
|
897 |
g_assert(desktop != NULL); |
|
898 |
g_assert(g_slist_find(views, desktop)); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
899 |
|
1
by mental
moving trunk for module inkscape |
900 |
SPDesktop *dt = static_cast<SPDesktop*>(desktop); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
901 |
|
1
by mental
moving trunk for module inkscape |
902 |
for (GSList *l = guides; l != NULL; l = l->next) { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
903 |
SP_GUIDE(l->data)->sensitize( sp_desktop_canvas(dt), active); |
1
by mental
moving trunk for module inkscape |
904 |
}
|
905 |
}
|
|
906 |
||
907 |
static void sp_namedview_setup_guides(SPNamedView *nv) |
|
908 |
{
|
|
909 |
for (GSList *l = nv->guides; l != NULL; l = l->next) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
910 |
sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides); |
1
by mental
moving trunk for module inkscape |
911 |
}
|
912 |
}
|
|
913 |
||
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
914 |
static void sp_namedview_show_single_guide(SPGuide* guide, bool show) |
915 |
{
|
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
916 |
for (GSList *v = guide->views; v != NULL; v = v->next) { |
917 |
if (show) { |
|
918 |
sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); |
|
919 |
sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); |
|
920 |
} else { |
|
921 |
sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); |
|
922 |
sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); |
|
923 |
}
|
|
924 |
}
|
|
7970
by dvlierop2
When a guide is hidden, then also hide its origin (fixes bug #371893) |
925 |
}
|
926 |
||
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
927 |
void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) |
1
by mental
moving trunk for module inkscape |
928 |
{
|
929 |
unsigned int v; |
|
930 |
unsigned int set = sp_repr_get_boolean(repr, "showguides", &v); |
|
931 |
if (!set) { // hide guides if not specified, for backwards compatibility |
|
932 |
v = FALSE; |
|
933 |
} else { |
|
934 |
v = !v; |
|
935 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
936 |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
937 |
bool saved = DocumentUndo::getUndoSensitive(doc); |
938 |
DocumentUndo::setUndoSensitive(doc, false); |
|
1
by mental
moving trunk for module inkscape |
939 |
sp_repr_set_boolean(repr, "showguides", v); |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
940 |
DocumentUndo::setUndoSensitive(doc, saved); |
4491
by mental
stop toggling insensitive state for modification flag updates (fixes critical bug #182401) |
941 |
|
942 |
doc->setModifiedSinceSave(); |
|
1
by mental
moving trunk for module inkscape |
943 |
}
|
944 |
||
4077
by cilix42
Don't set inkscape:modified on startup when grids are shown/hidden. |
945 |
void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_document) |
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
946 |
{
|
947 |
namedview->grids_visible = show; |
|
948 |
||
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
949 |
SPDocument *doc = namedview->document; |
950 |
Inkscape::XML::Node *repr = namedview->getRepr(); |
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
951 |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
952 |
bool saved = DocumentUndo::getUndoSensitive(doc); |
953 |
DocumentUndo::setUndoSensitive(doc, false); |
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
954 |
sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible); |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
955 |
DocumentUndo::setUndoSensitive(doc, saved); |
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
956 |
|
4077
by cilix42
Don't set inkscape:modified on startup when grids are shown/hidden. |
957 |
/* we don't want the document to get dirty on startup; that's when
|
958 |
we call this function with dirty_document = false */
|
|
959 |
if (dirty_document) { |
|
4491
by mental
stop toggling insensitive state for modification flag updates (fixes critical bug #182401) |
960 |
doc->setModifiedSinceSave(); |
4077
by cilix42
Don't set inkscape:modified on startup when grids are shown/hidden. |
961 |
}
|
3957
by johanengelen
Fix bug [ 1818794 ] Showing grid on opening svg |
962 |
}
|
963 |
||
1
by mental
moving trunk for module inkscape |
964 |
gchar const *SPNamedView::getName() const |
965 |
{
|
|
966 |
SPException ex; |
|
967 |
SP_EXCEPTION_INIT(&ex); |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
968 |
return this->getAttribute("id", &ex); |
1
by mental
moving trunk for module inkscape |
969 |
}
|
970 |
||
971 |
guint SPNamedView::getViewCount() |
|
972 |
{
|
|
973 |
return ++viewcount; |
|
974 |
}
|
|
975 |
||
976 |
GSList const *SPNamedView::getViewList() const |
|
977 |
{
|
|
978 |
return views; |
|
979 |
}
|
|
980 |
||
981 |
/* This should be moved somewhere */
|
|
982 |
||
1637
by kidproto
peeled back the gboolean code as it hit on some complexity theory principles... |
983 |
static gboolean sp_str_to_bool(const gchar *str) |
1
by mental
moving trunk for module inkscape |
984 |
{
|
985 |
if (str) { |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
986 |
if (!g_ascii_strcasecmp(str, "true") || |
987 |
!g_ascii_strcasecmp(str, "yes") || |
|
988 |
!g_ascii_strcasecmp(str, "y") || |
|
1
by mental
moving trunk for module inkscape |
989 |
(atoi(str) != 0)) { |
990 |
return TRUE; |
|
991 |
}
|
|
992 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
993 |
|
1
by mental
moving trunk for module inkscape |
994 |
return FALSE; |
995 |
}
|
|
996 |
||
1637
by kidproto
peeled back the gboolean code as it hit on some complexity theory principles... |
997 |
static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color) |
1
by mental
moving trunk for module inkscape |
998 |
{
|
999 |
if (!str) { |
|
1000 |
return FALSE; |
|
1001 |
}
|
|
1002 |
||
1003 |
gchar *u; |
|
2089
by johanengelen
FIXED BUG [ 1612814 ]: Guides and gridlines vanish on corresp. alpha value change |
1004 |
gdouble v = g_ascii_strtod(str, &u); |
1
by mental
moving trunk for module inkscape |
1005 |
if (!u) { |
1006 |
return FALSE; |
|
1007 |
}
|
|
1008 |
v = CLAMP(v, 0.0, 1.0); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1009 |
|
1
by mental
moving trunk for module inkscape |
1010 |
*color = (*color & 0xffffff00) | (guint32) floor(v * 255.9999); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1011 |
|
1
by mental
moving trunk for module inkscape |
1012 |
return TRUE; |
1013 |
}
|
|
1014 |
||
8422
by cilix42
Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. |
1015 |
SPNamedView *sp_document_namedview(SPDocument *document, const gchar *id) |
1
by mental
moving trunk for module inkscape |
1016 |
{
|
1017 |
g_return_val_if_fail(document != NULL, NULL); |
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1018 |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
1019 |
SPObject *nv = sp_item_group_get_child_by_name(document->getRoot(), NULL, "sodipodi:namedview"); |
1
by mental
moving trunk for module inkscape |
1020 |
g_assert(nv != NULL); |
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1021 |
|
1
by mental
moving trunk for module inkscape |
1022 |
if (id == NULL) { |
1023 |
return (SPNamedView *) nv; |
|
1024 |
}
|
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1025 |
|
9012.1.115
by Jon A. Cruz
Cleanup on id access. |
1026 |
while (nv && strcmp(nv->getId(), id)) { |
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
1027 |
nv = sp_item_group_get_child_by_name(document->getRoot(), nv, "sodipodi:namedview"); |
1
by mental
moving trunk for module inkscape |
1028 |
}
|
149
by rwst
bulk trailing spaces removal. consistency through MD5 of binary |
1029 |
|
1
by mental
moving trunk for module inkscape |
1030 |
return (SPNamedView *) nv; |
1031 |
}
|
|
1032 |
||
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
1033 |
void SPNamedView::setGuides(bool v) |
1034 |
{
|
|
1035 |
g_assert(this->getRepr() != NULL); |
|
1036 |
sp_repr_set_boolean(this->getRepr(), "showguides", v); |
|
1037 |
sp_repr_set_boolean(this->getRepr(), "inkscape:guide-bbox", v); |
|
1038 |
}
|
|
1039 |
||
1040 |
/**
|
|
1041 |
* Gets page fitting margin information from the namedview node in the XML.
|
|
1042 |
* \param nv_repr reference to this document's namedview
|
|
1043 |
* \param key the same key used by the RegisteredScalarUnit in
|
|
1044 |
* ui/widget/page-sizer.cpp
|
|
1045 |
* \param margin_units units for the margin
|
|
1046 |
* \param return_units units to return the result in
|
|
1047 |
* \param width width in px (for percentage margins)
|
|
1048 |
* \param height height in px (for percentage margins)
|
|
1049 |
* \param use_width true if the this key is left or right margins, false
|
|
1050 |
* otherwise. Used for percentage margins.
|
|
1051 |
* \return the margin size in px, else 0.0 if anything is invalid.
|
|
1052 |
*/
|
|
1053 |
double SPNamedView::getMarginLength(gchar const * const key, |
|
1054 |
SPUnit const * const margin_units, |
|
1055 |
SPUnit const * const return_units, |
|
1056 |
double const width, |
|
1057 |
double const height, |
|
1058 |
bool const use_width) |
|
1059 |
{
|
|
1060 |
double value; |
|
1061 |
if(!this->storeAsDouble(key,&value)) { |
|
1062 |
return 0.0; |
|
1063 |
}
|
|
1064 |
if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { |
|
1065 |
return (use_width)? width * value : height * value; |
|
1066 |
}
|
|
1067 |
if (!sp_convert_distance (&value, margin_units, return_units)) { |
|
1068 |
return 0.0; |
|
1069 |
}
|
|
1070 |
return value; |
|
1071 |
}
|
|
1072 |
||
1073 |
||
1
by mental
moving trunk for module inkscape |
1074 |
/**
|
1075 |
* Returns namedview's default metric.
|
|
1076 |
*/
|
|
1077 |
SPMetric SPNamedView::getDefaultMetric() const |
|
1078 |
{
|
|
1079 |
if (doc_units) { |
|
1080 |
return sp_unit_get_metric(doc_units); |
|
1081 |
} else { |
|
1082 |
return SP_PT; |
|
1083 |
}
|
|
1084 |
}
|
|
1085 |
||
4296
by johanengelen
angled guidelines: create angled line when dragging from edge of rulers |
1086 |
/**
|
1087 |
* Returns the first grid it could find that isEnabled(). Returns NULL, if none is enabled
|
|
1088 |
*/
|
|
1089 |
Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedview) |
|
1090 |
{
|
|
1091 |
for (GSList const * l = namedview->grids; l != NULL; l = l->next) { |
|
1092 |
Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; |
|
1093 |
if (grid->isEnabled()) |
|
1094 |
return grid; |
|
1095 |
}
|
|
1096 |
||
1097 |
return NULL; |
|
1098 |
}
|
|
1099 |
||
6839
by cilix42
Next roud of NR ==> Geom conversion |
1100 |
void SPNamedView::translateGuides(Geom::Translate const &tr) { |
5771
by sasilver
wrtlprnft's patch for bug 234834 - keeps guidelines in same position relative to objects when doing "Fit page to selection", and also keeps the objects in the same position on the screen |
1101 |
for (GSList *l = guides; l != NULL; l = l->next) { |
1102 |
SPGuide &guide = *SP_GUIDE(l->data); |
|
1103 |
Geom::Point point_on_line = guide.point_on_line; |
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
1104 |
point_on_line *= tr; |
5771
by sasilver
wrtlprnft's patch for bug 234834 - keeps guidelines in same position relative to objects when doing "Fit page to selection", and also keeps the objects in the same position on the screen |
1105 |
sp_guide_moveto(guide, point_on_line, true); |
1106 |
}
|
|
1107 |
}
|
|
1108 |
||
1109 |
void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) { |
|
1110 |
for(GSList *l = views; l; l = l->next) { |
|
1111 |
SPDesktop *desktop = static_cast<SPDesktop *>(l->data); |
|
1112 |
desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling); |
|
1113 |
}
|
|
1114 |
}
|
|
1115 |
||
3029
by pjrm
noop: Fix truncated vim modeline. |
1116 |
|
1
by mental
moving trunk for module inkscape |
1117 |
/*
|
1118 |
Local Variables:
|
|
1119 |
mode:c++
|
|
1120 |
c-file-style:"stroustrup"
|
|
1121 |
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
|
|
1122 |
indent-tabs-mode:nil
|
|
1123 |
fill-column:99
|
|
1124 |
End:
|
|
1125 |
*/
|
|
9020
by JazzyNico
Code refactoring and merging with trunk (revision 10599). |
1126 |
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|