summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-02-09 22:49:34 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx.marker.es>2013-02-09 22:49:34 +0000
commitf7fafe0ced665cbb122bd5828e68046d52086c71 (patch)
tree751c8c5912ab02f789a4291f22cf344d01bd8adc /src
parentMerge from branch (diff)
parentUse update_font_list() in font-lister.cpp. Remove equivalent code in text-too... (diff)
downloadinkscape-f7fafe0ced665cbb122bd5828e68046d52086c71.tar.gz
inkscape-f7fafe0ced665cbb122bd5828e68046d52086c71.zip
Merge from Trunk
(bzr r11950.1.20)
Diffstat (limited to 'src')
-rw-r--r--src/dom/CMakeLists.txt6
-rw-r--r--src/dom/Makefile_insert4
-rw-r--r--src/dom/odf/odfdocument.cpp167
-rw-r--r--src/dom/odf/odfdocument.h150
-rw-r--r--src/dom/svgimpl.h9
-rw-r--r--src/dom/svgtypes.h239
-rw-r--r--src/dom/util/thread.cpp126
-rw-r--r--src/dom/util/thread.h156
-rw-r--r--src/ink-comboboxentry-action.cpp62
-rw-r--r--src/ink-comboboxentry-action.h2
-rw-r--r--src/libnrtype/font-lister.cpp151
-rw-r--r--src/libnrtype/font-lister.h45
-rw-r--r--src/widgets/text-toolbar.cpp174
13 files changed, 496 insertions, 795 deletions
diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt
index df2411b13..15b4ba74d 100644
--- a/src/dom/CMakeLists.txt
+++ b/src/dom/CMakeLists.txt
@@ -26,10 +26,7 @@ set(dom_SRC
io/stringstream.cpp
io/uristream.cpp
- odf/odfdocument.cpp
-
util/digest.cpp
- util/thread.cpp
util/ziptool.cpp
@@ -64,8 +61,6 @@ set(dom_SRC
xpathparser.h
xpathtoken.h
- odf/odfdocument.h
-
io/base64stream.h
io/bufferstream.h
io/domstream.h
@@ -74,7 +69,6 @@ set(dom_SRC
io/uristream.h
util/digest.h
- util/thread.h
util/ziptool.h
)
diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert
index ace53b4a2..17bab94ac 100644
--- a/src/dom/Makefile_insert
+++ b/src/dom/Makefile_insert
@@ -64,12 +64,8 @@ dom_libdom_a_SOURCES = \
dom/io/stringstream.h \
dom/io/uristream.cpp \
dom/io/uristream.h \
- dom/odf/odfdocument.cpp \
- dom/odf/odfdocument.h \
dom/util/digest.h \
dom/util/digest.cpp \
- dom/util/thread.h \
- dom/util/thread.cpp \
dom/util/ziptool.h \
dom/util/ziptool.cpp
diff --git a/src/dom/odf/odfdocument.cpp b/src/dom/odf/odfdocument.cpp
deleted file mode 100644
index cf460c964..000000000
--- a/src/dom/odf/odfdocument.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *
- * This class contains an ODF Document.
- * Initially, we are just concerned with .odg content.xml + resources
- *
- * ---------------------------------------------------------------------
- *
- * Copyright (C) 2006-2008 Bob Jamison
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * For more information, please write to rwjj@earthlink.net
- *
- * RWJ : 080207: Changed to GPL2 by me
- *
- */
-
-#include "odfdocument.h"
-
-
-namespace odf
-{
-
-
-//########################################################################
-//# I M A G E D A T A
-//########################################################################
-
-
-/**
- *
- */
-ImageData::ImageData(const std::string &fname,
- const std::vector<unsigned char> &buf)
- : fileName (fname),
- data (buf)
-
-{
-}
-
-/**
- *
- */
-ImageData::ImageData(const ImageData &other)
- : fileName (other.fileName),
- data (other.data)
-
-{
-}
-
-/**
- *
- */
-ImageData::~ImageData()
-{
-}
-
-/**
- *
- */
-std::string ImageData::getFileName()
-{
- return fileName;
-}
-
-/**
- *
- */
-void ImageData::setFileName(const std::string &val)
-{
- fileName = val;
-}
-
-/**
- *
- */
-std::vector<unsigned char> &ImageData::getData()
-{
- return data;
-}
-
-/**
- *
- */
-void ImageData::setData(const std::vector<unsigned char> &buf)
-{
- data = buf;
-}
-
-
-
-
-
-//########################################################################
-//# O D F D O C U M E N T
-//########################################################################
-
-
-
-/**
- *
- */
-OdfDocument::OdfDocument() :
- content(0),
- images()
-{
-}
-
-
-/**
- *
- */
-OdfDocument::OdfDocument(const OdfDocument &other) :
- content (other.content),
- images (other.images)
-{
-}
-
-
-/**
- *
- */
-OdfDocument::~OdfDocument()
-{
-}
-
-/**
- *
- */
-bool OdfDocument::readFile(const std::string &/*fileName*/)
-{
- return true;
-}
-
-/**
- *
- */
-bool OdfDocument::writeFile(const std::string &/*fileName*/)
-{
- return true;
-}
-
-
-
-
-
-} //namespace odf
-
-
-
-
-//########################################################################
-//# E N D O F F I L E
-//########################################################################
-
diff --git a/src/dom/odf/odfdocument.h b/src/dom/odf/odfdocument.h
deleted file mode 100644
index 168df11c7..000000000
--- a/src/dom/odf/odfdocument.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef SEEN_ODF_DOCUMENT_H
-#define SEEN_ODF_DOCUMENT_H
-/*
- * Copyright (C) 2006 Bob Jamison
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * For more information, please write to rwjj@earthlink.net
- *
- * RWJ : 080207: Changed to GPL2 by me
- */
-
-#include <vector>
-#include <string>
-
-#include "dom/dom.h"
-
-namespace odf
-{
-
-
-//########################################################################
-//# I M A G E D A T A
-//########################################################################
-
-/**
- *
- */
-class ImageData
-{
-public:
-
- /**
- *
- */
- ImageData(const std::string &fileName,
- const std::vector<unsigned char> &buf);
-
- /**
- *
- */
- ImageData(const ImageData &other);
-
- /**
- *
- */
- virtual ~ImageData();
-
- /**
- *
- */
- virtual std::string getFileName();
-
- /**
- *
- */
- virtual void setFileName(const std::string &val);
-
- /**
- *
- */
- virtual std::vector<unsigned char> &getData();
-
- /**
- *
- */
- virtual void setData(const std::vector<unsigned char> &buf);
-
-private:
-
- std::string fileName;
-
- std::vector<unsigned char> data;
-
-};
-
-
-
-
-
-//########################################################################
-//# O D F D O C U M E N T
-//########################################################################
-
-
-/**
- *
- * This class contains an ODF Document.
- * Initially, we are just concerned with .odg content.xml + resources
- */
-class OdfDocument
-{
-public:
-
- /**
- *
- */
- OdfDocument();
-
- /**
- * Copy constructor
- */
- OdfDocument(const OdfDocument &other);
-
- /**
- *
- */
- virtual ~OdfDocument();
-
- /**
- *
- */
- virtual bool readFile(const std::string &fileName);
-
- /**
- *
- */
- virtual bool writeFile(const std::string &fileName);
-
-
-private:
-
- org::w3c::dom::Document *content;
-
- std::vector<ImageData> images;
-
-};
-
-} //namespace odf
-
-
-
-#endif // SEEN_ODF_DOCUMENT_H
-
-//########################################################################
-//# E N D O F F I L E
-//########################################################################
-
diff --git a/src/dom/svgimpl.h b/src/dom/svgimpl.h
index 83d56fa22..2ee5c8bc7 100644
--- a/src/dom/svgimpl.h
+++ b/src/dom/svgimpl.h
@@ -980,7 +980,14 @@ public:
/**
*
*/
- SVGSVGElementImpl() : SVGElementImpl()
+ SVGSVGElementImpl() : SVGElementImpl(),
+ pixelUnitToMillimeterX(0),
+ pixelUnitToMillimeterY(0),
+ screenPixelToMillimeterX(0),
+ screenPixelToMillimeterY(0),
+ useCurrentView(false),
+ currentScale(0),
+ currentTime(0)
{}
diff --git a/src/dom/svgtypes.h b/src/dom/svgtypes.h
index 41b4de307..bb828571f 100644
--- a/src/dom/svgtypes.h
+++ b/src/dom/svgtypes.h
@@ -645,20 +645,20 @@ public:
/**
*
*/
- SVGTransform()
+ SVGTransform() :
+ type (SVG_TRANSFORM_UNKNOWN),
+ angle (0.0)
{
- type = SVG_TRANSFORM_UNKNOWN;
- angle = 0.0;
}
/**
*
*/
- SVGTransform(const SVGTransform &other)
+ SVGTransform(const SVGTransform &other) :
+ type (other.type),
+ angle (other.angle),
+ matrix (other.matrix)
{
- type = other.type;
- angle = other.angle;
- matrix = other.matrix;
}
/**
@@ -834,9 +834,9 @@ public:
/**
*
*/
- SVGTransformList(const SVGTransformList &other)
+ SVGTransformList(const SVGTransformList &other) :
+ items (other.items)
{
- items = other.items;
}
/**
@@ -893,10 +893,10 @@ public:
/**
*
*/
- SVGAnimatedTransformList(const SVGAnimatedTransformList &other)
+ SVGAnimatedTransformList(const SVGAnimatedTransformList &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -1181,9 +1181,9 @@ public:
/**
*
*/
- SVGStringList(const SVGStringList &other)
+ SVGStringList(const SVGStringList &other) :
+ items (other.items)
{
- items = other.items;
}
/**
@@ -1657,9 +1657,9 @@ public:
/**
*
*/
- SVGNumberList(const SVGNumberList &other)
+ SVGNumberList(const SVGNumberList &other) :
+ items (other.items)
{
- items = other.items;
}
/**
@@ -1719,10 +1719,10 @@ public:
/**
*
*/
- SVGAnimatedNumberList(const SVGAnimatedNumberList &other)
+ SVGAnimatedNumberList(const SVGAnimatedNumberList &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -1934,10 +1934,10 @@ public:
/**
*
*/
- SVGAnimatedLength(const SVGAnimatedLength &other)
+ SVGAnimatedLength(const SVGAnimatedLength &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -2085,9 +2085,9 @@ public:
/**
*
*/
- SVGLengthList(const SVGLengthList &other)
+ SVGLengthList(const SVGLengthList &other) :
+ items (other.items)
{
- items = other.items;
}
/**
@@ -2147,10 +2147,10 @@ public:
/**
*
*/
- SVGAnimatedLengthList(const SVGAnimatedLengthList &other)
+ SVGAnimatedLengthList(const SVGAnimatedLengthList &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -2357,16 +2357,17 @@ public:
/**
*
*/
- SVGAnimatedAngle(const SVGAngle &angle)
- { baseVal = angle; }
+ SVGAnimatedAngle(const SVGAngle &angle) :
+ baseVal (angle)
+ {}
/**
*
*/
- SVGAnimatedAngle(const SVGAnimatedAngle &other)
+ SVGAnimatedAngle(const SVGAnimatedAngle &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -2434,10 +2435,10 @@ public:
/**
*
*/
- SVGICCColor(const SVGICCColor &other)
+ SVGICCColor(const SVGICCColor &other) :
+ colorProfile (other.colorProfile),
+ colors (other.colors)
{
- colorProfile = other.colorProfile;
- colors = other.colors;
}
/**
@@ -2448,7 +2449,6 @@ public:
protected:
DOMString colorProfile;
-
SVGNumberList colors;
};
@@ -2732,10 +2732,10 @@ public:
/**
*
*/
- SVGAnimatedRect(const SVGAnimatedRect &other)
+ SVGAnimatedRect(const SVGAnimatedRect &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- animVal = other.animVal;
}
/**
@@ -2956,9 +2956,9 @@ public:
/**
*
*/
- SVGPointList(const SVGPointList &other)
+ SVGPointList(const SVGPointList &other) :
+ items (other.items)
{
- items = other.items;
}
@@ -3071,10 +3071,10 @@ public:
/**
*
*/
- SVGStylable(const SVGStylable &other)
+ SVGStylable(const SVGStylable &other) :
+ className (other.className),
+ style (other.style)
{
- className = other.className;
- style = other.style;
}
/**
@@ -3168,7 +3168,10 @@ public:
/**
*
*/
- SVGLocatable(const SVGLocatable &/*other*/)
+ SVGLocatable(const SVGLocatable &/*other*/) :
+ bbox(),
+ ctm(),
+ screenCtm()
{
}
@@ -3224,9 +3227,9 @@ public:
/**
*
*/
- SVGTransformable(const SVGTransformable &other) : SVGLocatable(other)
+ SVGTransformable(const SVGTransformable &other) : SVGLocatable(other),
+ transforms (other.transforms)
{
- transforms = other.transforms;
}
/**
@@ -3303,11 +3306,11 @@ public:
/**
*
*/
- SVGTests(const SVGTests &other)
+ SVGTests(const SVGTests &other) :
+ requiredFeatures (other.requiredFeatures),
+ requiredExtensions (other.requiredExtensions),
+ systemLanguage (other.systemLanguage)
{
- requiredFeatures = other.requiredFeatures;
- requiredExtensions = other.requiredExtensions;
- systemLanguage = other.systemLanguage;
}
/**
@@ -3445,9 +3448,9 @@ public:
/**
*
*/
- SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other)
+ SVGExternalResourcesRequired(const SVGExternalResourcesRequired &other) :
+ required (other.required)
{
- required = other.required;
}
/**
@@ -3611,10 +3614,10 @@ public:
/**
*
*/
- SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other)
+ SVGAnimatedPreserveAspectRatio(const SVGAnimatedPreserveAspectRatio &other) :
+ baseVal (other.baseVal),
+ animVal (other.animVal)
{
- baseVal = other.baseVal;
- baseVal = other.animVal;
}
/**
@@ -3671,10 +3674,10 @@ public:
*
*/
- SVGFitToViewBox(const SVGFitToViewBox &other)
+ SVGFitToViewBox(const SVGFitToViewBox &other) :
+ viewBox (other.viewBox),
+ preserveAspectRatio (other.preserveAspectRatio)
{
- viewBox = other.viewBox;
- preserveAspectRatio = other.preserveAspectRatio;
}
/**
@@ -3685,7 +3688,6 @@ public:
protected:
SVGAnimatedRect viewBox;
-
SVGAnimatedPreserveAspectRatio preserveAspectRatio;
};
@@ -3828,18 +3830,19 @@ public:
/**
*
*/
- SVGViewSpec()
+ SVGViewSpec() :
+ viewTarget (NULL),
+ transform ()
{
- viewTarget = NULL;
}
/**
*
*/
- SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other)
+ SVGViewSpec(const SVGViewSpec &other) : SVGZoomAndPan(other), SVGFitToViewBox(other),
+ viewTarget (other.viewTarget),
+ transform (other.transform)
{
- viewTarget = other.viewTarget;
- transform = other.transform;
}
/**
@@ -3884,14 +3887,16 @@ public:
/**
*
*/
- SVGURIReference() {}
+ SVGURIReference() :
+ href ()
+ {}
/**
*
*/
- SVGURIReference(const SVGURIReference &other)
+ SVGURIReference(const SVGURIReference &other) :
+ href (other.href)
{
- href = other.href;
}
/**
@@ -6135,9 +6140,9 @@ public:
/**
*
*/
- SVGPathSegList(const SVGPathSegList &other)
+ SVGPathSegList(const SVGPathSegList &other) :
+ items (other.items)
{
- items = other.items;
}
@@ -6272,10 +6277,10 @@ public:
/**
*
*/
- SVGAnimatedPoints(const SVGAnimatedPoints &other)
+ SVGAnimatedPoints(const SVGAnimatedPoints &other) :
+ points (other.points),
+ animatedPoints (other.animatedPoints)
{
- points = other.points;
- animatedPoints = other.animatedPoints;
}
/**
@@ -6366,19 +6371,19 @@ public:
/**
*
*/
- SVGPaint()
+ SVGPaint() :
+ paintType (SVG_PAINTTYPE_UNKNOWN),
+ uri ("")
{
- uri = "";
- paintType = SVG_PAINTTYPE_UNKNOWN;
}
/**
*
*/
- SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other)
+ SVGPaint(const SVGPaint &other) : css::CSSValue(other), SVGColor(other),
+ paintType (SVG_PAINTTYPE_UNKNOWN),
+ uri ("")
{
- uri = "";
- paintType = SVG_PAINTTYPE_UNKNOWN;
}
/**
@@ -6452,17 +6457,19 @@ public:
/**
*
*/
- SVGColorProfileRule() {}
+ SVGColorProfileRule() :
+ renderingIntent(0)
+ {}
/**
*
*/
SVGColorProfileRule(const SVGColorProfileRule &other)
- : SVGCSSRule(other), SVGRenderingIntent(other)
+ : SVGCSSRule(other), SVGRenderingIntent(other),
+ renderingIntent (other.renderingIntent),
+ src (other.src),
+ name (other.name)
{
- renderingIntent = other.renderingIntent;
- src = other.src;
- name = other.name;
}
/**
@@ -6540,13 +6547,13 @@ public:
*
*/
SVGFilterPrimitiveStandardAttributes(const SVGFilterPrimitiveStandardAttributes &other)
- : SVGStylable(other)
+ : SVGStylable(other),
+ x (other.x),
+ y (other.y),
+ width (other.width),
+ height (other.height),
+ result (other.result)
{
- x = other.x;
- y = other.y;
- width = other.width;
- height = other.height;
- result = other.result;
}
/**
@@ -6567,13 +6574,6 @@ protected:
-
-
-
-
-
-
-
/*#########################################################################
## SVGEvent
#########################################################################*/
@@ -6660,20 +6660,26 @@ public:
/**
*
*/
- SVGZoomEvent()
+ SVGZoomEvent():
+ zoomRectScreen(),
+ previousScale(0),
+ previousTranslate(),
+ newScale(0),
+ newTranslate()
{}
/**
*
*/
- SVGZoomEvent(const SVGZoomEvent &other) : events::Event(other),
- events::UIEvent(other)
+ SVGZoomEvent(const SVGZoomEvent &other) :
+ events::Event(other),
+ events::UIEvent(other),
+ zoomRectScreen(other.zoomRectScreen),
+ previousScale(other.previousScale),
+ previousTranslate(other.previousTranslate),
+ newScale(other.newScale),
+ newTranslate(other.newTranslate)
{
- zoomRectScreen = other.zoomRectScreen;
- previousScale = other.previousScale;
- previousTranslate = other.previousTranslate;
- newScale = other.newScale;
- newTranslate = other.newTranslate;
}
/**
@@ -6776,13 +6782,18 @@ public:
/**
*
*/
- SVGElementInstance() {}
+ SVGElementInstance() :
+ correspondingElement(NULL),
+ correspondingUseElement(NULL)
+ {}
/**
*
*/
SVGElementInstance(const SVGElementInstance &other)
- : events::EventTarget(other)
+ : events::EventTarget(other),
+ correspondingElement(NULL),
+ correspondingUseElement(NULL)
{
}
@@ -6858,9 +6869,9 @@ public:
/**
*
*/
- SVGElementInstanceList(const SVGElementInstanceList &other)
+ SVGElementInstanceList(const SVGElementInstanceList &other) :
+ items (other.items)
{
- items = other.items;
}
/**
@@ -6877,16 +6888,6 @@ protected:
-
-
-
-
-
-
-
-
-
-
} //namespace svg
} //namespace dom
} //namespace w3c
diff --git a/src/dom/util/thread.cpp b/src/dom/util/thread.cpp
deleted file mode 100644
index d5368ef59..000000000
--- a/src/dom/util/thread.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Phoebe DOM Implementation.
- *
- * This is a C++ approximation of the W3C DOM model, which follows
- * fairly closely the specifications in the various .idl files, copies of
- * which are provided for reference. Most important is this one:
- *
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
- *
- * Authors:
- * Bob Jamison
- *
- * Copyright (C) 2006 Bob Jamison
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * Thread wrapper. This provides a platform-independent thread
- * class for IO and testing.
- *
- */
-
-#include "thread.h"
-#include <stdio.h>
-#include <string.h>
-
-namespace org
-{
-namespace w3c
-{
-namespace dom
-{
-namespace util
-{
-
-
-#ifdef __WIN32__
-#include <windows.h>
-
-static DWORD WINAPI WinThreadFunction(LPVOID context)
-{
- Thread *thread = static_cast<Thread *>(context);
- thread->execute();
- return 0;
-}
-
-
-void Thread::start()
-{
- DWORD dwThreadId;
- HANDLE hThread = CreateThread(NULL, 0, WinThreadFunction,
- (LPVOID)this, 0, &dwThreadId);
- //Make sure the thread is started before 'this' is deallocated
- while (!started)
- sleep(10);
- CloseHandle(hThread);
-}
-
-void Thread::sleep(unsigned long millis)
-{
- Sleep(millis);
-}
-
-
-
-#else /* UNIX */
-#include <pthread.h>
-
-void *PthreadThreadFunction(void *context)
-{
- Thread *thread = static_cast<Thread *>(context);
- thread->execute();
- return NULL;
-}
-
-
-void Thread::start()
-{
- pthread_t thread;
-
- int ret = pthread_create(&thread, NULL,
- PthreadThreadFunction, (void *)this);
- if (ret != 0)
- printf("Thread::start: thread creation failed: %s\n", strerror(ret));
-
- //Make sure the thread is started before 'this' is deallocated
- while (!started)
- sleep(10);
-
-}
-
-void Thread::sleep(unsigned long millis)
-{
- timespec requested;
- requested.tv_sec = millis / 1000;
- requested.tv_nsec = (millis % 1000 ) * 1000000L;
- nanosleep(&requested, NULL);
-}
-
-#endif /* __WIN32__ */
-
-} //namespace util
-} //namespace dom
-} //namespace w3c
-} //namespace org
-
-
-
-//#########################################################################
-//# E N D O F F I L E
-//#########################################################################
-
-
diff --git a/src/dom/util/thread.h b/src/dom/util/thread.h
deleted file mode 100644
index 1408cd78f..000000000
--- a/src/dom/util/thread.h
+++ /dev/null
@@ -1,156 +0,0 @@
-#ifndef SEEN_DOM_THREAD_H
-#define SEEN_DOM_THREAD_H
-/**
- * Phoebe DOM Implementation.
- *
- * This is a C++ approximation of the W3C DOM model, which follows
- * fairly closely the specifications in the various .idl files, copies of
- * which are provided for reference. Most important is this one:
- *
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
- */
-/*
- * Authors:
- * Bob Jamison
- *
- * Copyright (C) 2006 Bob Jamison
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Thread wrapper. This provides a platform-independent thread
- * class for IO and testing.
- *
- */
-
-
-namespace org
-{
-namespace w3c
-{
-namespace dom
-{
-namespace util
-{
-
-
-/**
- * This is the interface for a delegate class which can
- * be run by a Thread.
- * Thread thread(runnable);
- * thread.start();
- */
-class Runnable
-{
-public:
-
- Runnable()
- {}
- virtual ~Runnable()
- {}
-
- /**
- * The method of a delegate class which can
- * be run by a Thread. Thread is completed when this
- * method is done.
- */
- virtual void run() = 0;
-
-};
-
-
-
-/**
- * A simple wrapper of native threads in a portable class.
- * It can be used either to execute its own run() method, or
- * delegate to a Runnable class's run() method.
- */
-class Thread
-{
-public:
-
- /**
- * Create a thread which will execute its own run() method.
- */
- Thread()
- { runnable = (Runnable *)0 ; started = false; }
-
- /**
- * Create a thread which will run a Runnable class's run() method.
- */
- Thread(const Runnable &runner)
- { runnable = (Runnable *)&runner; started = false; }
-
- /**
- * This does not kill a spawned thread.
- */
- virtual ~Thread()
- {}
-
- /**
- * Static method to pause the current thread for a given
- * number of milliseconds.
- */
- static void sleep(unsigned long millis);
-
- /**
- * This method will be executed if the Thread was created with
- * no delegated Runnable class. The thread is completed when
- * the method is done.
- */
- virtual void run()
- {}
-
- /**
- * Starts the thread.
- */
- virtual void start();
-
- /**
- * Calls either this class's run() method, or that of a Runnable.
- * A user would normally not call this directly.
- */
- virtual void execute()
- {
- started = true;
- if (runnable)
- runnable->run();
- else
- run();
- }
-
-private:
-
- Runnable *runnable;
-
- bool started;
-
-};
-
-
-} //namespace util
-} //namespace dom
-} //namespace w3c
-} //namespace org
-
-
-
-#endif // SEEN_DOM_THREAD_H
-//#########################################################################
-//# E N D O F F I L E
-//#########################################################################
-
-
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp
index a28ec4f53..5adc3e73a 100644
--- a/src/ink-comboboxentry-action.cpp
+++ b/src/ink-comboboxentry-action.cpp
@@ -37,7 +37,7 @@ static GtkWidget* create_tool_item( GtkAction* action );
static GtkWidget* create_menu_item( GtkAction* action );
// Internal
-static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text );
+static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text, gboolean exclude = false );
static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* action );
// Callbacks
@@ -53,6 +53,7 @@ enum {
PROP_ENTRY_WIDTH,
PROP_EXTRA_WIDTH,
PROP_CELL_DATA_FUNC,
+ PROP_SEPARATOR_FUNC,
PROP_POPUP,
PROP_FOCUS_WIDGET
};
@@ -109,6 +110,10 @@ static void ink_comboboxentry_action_set_property (GObject *object, guint proper
action->cell_data_func = g_value_get_pointer( value );
break;
+ case PROP_SEPARATOR_FUNC:
+ action->separator_func = g_value_get_pointer( value );
+ break;
+
case PROP_POPUP:
action->popup = g_value_get_boolean( value );
break;
@@ -154,6 +159,10 @@ static void ink_comboboxentry_action_get_property (GObject *object, guint proper
g_value_set_pointer (value, action->cell_data_func);
break;
+ case PROP_SEPARATOR_FUNC:
+ g_value_set_pointer (value, action->separator_func);
+ break;
+
case PROP_POPUP:
g_value_set_boolean (value, action->popup);
break;
@@ -249,6 +258,14 @@ ink_comboboxentry_action_class_init (Ink_ComboBoxEntry_ActionClass *klass)
g_object_class_install_property (
gobject_class,
+ PROP_SEPARATOR_FUNC,
+ g_param_spec_pointer ("separator_func",
+ "Separator Func",
+ "Separator Function",
+ (GParamFlags)G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ gobject_class,
PROP_POPUP,
g_param_spec_boolean ("popup",
"Entry Popup",
@@ -303,6 +320,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name,
gint entry_width,
gint extra_width,
void *cell_data_func,
+ void *separator_func,
GtkWidget *focusWidget)
{
g_return_val_if_fail (name != NULL, NULL);
@@ -316,6 +334,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new (const gchar *name,
"entry_width", entry_width,
"extra_width", extra_width,
"cell_data_func", cell_data_func,
+ "separator_func", separator_func,
"focus-widget", focusWidget,
NULL);
}
@@ -365,6 +384,13 @@ GtkWidget* create_tool_item( GtkAction* action )
NULL, NULL );
}
+ // Optionally add separator function...
+ if( ink_comboboxentry_action->separator_func != NULL ) {
+ gtk_combo_box_set_row_separator_func( ink_comboboxentry_action->combobox,
+ GtkTreeViewRowSeparatorFunc (ink_comboboxentry_action->separator_func),
+ NULL, NULL );
+ }
+
// Optionally widen the combobox width... which widens the drop-down list in list mode.
if( ink_comboboxentry_action->extra_width > 0 ) {
GtkRequisition req;
@@ -469,7 +495,7 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink
// Explicitly set text in GtkEntry box (won't be set if text not in list).
gtk_entry_set_text( ink_comboboxentry_action->entry, text );
- // Show or hide warning
+ // Show or hide warning -- this might be better moved to text-toolbox.cpp
bool clear = true;
if( ink_comboboxentry_action->active == -1 &&
ink_comboboxentry_action->warning != NULL ) {
@@ -611,8 +637,11 @@ void ink_comboboxentry_action_set_altx_name( Ink_ComboBoxEntry_Action* actio
// Internal ---------------------------------------------------
-// Return row of active text or -1 if not found.
-gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ) {
+// Return row of active text or -1 if not found. If exclude is true,
+// use 3d colunm if available to exclude row from checking (useful to
+// skip rows added for font-families included in doc and not on
+// system)
+gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text, gboolean exclude ) {
// Check if text in list
gint row = 0;
@@ -621,15 +650,24 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta
gboolean valid = gtk_tree_model_get_iter_first( action->model, &iter );
while ( valid ) {
- // Get text from list entry
- gchar* text = 0;
- gtk_tree_model_get( action->model, &iter, 0, &text, -1 ); // Column 0
+ // See if we should exclude a row
+ gboolean check = true; // If true, font-family is on system.
+ if( exclude && gtk_tree_model_get_n_columns( action->model ) > 2 ) {
+ gtk_tree_model_get( action->model, &iter, 2, &check, -1 );
+ }
- // Check for match
- if( strcmp( target_text, text ) == 0 ){
- found = true;
- break;
+ if( check ) {
+ // Get text from list entry
+ gchar* text = 0;
+ gtk_tree_model_get( action->model, &iter, 0, &text, -1 ); // Column 0
+
+ // Check for match
+ if( strcmp( target_text, text ) == 0 ){
+ found = true;
+ break;
+ }
}
+
++row;
valid = gtk_tree_model_iter_next( action->model, &iter );
}
@@ -665,7 +703,7 @@ static Glib::ustring check_comma_separated_text( Ink_ComboBoxEntry_Action* actio
// Remove any surrounding white space.
g_strstrip( tokens[i] );
- if( get_active_row_from_text( action, tokens[i] ) == -1 ) {
+ if( get_active_row_from_text( action, tokens[i], true ) == -1 ) {
missing += tokens[i];
missing += ", ";
}
diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h
index 7d4093f4e..f0dc0ee7e 100644
--- a/src/ink-comboboxentry-action.h
+++ b/src/ink-comboboxentry-action.h
@@ -51,6 +51,7 @@ struct _Ink_ComboBoxEntry_Action {
GtkWidget *indicator;
gpointer cell_data_func; // drop-down menu format
+ gpointer separator_func;
gint active; // Index of active menu item (-1 if not in list).
gchar *text; // Text of active menu item or entry box.
@@ -76,6 +77,7 @@ Ink_ComboBoxEntry_Action *ink_comboboxentry_action_new ( const gchar *name,
gint entry_width = -1,
gint extra_width = -1,
gpointer cell_data_func = NULL,
+ gpointer separator_func = NULL,
GtkWidget* focusWidget = NULL);
GtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* action );
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 710e0b84f..1e51d8803 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -14,6 +14,11 @@
#include "font-lister.h"
#include "FontFactory.h"
+#include "sp-object.h"
+#include "sp-root.h"
+#include "document.h"
+#include "xml/repr.h"
+
namespace Inkscape
{
FontLister::FontLister ()
@@ -52,12 +57,154 @@ namespace Inkscape
}
(*treeModelIter)[FontList.styles] = styles;
-
- font_list_store_iter_map.insert(std::make_pair(familyName, Gtk::TreePath(treeModelIter)));
+ (*treeModelIter)[FontList.onSystem] = true;
}
}
}
+ // Example of how to use "foreach_iter"
+ // bool
+ // FontLister::print_document_font( const Gtk::TreeModel::iterator &iter ) {
+ // Gtk::TreeModel::Row row = *iter;
+ // if( !row[FontList.onSystem] ) {
+ // std::cout << " Not on system: " << row[FontList.font] << std::endl;
+ // return false;
+ // }
+ // return true;
+ // }
+ // font_list_store->foreach_iter( sigc::mem_fun(*this, &FontLister::print_document_font ));
+
+ void
+ FontLister::update_font_list( SPDocument* document ) {
+
+ SPObject *r = document->getRoot();
+ if( !r ) {
+ return;
+ }
+
+ /* Clear all old document font-family entries */
+ Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" );
+ while( iter != font_list_store->children().end() ) {
+ Gtk::TreeModel::Row row = *iter;
+ if( !row[FontList.onSystem] ) {
+ // std::cout << " Not on system: " << row[FontList.font] << std::endl;
+ iter = font_list_store->erase( iter );
+ } else {
+ // std::cout << " First on system: " << row[FontList.font] << std::endl;
+ break;
+ }
+ }
+
+ /* Create default styles for use when font-family is unknown on system. */
+ static GList *default_styles = NULL;
+ if( default_styles == NULL ) {
+ default_styles = g_list_append( default_styles, g_strdup("Normal") );
+ default_styles = g_list_append( default_styles, g_strdup("Italic") );
+ default_styles = g_list_append( default_styles, g_strdup("Bold") );
+ default_styles = g_list_append( default_styles, g_strdup("Bold Italic") );
+ default_styles = g_list_append( default_styles, g_strdup("Loopy") );
+ }
+
+ /* Get "font-family"s used in document. */
+ std::list<Glib::ustring> fontfamilies;
+ update_font_list_recursive( r, &fontfamilies );
+
+ fontfamilies.sort();
+ fontfamilies.unique();
+ fontfamilies.reverse();
+
+ /* Insert separator */
+ if( !fontfamilies.empty() ) {
+ Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend();
+ (*treeModelIter)[FontList.font] = "#";
+ (*treeModelIter)[FontList.onSystem] = false;
+ }
+
+ /* Insert font-family's in document. */
+ std::list<Glib::ustring>::iterator i;
+ for( i = fontfamilies.begin(); i != fontfamilies.end(); ++i) {
+
+ GList *styles = default_styles;
+
+ /* See if font-family (or first in fallback list) is on system. If so, get styles. */
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", *i );
+ if( !tokens[0].empty() ) {
+
+ Gtk::TreeModel::iterator iter2 = font_list_store->get_iter( "0" );
+ while( iter2 != font_list_store->children().end() ) {
+ Gtk::TreeModel::Row row = *iter2;
+ if( row[FontList.onSystem] && tokens[0].compare( row[FontList.font] ) == 0 ) {
+ styles = row[FontList.styles];
+ break;
+ }
+ ++iter2;
+ }
+ }
+
+ Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend();
+ (*treeModelIter)[FontList.font] = reinterpret_cast<const char*>(g_strdup((*i).c_str()));
+ (*treeModelIter)[FontList.styles] = styles;
+ (*treeModelIter)[FontList.onSystem] = false;
+ }
+ }
+
+ void
+ FontLister::update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ) {
+
+ const gchar *style = r->getRepr()->attribute("style");
+ if( style != NULL ) {
+
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(";", style );
+ for( size_t i=0; i < tokens.size(); ++i ) {
+
+ Glib::ustring token = tokens[i];
+ size_t found = token.find("font-family:");
+
+ if( found != Glib::ustring::npos ) {
+
+ // Remove "font-family:"
+ token.erase(found,12);
+
+ // Remove any leading single or double quote
+ if( token[0] == '\'' || token[0] == '"' ) {
+ token.erase(0,1);
+ }
+
+ // Remove any trailing single or double quote
+ if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) {
+ token.erase(token.length()-1);
+ }
+
+ l->push_back( token );
+ }
+ }
+ }
+
+ for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
+ update_font_list_recursive( child, l );
+ }
+ }
+
+ Gtk::TreePath
+ FontLister::get_row_for_font (Glib::ustring family)
+ {
+ Gtk::TreePath path;
+
+ Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" );
+ while( iter != font_list_store->children().end() ) {
+
+ Gtk::TreeModel::Row row = *iter;
+
+ if( family.compare( row[FontList.font] ) == 0 ) {
+ return font_list_store->get_path( iter );
+ }
+
+ ++iter;
+ }
+
+ throw FAMILY_NOT_FOUND;
+ }
+
FontLister::~FontLister ()
{
};
diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h
index c9ab7b21d..d4c48dd52 100644
--- a/src/libnrtype/font-lister.h
+++ b/src/libnrtype/font-lister.h
@@ -7,9 +7,11 @@
* Authors:
* Chris Lahey <clahey@ximian.com>
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 1999-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
+ * Copyright (C) 2013 Tavmjong Bah
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -21,6 +23,9 @@
#include <glibmm/ustring.h>
#include "nr-type-primitives.h"
+class SPObject;
+class SPDocument;
+
namespace Inkscape
{
/**
@@ -54,29 +59,19 @@ namespace Inkscape
*/
Gtk::TreeModelColumn<GList*> styles;
+ /** Column containing flag if font is on system
+ */
+ Gtk::TreeModelColumn<gboolean> onSystem;
+
FontListClass ()
{
add (font);
add (styles);
+ add (onSystem);
}
};
- /* Case-insensitive < compare for standard strings */
- class StringLessThan
- {
- public:
- bool operator () (std::string str1, std::string str2) const
- {
- std::string s1=str1; // Can't transform the originals!
- std::string s2=str2;
- std::transform(s1.begin(), s1.end(), s1.begin(), (int(*)(int)) toupper);
- std::transform(s2.begin(), s2.end(), s2.begin(), (int(*)(int)) toupper);
- return s1<s2;
- }
- };
-
FontListClass FontList;
- typedef std::map<Glib::ustring, Gtk::TreePath, StringLessThan> IterMapType;
/** Returns the ListStore with the font names
*
@@ -87,6 +82,17 @@ namespace Inkscape
const Glib::RefPtr<Gtk::ListStore>
get_font_list () const;
+ /** Updates font list to include fonts in document
+ *
+ */
+ void
+ update_font_list ( SPDocument* document);
+
+ private:
+ void
+ update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l );
+
+ public:
static Inkscape::FontLister*
get_instance ()
{
@@ -95,12 +101,7 @@ namespace Inkscape
}
Gtk::TreePath
- get_row_for_font (Glib::ustring family)
- {
- IterMapType::iterator iter = font_list_store_iter_map.find (family);
- if (iter == font_list_store_iter_map.end ()) throw FAMILY_NOT_FOUND;
- return (*iter).second;
- }
+ get_row_for_font (Glib::ustring family);
const NRNameList
get_name_list () const
@@ -108,7 +109,6 @@ namespace Inkscape
return families;
}
-
private:
FontLister ();
@@ -116,7 +116,6 @@ namespace Inkscape
NRNameList families;
Glib::RefPtr<Gtk::ListStore> font_list_store;
- IterMapType font_list_store_iter_map;
};
}
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 3eccf1d2f..5ba2065b9 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -18,7 +18,7 @@
*
* Copyright (C) 2004 David Turner
* Copyright (C) 2003 MenTaLguY
- * Copyright (C) 1999-2011 authors
+ * Copyright (C) 1999-2013 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -39,6 +39,7 @@
#include "../desktop-handles.h"
#include "../desktop-style.h"
#include "document-undo.h"
+#include "../sp-root.h"
#include "../verbs.h"
#include "../inkscape.h"
#include "../connection-pool.h"
@@ -105,6 +106,10 @@ static void sp_print_font( SPStyle *query ) {
<< " FontSpec: "
<< (query->text->font_specification.value ? query->text->font_specification.value : "No value")
<< std::endl;
+ std::cout << " LineHeight: " << query->line_height.computed
+ << " WordSpacing: " << query->word_spacing.computed
+ << " LetterSpacing: " << query->letter_spacing.computed
+ << std::endl;
}
static void sp_print_fontweight( SPStyle *query ) {
@@ -131,37 +136,92 @@ static void sp_print_fontstyle( SPStyle *query ) {
// Format family drop-down menu.
static void cell_data_func(GtkCellLayout * /*cell_layout*/,
GtkCellRenderer *cell,
- GtkTreeModel *tree_model,
+ GtkTreeModel *model,
GtkTreeIter *iter,
gpointer /*data*/)
{
gchar *family;
- gtk_tree_model_get(tree_model, iter, 0, &family, -1);
- gchar *const family_escaped = g_markup_escape_text(family, -1);
+ gboolean onSystem = false;
+ gtk_tree_model_get(model, iter, 0, &family, 2, &onSystem, -1);
+ Glib::ustring family_escaped = g_markup_escape_text(family, -1);
+ g_free(family);
+ Glib::ustring markup;
+
+ if( !onSystem ) {
+ markup = "<span foreground='darkblue'>";
+
+ /* See if font-family on system */
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("\\s*,\\s*", family_escaped );
+ for( size_t i=0; i < tokens.size(); ++i ) {
+
+ Glib::ustring token = tokens[i];
+
+ GtkTreeIter iter;
+ gboolean valid;
+ gchar *family = 0;
+ gboolean onSystem = true;
+ gboolean found = false;
+ for( valid = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(model), &iter );
+ valid;
+ valid = gtk_tree_model_iter_next( GTK_TREE_MODEL(model), &iter ) ) {
+
+ gtk_tree_model_get(model, &iter, 0, &family, 2, &onSystem, -1);
+ if( onSystem && token.compare( family ) == 0 ) {
+ found = true;
+ break;
+ }
+ }
+ if( found ) {
+ markup += g_markup_escape_text(token.c_str(), -1);
+ markup += ", ";
+ } else {
+ markup += "<span strikethrough=\"true\" strikethrough_color=\"red\">";
+ markup += g_markup_escape_text(token.c_str(), -1);
+ markup += "</span>";
+ markup += ", ";
+ }
+ }
+ // Remove extra comma and space from end.
+ if( markup.size() >= 2 ) {
+ markup.resize( markup.size()-2 );
+ }
+ markup += "</span>";
+ // std::cout << markup << std::endl;
+ } else {
+ markup = family_escaped;
+ }
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1);
if (show_sample) {
Glib::ustring sample = prefs->getString("/tools/text/font_sample");
- gchar *const sample_escaped = g_markup_escape_text(sample.data(), -1);
+ Glib::ustring sample_escaped = g_markup_escape_text(sample.data(), -1);
- std::stringstream markup;
- markup << family_escaped << " <span foreground='gray' font_family='"
- << family_escaped << "'>" << sample_escaped << "</span>";
- g_object_set (G_OBJECT (cell), "markup", markup.str().c_str(), NULL);
-
- g_free(sample_escaped);
- } else {
- g_object_set (G_OBJECT (cell), "markup", family_escaped, NULL);
+ markup += " <span foreground='gray' font_family='";
+ markup += family_escaped;
+ markup += "'>";
+ markup += sample_escaped;
+ markup += "</span>";
}
+
+ g_object_set (G_OBJECT (cell), "markup", markup.c_str(), NULL);
+
// This doesn't work for two reasons... it set both selected and not selected backgrounds
// to white.. which means that white foreground text is invisible. It also only effects
// the text region, leaving the padding untouched.
// g_object_set (G_OBJECT (cell), "cell-background", "white", "cell-background-set", true, NULL);
- g_free(family);
- g_free(family_escaped);
+}
+
+// Separator function (if true, a separator will be drawn)
+static gboolean separator_func(GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer /*data*/)
+{
+ gchar* text = 0;
+ gtk_tree_model_get(model, iter, 0, &text, -1 ); // Column 0
+ return (text && strcmp(text,"#") == 0);
}
/*
@@ -256,7 +316,6 @@ static void sp_text_fontstyle_populate(GObject *tbl, font_instance *font=NULL)
} else if (current_style) {
ink_comboboxentry_action_set_active_text( fontStyleAction, current_style );
}
-
}
// Font family
@@ -1184,6 +1243,15 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
+ // Update font list, but only if widget already created.
+ Ink_ComboBoxEntry_Action* fontFamilyAction =
+ INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
+ if( fontFamilyAction->combobox != NULL ) {
+ Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
+ fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP ));
+ }
+
+
// Only flowed text can be justified, only normal text can be kerned...
// Find out if we have flowed text now so we can use it several places
gboolean isFlow = false;
@@ -1238,8 +1306,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
// To ensure the value of the combobox is properly set on start-up, only mark
// the prefs set if the combobox has already been constructed.
- Ink_ComboBoxEntry_Action* fontFamilyAction =
- INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontFamilyAction" ) );
if( fontFamilyAction->combobox != NULL ) {
g_object_set_data(tbl, "text_style_from_prefs", GINT_TO_POINTER(TRUE));
}
@@ -1482,6 +1548,44 @@ sp_text_toolbox_subselection_changed (gpointer /*tc*/, GObject *tbl)
sp_text_toolbox_selection_changed (NULL, tbl);
}
+
+/* Recursively extract all "font-family" attributes from a document. */
+void
+sp_text_toolbox_get_font_list_in_doc_recursive (SPObject *r, std::list<Glib::ustring> *l)
+{
+ if (!r) {
+ return;
+ }
+
+ const gchar *style = r->getRepr()->attribute("style");
+ if( style != NULL ) {
+ //std::cout << style << std::endl;
+ std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(";", style );
+ for( size_t i=0; i < tokens.size(); ++i ) {
+ Glib::ustring token = tokens[i];
+ size_t found = token.find("font-family:");
+ if( found != Glib::ustring::npos ) {
+ // Remove "font-family:"
+ token.erase(found,12);
+ // Remove any leading single or double quote
+ if( token[0] == '\'' || token[0] == '"' ) {
+ token.erase(0,1);
+ }
+ // Remove any trailing single or double quote
+ if( token[token.length()-1] == '\'' || token[token.length()-1] == '"' ) {
+ token.erase(token.length()-1);
+ }
+ l->push_back( token );
+ }
+ }
+ }
+
+ for (SPObject *child = r->firstChild(); child; child = child->getNext()) {
+ sp_text_toolbox_get_font_list_in_doc_recursive( child, l );
+ }
+}
+
+
// Define all the "widgets" in the toolbar.
void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
@@ -1496,18 +1600,22 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
/* Font family */
{
// Font list
- Glib::RefPtr<Gtk::ListStore> store = Inkscape::FontLister::get_instance()->get_font_list();
+ Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance();
+ fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP ));
+ Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list();
GtkListStore* model = store->gobj();
- Ink_ComboBoxEntry_Action* act = ink_comboboxentry_action_new( "TextFontFamilyAction",
- _("Font Family"),
- _("Select Font Family (Alt-X to access)"),
- NULL,
- GTK_TREE_MODEL(model),
- -1, // Entry width
- 50, // Extra list width
- (gpointer)cell_data_func,// Cell layout
- GTK_WIDGET(desktop->canvas)); // Focus widget
+ Ink_ComboBoxEntry_Action* act =
+ ink_comboboxentry_action_new( "TextFontFamilyAction",
+ _("Font Family"),
+ _("Select Font Family (Alt-X to access)"),
+ NULL,
+ GTK_TREE_MODEL(model),
+ -1, // Entry width
+ 50, // Extra list width
+ (gpointer)cell_data_func, // Cell layout
+ (gpointer)separator_func,
+ GTK_WIDGET(desktop->canvas)); // Focus widget
ink_comboboxentry_action_popup_enable( act ); // Enable entry completion
gchar *const warning = _("Font not found on system");
ink_comboboxentry_action_set_warning( act, warning ); // Show icon with tooltip if missing font
@@ -1522,7 +1630,13 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
"{\n"
" GtkComboBox::appears-as-list = 1\n"
"}\n"
- "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\"");
+ "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\""
+ "style \"fontfamily-separator-style\"\n"
+ "{\n"
+ " GtkWidget::wide-separators = 1\n"
+ " GtkWidget::separator-height = 6\n"
+ "}\n"
+ "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\"");
}
/* Font size */
@@ -1544,6 +1658,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
4, // Width in characters
0, // Extra list width
NULL, // Cell layout
+ NULL, // Separator
GTK_WIDGET(desktop->canvas)); // Focus widget
g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontsize_value_changed), holder );
@@ -1563,6 +1678,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
12, // Width in characters
0, // Extra list width
NULL, // Cell layout
+ NULL, // Separator
GTK_WIDGET(desktop->canvas)); // Focus widget
g_signal_connect( G_OBJECT(act), "changed", G_CALLBACK(sp_text_fontstyle_value_changed), holder );