summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-11-16 08:16:35 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-11-16 08:16:35 +0000
commit416947d528b47899e30e67526d862f466f5816d8 (patch)
treedbdf89205b5af4d16d28d02d0d8ae61e17c4faab /src
parentFix unincilizated value that not work in release mode. also remove duplicate ... (diff)
downloadinkscape-416947d528b47899e30e67526d862f466f5816d8.tar.gz
inkscape-416947d528b47899e30e67526d862f466f5816d8.zip
Working on fix
Diffstat (limited to 'src')
-rw-r--r--src/selection-chemistry.cpp41
-rw-r--r--src/ui/dialog/symbols.cpp68
-rw-r--r--src/ui/dialog/symbols.h5
3 files changed, 61 insertions, 53 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index efc378845..e6fa11c4c 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -3149,14 +3149,25 @@ void ObjectSet::toSymbol()
// Create new <symbol>
Inkscape::XML::Node *defsrepr = doc->getDefs()->getRepr();
Inkscape::XML::Node *symbol_repr = xml_doc->createElement("svg:symbol");
+ Inkscape::XML::Node *title_repr = xml_doc->createElement("svg:title");
+ Inkscape::XML::Node *desc_repr = xml_doc->createElement("svg:desc");
defsrepr->appendChild(symbol_repr);
-
+ bool settitle = false;
// For a single group, copy relevant attributes.
if( single_group ) {
symbol_repr->setAttribute("style", the_group->getAttribute("style"));
- symbol_repr->setAttribute("title", the_group->getAttribute("title"));
- if (!the_group->getAttribute("title")) {
- symbol_repr->setAttribute("title", _("Symbol without title"));
+
+ symbol_repr->appendChild(title_repr);
+ gchar * title = the_group->title();
+ if (title) {
+ title_repr->setContent(title);
+ } else {
+ title_repr->setContent(_("Symbol without title"));
+ }
+ gchar * desc = the_group->desc();
+ if (desc) {
+ desc_repr->setContent(desc);
+ symbol_repr->appendChild(desc_repr);
}
symbol_repr->setAttribute("class", the_group->getAttribute("class"));
Glib::ustring id = the_group->getAttribute("id");
@@ -3176,9 +3187,25 @@ void ObjectSet::toSymbol()
// Move selected items to new <symbol>
for (std::vector<SPObject*>::const_reverse_iterator i=items_.rbegin();i!=items_.rend();++i){
- Inkscape::XML::Node *repr = (*i)->getRepr();
- repr->parent()->removeChild(repr);
- symbol_repr->addChild(repr,NULL);
+ gchar* title = (*i)->title();
+ if (!single_group && !settitle && title) {
+ symbol_repr->appendChild(title_repr);
+ title_repr->setContent(title);
+ gchar * desc = (*i)->desc();
+ if (desc) {
+ desc_repr->setContent(desc);
+ symbol_repr->appendChild(desc_repr);
+ }
+ settitle = true;
+ }
+ Inkscape::XML::Node *repr = (*i)->getRepr();
+ repr->parent()->removeChild(repr);
+ symbol_repr->addChild(repr, NULL);
+ }
+
+ if (!settitle) {
+ symbol_repr->appendChild(title_repr);
+ title_repr->setContent(_("Symbol without title"));
}
if( single_group && transform.isTranslation() ) {
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index e5348366c..4d2315def 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -25,6 +25,7 @@
#include "io/sys.h"
#include "io/resource.h"
+#include "display/cairo-utils.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/clipboard.h"
#include "ui/icon-names.h"
@@ -226,6 +227,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
#else
table->attach(*Gtk::manage(scroller),0,row,2,1);
#endif
+ previous_height = 0;
++row;
/******************** Progress *******************************/
@@ -349,9 +351,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) :
// This might need to be a global variable so setTargetDesktop can modify it
SPDefs *defs = current_document->getDefs();
-#if GTK_CHECK_VERSION(3,2,4)
- overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000));
-#endif
+
sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified));
instanceConns.push_back(defsModifiedConn);
@@ -432,6 +432,7 @@ void SymbolsDialog::rebuild() {
SPDocument* symbol_document = selectedSymbols();
icons_found = false;
//We are not in search all docs
+
if (search->get_text() != _("Searching...") &&
search->get_text() != _("Loading all symbols...") &&
search->get_text() != _("Searching....") )
@@ -472,7 +473,14 @@ void SymbolsDialog::showOverlay() {
} else if (!icons_found && !search_str.empty()) {
overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>"));
overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>"));
- }
+ }
+ gint width = scroller->get_allocated_width();
+ gint height = scroller->get_allocated_height();
+ if (previous_height != height) {
+ previous_height = height;
+ overlay_opacity->set_size_request(width, height);
+ overlay_opacity->set(getOverlay(width, height));
+ }
overlay_opacity->show();
overlay_icon->show();
overlay_title->show();
@@ -1175,7 +1183,7 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) {
* the temporary document is rendered.
*/
Glib::RefPtr<Gdk::Pixbuf>
-SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize)
+SymbolsDialog::drawSymbol(SPObject *symbol)
{
// Create a copy repr of the symbol with id="the_symbol"
Inkscape::XML::Document *xml_doc = preview_document->getReprDoc();
@@ -1253,11 +1261,6 @@ SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize)
else
scale = pow( 2.0, scale_factor/2.0 ) * psize / 32.0;
- if (force_psize > 0) {
- psize = force_psize;
- scale = psize / ceil(std::max(width, height));
- }
-
pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize));
}
@@ -1289,41 +1292,18 @@ SPDocument* SymbolsDialog::symbolsPreviewDoc()
* Update image widgets
*/
Glib::RefPtr<Gdk::Pixbuf>
-SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize)
+SymbolsDialog::getOverlay(gint width, gint height)
{
-gchar const *buffer =
-"<svg xmlns=\"http://www.w3.org/2000/svg\""
-" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\""
-" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\""
-" xmlns:xlink=\"http://www.w3.org/1999/xlink\">"
-" <title>Inkscape</title> "
-" <defs id=\"defs\">"
-" <symbol"
-" id=\"overlay\">"
-" <title"
-" id=\"overlay_title\">Overlay</title>"
-" <desc"
-" id=\"overlay_desc\">Overlay Square</desc>"
-" <path"
-" style=\"fill:#ffffff;opacity:0.75;stroke:none\""
-" d=\"M 0,1 H 1 V 2 H 0 Z\""
-" id=\"overlay_shape_1\" />"
-" </symbol>"
-" </defs>"
-"</svg>";
-
- SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE );
- std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > symbols_data = symbolsInDoc(doc, "Overlay Doc");
- Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL);
- for(auto data:symbols_data) {
- Glib::ustring doc_title = data.second.first;
- SPSymbol * symbol = data.second.second;
- if (!strcmp(symbol->getId(), icon_title)) {
- pixbuf = drawSymbol(symbol, psize);
- return pixbuf;
- }
- }
- return pixbuf;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+ cr = cairo_create (surface);
+ cairo_set_source_rgba(cr, 1, 1, 1, 0.75);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+ GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(surface);
+ cairo_destroy (cr);
+ return Glib::wrap(pixbuf);
}
void SymbolsDialog::setTargetDesktop(SPDesktop *desktop)
diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h
index f387dde51..6e49939af 100644
--- a/src/ui/dialog/symbols.h
+++ b/src/ui/dialog/symbols.h
@@ -102,8 +102,8 @@ private:
void enableWidgets(bool enable);
Glib::ustring ellipsize(Glib::ustring data, size_t limit);
gchar const* styleFromUse( gchar const* id, SPDocument* document);
- Glib::RefPtr<Gdk::Pixbuf> drawSymbol(SPObject *symbol, unsigned force_psize = 0);
- Glib::RefPtr<Gdk::Pixbuf> getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize);
+ Glib::RefPtr<Gdk::Pixbuf> drawSymbol(SPObject *symbol);
+ Glib::RefPtr<Gdk::Pixbuf> getOverlay(gint width, gint height);
/* Keep track of all symbol template documents */
std::map<Glib::ustring, SPDocument*> symbol_sets;
std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > l;
@@ -112,6 +112,7 @@ private:
// Scale factor
int scale_factor;
bool sensitive;
+ double previous_height;
bool all_docs_processed;
size_t number_docs;
size_t number_symbols;