summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-27 22:15:27 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-27 22:15:27 +0000
commit1963c876e1df4780d41252de325e8b19e0cedc3a (patch)
tree0225d228c850bb8d9be7f7fb74bd9addfa1fcd9a /src
parentvarious changes (diff)
parentmodify bbox width for Blur filter in Fill & Stroke (Bug 1171208) (diff)
downloadinkscape-1963c876e1df4780d41252de325e8b19e0cedc3a.tar.gz
inkscape-1963c876e1df4780d41252de325e8b19e0cedc3a.zip
Merged from trunk (r12305)
(bzr r11608.1.106)
Diffstat (limited to 'src')
-rw-r--r--src/color-profile.cpp6
-rw-r--r--src/color.cpp4
-rw-r--r--src/dom/util/ziptool.cpp26
-rw-r--r--src/filter-chemistry.cpp2
-rw-r--r--src/selection-chemistry.cpp78
-rw-r--r--src/selection-chemistry.h3
-rw-r--r--src/snapped-point.cpp163
-rw-r--r--src/sp-use.cpp12
-rw-r--r--src/style.cpp2
-rw-r--r--src/style.h6
-rw-r--r--src/ui/clipboard.cpp12
-rw-r--r--src/ui/dialog/symbols.cpp81
-rw-r--r--src/ui/dialog/symbols.h8
-rw-r--r--src/ui/previewholder.cpp2
-rw-r--r--src/verbs.cpp2
-rw-r--r--src/widgets/desktop-widget.cpp20
-rw-r--r--src/widgets/widget-sizes.h2
-rw-r--r--src/xml/repr-util.cpp2
18 files changed, 233 insertions, 198 deletions
diff --git a/src/color-profile.cpp b/src/color-profile.cpp
index 6e9414074..57cf372a8 100644
--- a/src/color-profile.cpp
+++ b/src/color-profile.cpp
@@ -583,8 +583,6 @@ cmsHTRANSFORM ColorProfile::getTransfGamutCheck()
bool ColorProfile::GamutCheck(SPColor color)
{
- bool result = false;
-
guint32 val = color.toRGBA32(0);
#if HAVE_LIBLCMS1
@@ -615,9 +613,7 @@ bool ColorProfile::GamutCheck(SPColor color)
cmsSetAlarmCodes(oldAlarmCodes);
#endif // HAVE_LIBLCMS1
- result = (outofgamut != 0);
-
- return result;
+ return (outofgamut != 0);
}
class ProfileInfo
diff --git a/src/color.cpp b/src/color.cpp
index 0a07d3f21..5eb0d91ef 100644
--- a/src/color.cpp
+++ b/src/color.cpp
@@ -99,9 +99,7 @@ bool SPColor::operator == (SPColor const& other) const
*/
bool SPColor::isClose( SPColor const& other, float epsilon ) const
{
- bool match = false;
-
- match = (fabs((v.c[0]) - (other.v.c[0])) < epsilon)
+ bool match = (fabs((v.c[0]) - (other.v.c[0])) < epsilon)
&& (fabs((v.c[1]) - (other.v.c[1])) < epsilon)
&& (fabs((v.c[2]) - (other.v.c[2])) < epsilon);
diff --git a/src/dom/util/ziptool.cpp b/src/dom/util/ziptool.cpp
index 9d9d5685c..cf024008f 100644
--- a/src/dom/util/ziptool.cpp
+++ b/src/dom/util/ziptool.cpp
@@ -1895,24 +1895,30 @@ bool GzipFile::readFile(const std::string &fileName)
/**
* Constructor
*/
-ZipEntry::ZipEntry()
+ZipEntry::ZipEntry() :
+ crc (0L),
+ fileName (),
+ comment (),
+ compressionMethod (8),
+ compressedData (),
+ uncompressedData (),
+ position (0)
{
- crc = 0L;
- compressionMethod = 8;
- position = 0;
}
/**
*
*/
ZipEntry::ZipEntry(const std::string &fileNameArg,
- const std::string &commentArg)
+ const std::string &commentArg) :
+ crc (0L),
+ fileName (fileNameArg),
+ comment (commentArg),
+ compressionMethod (8),
+ compressedData (),
+ uncompressedData (),
+ position (0)
{
- crc = 0L;
- compressionMethod = 8;
- fileName = fileNameArg;
- comment = commentArg;
- position = 0;
}
/**
diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp
index 14bd00057..be030e12f 100644
--- a/src/filter-chemistry.cpp
+++ b/src/filter-chemistry.cpp
@@ -70,7 +70,7 @@ static void set_filter_area(Inkscape::XML::Node *repr, gdouble radius,
double rx = radius * (expansionY != 0 ? (expansion / expansionY) : 1);
double ry = radius * (expansionX != 0 ? (expansion / expansionX) : 1);
- if (width != 0 && height != 0 && (2.4 * rx > width * 0.1 || 2.4 * ry > height * 0.1)) {
+ if (width != 0 && height != 0) {
// If not within the default 10% margin (see
// http://www.w3.org/TR/SVG11/filters.html#FilterEffectsRegion), specify margins
// The 2.4 is an empirical coefficient: at that distance the cutoff is practically invisible
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 62ff04cc4..bea65a8e6 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -2892,45 +2892,52 @@ void sp_selection_to_guides(SPDesktop *desktop)
/*
* Convert <g> to <symbol>, leaving all <use> elements referencing group unchanged.
*/
-void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
+void sp_selection_symbols(SPDesktop *desktop, bool /*apply*/ )
{
-
if (desktop == NULL) {
return;
}
SPDocument *doc = sp_desktop_document(desktop);
- Inkscape::XML::Document *xml_doc = doc->getReprDoc();
+ doc->ensureUpToDate();
Inkscape::Selection *selection = sp_desktop_selection(desktop);
// Check if something is selected.
if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one <b>group</b> to convert to symbol."));
- return;
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>groups</b> to convert to symbols."));
+ return;
}
- SPObject* group = selection->single();
+ GSList *items = g_slist_copy(const_cast<GSList *>(selection->list()));
+ bool hasWorked = false;
- // Make sure we have only one object in selection.
- if( group == NULL ) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>group</b> to convert to symbol."));
- return;
- }
+ for ( GSList const *iter=items; iter != NULL ; iter = iter->next ) {
+ SPObject *object = reinterpret_cast<SPObject *>( iter->data );
- // Make sure we convert the original.
- if( SP_IS_USE( group ) ) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select original (<b>Shift+D</b>) to convert to symbol."));
- return;
+ // Require that we really have a group.
+ if( SP_IS_GROUP( object ) ) {
+ sp_selection_symbol( doc, object );
+ hasWorked = true;
+ }
}
- // Require that we really have a group.
- if( !SP_IS_GROUP( group ) ) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Group selection first to convert to symbol."));
- return;
+ g_slist_free(items);
+
+ if( !hasWorked ) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No <b>groups</b> converted to symbols."));
+ return;
}
- doc->ensureUpToDate();
+ selection->clear();
+ // Group just disappears, nothing to select.
+
+ DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol"));
+}
+
+void sp_selection_symbol(SPDocument *doc, SPObject *group)
+{
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *symbol = xml_doc->createElement("svg:symbol");
symbol->setAttribute("style", group->getAttribute("style"));
@@ -2952,20 +2959,25 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
// Need to delete <g>; all <use> elements that referenced <g> should
// auto-magically reference <symbol>.
doc->getDefs()->getRepr()->appendChild(symbol);
- symbol->setAttribute("id",id.c_str()); // After we delete group with same id.
- // Mysterious, must set symbol ID before deleting group or all <use>
- // refering to symbol get turned into groups. (Linked to unlinking clones?)
- group->deleteObject(true);
+ // Mysterious, must set symbol ID before deleting group or all <use> items
+ // get turned into groups. (Linked to unlinking clones?)
+ symbol->setAttribute("id",id.c_str());
- Inkscape::GC::release(symbol);
- selection->clear();
- // Group just disappears, nothing to select.
+ // Create a clone of the symbol to replace the deleted group.
+ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
+ clone->setAttribute("x", "0", false);
+ clone->setAttribute("y", "0", false);
+ clone->setAttribute("xlink:href", g_strdup_printf("#%s", id.c_str()), false);
- // Need to signal Symbol dialog to update
+ clone->setAttribute("inkscape:transform-center-x", group->getAttribute("inkscape:transform-center-x"), false);
+ clone->setAttribute("inkscape:transform-center-y", group->getAttribute("inkscape:transform-center-y"), false);
+ group->parent->getRepr()->appendChild(clone);
+
+ group->deleteObject(true);
g_slist_free(children);
- DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol"));
+ Inkscape::GC::release(symbol);
}
/*
@@ -2973,7 +2985,6 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
*/
void sp_selection_unsymbol(SPDesktop *desktop)
{
-
if (desktop == NULL) {
return;
}
@@ -2992,13 +3003,8 @@ void sp_selection_unsymbol(SPDesktop *desktop)
SPObject* use = selection->single();
// Make sure we have only one object in selection.
- if( use == NULL ) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> to convert to group."));
- return;
- }
-
// Require that we really have a <use> that references a <symbol>.
- if( !SP_IS_USE( use ) && !SP_IS_SYMBOL( use->firstChild() ) ) {
+ if( use == NULL || ( !SP_IS_USE( use ) && !SP_IS_SYMBOL( use->firstChild() ))) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> to convert to group."));
return;
}
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 83dd93bdd..1c627fd1a 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -68,7 +68,8 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop);
void sp_selection_to_marker(SPDesktop *desktop, bool apply = true);
void sp_selection_to_guides(SPDesktop *desktop);
-void sp_selection_symbol(SPDesktop *desktop, bool apply = true);
+void sp_selection_symbols(SPDesktop *desktop, bool apply = true);
+void sp_selection_symbol(SPDocument *doc, SPObject *group);
void sp_selection_unsymbol(SPDesktop *desktop);
void sp_selection_tile(SPDesktop *desktop, bool apply = true);
diff --git a/src/snapped-point.cpp b/src/snapped-point.cpp
index d155babd7..ab545bd5f 100644
--- a/src/snapped-point.cpp
+++ b/src/snapped-point.cpp
@@ -14,92 +14,111 @@
#include "preferences.h"
// overloaded constructor
-Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained, Geom::OptRect target_bbox)
- : _point(p), _source(source), _source_num(source_num), _target(target), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a), _target_bbox(target_bbox)
+Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained, Geom::OptRect target_bbox) :
+ _point(p),
+ _tangent(Geom::Point(0,0)),
+ _source(source),
+ _source_num(source_num),
+ _target(target),
+ _at_intersection (false),
+ _constrained_snap (constrained_snap),
+ _fully_constrained (fully_constrained),
+ _distance(d),
+ _tolerance(std::max(t,1.0)),// tolerance should never be smaller than 1 px, as it is used for normalization in isOtherSnapBetter. We don't want a division by zero.
+ _always_snap(a),
+ _second_distance (Geom::infinity()),
+ _second_tolerance (1),
+ _second_always_snap (false),
+ _transformation (Geom::Point(1,1)),
+ _target_bbox(target_bbox),
+ _pointer_distance (Geom::infinity())
{
- // tolerance should never be smaller than 1 px, as it is used for normalization in isOtherSnapBetter. We don't want a division by zero.
- _at_intersection = false;
- _constrained_snap = constrained_snap;
- _fully_constrained = fully_constrained;
- _second_distance = Geom::infinity();
- _second_tolerance = 1;
- _second_always_snap = false;
- _transformation = Geom::Point(1,1);
- _tangent = Geom::Point(0,0);
- _pointer_distance = Geom::infinity();
}
-Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained)
- : _target(target), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a)
+Inkscape::SnappedPoint::SnappedPoint(Inkscape::SnapCandidatePoint const &p, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &constrained_snap, bool const &fully_constrained) :
+ _point (p.getPoint()),
+ _tangent (Geom::Point(0,0)),
+ _source (p.getSourceType()),
+ _source_num (p.getSourceNum()),
+ _target(target),
+ _at_intersection (false),
+ _constrained_snap (constrained_snap),
+ _fully_constrained (fully_constrained),
+ _distance(d),
+ _tolerance(std::max(t,1.0)),
+ _always_snap(a),
+ _second_distance (Geom::infinity()),
+ _second_tolerance (1),
+ _second_always_snap (false),
+ _transformation (Geom::Point(1,1)),
+ _target_bbox (p.getTargetBBox()),
+ _pointer_distance (Geom::infinity())
{
- _point = p.getPoint();
- _source = p.getSourceType();
- _source_num = p.getSourceNum();
- _at_intersection = false;
- _constrained_snap = constrained_snap;
- _fully_constrained = fully_constrained;
- _second_distance = Geom::infinity();
- _second_tolerance = 1;
- _second_always_snap = false;
- _transformation = Geom::Point(1,1);
- _tangent = Geom::Point(0,0);
- _pointer_distance = Geom::infinity();
- _target_bbox = p.getTargetBBox();
-
}
-Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &constrained_snap, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2)
- : _point(p), _source(source), _source_num(source_num), _target(target), _at_intersection(at_intersection), _constrained_snap(constrained_snap), _fully_constrained(fully_constrained), _distance(d), _tolerance(std::max(t,1.0)), _always_snap(a),
- _second_distance(d2), _second_tolerance(std::max(t2,1.0)), _second_always_snap(a2)
-{
+Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &d, Geom::Coord const &t, bool const &a, bool const &at_intersection, bool const &constrained_snap, bool const &fully_constrained, Geom::Coord const &d2, Geom::Coord const &t2, bool const &a2) :
+ _point(p),
+ _tangent (Geom::Point(0,0)),
+ _source(source),
+ _source_num(source_num),
+ _target(target),
+ _at_intersection(at_intersection),
+ _constrained_snap(constrained_snap),
+ _fully_constrained(fully_constrained),
+ _distance(d),
+ _tolerance(std::max(t,1.0)),
+ _always_snap(a),
+ _second_distance(d2),
+ _second_tolerance(std::max(t2,1.0)),
+ _second_always_snap(a2),
// tolerance should never be smaller than 1 px, as it is used for normalization in
// isOtherSnapBetter. We don't want a division by zero.
- _transformation = Geom::Point(1,1);
- _tangent = Geom::Point(0,0);
- _pointer_distance = Geom::infinity();
- _target_bbox = Geom::OptRect();
+ _transformation (Geom::Point(1,1)),
+ _target_bbox (Geom::OptRect()),
+ _pointer_distance (Geom::infinity())
+{
}
-Inkscape::SnappedPoint::SnappedPoint()
+Inkscape::SnappedPoint::SnappedPoint():
+ _point (Geom::Point(0,0)),
+ _tangent (Geom::Point(0,0)),
+ _source (SNAPSOURCE_UNDEFINED),
+ _source_num (-1),
+ _target (SNAPTARGET_UNDEFINED),
+ _at_intersection (false),
+ _constrained_snap (false),
+ _fully_constrained (false),
+ _distance (Geom::infinity()),
+ _tolerance (1),
+ _always_snap (false),
+ _second_distance (Geom::infinity()),
+ _second_tolerance (1),
+ _second_always_snap (false),
+ _transformation (Geom::Point(1,1)),
+ _target_bbox (Geom::OptRect()),
+ _pointer_distance (Geom::infinity())
{
- _point = Geom::Point(0,0);
- _source = SNAPSOURCE_UNDEFINED,
- _source_num = -1,
- _target = SNAPTARGET_UNDEFINED,
- _at_intersection = false;
- _constrained_snap = false;
- _fully_constrained = false;
- _distance = Geom::infinity();
- _tolerance = 1;
- _always_snap = false;
- _second_distance = Geom::infinity();
- _second_tolerance = 1;
- _second_always_snap = false;
- _transformation = Geom::Point(1,1);
- _tangent = Geom::Point(0,0);
- _pointer_distance = Geom::infinity();
- _target_bbox = Geom::OptRect();
}
-Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p)
+Inkscape::SnappedPoint::SnappedPoint(Geom::Point const &p):
+ _point (p),
+ _tangent (Geom::Point(0,0)),
+ _source (SNAPSOURCE_UNDEFINED),
+ _source_num (-1),
+ _target (SNAPTARGET_UNDEFINED),
+ _at_intersection (false),
+ _constrained_snap (false),
+ _fully_constrained (false),
+ _distance (Geom::infinity()),
+ _tolerance (1),
+ _always_snap (false),
+ _second_distance (Geom::infinity()),
+ _second_tolerance (1),
+ _second_always_snap (false),
+ _transformation (Geom::Point(1,1)),
+ _target_bbox (Geom::OptRect()),
+ _pointer_distance (Geom::infinity())
{
- _point = p;
- _source = SNAPSOURCE_UNDEFINED,
- _source_num = -1,
- _target = SNAPTARGET_UNDEFINED,
- _at_intersection = false;
- _constrained_snap = false;
- _fully_constrained = false;
- _distance = Geom::infinity();
- _tolerance = 1;
- _always_snap = false;
- _second_distance = Geom::infinity();
- _second_tolerance = 1;
- _second_always_snap = false;
- _transformation = Geom::Point(1,1);
- _tangent = Geom::Point(0,0);
- _pointer_distance = Geom::infinity();
- _target_bbox = Geom::OptRect();
}
Inkscape::SnappedPoint::~SnappedPoint()
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index f565cba20..d923410c8 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -30,6 +30,7 @@
#include "uri.h"
#include "print.h"
#include "xml/repr.h"
+#include "svg/svg.h"
#include "preferences.h"
#include "style.h"
#include "sp-symbol.h"
@@ -179,8 +180,8 @@ Inkscape::XML::Node* SPUse::write(Inkscape::XML::Document *xml_doc, Inkscape::XM
sp_repr_set_svg_double(repr, "x", this->x.computed);
sp_repr_set_svg_double(repr, "y", this->y.computed);
- sp_repr_set_svg_double(repr, "width", this->width.computed);
- sp_repr_set_svg_double(repr, "height", this->height.computed);
+ repr->setAttribute("width", sp_svg_length_write_with_units(this->width).c_str());
+ repr->setAttribute("height", sp_svg_length_write_with_units(this->height).c_str());
if (this->ref->getURI()) {
gchar *uri_string = this->ref->getURI()->toString();
@@ -230,10 +231,9 @@ gchar* SPUse::description() {
if (this->child) {
if( SP_IS_SYMBOL( this->child ) ) {
- //char *symbol_desc = SP_ITEM(this->child)->description();
- //g_free(symbol_desc);
- return g_strdup(_("<b>Clone of Symbol</b>"));
- //return g_strdup_printf(_("<b>Clone of Symbol</b>: %s"), symbol_desc );
+ char *symbol_desc = SP_ITEM(this->child)->title();
+ return g_strdup_printf(_("<b>'%s' Symbol</b>"), symbol_desc );
+ g_free(symbol_desc);
}
static unsigned recursion_depth = 0;
diff --git a/src/style.cpp b/src/style.cpp
index ca89e6f65..479f30597 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -4358,7 +4358,7 @@ sp_style_write_ifilter(gchar *p, gint const len, gchar const *key,
}
SPIPaint::SPIPaint() :
- set(0),
+ set(false),
inherit(0),
currentcolor(0),
colorSet(0),
diff --git a/src/style.h b/src/style.h
index 534a6ae70..2b98c9e5d 100644
--- a/src/style.h
+++ b/src/style.h
@@ -136,9 +136,9 @@ struct SPILength {
/// Paint type internal to SPStyle.
struct SPIPaint {
- unsigned set : 1;
- unsigned inherit : 1;
- unsigned currentcolor : 1;
+ unsigned int set : 1; //c++ bitfields are used here as opposed to bools to reduce memory consumption, see http://tinyurl.com/cswh6mq
+ unsigned int inherit : 1;
+ unsigned int currentcolor : 1;
unsigned int colorSet : 1;
unsigned int noneSet : 1;
struct {
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 822f55a93..59fcb9ec0 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -332,6 +332,10 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const*
use->setAttribute("style", style );
_root->appendChild(use);
+ // This min and max sets offsets, we don't have any so set to zero.
+ sp_repr_set_point(_clipnode, "min", Geom::Point(0,0));
+ sp_repr_set_point(_clipnode, "max", Geom::Point(0,0));
+
fit_canvas_to_drawing(_clipboardSPDoc);
_setClipboardTargets();
}
@@ -767,14 +771,6 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
- // Copy symbols: We may want to be more clever...
- // if (SP_IS_USE(item)) {
- // SPObject *symbol = SP_USE(item)->child;
- // if( symbol && SP_IS_SYMBOL(symbol) ) {
- // _copyNode(symbol->getRepr(), _doc, _defs);
- // }
- // }
-
// recurse
for (SPObject *o = item->children ; o != NULL ; o = o->next) {
if (SP_IS_ITEM(o)) {
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index 4eeb1b5f0..989375bbd 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -49,6 +49,7 @@
#include "inkscape.h"
#include "sp-root.h"
#include "sp-use.h"
+#include "sp-defs.h"
#include "sp-symbol.h"
#ifdef WITH_LIBVISIO
@@ -246,12 +247,19 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
key = SPItem::display_key_new(1);
renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY ));
+ // This might need to be a global variable so setTargetDesktop can modify it
+ SPDefs *defs = currentDocument->getDefs();
+ sigc::connection defsModifiedConn = (SP_OBJECT(defs))->connectModified(
+ sigc::mem_fun(*this, &SymbolsDialog::defsModified));
+ instanceConns.push_back(defsModifiedConn);
+
get_symbols();
draw_symbols( currentDocument ); /* Defaults to current document */
- desktopChangeConn =
+ sigc::connection desktopChangeConn =
deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) );
instanceConns.push_back( desktopChangeConn );
+
deskTrack.connect(GTK_WIDGET(gobj()));
}
@@ -304,6 +312,13 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*cont
}
+void SymbolsDialog::defsModified(SPObject *object, guint flags)
+{
+ if ( !symbolSets[symbolSet->get_active_text()] ) {
+ rebuild();
+ }
+}
+
void SymbolsDialog::iconChanged() {
#if WITH_GTKMM_3_0
std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items();
@@ -484,10 +499,8 @@ void SymbolsDialog::get_symbols() {
}
GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l)
-{
- if (!r) {
- return l;
- }
+{
+ g_return_val_if_fail(r != NULL, l);
// Stop multiple counting of same symbol
if( SP_IS_USE(r) ) {
@@ -559,32 +572,32 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen
void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) {
-
- SymbolColumns* columns = getColumns();
-
GSList* l = symbols_in_doc( symbolDocument );
for( ; l != NULL; l = l->next ) {
-
SPObject* symbol = SP_OBJECT(l->data);
- if (!SP_IS_SYMBOL(symbol)) {
- //std::cout << " Error: not symbol" << std::endl;
- continue;
+ if (SP_IS_SYMBOL(symbol)) {
+ draw_symbol( symbol );
}
+ }
+}
- gchar const *id = symbol->getRepr()->attribute("id");
- gchar const *title = symbol->title(); // From title element
- if( !title ) {
- title = id;
- }
+void SymbolsDialog::draw_symbol( SPObject* symbol ) {
+
+ SymbolColumns* columns = getColumns();
- Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbolDocument, &renderDrawing, key );
- if( pixbuf ) {
+ gchar const *id = symbol->getRepr()->attribute("id");
+ gchar const *title = symbol->title(); // From title element
+ if( !title ) {
+ title = id;
+ }
- Gtk::ListStore::iterator row = store->append();
- (*row)[columns->symbol_id] = Glib::ustring( id );
- (*row)[columns->symbol_title] = Glib::ustring( title );
- (*row)[columns->symbol_image] = pixbuf;
- }
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = create_symbol_image(id, symbol );
+
+ if( pixbuf ) {
+ Gtk::ListStore::iterator row = store->append();
+ (*row)[columns->symbol_id] = Glib::ustring( id );
+ (*row)[columns->symbol_title] = Glib::ustring( title );
+ (*row)[columns->symbol_image] = pixbuf;
}
delete columns;
@@ -600,18 +613,8 @@ void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) {
* the temporary document is rendered.
*/
Glib::RefPtr<Gdk::Pixbuf>
-SymbolsDialog::create_symbol_image(gchar const *symbol_id,
- SPDocument *source,
- Inkscape::Drawing* drawing,
- unsigned /*visionkey*/)
+SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol)
{
- // Retrieve the symbol named 'symbol_id' from the source SVG document
- SPObject const* symbol = source->getObjectById(symbol_id);
- if (symbol == NULL) {
- //std::cout << " Failed to find symbol: " << symbol_id << std::endl;
- //return 0;
- }
-
// Create a copy repr of the symbol with id="the_symbol"
Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc();
Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc);
@@ -628,10 +631,10 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id,
gchar const* style = repr->attribute("inkscape:symbol-style");
if( !style ) {
// If no default style in <symbol>, look in documents.
- if( source == currentDocument ) {
- style = style_from_use( symbol_id, source );
+ if( symbol->document == currentDocument ) {
+ style = style_from_use( symbol_id, symbol->document );
} else {
- style = source->getReprRoot()->attribute("style");
+ style = symbol->document->getReprRoot()->attribute("style");
}
}
// Last ditch effort to provide some default styling
@@ -721,7 +724,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id,
scale = atof( previewScaleString.c_str() );
}
- pixbuf = Glib::wrap(render_pixbuf(*drawing, scale, *dbox, psize));
+ pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize));
svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj());
}
diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h
index 08221bf22..b81f6981e 100644
--- a/src/ui/dialog/symbols.h
+++ b/src/ui/dialog/symbols.h
@@ -46,11 +46,13 @@ private:
static SymbolColumns *getColumns();
void rebuild();
+ void defsModified(SPObject *object, guint flags);
void iconChanged();
void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time);
void get_symbols();
void draw_symbols( SPDocument* symbol_document );
+ void draw_symbol( SPObject* symbol_document );
SPDocument* symbols_preview_doc();
GSList* symbols_in_doc_recursive(SPObject *r, GSList *l);
@@ -60,9 +62,7 @@ private:
gchar const* style_from_use( gchar const* id, SPDocument* document);
Glib::RefPtr<Gdk::Pixbuf>
- create_symbol_image(gchar const *symbol_name,
- SPDocument *source, Inkscape::Drawing* drawing,
- unsigned /*visionkey*/);
+ create_symbol_image(gchar const *symbol_name, SPObject *symbol);
/* Keep track of all symbol template documents */
std::map<Glib::ustring, SPDocument*> symbolSets;
@@ -85,8 +85,6 @@ private:
Inkscape::Drawing renderDrawing;
std::vector<sigc::connection> instanceConns;
- sigc::connection desktopChangeConn;
-
};
} //namespace Dialogs
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index b5a1a29a8..38f6f353f 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -50,6 +50,8 @@ PreviewHolder::PreviewHolder() :
_border(BORDER_NONE)
{
_scroller = manage(new Gtk::ScrolledWindow());
+ ((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC,
+ Gtk::POLICY_AUTOMATIC);
#if WITH_GTKMM_3_0
_insides = manage(new Gtk::Grid());
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 4777e168c..ec7cad8dd 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -955,7 +955,7 @@ void EditVerb::perform(SPAction *action, void *data)
sp_selection_untile(dt);
break;
case SP_VERB_EDIT_SYMBOL:
- sp_selection_symbol(dt);
+ sp_selection_symbols(dt);
break;
case SP_VERB_EDIT_UNSYMBOL:
sp_selection_unsymbol(dt);
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 55451c035..3c24bcc67 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -55,6 +55,7 @@
#include "ui/widget/dock.h"
#include "ui/widget/layer-selector.h"
#include "ui/widget/selected-style.h"
+#include "ui/widget/gimpspinscale.h"
#include "ui/uxmanager.h"
#include "util/ege-appear-time-tracker.h"
#include "sp-root.h"
@@ -628,7 +629,14 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
gtk_box_pack_end (GTK_BOX (dtw->statusbar), statusbar_tail, FALSE, FALSE, 0);
// zoom status spinbutton
- dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1);
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _adjustment = Gtk::Adjustment::create(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0);
+#else
+ Gtk::Adjustment *_adjustment = new Gtk::Adjustment(100.0, log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1, 1.0);
+#endif
+ dtw->zoom_status = gimp_spin_scale_new (_adjustment->gobj(), _("Zoom"), 1);
+
+ //dtw->zoom_status = gtk_spin_button_new_with_range (log(SP_DESKTOP_ZOOM_MIN)/log(2), log(SP_DESKTOP_ZOOM_MAX)/log(2), 0.1);
gtk_widget_set_tooltip_text (dtw->zoom_status, _("Zoom"));
gtk_widget_set_size_request (dtw->zoom_status, STATUS_ZOOM_WIDTH, -1);
gtk_entry_set_width_chars (GTK_ENTRY (dtw->zoom_status), 6);
@@ -689,18 +697,18 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
dtw->coord_status_y = gtk_label_new(NULL);
gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" );
gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5);
- GtkWidget* label_z = gtk_label_new(_("Z:"));
+ //GtkWidget* label_z = gtk_label_new(_("Z:"));
#if GTK_CHECK_VERSION(3,0,0)
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_x, 2, 0, 1, 1);
gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->coord_status_y, 2, 1, 1, 1);
- gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
- gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 4, 0, 1, 2);
+ //gtk_grid_attach(GTK_GRID(dtw->coord_status), label_z, 3, 0, 1, 2);
+ gtk_grid_attach(GTK_GRID(dtw->coord_status), dtw->zoom_status, 3, 0, 1, 2);
#else
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_x, 2,3, 0,1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->coord_status_y, 2,3, 1,2, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
- gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 4,5, 0,2, GTK_FILL, GTK_FILL, 0, 0);
+ //gtk_table_attach(GTK_TABLE(dtw->coord_status), label_z, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(dtw->coord_status), dtw->zoom_status, 3,4, 0,2, GTK_FILL, GTK_FILL, 0, 0);
#endif
sp_set_font_size_smaller (dtw->coord_status);
diff --git a/src/widgets/widget-sizes.h b/src/widgets/widget-sizes.h
index 87c7ca2e0..8db036734 100644
--- a/src/widgets/widget-sizes.h
+++ b/src/widgets/widget-sizes.h
@@ -27,7 +27,7 @@
#define STATUS_BAR_FONT_SIZE 10000
-#define STATUS_ZOOM_WIDTH 57
+#define STATUS_ZOOM_WIDTH 100
#define SELECTED_STYLE_SB_WIDTH 48
#define SELECTED_STYLE_WIDTH 190
diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp
index 6ea20b87a..8c8425de0 100644
--- a/src/xml/repr-util.cpp
+++ b/src/xml/repr-util.cpp
@@ -524,6 +524,8 @@ unsigned int sp_repr_get_point(Inkscape::XML::Node *repr, gchar const *key, Geom
gchar const *v = repr->attribute(key);
+ g_return_val_if_fail(v != NULL, FALSE);
+
gchar ** strarray = g_strsplit(v, ",", 2);
if (strarray && strarray[0] && strarray[1]) {