From aa33189524513d54d049ee866c126c892461c62c Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 18 Oct 2017 11:59:53 +0200 Subject: Add search to symbols dialog --- src/ui/dialog/symbols.cpp | 78 +++++++++++++++++++++++++++++++++++++++-------- src/ui/dialog/symbols.h | 11 ++++--- 2 files changed, 72 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 558b0b19e..28fd491fd 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -84,11 +84,14 @@ public: Gtk::TreeModelColumn symbol_id; Gtk::TreeModelColumn symbol_title; + Gtk::TreeModelColumn symbol_doc_title; Gtk::TreeModelColumn< Glib::RefPtr > symbol_image; + SymbolColumns() { add(symbol_id); add(symbol_title); + add(symbol_doc_title); add(symbol_image); } }; @@ -182,7 +185,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : addSymbol->set_tooltip_text(_("Add Symbol from the current document.")); addSymbol->set_relief( Gtk::RELIEF_NONE ); addSymbol->set_focus_on_click( false ); - addSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); + addSymbol->signal_activate().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); tools->pack_start(* addSymbol, Gtk::PACK_SHRINK); auto removeSymbolImage = Gtk::manage(new Gtk::Image()); @@ -198,7 +201,10 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); tools->pack_start(* Gtk::manage(spacer)); - + search = Gtk::manage(new Gtk::SearchEntry()); // Search + tools->pack_start(* search, Gtk::PACK_SHRINK); + sigc::connection connSetSearch = search->signal_key_press_event().connect_notify(sigc::bind<0>(sigc::mem_fun(*this, &SymbolsDialog::find_symbols), search)); + // Pack size (controls display area) pack_size = 2; // Default 32px @@ -422,8 +428,10 @@ void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) SPDocument* SymbolsDialog::selectedSymbols() { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ - Glib::ustring symbolSetString = symbolSet->get_active_text(); - + Glib::ustring symbolSetString = selectedSymbolDocTitle(); + if (symbolSetString.empty()) { + symbolSetString = symbolSet->get_active_text(); + } SPDocument* symbolDocument = symbolSets[symbolSetString]; if( !symbolDocument ) { // Symbol must be from Current Document (this method of checking should be language independent). @@ -444,6 +452,18 @@ Glib::ustring SymbolsDialog::selectedSymbolId() { return Glib::ustring(""); } +Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { + + auto iconArray = iconView->get_selected_items(); + + if( !iconArray.empty() ) { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + return (*row)[getColumns()->symbol_doc_title]; + } + return Glib::ustring(""); +} + void SymbolsDialog::iconChanged() { Glib::ustring symbol_id = selectedSymbolId(); @@ -635,7 +655,7 @@ void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) +std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument) { std::vector l; @@ -655,8 +675,7 @@ void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector &l) } } -std::vector SymbolsDialog::use_in_doc( SPDocument* useDocument ) { - +std::vector SymbolsDialog::use_in_doc( SPDocument* useDocument) { std::vector l; use_in_doc_recursive (useDocument->getRoot(), l); return l; @@ -685,17 +704,46 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen return style; } -void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) { +void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { + if (symbol_document) { + std::vector l = symbols_in_doc( symbol_document ); + Glib::ustring doc_title = ""; + if (symbol_document->getRoot()->title()) { + doc_title = symbol_document->getRoot()->title(); + } + for(auto symbol:l) { + if (symbol) { + add_symbol( symbol, doc_title); + } + } + } +} - std::vector l = symbols_in_doc( symbolDocument ); - for(auto symbol:l) { - if (symbol) { - add_symbol( symbol ); +void SymbolsDialog::find_symbols(Gtk::SearchEntry* search, GdkEventKey* evt) { + store->clear(); + Glib::ustring title = search->get_text(); + if (evt->keyval != GDK_KEY_Return || title.empty()) { + return; + } + symbolSet->set_active_text(_("Search")); + for(auto const &symbol_document_map : symbolSets) { + SPDocument* symbol_document = symbol_document_map.second; + std::vector l = symbols_in_doc( symbol_document); + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + if (symbol_title_char) { + Glib::ustring symbol_title = Glib::ustring(symbol_title_char); + auto pos = symbol_title.rfind(title); + if (symbol && pos != std::string::npos) { + Glib::ustring doc_title = symbol_document_map.first; // From doc title element + add_symbol( symbol, doc_title); + } + } } } } -void SymbolsDialog::add_symbol( SPObject* symbol ) { +void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { SymbolColumns* columns = getColumns(); @@ -704,6 +752,9 @@ void SymbolsDialog::add_symbol( SPObject* symbol ) { if( !title ) { title = id; } + if( doc_title.empty() ) { + return; + } Glib::RefPtr pixbuf = draw_symbol( symbol ); @@ -711,6 +762,7 @@ void SymbolsDialog::add_symbol( SPObject* symbol ) { Gtk::ListStore::iterator row = store->append(); (*row)[columns->symbol_id] = Glib::ustring( id ); (*row)[columns->symbol_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); + (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(doc_title); (*row)[columns->symbol_image] = pixbuf; } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 747e5c6c9..1ce826f4b 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -18,7 +18,7 @@ #include "ui/widget/panel.h" #include "sp-symbol.h" #include "sp-use.h" - +#include #include class SPObject; @@ -77,18 +77,20 @@ private: void documentReplaced(SPDesktop *desktop, SPDocument *document); SPDocument* selectedSymbols(); Glib::ustring selectedSymbolId(); + Glib::ustring selectedSymbolDocTitle(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); void add_symbols( SPDocument* symbol_document ); - void add_symbol( SPObject* symbol_document ); + void add_symbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbols_preview_doc(); void symbols_in_doc_recursive(SPObject *r, std::vector &l); - std::vector symbols_in_doc( SPDocument* document ); + std::vector symbols_in_doc( SPDocument* document); void use_in_doc_recursive(SPObject *r, std::vector &l); - std::vector use_in_doc( SPDocument* document ); + std::vector use_in_doc( SPDocument* document); + void find_symbols(Gtk::SearchEntry* search, GdkEventKey* evt); gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr draw_symbol(SPObject *symbol); @@ -104,6 +106,7 @@ private: Glib::RefPtr store; Gtk::ComboBoxText* symbolSet; + Gtk::SearchEntry* search; Gtk::IconView* iconView; Gtk::Button* addSymbol; Gtk::Button* removeSymbol; -- cgit v1.2.3 From f515f9cb276b1fb5027cf592ed07c1f0b660d03c Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 18 Oct 2017 22:45:05 +0200 Subject: Working on speed improvements --- src/ui/dialog/symbols.cpp | 120 +++++++++++++++++++++++++++++++++------------- src/ui/dialog/symbols.h | 1 + 2 files changed, 89 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 28fd491fd..152c1e7e3 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -202,6 +202,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); tools->pack_start(* Gtk::manage(spacer)); search = Gtk::manage(new Gtk::SearchEntry()); // Search + search->set_tooltip_text(_("Search trought all symbols. Use * to get all (slow).")); tools->pack_start(* search, Gtk::PACK_SHRINK); sigc::connection connSetSearch = search->signal_key_press_event().connect_notify(sigc::bind<0>(sigc::mem_fun(*this, &SymbolsDialog::find_symbols), search)); @@ -359,18 +360,24 @@ void SymbolsDialog::rebuild() { store->clear(); Glib::ustring symbolSetString = symbolSet->get_active_text(); - SPDocument* symbolDocument = symbolSets[symbolSetString]; - if( !symbolDocument ) { - // Symbol must be from Current Document (this method of - // checking should be language independent). - symbolDocument = currentDocument; - addSymbol->set_sensitive( true ); - removeSymbol->set_sensitive( true ); + SPDocument* symbol_document = symbolSets[symbolSetString]; + if( !symbol_document ) { + get_symbols(symbolSetString); + symbolSetString = symbolSet->get_active_text(); + symbol_document = symbolSets[symbolSetString]; + // Symbol must be from Current Document (this method of checking should be language independent). + if( !symbol_document ) { + // Symbol must be from Current Document (this method of + // checking should be language independent). + symbol_document = currentDocument; + addSymbol->set_sensitive( true ); + removeSymbol->set_sensitive( true ); + } } else { addSymbol->set_sensitive( false ); removeSymbol->set_sensitive( false ); } - add_symbols( symbolDocument ); + add_symbols( symbol_document ); } void SymbolsDialog::insertSymbol() { @@ -411,8 +418,8 @@ void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbolDocument = selectedSymbols(); - SPObject* symbol = symbolDocument->getObjectById(symbol_id); + SPDocument* symbol_document = selectedSymbols(); + SPObject* symbol = symbol_document->getObjectById(symbol_id); if(symbol && !selection->includes(symbol)) { iconView->unselect_all(); @@ -432,12 +439,17 @@ SPDocument* SymbolsDialog::selectedSymbols() { if (symbolSetString.empty()) { symbolSetString = symbolSet->get_active_text(); } - SPDocument* symbolDocument = symbolSets[symbolSetString]; - if( !symbolDocument ) { + SPDocument* symbol_document = symbolSets[symbolSetString]; + if( !symbol_document ) { + get_symbols(symbolSetString); + symbolSetString = symbolSet->get_active_text(); + symbol_document = symbolSets[symbolSetString]; // Symbol must be from Current Document (this method of checking should be language independent). - return currentDocument; + if( !symbol_document ) { + return currentDocument; + } } - return symbolDocument; + return symbol_document; } Glib::ustring SymbolsDialog::selectedSymbolId() { @@ -467,8 +479,8 @@ Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { void SymbolsDialog::iconChanged() { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbolDocument = selectedSymbols(); - SPObject* symbol = symbolDocument->getObjectById(symbol_id); + SPDocument* symbol_document = selectedSymbols(); + SPObject* symbol = symbol_document->getObjectById(symbol_id); if( symbol ) { // Find style for use in @@ -476,15 +488,15 @@ void SymbolsDialog::iconChanged() { gchar const* style = symbol->getAttribute("inkscape:symbol-style"); if( !style ) { // If no default style in , look in documents. - if( symbolDocument == currentDocument ) { + if( symbol_document == currentDocument ) { style = style_from_use( symbol_id.c_str(), currentDocument ); } else { - style = symbolDocument->getReprRoot()->attribute("style"); + style = symbol_document->getReprRoot()->attribute("style"); } } ClipboardManager *cm = ClipboardManager::get(); - cm->copySymbol(symbol->getRepr(), style, symbolDocument == currentDocument); + cm->copySymbol(symbol->getRepr(), style, symbol_document == currentDocument); } } @@ -610,29 +622,68 @@ SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { void SymbolsDialog::get_symbols() { using namespace Inkscape::IO::Resource; - SPDocument* symbol_doc = NULL; Glib::ustring title; - for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { if(Glib::str_has_suffix(filename, ".svg")) { + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbolSets[title]= NULL; + symbolSet->append(title); + } +#ifdef WITH_LIBVISIO + if(Glib::str_has_suffix(filename, ".vss")) { + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbolSets[title]= NULL; + symbolSet->append(title); + } +#endif + } +} + +/* Hunts preference directories for symbol files */ +void SymbolsDialog::get_symbols(Glib::ustring title) { + + using namespace Inkscape::IO::Resource; + SPDocument* symbol_doc = NULL; + Glib::ustring new_title; + size_t i = 0; + for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { + if(filename == title + ".svg") { symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); if(symbol_doc) { - title = symbol_doc->getRoot()->title(); - if(title.empty()) { - title = _("Unnamed Symbols"); + new_title = symbol_doc->getRoot()->title(); + if(new_title.empty()) { + new_title = _("Unnamed Symbols"); } } - + } + if(Glib::str_has_suffix(filename, ".svg")) { + i++; } #ifdef WITH_LIBVISIO if(Glib::str_has_suffix(filename, ".vss")) { - Glib::ustring title = filename.erase(filename.rfind('.')); + i++; + } + if(filename == title + ".vss") { symbol_doc = read_vss(filename, title); + if(symbol_doc) { + new_title = symbol_doc->getRoot()->title(); + if(new_title.empty()) { + new_title = _("Unnamed Symbols"); + } + } } #endif if(symbol_doc) { - symbolSets[title]= symbol_doc; - symbolSet->append(title); + symbolSets.erase(title); + symbolSets[new_title]= symbol_doc; + symbolSet->set_active(i); + symbolSet->set_active_text(new_title); } } } @@ -655,11 +706,11 @@ void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument) +std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbol_document) { std::vector l; - symbols_in_doc_recursive (symbolDocument->getRoot(), l ); + symbols_in_doc_recursive (symbol_document->getRoot(), l ); return l; } @@ -725,22 +776,27 @@ void SymbolsDialog::find_symbols(Gtk::SearchEntry* search, GdkEventKey* evt) { if (evt->keyval != GDK_KEY_Return || title.empty()) { return; } - symbolSet->set_active_text(_("Search")); for(auto const &symbol_document_map : symbolSets) { SPDocument* symbol_document = symbol_document_map.second; + if (!symbol_document) { + get_symbols(symbol_document_map.first); + Glib::ustring symbolSetString = symbolSet->get_active_text(); + symbol_document = symbolSets[symbolSetString]; + } std::vector l = symbols_in_doc( symbol_document); for(auto symbol:l) { gchar const *symbol_title_char = symbol->title(); if (symbol_title_char) { Glib::ustring symbol_title = Glib::ustring(symbol_title_char); auto pos = symbol_title.rfind(title); - if (symbol && pos != std::string::npos) { + if (title == "*" || symbol && pos != std::string::npos) { Glib::ustring doc_title = symbol_document_map.first; // From doc title element add_symbol( symbol, doc_title); } } } } + symbolSet->set_active_text(_("Search")); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 1ce826f4b..96c9585f5 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -82,6 +82,7 @@ private: void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); + void get_symbols(Glib::ustring title); void add_symbols( SPDocument* symbol_document ); void add_symbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbols_preview_doc(); -- cgit v1.2.3 From 62a1c37f667a8095a834deef50134af8ec477592 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 19 Oct 2017 03:25:18 +0200 Subject: Improving speed --- src/ui/dialog/symbols.cpp | 105 ++++++++++++++++++++++++++++------------------ src/ui/dialog/symbols.h | 6 ++- 2 files changed, 69 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 152c1e7e3..d4b460d1d 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -204,7 +204,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : search = Gtk::manage(new Gtk::SearchEntry()); // Search search->set_tooltip_text(_("Search trought all symbols. Use * to get all (slow).")); tools->pack_start(* search, Gtk::PACK_SHRINK); - sigc::connection connSetSearch = search->signal_key_press_event().connect_notify(sigc::bind<0>(sigc::mem_fun(*this, &SymbolsDialog::find_symbols), search)); + + search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::find_symbols)); // Pack size (controls display area) pack_size = 2; // Default 32px @@ -273,6 +274,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; /**********************************************************/ + sensitive = true; currentDesktop = SP_ACTIVE_DESKTOP; currentDocument = currentDesktop->getDocument(); @@ -349,6 +351,9 @@ void SymbolsDialog::zoomout() { void SymbolsDialog::rebuild() { + if (!sensitive) { + return; + } if( fitSymbol->get_active() ) { zoomIn->set_sensitive( false ); zoomOut->set_sensitive( false ); @@ -358,26 +363,22 @@ void SymbolsDialog::rebuild() { } store->clear(); - Glib::ustring symbolSetString = symbolSet->get_active_text(); - - SPDocument* symbol_document = symbolSets[symbolSetString]; + SPDocument* symbol_document = selectedSymbols(); if( !symbol_document ) { - get_symbols(symbolSetString); - symbolSetString = symbolSet->get_active_text(); - symbol_document = symbolSets[symbolSetString]; - // Symbol must be from Current Document (this method of checking should be language independent). - if( !symbol_document ) { // Symbol must be from Current Document (this method of // checking should be language independent). symbol_document = currentDocument; addSymbol->set_sensitive( true ); removeSymbol->set_sensitive( true ); - } } else { addSymbol->set_sensitive( false ); removeSymbol->set_sensitive( false ); } - add_symbols( symbol_document ); + if (symbolSet->get_active_text() == "Search") { + find_symbols_overload(); + } else { + add_symbols( symbol_document ); + } } void SymbolsDialog::insertSymbol() { @@ -435,15 +436,14 @@ void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) SPDocument* SymbolsDialog::selectedSymbols() { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ - Glib::ustring symbolSetString = selectedSymbolDocTitle(); - if (symbolSetString.empty()) { - symbolSetString = symbolSet->get_active_text(); + Glib::ustring doc_title = selectedSymbolDocTitle(); + if (doc_title.empty()) { + doc_title = symbolSet->get_active_text(); } - SPDocument* symbol_document = symbolSets[symbolSetString]; + SPDocument* symbol_document = symbolSets[doc_title]; if( !symbol_document ) { - get_symbols(symbolSetString); - symbolSetString = symbolSet->get_active_text(); - symbol_document = symbolSets[symbolSetString]; + doc_title = get_symbols(doc_title); + symbol_document = symbolSets[doc_title]; // Symbol must be from Current Document (this method of checking should be language independent). if( !symbol_document ) { return currentDocument; @@ -625,6 +625,9 @@ void SymbolsDialog::get_symbols() { Glib::ustring title; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { if(Glib::str_has_suffix(filename, ".svg")) { + //TODO: find a way to get real title without loading all SPDocument + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); title = filename.erase(filename.rfind('.')); if(title.empty()) { title = _("Unnamed Symbols"); @@ -634,6 +637,8 @@ void SymbolsDialog::get_symbols() { } #ifdef WITH_LIBVISIO if(Glib::str_has_suffix(filename, ".vss")) { + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); title = filename.erase(filename.rfind('.')); if(title.empty()) { title = _("Unnamed Symbols"); @@ -646,14 +651,16 @@ void SymbolsDialog::get_symbols() { } /* Hunts preference directories for symbol files */ -void SymbolsDialog::get_symbols(Glib::ustring title) { +Glib::ustring SymbolsDialog::get_symbols(Glib::ustring title) { using namespace Inkscape::IO::Resource; SPDocument* symbol_doc = NULL; Glib::ustring new_title; size_t i = 0; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - if(filename == title + ".svg") { + std::size_t found = filename.find_last_of("/\\"); + Glib::ustring filename_short = filename.substr(found+1); + if(filename_short == title + ".svg") { symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); if(symbol_doc) { new_title = symbol_doc->getRoot()->title(); @@ -666,10 +673,7 @@ void SymbolsDialog::get_symbols(Glib::ustring title) { i++; } #ifdef WITH_LIBVISIO - if(Glib::str_has_suffix(filename, ".vss")) { - i++; - } - if(filename == title + ".vss") { + if(filename_short == title + ".vss") { symbol_doc = read_vss(filename, title); if(symbol_doc) { new_title = symbol_doc->getRoot()->title(); @@ -678,14 +682,23 @@ void SymbolsDialog::get_symbols(Glib::ustring title) { } } } + if(Glib::str_has_suffix(filename, ".vss")) { + i++; + } #endif if(symbol_doc) { - symbolSets.erase(title); + symbolSets.erase(title); symbolSets[new_title]= symbol_doc; + sensitive = false; + symbolSet->remove_text(i); + symbolSet->insert (i, new_title); symbolSet->set_active(i); symbolSet->set_active_text(new_title); + sensitive = true; + break; } } + return new_title; } void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector &l) @@ -770,33 +783,45 @@ void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { } } -void SymbolsDialog::find_symbols(Gtk::SearchEntry* search, GdkEventKey* evt) { +void SymbolsDialog::find_symbols(GdkEventKey* evt) { + if (evt->keyval != GDK_KEY_Return) { + return; + } + find_symbols_overload(); +} + +void SymbolsDialog::find_symbols_overload() { store->clear(); Glib::ustring title = search->get_text(); - if (evt->keyval != GDK_KEY_Return || title.empty()) { + if (title.empty()) { return; } - for(auto const &symbol_document_map : symbolSets) { + std::map symbolSetsCopy = symbolSets; + for(auto const &symbol_document_map : symbolSetsCopy) { SPDocument* symbol_document = symbol_document_map.second; + Glib::ustring doc_title = symbol_document_map.first; if (!symbol_document) { - get_symbols(symbol_document_map.first); - Glib::ustring symbolSetString = symbolSet->get_active_text(); - symbol_document = symbolSets[symbolSetString]; + doc_title = get_symbols(symbol_document_map.first); + search->set_text(doc_title); + symbol_document = symbolSets[doc_title]; } - std::vector l = symbols_in_doc( symbol_document); - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - if (symbol_title_char) { - Glib::ustring symbol_title = Glib::ustring(symbol_title_char); - auto pos = symbol_title.rfind(title); - if (title == "*" || symbol && pos != std::string::npos) { - Glib::ustring doc_title = symbol_document_map.first; // From doc title element - add_symbol( symbol, doc_title); + if (symbol_document) { + std::vector l = symbols_in_doc(symbol_document); + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + if (symbol_title_char) { + Glib::ustring symbol_title = Glib::ustring(symbol_title_char); + auto pos = symbol_title.rfind(title); + if (symbol && (title == "*" || pos != std::string::npos)) { + add_symbol( symbol, doc_title); + } } } } } + search->set_text(title); symbolSet->set_active_text(_("Search")); + symbolSetsCopy.clear(); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 96c9585f5..0ae8c4fcc 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -82,7 +82,7 @@ private: void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); - void get_symbols(Glib::ustring title); + Glib::ustring get_symbols(Glib::ustring title); void add_symbols( SPDocument* symbol_document ); void add_symbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbols_preview_doc(); @@ -91,7 +91,8 @@ private: std::vector symbols_in_doc( SPDocument* document); void use_in_doc_recursive(SPObject *r, std::vector &l); std::vector use_in_doc( SPDocument* document); - void find_symbols(Gtk::SearchEntry* search, GdkEventKey* evt); + void find_symbols(GdkEventKey* evt); + void find_symbols_overload(); gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr draw_symbol(SPObject *symbol); @@ -107,6 +108,7 @@ private: Glib::RefPtr store; Gtk::ComboBoxText* symbolSet; + bool sensitive; Gtk::SearchEntry* search; Gtk::IconView* iconView; Gtk::Button* addSymbol; -- cgit v1.2.3 From d1b095af84220d7f46123cdd2a2fae1de79d184e Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 19 Oct 2017 11:15:11 +0200 Subject: Working on current document --- src/ui/dialog/symbols.cpp | 32 +++++++++++++++++++------------- src/ui/dialog/symbols.h | 3 ++- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index d4b460d1d..ccaacd6a3 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -363,7 +363,7 @@ void SymbolsDialog::rebuild() { } store->clear(); - SPDocument* symbol_document = selectedSymbols(); + SPDocument* symbol_document = selectedSymbols(true); if( !symbol_document ) { // Symbol must be from Current Document (this method of // checking should be language independent). @@ -434,7 +434,7 @@ void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) rebuild(); } -SPDocument* SymbolsDialog::selectedSymbols() { +SPDocument* SymbolsDialog::selectedSymbols(bool ignorecurrent) { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ Glib::ustring doc_title = selectedSymbolDocTitle(); if (doc_title.empty()) { @@ -446,6 +446,9 @@ SPDocument* SymbolsDialog::selectedSymbols() { symbol_document = symbolSets[doc_title]; // Symbol must be from Current Document (this method of checking should be language independent). if( !symbol_document ) { + if (ignorecurrent) { + return NULL; + } return currentDocument; } } @@ -769,16 +772,14 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen } void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { - if (symbol_document) { - std::vector l = symbols_in_doc( symbol_document ); - Glib::ustring doc_title = ""; - if (symbol_document->getRoot()->title()) { - doc_title = symbol_document->getRoot()->title(); - } - for(auto symbol:l) { - if (symbol) { - add_symbol( symbol, doc_title); - } + std::vector l = symbols_in_doc( symbol_document ); + Glib::ustring doc_title = ""; + if (symbol_document->getRoot()->title()) { + doc_title = symbol_document->getRoot()->title(); + } + for(auto symbol:l) { + if (symbol) { + add_symbol( symbol, doc_title); } } } @@ -790,6 +791,12 @@ void SymbolsDialog::find_symbols(GdkEventKey* evt) { find_symbols_overload(); } +void SymbolsDialog::update_search_box(gpointer data) +{ + Glib::ustring doc_title = *reinterpret_cast(data); + search->set_text(doc_title); +} + void SymbolsDialog::find_symbols_overload() { store->clear(); Glib::ustring title = search->get_text(); @@ -802,7 +809,6 @@ void SymbolsDialog::find_symbols_overload() { Glib::ustring doc_title = symbol_document_map.first; if (!symbol_document) { doc_title = get_symbols(symbol_document_map.first); - search->set_text(doc_title); symbol_document = symbolSets[doc_title]; } if (symbol_document) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 0ae8c4fcc..585e8f98f 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -75,7 +75,8 @@ private: void defsModified(SPObject *object, guint flags); void selectionChanged(Inkscape::Selection *selection); void documentReplaced(SPDesktop *desktop, SPDocument *document); - SPDocument* selectedSymbols(); + SPDocument* selectedSymbols(bool ignorecurrent = false); + void update_search_box(gpointer data); Glib::ustring selectedSymbolId(); Glib::ustring selectedSymbolDocTitle(); void iconChanged(); -- cgit v1.2.3 From 5b1b6e8cf111c4c7c691f9e87bc52dd3626e29cb Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 19 Oct 2017 19:43:46 +0200 Subject: Finish speed improvements --- src/ui/dialog/symbols.cpp | 82 ++++++++++++++++++++++++++++------------------- src/ui/dialog/symbols.h | 3 +- 2 files changed, 51 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index ccaacd6a3..00796e096 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -17,14 +17,6 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -202,7 +194,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); tools->pack_start(* Gtk::manage(spacer)); search = Gtk::manage(new Gtk::SearchEntry()); // Search - search->set_tooltip_text(_("Search trought all symbols. Use * to get all (slow).")); + search->set_tooltip_text(_("Return to start search. Use * to get all symbols (slow).")); tools->pack_start(* search, Gtk::PACK_SHRINK); search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::find_symbols)); @@ -275,6 +267,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /**********************************************************/ sensitive = true; + finded = false; currentDesktop = SP_ACTIVE_DESKTOP; currentDocument = currentDesktop->getDocument(); @@ -798,36 +791,57 @@ void SymbolsDialog::update_search_box(gpointer data) } void SymbolsDialog::find_symbols_overload() { - store->clear(); Glib::ustring title = search->get_text(); if (title.empty()) { return; } - std::map symbolSetsCopy = symbolSets; - for(auto const &symbol_document_map : symbolSetsCopy) { - SPDocument* symbol_document = symbol_document_map.second; - Glib::ustring doc_title = symbol_document_map.first; - if (!symbol_document) { - doc_title = get_symbols(symbol_document_map.first); - symbol_document = symbolSets[doc_title]; + if (!finded) { + Gtk::Dialog search_dialog(_("Slow process please read")); + search_dialog.set_border_width(10); + Gtk::Label explanation; + explanation.set_markup(_("First time search is slow, next searchs are fast")); + explanation.set_line_wrap(true); + Gtk::Box *content = search_dialog.get_content_area(); + content->pack_start(explanation, false, false, 5); + Gtk::Button *ko_button = search_dialog.add_button(_("Cancel"), GTK_RESPONSE_CLOSE); + ko_button->grab_focus(); + Gtk::Button *ok_button = search_dialog.add_button(_("Search"), GTK_RESPONSE_ACCEPT); + ok_button->grab_focus(); + ko_button->grab_focus(); + search_dialog.show_all_children(); + int status = search_dialog.run(); + if ( status == GTK_RESPONSE_ACCEPT ) { + finded = true; } - if (symbol_document) { - std::vector l = symbols_in_doc(symbol_document); - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - if (symbol_title_char) { - Glib::ustring symbol_title = Glib::ustring(symbol_title_char); - auto pos = symbol_title.rfind(title); - if (symbol && (title == "*" || pos != std::string::npos)) { - add_symbol( symbol, doc_title); + } + if (finded) { + store->clear(); + std::map symbolSetsCopy = symbolSets; + for(auto const &symbol_document_map : symbolSetsCopy) { + SPDocument* symbol_document = symbol_document_map.second; + Glib::ustring doc_title = symbol_document_map.first; + if (!symbol_document) { + doc_title = get_symbols(symbol_document_map.first); + symbol_document = symbolSets[doc_title]; + } + if (symbol_document) { + std::vector l = symbols_in_doc(symbol_document); + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + if (symbol_title_char) { + Glib::ustring symbol_title = Glib::ustring(symbol_title_char); + auto pos = symbol_title.rfind(title); + if (symbol && (title == "*" || pos != std::string::npos)) { + add_symbol( symbol, doc_title); + } } } } } + search->set_text(title); + symbolSet->set_active_text(_("Search")); + symbolSetsCopy.clear(); } - search->set_text(title); - symbolSet->set_active_text(_("Search")); - symbolSetsCopy.clear(); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { @@ -839,16 +853,18 @@ void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { if( !title ) { title = id; } - if( doc_title.empty() ) { - return; + Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); + if (doc_title.empty()) { + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(" [") +_("Current Document") + Glib::ustring("]")); + } else { + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(" [") + doc_title + Glib::ustring("]")); } - Glib::RefPtr pixbuf = draw_symbol( symbol ); if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); + (*row)[columns->symbol_title] = symbol_title; (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(doc_title); (*row)[columns->symbol_image] = pixbuf; } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 585e8f98f..9a28da1a0 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -12,13 +12,13 @@ #ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H #define INKSCAPE_UI_DIALOG_SYMBOLS_H +#include #include "display/drawing.h" #include "ui/dialog/desktop-tracker.h" #include "ui/widget/panel.h" #include "sp-symbol.h" #include "sp-use.h" -#include #include class SPObject; @@ -110,6 +110,7 @@ private: Glib::RefPtr store; Gtk::ComboBoxText* symbolSet; bool sensitive; + bool finded; Gtk::SearchEntry* search; Gtk::IconView* iconView; Gtk::Button* addSymbol; -- cgit v1.2.3 From f2149d04cdff6c8278fef20928b1bbee6bcbb06f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 20 Oct 2017 05:51:55 +0200 Subject: Add case insensitive and no dialog loading --- src/ui/dialog/symbols.cpp | 91 +++++++++++++++++++---------------------------- src/ui/dialog/symbols.h | 6 ++-- 2 files changed, 39 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 00796e096..a098d64c1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -197,8 +197,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : search->set_tooltip_text(_("Return to start search. Use * to get all symbols (slow).")); tools->pack_start(* search, Gtk::PACK_SHRINK); - search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::find_symbols)); - + search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::prepare_find_symbols)); + search->signal_key_release_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::find_symbols)); + // Pack size (controls display area) pack_size = 2; // Default 32px @@ -267,7 +268,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /**********************************************************/ sensitive = true; - finded = false; currentDesktop = SP_ACTIVE_DESKTOP; currentDocument = currentDesktop->getDocument(); @@ -368,7 +368,7 @@ void SymbolsDialog::rebuild() { removeSymbol->set_sensitive( false ); } if (symbolSet->get_active_text() == "Search") { - find_symbols_overload(); + find_symbols_overloaded(); } else { add_symbols( symbol_document ); } @@ -781,67 +781,48 @@ void SymbolsDialog::find_symbols(GdkEventKey* evt) { if (evt->keyval != GDK_KEY_Return) { return; } - find_symbols_overload(); + find_symbols_overloaded(); } -void SymbolsDialog::update_search_box(gpointer data) -{ - Glib::ustring doc_title = *reinterpret_cast(data); - search->set_text(doc_title); +void SymbolsDialog::prepare_find_symbols(GdkEventKey* evt) { + if (evt->keyval != GDK_KEY_Return) { + return; + } + search_str = search->get_text().lowercase(); + search->set_text(_("Loading...")); + } -void SymbolsDialog::find_symbols_overload() { - Glib::ustring title = search->get_text(); - if (title.empty()) { +void SymbolsDialog::find_symbols_overloaded() { + if (search_str.empty()) { return; } - if (!finded) { - Gtk::Dialog search_dialog(_("Slow process please read")); - search_dialog.set_border_width(10); - Gtk::Label explanation; - explanation.set_markup(_("First time search is slow, next searchs are fast")); - explanation.set_line_wrap(true); - Gtk::Box *content = search_dialog.get_content_area(); - content->pack_start(explanation, false, false, 5); - Gtk::Button *ko_button = search_dialog.add_button(_("Cancel"), GTK_RESPONSE_CLOSE); - ko_button->grab_focus(); - Gtk::Button *ok_button = search_dialog.add_button(_("Search"), GTK_RESPONSE_ACCEPT); - ok_button->grab_focus(); - ko_button->grab_focus(); - search_dialog.show_all_children(); - int status = search_dialog.run(); - if ( status == GTK_RESPONSE_ACCEPT ) { - finded = true; + store->clear(); + std::map symbolSetsCopy = symbolSets; + for(auto const &symbol_document_map : symbolSetsCopy) { + SPDocument* symbol_document = symbol_document_map.second; + Glib::ustring doc_title = symbol_document_map.first; + if (!symbol_document) { + doc_title = get_symbols(symbol_document_map.first); + symbol_document = symbolSets[doc_title]; } - } - if (finded) { - store->clear(); - std::map symbolSetsCopy = symbolSets; - for(auto const &symbol_document_map : symbolSetsCopy) { - SPDocument* symbol_document = symbol_document_map.second; - Glib::ustring doc_title = symbol_document_map.first; - if (!symbol_document) { - doc_title = get_symbols(symbol_document_map.first); - symbol_document = symbolSets[doc_title]; - } - if (symbol_document) { - std::vector l = symbols_in_doc(symbol_document); - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - if (symbol_title_char) { - Glib::ustring symbol_title = Glib::ustring(symbol_title_char); - auto pos = symbol_title.rfind(title); - if (symbol && (title == "*" || pos != std::string::npos)) { - add_symbol( symbol, doc_title); - } + if (symbol_document) { + std::vector l = symbols_in_doc(symbol_document); + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + if (symbol_title_char) { + Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_title.rfind(search_str); + if (symbol && (search_str == "*" || pos != std::string::npos)) { + add_symbol( symbol, doc_title); } } } } - search->set_text(title); - symbolSet->set_active_text(_("Search")); - symbolSetsCopy.clear(); } + search->set_text(search_str); + symbolSet->set_active_text(_("Search")); + symbolSetsCopy.clear(); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { @@ -855,9 +836,9 @@ void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { } Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); if (doc_title.empty()) { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(" [") +_("Current Document") + Glib::ustring("]")); + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" [") +_("Current Document") + Glib::ustring("]")).c_str()))); } else { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(" [") + doc_title + Glib::ustring("]")); + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" [") + doc_title + Glib::ustring("]")).c_str()))); } Glib::RefPtr pixbuf = draw_symbol( symbol ); diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 9a28da1a0..e2e467cd6 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -76,7 +76,6 @@ private: void selectionChanged(Inkscape::Selection *selection); void documentReplaced(SPDesktop *desktop, SPDocument *document); SPDocument* selectedSymbols(bool ignorecurrent = false); - void update_search_box(gpointer data); Glib::ustring selectedSymbolId(); Glib::ustring selectedSymbolDocTitle(); void iconChanged(); @@ -93,7 +92,8 @@ private: void use_in_doc_recursive(SPObject *r, std::vector &l); std::vector use_in_doc( SPDocument* document); void find_symbols(GdkEventKey* evt); - void find_symbols_overload(); + void prepare_find_symbols(GdkEventKey* evt); + void find_symbols_overloaded(); gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr draw_symbol(SPObject *symbol); @@ -110,8 +110,8 @@ private: Glib::RefPtr store; Gtk::ComboBoxText* symbolSet; bool sensitive; - bool finded; Gtk::SearchEntry* search; + Glib::ustring search_str; Gtk::IconView* iconView; Gtk::Button* addSymbol; Gtk::Button* removeSymbol; -- cgit v1.2.3 From f99611197da52e8854719e1bd10d14f1f00d074f Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 20 Oct 2017 09:53:04 +0200 Subject: Add description search and icon if no results --- src/ui/dialog/symbols.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index a098d64c1..434dcf3b9 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -799,6 +799,8 @@ void SymbolsDialog::find_symbols_overloaded() { } store->clear(); std::map symbolSetsCopy = symbolSets; + bool icons_found = false; + SPDocument* searchdoc; for(auto const &symbol_document_map : symbolSetsCopy) { SPDocument* symbol_document = symbol_document_map.second; Glib::ustring doc_title = symbol_document_map.first; @@ -806,22 +808,42 @@ void SymbolsDialog::find_symbols_overloaded() { doc_title = get_symbols(symbol_document_map.first); symbol_document = symbolSets[doc_title]; } + if (doc_title == "Search") { + searchdoc = symbol_document; + continue; + } if (symbol_document) { std::vector l = symbols_in_doc(symbol_document); for(auto symbol:l) { gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); if (symbol_title_char) { + bool found = false; Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); auto pos = symbol_title.rfind(search_str); - if (symbol && (search_str == "*" || pos != std::string::npos)) { + if (pos != std::string::npos) { + found = true; + } + if (!found && symbol_desc_char) { + Glib::ustring symbol_desc = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_desc.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + } + if (symbol && (search_str == "*" || found)) { add_symbol( symbol, doc_title); + icons_found = true; } } } } } + if (!icons_found) { + add_symbols(searchdoc); + } + symbolSet->set_active_text(_("Search")); search->set_text(search_str); - symbolSet->set_active_text(_("Search")); symbolSetsCopy.clear(); } -- cgit v1.2.3 From cd617235986381ed4de6cba8ba4cf6c74a6cf2d3 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 20 Oct 2017 12:58:40 +0200 Subject: Add progress bar to loading, currently not working but all the base code is done. need to look into idle methods --- src/ui/dialog/symbols.cpp | 27 +++++++++++++++++++++------ src/ui/dialog/symbols.h | 8 +++++++- 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 434dcf3b9..77a9b8ca5 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -20,7 +20,7 @@ #include #include #include -#include + #include "path-prefix.h" #include "io/sys.h" #include "io/resource.h" @@ -63,6 +63,7 @@ #include "verbs.h" #include "helper/action.h" +#include namespace Inkscape { namespace UI { @@ -109,7 +110,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : { /******************** Table *************************/ - auto table = new Gtk::Grid(); + table = new Gtk::Grid(); // panel is a cloked Gtk::VBox _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); @@ -152,13 +153,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); instanceConns.push_back(connIconChanged); - Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); + scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scroller->add(*Gtk::manage(iconView)); scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller),0,row,2,1); - ++row; /******************** Tools *******************************/ @@ -266,6 +266,14 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; + /******************** Progress *******************************/ + progress = new Gtk::HBox(); + progressbar = Gtk::manage(new Gtk::ProgressBar()); + table->attach(*Gtk::manage(progress),0,row, 2, 1); + progress->pack_start(* progressbar, Gtk::PACK_EXPAND_WIDGET); + progress->set_margin_top(5); + ++row; + /**********************************************************/ sensitive = true; currentDesktop = SP_ACTIVE_DESKTOP; @@ -289,7 +297,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::connection documentReplacedConn = currentDesktop->connectDocumentReplaced( sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); instanceConns.push_back(documentReplacedConn); - get_symbols(); add_symbols( currentDocument ); /* Defaults to current document */ @@ -619,6 +626,7 @@ void SymbolsDialog::get_symbols() { using namespace Inkscape::IO::Resource; Glib::ustring title; + number_docs = 0; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { if(Glib::str_has_suffix(filename, ".svg")) { //TODO: find a way to get real title without loading all SPDocument @@ -630,6 +638,7 @@ void SymbolsDialog::get_symbols() { } symbolSets[title]= NULL; symbolSet->append(title); + ++number_docs; } #ifdef WITH_LIBVISIO if(Glib::str_has_suffix(filename, ".vss")) { @@ -641,6 +650,7 @@ void SymbolsDialog::get_symbols() { } symbolSets[title]= NULL; symbolSet->append(title); + ++number_docs; } #endif } @@ -788,9 +798,9 @@ void SymbolsDialog::prepare_find_symbols(GdkEventKey* evt) { if (evt->keyval != GDK_KEY_Return) { return; } + progressbar->set_fraction(0.0); search_str = search->get_text().lowercase(); search->set_text(_("Loading...")); - } void SymbolsDialog::find_symbols_overloaded() { @@ -801,7 +811,9 @@ void SymbolsDialog::find_symbols_overloaded() { std::map symbolSetsCopy = symbolSets; bool icons_found = false; SPDocument* searchdoc; + size_t counter = 0; for(auto const &symbol_document_map : symbolSetsCopy) { + ++counter; SPDocument* symbol_document = symbol_document_map.second; Glib::ustring doc_title = symbol_document_map.first; if (!symbol_document) { @@ -813,6 +825,8 @@ void SymbolsDialog::find_symbols_overloaded() { continue; } if (symbol_document) { + progressbar->set_fraction(((100.0/number_docs) * counter)/100.0); + progressbar->set_text(doc_title); std::vector l = symbols_in_doc(symbol_document); for(auto symbol:l) { gchar const *symbol_title_char = symbol->title(); @@ -845,6 +859,7 @@ void SymbolsDialog::find_symbols_overloaded() { symbolSet->set_active_text(_("Search")); search->set_text(search_str); symbolSetsCopy.clear(); + progressbar->set_fraction(1.0); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index e2e467cd6..1b7d04acd 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -107,9 +107,13 @@ private: // Scale factor int scale_factor; + bool sensitive; + size_t number_docs; + Glib::RefPtr store; Gtk::ComboBoxText* symbolSet; - bool sensitive; + Gtk::ProgressBar* progressbar; + Gtk::HBox* progress; Gtk::SearchEntry* search; Glib::ustring search_str; Gtk::IconView* iconView; @@ -117,6 +121,8 @@ private: Gtk::Button* removeSymbol; Gtk::Button* zoomIn; Gtk::Button* zoomOut; + Gtk::Grid* table; + Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fitSymbol; void setTargetDesktop(SPDesktop *desktop); -- cgit v1.2.3 From eda9c670f48804bf43707de3001300496e9cf809 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 20 Oct 2017 16:01:49 +0200 Subject: Fiz the MR note note_44059492. Thanks Eduard --- src/ui/dialog/symbols.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 77a9b8ca5..7f2c69ffd 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -839,7 +839,7 @@ void SymbolsDialog::find_symbols_overloaded() { found = true; } if (!found && symbol_desc_char) { - Glib::ustring symbol_desc = Glib::ustring(symbol_title_char).lowercase(); + Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); auto pos = symbol_desc.rfind(search_str); if (pos != std::string::npos) { found = true; -- cgit v1.2.3 From 4bcc974f13115b19f2b320b98355ef1431e4f9ed Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 21 Oct 2017 00:20:40 +0200 Subject: Progress Bar workinggit add .git add . --- src/ui/dialog/symbols.cpp | 96 +++++++++++++++++++++++++---------------------- src/ui/dialog/symbols.h | 7 +++- 2 files changed, 57 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 7f2c69ffd..eb787387a 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -198,7 +198,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : tools->pack_start(* search, Gtk::PACK_SHRINK); search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::prepare_find_symbols)); - search->signal_key_release_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::find_symbols)); // Pack size (controls display area) pack_size = 2; // Default 32px @@ -276,6 +275,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /**********************************************************/ sensitive = true; + processed = false; + search_str = ""; currentDesktop = SP_ACTIVE_DESKTOP; currentDocument = currentDesktop->getDocument(); @@ -303,7 +304,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::connection desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); - + Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::parse_documents) ); deskTrack.connect(GTK_WIDGET(gobj())); } @@ -375,7 +376,7 @@ void SymbolsDialog::rebuild() { removeSymbol->set_sensitive( false ); } if (symbolSet->get_active_text() == "Search") { - find_symbols_overloaded(); + find_symbols(); } else { add_symbols( symbol_document ); } @@ -787,68 +788,76 @@ void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { } } -void SymbolsDialog::find_symbols(GdkEventKey* evt) { - if (evt->keyval != GDK_KEY_Return) { - return; - } - find_symbols_overloaded(); -} - void SymbolsDialog::prepare_find_symbols(GdkEventKey* evt) { if (evt->keyval != GDK_KEY_Return) { return; } progressbar->set_fraction(0.0); search_str = search->get_text().lowercase(); - search->set_text(_("Loading...")); + search->set_text(_("Searching...")); + if(processed) { + find_symbols(); + } } -void SymbolsDialog::find_symbols_overloaded() { - if (search_str.empty()) { - return; +bool SymbolsDialog::parse_documents(){ + if (search->get_text() != _("Searching...")) { + return true; } - store->clear(); - std::map symbolSetsCopy = symbolSets; + size_t counter = 0; + for(auto const &symbol_document_map : symbolSets) { + ++counter; + SPDocument* symbol_document = symbol_document_map.second; + if (symbol_document) { + continue; + } + get_symbols(symbol_document_map.first); + progressbar->set_fraction(((100.0/number_docs) * counter)/100.0); + return true; + } + find_symbols(); + processed = true; + progressbar->set_fraction(1.0); + return false; +} + +void SymbolsDialog::find_symbols() { bool icons_found = false; SPDocument* searchdoc; size_t counter = 0; - for(auto const &symbol_document_map : symbolSetsCopy) { + store->clear(); + for(auto const &symbol_document_map : symbolSets) { ++counter; SPDocument* symbol_document = symbol_document_map.second; - Glib::ustring doc_title = symbol_document_map.first; if (!symbol_document) { - doc_title = get_symbols(symbol_document_map.first); - symbol_document = symbolSets[doc_title]; + return; } + Glib::ustring doc_title = symbol_document_map.first; if (doc_title == "Search") { searchdoc = symbol_document; continue; } - if (symbol_document) { - progressbar->set_fraction(((100.0/number_docs) * counter)/100.0); - progressbar->set_text(doc_title); - std::vector l = symbols_in_doc(symbol_document); - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - gchar const *symbol_desc_char = symbol->description(); - if (symbol_title_char) { - bool found = false; - Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); - auto pos = symbol_title.rfind(search_str); + std::vector l = symbols_in_doc(symbol_document); + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); + if (symbol_title_char) { + bool found = false; + Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_title.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + if (!found && symbol_desc_char) { + Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); + auto pos = symbol_desc.rfind(search_str); if (pos != std::string::npos) { found = true; } - if (!found && symbol_desc_char) { - Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); - auto pos = symbol_desc.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - } - if (symbol && (search_str == "*" || found)) { - add_symbol( symbol, doc_title); - icons_found = true; - } + } + if (symbol && (search_str == "*" || found)) { + add_symbol( symbol, doc_title); + icons_found = true; } } } @@ -858,8 +867,7 @@ void SymbolsDialog::find_symbols_overloaded() { } symbolSet->set_active_text(_("Search")); search->set_text(search_str); - symbolSetsCopy.clear(); - progressbar->set_fraction(1.0); + dynamic_cast(progress)->hide(); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 1b7d04acd..23a81c68c 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -91,9 +91,9 @@ private: std::vector symbols_in_doc( SPDocument* document); void use_in_doc_recursive(SPObject *r, std::vector &l); std::vector use_in_doc( SPDocument* document); - void find_symbols(GdkEventKey* evt); void prepare_find_symbols(GdkEventKey* evt); - void find_symbols_overloaded(); + void find_symbols(); + bool parse_documents(); gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr draw_symbol(SPObject *symbol); @@ -108,6 +108,9 @@ private: int scale_factor; bool sensitive; + + bool processed; + size_t number_docs; Glib::RefPtr store; -- cgit v1.2.3 From 3bd9472b2498d5a0a33026260c64d2cac8ad2878 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 21 Oct 2017 02:44:59 +0200 Subject: Fis come things pointed by Eduard in the MR --- src/ui/dialog/symbols.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index eb787387a..5e9a5ae2b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -355,6 +355,7 @@ void SymbolsDialog::rebuild() { if (!sensitive) { return; } + if( fitSymbol->get_active() ) { zoomIn->set_sensitive( false ); zoomOut->set_sensitive( false ); @@ -789,19 +790,23 @@ void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { } void SymbolsDialog::prepare_find_symbols(GdkEventKey* evt) { - if (evt->keyval != GDK_KEY_Return) { + search_str = search->get_text().lowercase(); + if (evt->keyval != GDK_KEY_Return || search_str.empty()) { return; } progressbar->set_fraction(0.0); - search_str = search->get_text().lowercase(); search->set_text(_("Searching...")); + search->set_sensitive(false); if(processed) { find_symbols(); + } else { + dynamic_cast(progressbar)->set_visible(true); } } bool SymbolsDialog::parse_documents(){ if (search->get_text() != _("Searching...")) { + dynamic_cast(progressbar)->set_visible(false); return true; } size_t counter = 0; @@ -867,7 +872,8 @@ void SymbolsDialog::find_symbols() { } symbolSet->set_active_text(_("Search")); search->set_text(search_str); - dynamic_cast(progress)->hide(); + search->set_sensitive(true); + dynamic_cast(progressbar)->set_visible(false); } void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { @@ -1010,7 +1016,6 @@ SPDocument* SymbolsDialog::symbols_preview_doc() " " " " ""; - return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); } -- cgit v1.2.3 From 5d8948b99524245009680f3af3013f15bc8e8086 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 22 Oct 2017 11:21:17 +0200 Subject: Add discarted switch mode, working on global search --- src/ui/dialog/symbols.cpp | 533 ++++++++++++++++++++++++++-------------------- src/ui/dialog/symbols.h | 66 +++--- 2 files changed, 342 insertions(+), 257 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 5e9a5ae2b..56af2256b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -101,11 +101,11 @@ SymbolColumns* SymbolsDialog::getColumns() SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), store(Gtk::ListStore::create(*getColumns())), - iconView(0), - currentDesktop(0), - deskTrack(), - currentDocument(0), - previewDocument(0), + icon_view(0), + current_desktop(0), + desk_track(), + current_document(0), + preview_document(0), instanceConns() { @@ -119,43 +119,87 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /******************** Symbol Sets *************************/ Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: ")); table->attach(*Gtk::manage(labelSet),0,row,1,1); - symbolSet = new Gtk::ComboBoxText(); // Fill in later - symbolSet->append(_("Current Document")); - symbolSet->set_active_text(_("Current Document")); - symbolSet->set_hexpand(); - table->attach(*Gtk::manage(symbolSet),1,row,1,1); - sigc::connection connSet = symbolSet->signal_changed().connect( + symbol_set = new Gtk::ComboBoxText(); // Fill in later + symbol_set->append(_("Current Document")); + symbol_set->set_active_text(_("Current Document")); + symbol_set->set_hexpand(); + table->attach(*Gtk::manage(symbol_set),1,row,1,1); + sigc::connection connSet = symbol_set->signal_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::rebuild)); instanceConns.push_back(connSet); ++row; + + Gtk::Separator* separator_sets = new Gtk::Separator(); + separator_sets->set_margin_top(3); + separator_sets->set_margin_bottom(3); + table->attach(*Gtk::manage(separator_sets),0,row,2,1); + + ++row; + /******************** Search *************************/ + + Gtk::Label* label_global = new Gtk::Label(_("Global Search: ")); + table->attach(*Gtk::manage(label_global),0,row,1,1); + Gtk::HBox * global_container = new Gtk::HBox(); + global = new Gtk::Switch(); + global->set_state(false); + global_container->pack_start(* global, Gtk::PACK_SHRINK); + Gtk::Separator* separator_global = new Gtk::Separator(Gtk::ORIENTATION_VERTICAL); + separator_global->set_margin_right(3); + separator_global->set_margin_left(3); + global_container->pack_start(* separator_global, Gtk::PACK_SHRINK); + search = Gtk::manage(new Gtk::SearchEntry()); // Search + search->set_tooltip_text(_("Return to start search.")); + search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::prepareFindSymbols)); + search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); + global_container->pack_start(* search, Gtk::PACK_EXPAND_WIDGET); + table->attach(*Gtk::manage(global_container),1,row,1,1); + + ++row; + + /******************** Progress *******************************/ + progress = new Gtk::HBox(); + progress_bar = Gtk::manage(new Gtk::ProgressBar()); + table->attach(*Gtk::manage(progress),0,row, 2, 1); + progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); + progress->set_margin_top(5); + + ++row; + + Gtk::Separator* separator_search = new Gtk::Separator(); + separator_search->set_margin_top(2); + separator_search->set_margin_bottom(3); + table->attach(*Gtk::manage(separator_search),0,row,2,1); + + ++row; + /********************* Icon View **************************/ SymbolColumns* columns = getColumns(); - iconView = new Gtk::IconView(static_cast >(store)); - //iconView->set_text_column( columns->symbol_id ); - iconView->set_tooltip_column( 1 ); - iconView->set_pixbuf_column( columns->symbol_image ); + icon_view = new Gtk::IconView(static_cast >(store)); + //icon_view->set_text_column( columns->symbol_id ); + icon_view->set_tooltip_column( 1 ); + icon_view->set_pixbuf_column( columns->symbol_image ); // Giving the iconview a small minimum size will help users understand // What the dialog does. - iconView->set_size_request( 100, 200 ); + icon_view->set_size_request( 100, 200 ); std::vector< Gtk::TargetEntry > targets; targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); - iconView->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); - iconView->signal_drag_data_get().connect( + icon_view->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); + icon_view->signal_drag_data_get().connect( sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); sigc::connection connIconChanged; - connIconChanged = iconView->signal_selection_changed().connect( + connIconChanged = icon_view->signal_selection_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); instanceConns.push_back(connIconChanged); scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); - scroller->add(*Gtk::manage(iconView)); + scroller->add(*Gtk::manage(icon_view)); scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller),0,row,2,1); @@ -169,35 +213,30 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : scroller->set_hexpand(); table->attach(*Gtk::manage(tools),0,row,2,1); - auto addSymbolImage = Gtk::manage(new Gtk::Image()); - addSymbolImage->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR); + auto add_symbol_image = Gtk::manage(new Gtk::Image()); + add_symbol_image->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR); - addSymbol = Gtk::manage(new Gtk::Button()); - addSymbol->add(*addSymbolImage); - addSymbol->set_tooltip_text(_("Add Symbol from the current document.")); - addSymbol->set_relief( Gtk::RELIEF_NONE ); - addSymbol->set_focus_on_click( false ); - addSymbol->signal_activate().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); - tools->pack_start(* addSymbol, Gtk::PACK_SHRINK); + add_symbol = Gtk::manage(new Gtk::Button()); + add_symbol->add(*add_symbol_image); + add_symbol->set_tooltip_text(_("Add Symbol from the current document.")); + add_symbol->set_relief( Gtk::RELIEF_NONE ); + add_symbol->set_focus_on_click( false ); + add_symbol->signal_activate().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); + tools->pack_start(* add_symbol, Gtk::PACK_SHRINK); - auto removeSymbolImage = Gtk::manage(new Gtk::Image()); - removeSymbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR); + auto remove_symbolImage = Gtk::manage(new Gtk::Image()); + remove_symbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR); - removeSymbol = Gtk::manage(new Gtk::Button()); - removeSymbol->add(*removeSymbolImage); - removeSymbol->set_tooltip_text(_("Remove Symbol from the current document.")); - removeSymbol->set_relief( Gtk::RELIEF_NONE ); - removeSymbol->set_focus_on_click( false ); - removeSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol)); - tools->pack_start(* removeSymbol, Gtk::PACK_SHRINK); + remove_symbol = Gtk::manage(new Gtk::Button()); + remove_symbol->add(*remove_symbolImage); + remove_symbol->set_tooltip_text(_("Remove Symbol from the current document.")); + remove_symbol->set_relief( Gtk::RELIEF_NONE ); + remove_symbol->set_focus_on_click( false ); + remove_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol)); + tools->pack_start(* remove_symbol, Gtk::PACK_SHRINK); Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); tools->pack_start(* Gtk::manage(spacer)); - search = Gtk::manage(new Gtk::SearchEntry()); // Search - search->set_tooltip_text(_("Return to start search. Use * to get all symbols (slow).")); - tools->pack_start(* search, Gtk::PACK_SHRINK); - - search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::prepare_find_symbols)); // Pack size (controls display area) pack_size = 2; // Default 32px @@ -225,87 +264,79 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : tools->pack_start(* button, Gtk::PACK_SHRINK); // Toggle scale to fit on/off - auto fitSymbolImage = Gtk::manage(new Gtk::Image()); - fitSymbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - fitSymbol = Gtk::manage(new Gtk::ToggleButton()); - fitSymbol->add(*fitSymbolImage); - fitSymbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); - fitSymbol->set_relief( Gtk::RELIEF_NONE ); - fitSymbol->set_focus_on_click( false ); - fitSymbol->set_active( true ); - fitSymbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); - tools->pack_start(* fitSymbol, Gtk::PACK_SHRINK); + auto fit_symbolImage = Gtk::manage(new Gtk::Image()); + fit_symbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + fit_symbol = Gtk::manage(new Gtk::ToggleButton()); + fit_symbol->add(*fit_symbolImage); + fit_symbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); + fit_symbol->set_relief( Gtk::RELIEF_NONE ); + fit_symbol->set_focus_on_click( false ); + fit_symbol->set_active( true ); + fit_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + tools->pack_start(* fit_symbol, Gtk::PACK_SHRINK); // Render size (scales symbols within display area) scale_factor = 0; // Default 1:1 * pack_size/pack_size default - auto zoomOutImage = Gtk::manage(new Gtk::Image()); - zoomOutImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - zoomOut = Gtk::manage(new Gtk::Button()); - zoomOut->add(*zoomOutImage); - zoomOut->set_tooltip_text(_("Make symbols smaller by zooming out.")); - zoomOut->set_relief( Gtk::RELIEF_NONE ); - zoomOut->set_focus_on_click( false ); - zoomOut->set_sensitive( false ); - zoomOut->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); - tools->pack_start(* zoomOut, Gtk::PACK_SHRINK); - - auto zoomInImage = Gtk::manage(new Gtk::Image()); - zoomInImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - zoomIn = Gtk::manage(new Gtk::Button()); - zoomIn->add(*zoomInImage); - zoomIn->set_tooltip_text(_("Make symbols bigger by zooming in.")); - zoomIn->set_relief( Gtk::RELIEF_NONE ); - zoomIn->set_focus_on_click( false ); - zoomIn->set_sensitive( false ); - zoomIn->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin)); - tools->pack_start(* zoomIn, Gtk::PACK_SHRINK); - - ++row; + auto zoom_outImage = Gtk::manage(new Gtk::Image()); + zoom_outImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + zoom_out = Gtk::manage(new Gtk::Button()); + zoom_out->add(*zoom_outImage); + zoom_out->set_tooltip_text(_("Make symbols smaller by zooming out.")); + zoom_out->set_relief( Gtk::RELIEF_NONE ); + zoom_out->set_focus_on_click( false ); + zoom_out->set_sensitive( false ); + zoom_out->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); + tools->pack_start(* zoom_out, Gtk::PACK_SHRINK); + + auto zoom_inImage = Gtk::manage(new Gtk::Image()); + zoom_inImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + zoom_in = Gtk::manage(new Gtk::Button()); + zoom_in->add(*zoom_inImage); + zoom_in->set_tooltip_text(_("Make symbols bigger by zooming in.")); + zoom_in->set_relief( Gtk::RELIEF_NONE ); + zoom_in->set_focus_on_click( false ); + zoom_in->set_sensitive( false ); + zoom_in->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin)); + tools->pack_start(* zoom_in, Gtk::PACK_SHRINK); - /******************** Progress *******************************/ - progress = new Gtk::HBox(); - progressbar = Gtk::manage(new Gtk::ProgressBar()); - table->attach(*Gtk::manage(progress),0,row, 2, 1); - progress->pack_start(* progressbar, Gtk::PACK_EXPAND_WIDGET); - progress->set_margin_top(5); ++row; /**********************************************************/ sensitive = true; processed = false; search_str = ""; - currentDesktop = SP_ACTIVE_DESKTOP; - currentDocument = currentDesktop->getDocument(); + current_desktop = SP_ACTIVE_DESKTOP; + current_document = current_desktop->getDocument(); - previewDocument = symbols_preview_doc(); /* Template to render symbols in */ - previewDocument->ensureUpToDate(); /* Necessary? */ + preview_document = symbolsPreviewDoc(); /* Template to render symbols in */ + preview_document->ensureUpToDate(); /* Necessary? */ key = SPItem::display_key_new(1); - renderDrawing.setRoot(previewDocument->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); + renderDrawing.setRoot(preview_document->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(); + SPDefs *defs = current_document->getDefs(); sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); - sigc::connection selectionChangedConn = currentDesktop->selection->connectChanged( + sigc::connection selectionChangedConn = current_desktop->selection->connectChanged( sigc::mem_fun(*this, &SymbolsDialog::selectionChanged)); instanceConns.push_back(selectionChangedConn); - sigc::connection documentReplacedConn = currentDesktop->connectDocumentReplaced( + sigc::connection documentReplacedConn = current_desktop->connectDocumentReplaced( sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); instanceConns.push_back(documentReplacedConn); - get_symbols(); - add_symbols( currentDocument ); /* Defaults to current document */ + getSymbols(); + addSymbols( current_document ); /* Defaults to current document */ sigc::connection desktopChangeConn = - deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); + desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); - Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::parse_documents) ); - deskTrack.connect(GTK_WIDGET(gobj())); + Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::parseDocuments) ); + desk_track.connect(GTK_WIDGET(gobj())); } SymbolsDialog::~SymbolsDialog() @@ -314,7 +345,7 @@ SymbolsDialog::~SymbolsDialog() it->disconnect(); } instanceConns.clear(); - deskTrack.disconnect(); + desk_track.disconnect(); } SymbolsDialog& SymbolsDialog::getInstance() @@ -356,12 +387,12 @@ void SymbolsDialog::rebuild() { return; } - if( fitSymbol->get_active() ) { - zoomIn->set_sensitive( false ); - zoomOut->set_sensitive( false ); + if( fit_symbol->get_active() ) { + zoom_in->set_sensitive( false ); + zoom_out->set_sensitive( false ); } else { - zoomIn->set_sensitive( true); - zoomOut->set_sensitive( true ); + zoom_in->set_sensitive( true); + zoom_out->set_sensitive( true ); } store->clear(); @@ -369,35 +400,35 @@ void SymbolsDialog::rebuild() { if( !symbol_document ) { // Symbol must be from Current Document (this method of // checking should be language independent). - symbol_document = currentDocument; - addSymbol->set_sensitive( true ); - removeSymbol->set_sensitive( true ); + symbol_document = current_document; + add_symbol->set_sensitive( true ); + remove_symbol->set_sensitive( true ); } else { - addSymbol->set_sensitive( false ); - removeSymbol->set_sensitive( false ); + add_symbol->set_sensitive( false ); + remove_symbol->set_sensitive( false ); } - if (symbolSet->get_active_text() == "Search") { - find_symbols(); + if (symbol_set->get_active_text() == _("Global Search")) { + findSymbols(); } else { - add_symbols( symbol_document ); + findSymbolsInDoc(symbol_document, last_symbol_set); } } void SymbolsDialog::insertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop) ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->current_desktop) ); sp_action_perform (action, NULL); } void SymbolsDialog::revertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop ) ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->current_desktop ) ); sp_action_perform (action, NULL); } void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) { - auto iconArray = iconView->get_selected_items(); + auto iconArray = icon_view->get_selected_items(); if( iconArray.empty() ) { //std::cout << " iconArray empty: huh? " << std::endl; @@ -414,7 +445,7 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*cont void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) { - if ( !symbolSets[symbolSet->get_active_text()] ) { + if ( !symbol_sets[symbol_set->get_active_text()] ) { rebuild(); } } @@ -425,14 +456,14 @@ void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { SPObject* symbol = symbol_document->getObjectById(symbol_id); if(symbol && !selection->includes(symbol)) { - iconView->unselect_all(); + icon_view->unselect_all(); } } void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) { - currentDesktop = desktop; - currentDocument = document; + current_desktop = desktop; + current_document = document; rebuild(); } @@ -440,18 +471,17 @@ SPDocument* SymbolsDialog::selectedSymbols(bool ignorecurrent) { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ Glib::ustring doc_title = selectedSymbolDocTitle(); if (doc_title.empty()) { - doc_title = symbolSet->get_active_text(); + doc_title = symbol_set->get_active_text(); } - SPDocument* symbol_document = symbolSets[doc_title]; + SPDocument* symbol_document = symbol_sets[doc_title]; if( !symbol_document ) { - doc_title = get_symbols(doc_title); - symbol_document = symbolSets[doc_title]; + symbol_document = getSymbols(doc_title).second; // Symbol must be from Current Document (this method of checking should be language independent). if( !symbol_document ) { if (ignorecurrent) { return NULL; } - return currentDocument; + return current_document; } } return symbol_document; @@ -459,7 +489,7 @@ SPDocument* SymbolsDialog::selectedSymbols(bool ignorecurrent) { Glib::ustring SymbolsDialog::selectedSymbolId() { - auto iconArray = iconView->get_selected_items(); + auto iconArray = icon_view->get_selected_items(); if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); @@ -471,7 +501,7 @@ Glib::ustring SymbolsDialog::selectedSymbolId() { Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { - auto iconArray = iconView->get_selected_items(); + auto iconArray = icon_view->get_selected_items(); if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); @@ -493,15 +523,15 @@ void SymbolsDialog::iconChanged() { gchar const* style = symbol->getAttribute("inkscape:symbol-style"); if( !style ) { // If no default style in , look in documents. - if( symbol_document == currentDocument ) { - style = style_from_use( symbol_id.c_str(), currentDocument ); + if( symbol_document == current_document ) { + style = styleFromUse( symbol_id.c_str(), current_document ); } else { style = symbol_document->getReprRoot()->attribute("style"); } } ClipboardManager *cm = ClipboardManager::get(); - cm->copySymbol(symbol->getRepr(), style, symbol_document == currentDocument); + cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); } } @@ -624,7 +654,7 @@ SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { #endif /* Hunts preference directories for symbol files */ -void SymbolsDialog::get_symbols() { +void SymbolsDialog::getSymbols() { using namespace Inkscape::IO::Resource; Glib::ustring title; @@ -638,8 +668,8 @@ void SymbolsDialog::get_symbols() { if(title.empty()) { title = _("Unnamed Symbols"); } - symbolSets[title]= NULL; - symbolSet->append(title); + symbol_sets[title]= NULL; + symbol_set->append(title); ++number_docs; } #ifdef WITH_LIBVISIO @@ -650,8 +680,8 @@ void SymbolsDialog::get_symbols() { if(title.empty()) { title = _("Unnamed Symbols"); } - symbolSets[title]= NULL; - symbolSet->append(title); + symbol_sets[title]= NULL; + symbol_set->append(title); ++number_docs; } #endif @@ -659,8 +689,9 @@ void SymbolsDialog::get_symbols() { } /* Hunts preference directories for symbol files */ -Glib::ustring SymbolsDialog::get_symbols(Glib::ustring title) { - +std::pair +SymbolsDialog::getSymbols(Glib::ustring title) +{ using namespace Inkscape::IO::Resource; SPDocument* symbol_doc = NULL; Glib::ustring new_title; @@ -695,21 +726,21 @@ Glib::ustring SymbolsDialog::get_symbols(Glib::ustring title) { } #endif if(symbol_doc) { - symbolSets.erase(title); - symbolSets[new_title]= symbol_doc; + symbol_sets.erase(title); + symbol_sets[new_title]= symbol_doc; sensitive = false; - symbolSet->remove_text(i); - symbolSet->insert (i, new_title); - symbolSet->set_active(i); - symbolSet->set_active_text(new_title); + symbol_set->remove_text(i); + symbol_set->insert (i, new_title); + symbol_set->set_active(i); + symbol_set->set_active_text(new_title); sensitive = true; break; } } - return new_title; + return std::make_pair(new_title, symbol_doc); } -void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector &l) +void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector &l) { if(!r) return; @@ -723,19 +754,19 @@ void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vectorchildren) { - symbols_in_doc_recursive( &child, l ); + symbolsInDocRecursive( &child, l ); } } -std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbol_document) +std::vector SymbolsDialog::symbolsInDoc( SPDocument* symbol_document) { std::vector l; - symbols_in_doc_recursive (symbol_document->getRoot(), l ); + symbolsInDocRecursive (symbol_document->getRoot(), l ); return l; } -void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector &l) +void SymbolsDialog::useInDoc (SPObject *r, std::vector &l) { if ( dynamic_cast(r) ) { @@ -743,22 +774,22 @@ void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector &l) } for (auto& child: r->children) { - use_in_doc_recursive( &child, l ); + useInDoc( &child, l ); } } -std::vector SymbolsDialog::use_in_doc( SPDocument* useDocument) { +std::vector SymbolsDialog::useInDoc( SPDocument* useDocument) { std::vector l; - use_in_doc_recursive (useDocument->getRoot(), l); + useInDoc (useDocument->getRoot(), l); return l; } // Returns style from first element found that references id. // This is a last ditch effort to find a style. -gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* document) { +gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) { gchar const* style = 0; - std::vector l = use_in_doc( document ); + std::vector l = useInDoc( document ); for( auto use:l ) { if ( use ) { gchar const *href = use->getRepr()->attribute("xlink:href"); @@ -776,107 +807,157 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen return style; } -void SymbolsDialog::add_symbols( SPDocument* symbol_document ) { - std::vector l = symbols_in_doc( symbol_document ); +void SymbolsDialog::addSymbols( SPDocument* symbol_document ) { + std::vector l = symbolsInDoc( symbol_document ); Glib::ustring doc_title = ""; if (symbol_document->getRoot()->title()) { doc_title = symbol_document->getRoot()->title(); } for(auto symbol:l) { if (symbol) { - add_symbol( symbol, doc_title); + addSymbol( symbol, doc_title); } } } -void SymbolsDialog::prepare_find_symbols(GdkEventKey* evt) { +void SymbolsDialog::clearSearch() +{ + search_str = search->get_text(); + if(search_str.empty()) { + store->clear(); + findSymbolsInDoc(symbol_sets[last_symbol_set], last_symbol_set); + symbol_set->set_active_text(last_symbol_set); + } +} + +void SymbolsDialog::prepareFindSymbols(GdkEventKey* evt) +{ search_str = search->get_text().lowercase(); - if (evt->keyval != GDK_KEY_Return || search_str.empty()) { + if (evt->keyval != GDK_KEY_Return) { return; } - progressbar->set_fraction(0.0); + progress_bar->set_fraction(0.0); search->set_text(_("Searching...")); search->set_sensitive(false); - if(processed) { - find_symbols(); + global->set_sensitive(false); + if(!global->get_active()) { + bool icons_found = false; + Glib::ustring doc_title = symbol_set->get_active_text(); + if (!doc_title.empty()) { + SPDocument* symbol_document = symbol_sets[doc_title]; + if(symbol_document) { + store->clear(); + icons_found = findSymbolsInDoc(symbol_document, doc_title); + } + } + if (!icons_found) { + for(auto const &symbol_document_map : symbol_sets) { + SPDocument* symbol_document = symbol_document_map.second; + Glib::ustring doc_title = symbol_document_map.first; + //Cover the two cases if search document is procesed or not (title based or filename based) + if (doc_title.lowercase() == "search") { + if(!symbol_document) { + symbol_document = getSymbols(symbol_document_map.first).second; + } + addSymbols(symbol_document); + break; + } + } + } + search->set_text(search_str); + search->set_sensitive(true); + global->set_sensitive(true); + dynamic_cast(progress_bar)->set_visible(false); + } else if(processed) { + findSymbols(); } else { - dynamic_cast(progressbar)->set_visible(true); + dynamic_cast(progress_bar)->set_visible(true); } } -bool SymbolsDialog::parse_documents(){ - if (search->get_text() != _("Searching...")) { - dynamic_cast(progressbar)->set_visible(false); +bool SymbolsDialog::parseDocuments(){ + if (search->get_text() != _("Searching...") || !global->get_active()) { + dynamic_cast(progress_bar)->set_visible(false); return true; } size_t counter = 0; - for(auto const &symbol_document_map : symbolSets) { + for(auto const &symbol_document_map : symbol_sets) { ++counter; SPDocument* symbol_document = symbol_document_map.second; if (symbol_document) { continue; } - get_symbols(symbol_document_map.first); - progressbar->set_fraction(((100.0/number_docs) * counter)/100.0); + getSymbols(symbol_document_map.first); + progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); return true; } - find_symbols(); + findSymbols(); processed = true; - progressbar->set_fraction(1.0); + progress_bar->set_fraction(1.0); return false; } -void SymbolsDialog::find_symbols() { +bool SymbolsDialog::findSymbolsInDoc(SPDocument* symbol_document, Glib::ustring doc_title) { + bool icons_found = false; + std::vector l = symbolsInDoc(symbol_document); + last_symbol_set = doc_title; + for(auto symbol:l) { + gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); + if (symbol_title_char) { + bool found = false; + Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_title.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + if (!found && symbol_desc_char) { + Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); + auto pos = symbol_desc.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + } + if (symbol && (search_str.empty() || found)) { + addSymbol( symbol, doc_title); + icons_found = true; + } + } + } + return icons_found; +} + +void SymbolsDialog::findSymbols() { bool icons_found = false; SPDocument* searchdoc; - size_t counter = 0; store->clear(); - for(auto const &symbol_document_map : symbolSets) { - ++counter; + for(auto const &symbol_document_map : symbol_sets) { SPDocument* symbol_document = symbol_document_map.second; if (!symbol_document) { - return; + continue; } Glib::ustring doc_title = symbol_document_map.first; if (doc_title == "Search") { searchdoc = symbol_document; continue; } - std::vector l = symbols_in_doc(symbol_document); - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - gchar const *symbol_desc_char = symbol->description(); - if (symbol_title_char) { - bool found = false; - Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); - auto pos = symbol_title.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - if (!found && symbol_desc_char) { - Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); - auto pos = symbol_desc.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - } - if (symbol && (search_str == "*" || found)) { - add_symbol( symbol, doc_title); - icons_found = true; - } - } + if(findSymbolsInDoc(symbol_document, doc_title) && !icons_found) { + icons_found = true; } } if (!icons_found) { - add_symbols(searchdoc); + addSymbols(searchdoc); + } + if (global->get_active()) { + symbol_set->set_active_text(_("Global Search")); } - symbolSet->set_active_text(_("Search")); search->set_text(search_str); search->set_sensitive(true); - dynamic_cast(progressbar)->set_visible(false); + global->set_sensitive(true); + dynamic_cast(progress_bar)->set_visible(false); } -void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { +void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { SymbolColumns* columns = getColumns(); @@ -887,11 +968,11 @@ void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { } Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); if (doc_title.empty()) { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" [") +_("Current Document") + Glib::ustring("]")).c_str()))); + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") +_("Current Document") + Glib::ustring(")")).c_str()))); } else { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" [") + doc_title + Glib::ustring("]")).c_str()))); + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); } - Glib::RefPtr pixbuf = draw_symbol( symbol ); + Glib::RefPtr pixbuf = drawSymbol( symbol ); if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); @@ -914,16 +995,16 @@ void SymbolsDialog::add_symbol( SPObject* symbol, Glib::ustring doc_title) { * the temporary document is rendered. */ Glib::RefPtr -SymbolsDialog::draw_symbol(SPObject *symbol) +SymbolsDialog::drawSymbol(SPObject *symbol) { // Create a copy repr of the symbol with id="the_symbol" - Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc(); + Inkscape::XML::Document *xml_doc = preview_document->getReprDoc(); Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc); repr->setAttribute("id", "the_symbol"); - // Replace old "the_symbol" in previewDocument by new. - Inkscape::XML::Node *root = previewDocument->getReprRoot(); - SPObject *symbol_old = previewDocument->getObjectById("the_symbol"); + // Replace old "the_symbol" in preview_document by new. + Inkscape::XML::Node *root = preview_document->getReprRoot(); + SPObject *symbol_old = preview_document->getObjectById("the_symbol"); if (symbol_old) { symbol_old->deleteObject(false); } @@ -932,9 +1013,9 @@ SymbolsDialog::draw_symbol(SPObject *symbol) gchar const* style = repr->attribute("inkscape:symbol-style"); if( !style ) { // If no default style in , look in documents. - if( symbol->document == currentDocument ) { + if( symbol->document == current_document ) { gchar const *id = symbol->getRepr()->attribute("id"); - style = style_from_use( id, symbol->document ); + style = styleFromUse( id, symbol->document ); } else { style = symbol->document->getReprRoot()->attribute("style"); } @@ -951,19 +1032,19 @@ SymbolsDialog::draw_symbol(SPObject *symbol) //defsrepr->appendChild(repr); Inkscape::GC::release(repr); - // Uncomment this to get the previewDocument documents saved (useful for debugging) + // Uncomment this to get the preview_document documents saved (useful for debugging) // FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w"); - // sp_repr_save_stream(previewDocument->getReprDoc(), fp); + // sp_repr_save_stream(preview_document->getReprDoc(), fp); // fclose (fp); - // Make sure previewDocument is up-to-date. - previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - previewDocument->ensureUpToDate(); + // Make sure preview_document is up-to-date. + preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + preview_document->ensureUpToDate(); - // Make sure we have symbol in previewDocument - SPObject *object_temp = previewDocument->getObjectById( "the_use" ); - previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - previewDocument->ensureUpToDate(); + // Make sure we have symbol in preview_document + SPObject *object_temp = preview_document->getObjectById( "the_use" ); + preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + preview_document->ensureUpToDate(); SPItem *item = dynamic_cast(object_temp); g_assert(item != NULL); @@ -987,7 +1068,7 @@ SymbolsDialog::draw_symbol(SPObject *symbol) if( width == 0.0 ) width = 1.0; if( height == 0.0 ) height = 1.0; - if( fitSymbol->get_active() ) + if( fit_symbol->get_active() ) scale = psize / std::max(width, height); else scale = pow( 2.0, scale_factor/2.0 ) * psize / 32.0; @@ -1003,7 +1084,7 @@ SymbolsDialog::draw_symbol(SPObject *symbol) * Symbols are by default not rendered so a element is * provided. */ -SPDocument* SymbolsDialog::symbols_preview_doc() +SPDocument* SymbolsDialog::symbolsPreviewDoc() { // BUG: must be inside gchar const *buffer = @@ -1021,9 +1102,9 @@ SPDocument* SymbolsDialog::symbols_preview_doc() void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) { - if (this->currentDesktop != desktop) { - this->currentDesktop = desktop; - if( !symbolSets[symbolSet->get_active_text()] ) { + if (this->current_desktop != desktop) { + this->current_desktop = desktop; + if( !symbol_sets[symbol_set->get_active_text()] ) { // Symbol set is from Current document, update rebuild(); } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 23a81c68c..54a42ec71 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -6,6 +6,7 @@ * * Copyright (C) 2012 Tavmjong Bah * 2013 Martin Owens + * 2017 Jabiertxo Arraiza * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -81,29 +82,31 @@ private: void iconChanged(); void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); - void get_symbols(); - Glib::ustring get_symbols(Glib::ustring title); - void add_symbols( SPDocument* symbol_document ); - void add_symbol( SPObject* symbol, Glib::ustring doc_title); - SPDocument* symbols_preview_doc(); - - void symbols_in_doc_recursive(SPObject *r, std::vector &l); - std::vector symbols_in_doc( SPDocument* document); - void use_in_doc_recursive(SPObject *r, std::vector &l); - std::vector use_in_doc( SPDocument* document); - void prepare_find_symbols(GdkEventKey* evt); - void find_symbols(); - bool parse_documents(); - gchar const* style_from_use( gchar const* id, SPDocument* document); - - Glib::RefPtr draw_symbol(SPObject *symbol); + void getSymbols(); + std::pair getSymbols(Glib::ustring title); + void addSymbols( SPDocument* symbol_document ); + void addSymbol( SPObject* symbol, Glib::ustring doc_title); + SPDocument* symbolsPreviewDoc(); + + void symbolsInDocRecursive(SPObject *r, std::vector &l); + std::vector symbolsInDoc( SPDocument* document); + void useInDoc(SPObject *r, std::vector &l); + std::vector useInDoc( SPDocument* document); + void prepareFindSymbols(GdkEventKey* evt); + void findSymbols(); + void clearSearch(); + bool findSymbolsInDoc(SPDocument* document, Glib::ustring doc_title); + bool parseDocuments(); + gchar const* styleFromUse( gchar const* id, SPDocument* document); + + Glib::RefPtr drawSymbol(SPObject *symbol); /* Keep track of all symbol template documents */ - std::map symbolSets; + std::map symbol_sets; // Index into sizes which is selected int pack_size; - + // Scale factor int scale_factor; @@ -112,27 +115,28 @@ private: bool processed; size_t number_docs; - + Glib::ustring last_symbol_set; Glib::RefPtr store; - Gtk::ComboBoxText* symbolSet; - Gtk::ProgressBar* progressbar; + Gtk::ComboBoxText* symbol_set; + Gtk::ProgressBar* progress_bar; Gtk::HBox* progress; Gtk::SearchEntry* search; Glib::ustring search_str; - Gtk::IconView* iconView; - Gtk::Button* addSymbol; - Gtk::Button* removeSymbol; - Gtk::Button* zoomIn; - Gtk::Button* zoomOut; + Gtk::IconView* icon_view; + Gtk::Button* add_symbol; + Gtk::Button* remove_symbol; + Gtk::Button* zoom_in; + Gtk::Button* zoom_out; Gtk::Grid* table; + Gtk::Switch * global; Gtk::ScrolledWindow *scroller; - Gtk::ToggleButton* fitSymbol; + Gtk::ToggleButton* fit_symbol; void setTargetDesktop(SPDesktop *desktop); - SPDesktop* currentDesktop; - DesktopTracker deskTrack; - SPDocument* currentDocument; - SPDocument* previewDocument; /* Document to render single symbol */ + SPDesktop* current_desktop; + DesktopTracker desk_track; + SPDocument* current_document; + SPDocument* preview_document; /* Document to render single symbol */ /* For rendering the template drawing */ unsigned key; -- cgit v1.2.3 From 9ff0e67294c5bf435c76fe74ec39c13adeb10d86 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 22 Oct 2017 19:17:34 +0200 Subject: Added some improvements discused in MR --- src/ui/dialog/symbols.cpp | 267 ++++++++++++++++++++++------------------------ src/ui/dialog/symbols.h | 24 ++--- 2 files changed, 141 insertions(+), 150 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 56af2256b..6c7fa6bef 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -111,7 +111,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /******************** Table *************************/ table = new Gtk::Grid(); - + table->set_margin_left(3); + table->set_margin_right(3); + table->set_margin_top(4); // panel is a cloked Gtk::VBox _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; @@ -121,6 +123,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : table->attach(*Gtk::manage(labelSet),0,row,1,1); symbol_set = new Gtk::ComboBoxText(); // Fill in later symbol_set->append(_("Current Document")); + symbol_set->append(_("Search all sets")); symbol_set->set_active_text(_("Current Document")); symbol_set->set_hexpand(); table->attach(*Gtk::manage(symbol_set),1,row,1,1); @@ -130,49 +133,29 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; - Gtk::Separator* separator_sets = new Gtk::Separator(); - separator_sets->set_margin_top(3); - separator_sets->set_margin_bottom(3); - table->attach(*Gtk::manage(separator_sets),0,row,2,1); - - ++row; - /******************** Search *************************/ - - Gtk::Label* label_global = new Gtk::Label(_("Global Search: ")); - table->attach(*Gtk::manage(label_global),0,row,1,1); - Gtk::HBox * global_container = new Gtk::HBox(); - global = new Gtk::Switch(); - global->set_state(false); - global_container->pack_start(* global, Gtk::PACK_SHRINK); - Gtk::Separator* separator_global = new Gtk::Separator(Gtk::ORIENTATION_VERTICAL); - separator_global->set_margin_right(3); - separator_global->set_margin_left(3); - global_container->pack_start(* separator_global, Gtk::PACK_SHRINK); - search = Gtk::manage(new Gtk::SearchEntry()); // Search - search->set_tooltip_text(_("Return to start search.")); - search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::prepareFindSymbols)); - search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); - global_container->pack_start(* search, Gtk::PACK_EXPAND_WIDGET); - table->attach(*Gtk::manage(global_container),1,row,1,1); - - ++row; - /******************** Progress *******************************/ progress = new Gtk::HBox(); progress_bar = Gtk::manage(new Gtk::ProgressBar()); table->attach(*Gtk::manage(progress),0,row, 2, 1); progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); - progress->set_margin_top(5); + progress->set_margin_top(8); + progress->set_margin_bottom(8); ++row; - Gtk::Separator* separator_search = new Gtk::Separator(); - separator_search->set_margin_top(2); - separator_search->set_margin_bottom(3); - table->attach(*Gtk::manage(separator_search),0,row,2,1); + /******************** Search *************************/ + - ++row; + search = Gtk::manage(new Gtk::SearchEntry()); // Search + search->set_tooltip_text(_("Return to start search.")); + search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::beforeAddSymbols)); + search->set_margin_left(10); + search->set_margin_right(10); + search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); + table->attach(*Gtk::manage(search),0,row,2,1); + ++row; + /********************* Icon View **************************/ SymbolColumns* columns = getColumns(); @@ -329,13 +312,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::connection documentReplacedConn = current_desktop->connectDocumentReplaced( sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); instanceConns.push_back(documentReplacedConn); - getSymbols(); - addSymbols( current_document ); /* Defaults to current document */ + getSymbolsFilename(); + addSymbolsInDoc(current_document); /* Defaults to current document */ sigc::connection desktopChangeConn = desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); - Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::parseDocuments) ); desk_track.connect(GTK_WIDGET(gobj())); } @@ -407,10 +389,14 @@ void SymbolsDialog::rebuild() { add_symbol->set_sensitive( false ); remove_symbol->set_sensitive( false ); } - if (symbol_set->get_active_text() == _("Global Search")) { - findSymbols(); + if (symbol_set->get_active_text() == _("Search all sets")) { + store->clear(); + if (search_str != "" && processed) { + addSymbols(); + } } else { - findSymbolsInDoc(symbol_document, last_symbol_set); + search->set_text(""); + addSymbolsInDoc(symbol_document); } } @@ -475,7 +461,7 @@ SPDocument* SymbolsDialog::selectedSymbols(bool ignorecurrent) { } SPDocument* symbol_document = symbol_sets[doc_title]; if( !symbol_document ) { - symbol_document = getSymbols(doc_title).second; + symbol_document = getSymbolsSet(doc_title).second; // Symbol must be from Current Document (this method of checking should be language independent). if( !symbol_document ) { if (ignorecurrent) { @@ -511,6 +497,18 @@ Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { return Glib::ustring(""); } +Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { + Glib::ustring title = ""; + if (symbol_doc) { + SPRoot * root = symbol_doc->getRoot(); + if (root->title()) { + title = Glib::ustring(root->title()); + } + return title; + } + return title; +} + void SymbolsDialog::iconChanged() { Glib::ustring symbol_id = selectedSymbolId(); @@ -654,7 +652,7 @@ SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { #endif /* Hunts preference directories for symbol files */ -void SymbolsDialog::getSymbols() { +void SymbolsDialog::getSymbolsFilename() { using namespace Inkscape::IO::Resource; Glib::ustring title; @@ -690,52 +688,57 @@ void SymbolsDialog::getSymbols() { /* Hunts preference directories for symbol files */ std::pair -SymbolsDialog::getSymbols(Glib::ustring title) +SymbolsDialog::getSymbolsSet(Glib::ustring title) { + if (symbol_sets[title]) { + return std::make_pair(title, symbol_sets[title]); + } using namespace Inkscape::IO::Resource; SPDocument* symbol_doc = NULL; Glib::ustring new_title; size_t i = 0; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - std::size_t found = filename.find_last_of("/\\"); - Glib::ustring filename_short = filename.substr(found+1); - if(filename_short == title + ".svg") { - symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); - if(symbol_doc) { - new_title = symbol_doc->getRoot()->title(); - if(new_title.empty()) { - new_title = _("Unnamed Symbols"); - } - } - } - if(Glib::str_has_suffix(filename, ".svg")) { - i++; - } + std::size_t pos = filename.find_last_of("/\\"); + if (pos != std::string::npos) { + Glib::ustring filename_short = filename.substr(pos+1); + if(filename_short == title + ".svg") { + symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); + if(symbol_doc) { + new_title = symbol_doc->getRoot()->title(); + if(new_title.empty()) { + new_title = _("Unnamed Symbols"); + } + } + } + if(Glib::str_has_suffix(filename, ".svg")) { + i++; + } #ifdef WITH_LIBVISIO - if(filename_short == title + ".vss") { - symbol_doc = read_vss(filename, title); - if(symbol_doc) { - new_title = symbol_doc->getRoot()->title(); - if(new_title.empty()) { - new_title = _("Unnamed Symbols"); - } - } - } - if(Glib::str_has_suffix(filename, ".vss")) { - i++; - } + if(filename_short == title + ".vss") { + symbol_doc = read_vss(filename, title); + if(symbol_doc) { + new_title = symbol_doc->getRoot()->title(); + if(new_title.empty()) { + new_title = _("Unnamed Symbols"); + } + } + } + if(Glib::str_has_suffix(filename, ".vss")) { + i++; + } #endif - if(symbol_doc) { - symbol_sets.erase(title); - symbol_sets[new_title]= symbol_doc; - sensitive = false; - symbol_set->remove_text(i); - symbol_set->insert (i, new_title); - symbol_set->set_active(i); - symbol_set->set_active_text(new_title); - sensitive = true; - break; - } + if(symbol_doc) { + symbol_sets.erase(title); + symbol_sets[new_title]= symbol_doc; + sensitive = false; + symbol_set->remove_text(i+1); + symbol_set->insert (i+1, new_title); + symbol_set->set_active(i+1); + symbol_set->set_active_text(new_title); + sensitive = true; + break; + } + } } return std::make_pair(new_title, symbol_doc); } @@ -807,30 +810,19 @@ gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) return style; } -void SymbolsDialog::addSymbols( SPDocument* symbol_document ) { - std::vector l = symbolsInDoc( symbol_document ); - Glib::ustring doc_title = ""; - if (symbol_document->getRoot()->title()) { - doc_title = symbol_document->getRoot()->title(); - } - for(auto symbol:l) { - if (symbol) { - addSymbol( symbol, doc_title); - } - } -} - void SymbolsDialog::clearSearch() { - search_str = search->get_text(); - if(search_str.empty()) { + if(search->get_text().empty()) { + search_str = ""; store->clear(); - findSymbolsInDoc(symbol_sets[last_symbol_set], last_symbol_set); - symbol_set->set_active_text(last_symbol_set); + Glib::ustring current = symbol_set->get_active_text(); + if (current != _("Search all sets")) { + addSymbolsInDoc(symbol_sets[current]); + } } } -void SymbolsDialog::prepareFindSymbols(GdkEventKey* evt) +void SymbolsDialog::beforeAddSymbols(GdkEventKey* evt) { search_str = search->get_text().lowercase(); if (evt->keyval != GDK_KEY_Return) { @@ -839,45 +831,33 @@ void SymbolsDialog::prepareFindSymbols(GdkEventKey* evt) progress_bar->set_fraction(0.0); search->set_text(_("Searching...")); search->set_sensitive(false); - global->set_sensitive(false); - if(!global->get_active()) { + Glib::ustring current = symbol_set->get_active_text(); + if (current != _("Search all sets")) { bool icons_found = false; Glib::ustring doc_title = symbol_set->get_active_text(); if (!doc_title.empty()) { SPDocument* symbol_document = symbol_sets[doc_title]; if(symbol_document) { store->clear(); - icons_found = findSymbolsInDoc(symbol_document, doc_title); + icons_found = addSymbolsInDoc(symbol_document); } } if (!icons_found) { - for(auto const &symbol_document_map : symbol_sets) { - SPDocument* symbol_document = symbol_document_map.second; - Glib::ustring doc_title = symbol_document_map.first; - //Cover the two cases if search document is procesed or not (title based or filename based) - if (doc_title.lowercase() == "search") { - if(!symbol_document) { - symbol_document = getSymbols(symbol_document_map.first).second; - } - addSymbols(symbol_document); - break; - } - } + //show overlay } search->set_text(search_str); search->set_sensitive(true); - global->set_sensitive(true); - dynamic_cast(progress_bar)->set_visible(false); } else if(processed) { - findSymbols(); + Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackGetSymbols) ); + addSymbols(); } else { - dynamic_cast(progress_bar)->set_visible(true); + Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackGetSymbolsSets) ); } } -bool SymbolsDialog::parseDocuments(){ - if (search->get_text() != _("Searching...") || !global->get_active()) { - dynamic_cast(progress_bar)->set_visible(false); +bool SymbolsDialog::callbackGetSymbolsSets(){ + Glib::ustring current = symbol_set->get_active_text(); + if (search->get_text() != _("Searching...") || current != _("Search all sets")) { return true; } size_t counter = 0; @@ -887,20 +867,40 @@ bool SymbolsDialog::parseDocuments(){ if (symbol_document) { continue; } - getSymbols(symbol_document_map.first); + symbol_document = getSymbolsSet(symbol_document_map.first).second; + symbol_set->set_active_text(_("Search all sets")); + if (!symbol_document) { + continue; + } progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); return true; } - findSymbols(); + addSymbols(); processed = true; progress_bar->set_fraction(1.0); return false; } -bool SymbolsDialog::findSymbolsInDoc(SPDocument* symbol_document, Glib::ustring doc_title) { +bool SymbolsDialog::callbackGetSymbols() +{ + if (loading && processed) { + progress_bar->pulse(); + return true; + } + return false; +} + +bool SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { bool icons_found = false; + if (!symbol_document) { + return false; //Search all + } + Glib::ustring doc_title = documentTitle(symbol_document); + if (doc_title.empty()) { + return false; + } std::vector l = symbolsInDoc(symbol_document); - last_symbol_set = doc_title; + loading = false; for(auto symbol:l) { gchar const *symbol_title_char = symbol->title(); gchar const *symbol_desc_char = symbol->description(); @@ -923,38 +923,29 @@ bool SymbolsDialog::findSymbolsInDoc(SPDocument* symbol_document, Glib::ustring icons_found = true; } } + } + loading = false; return icons_found; } -void SymbolsDialog::findSymbols() { +void SymbolsDialog::addSymbols() { bool icons_found = false; - SPDocument* searchdoc; store->clear(); for(auto const &symbol_document_map : symbol_sets) { SPDocument* symbol_document = symbol_document_map.second; if (!symbol_document) { continue; } - Glib::ustring doc_title = symbol_document_map.first; - if (doc_title == "Search") { - searchdoc = symbol_document; - continue; - } - if(findSymbolsInDoc(symbol_document, doc_title) && !icons_found) { + if(addSymbolsInDoc(symbol_document) && !icons_found) { icons_found = true; } } if (!icons_found) { - addSymbols(searchdoc); - } - if (global->get_active()) { - symbol_set->set_active_text(_("Global Search")); + //Show overlay } search->set_text(search_str); search->set_sensitive(true); - global->set_sensitive(true); - dynamic_cast(progress_bar)->set_visible(false); } void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 54a42ec71..bc6c127a7 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -81,22 +81,22 @@ private: Glib::ustring selectedSymbolDocTitle(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); - - void getSymbols(); - std::pair getSymbols(Glib::ustring title); - void addSymbols( SPDocument* symbol_document ); + void getSymbolsFilename(); + Glib::ustring documentTitle(SPDocument* doc); + std::pair getSymbolsSet(Glib::ustring title); void addSymbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbolsPreviewDoc(); - void symbolsInDocRecursive(SPObject *r, std::vector &l); std::vector symbolsInDoc( SPDocument* document); void useInDoc(SPObject *r, std::vector &l); std::vector useInDoc( SPDocument* document); - void prepareFindSymbols(GdkEventKey* evt); - void findSymbols(); + void beforeAddSymbols(GdkEventKey* evt); + void addSymbols(); + bool addSymbolsInDoc(SPDocument* document); void clearSearch(); - bool findSymbolsInDoc(SPDocument* document, Glib::ustring doc_title); - bool parseDocuments(); + bool callbackGetSymbolsSets(); + bool callbackGetSymbols(); + gchar const* styleFromUse( gchar const* id, SPDocument* document); Glib::RefPtr drawSymbol(SPObject *symbol); @@ -112,23 +112,23 @@ private: bool sensitive; + bool loading; + bool processed; size_t number_docs; - Glib::ustring last_symbol_set; Glib::RefPtr store; + Glib::ustring search_str; Gtk::ComboBoxText* symbol_set; Gtk::ProgressBar* progress_bar; Gtk::HBox* progress; Gtk::SearchEntry* search; - Glib::ustring search_str; Gtk::IconView* icon_view; Gtk::Button* add_symbol; Gtk::Button* remove_symbol; Gtk::Button* zoom_in; Gtk::Button* zoom_out; Gtk::Grid* table; - Gtk::Switch * global; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; -- cgit v1.2.3 From d26f81a4c3c918fa2af5cb454ec569376a7c0b51 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 25 Oct 2017 01:12:45 +0200 Subject: Add progressbar to all actions --- src/ui/dialog/symbols.cpp | 278 +++++++++++++++++++++++++++++----------------- src/ui/dialog/symbols.h | 24 ++-- 2 files changed, 185 insertions(+), 117 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 6c7fa6bef..bb544e4c9 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -115,15 +115,15 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : table->set_margin_right(3); table->set_margin_top(4); // panel is a cloked Gtk::VBox - _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(* Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; /******************** Symbol Sets *************************/ - Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: ")); - table->attach(*Gtk::manage(labelSet),0,row,1,1); + Gtk::Label* label_set = new Gtk::Label(_("Symbol set: ")); + table->attach(*Gtk::manage(label_set),0,row,1,1); symbol_set = new Gtk::ComboBoxText(); // Fill in later symbol_set->append(_("Current Document")); - symbol_set->append(_("Search all sets")); + symbol_set->append(_("All symbols sets")); symbol_set->set_active_text(_("Current Document")); symbol_set->set_hexpand(); table->attach(*Gtk::manage(symbol_set),1,row,1,1); @@ -133,13 +133,13 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; - /******************** Progress *******************************/ - progress = new Gtk::HBox(); - progress_bar = Gtk::manage(new Gtk::ProgressBar()); - table->attach(*Gtk::manage(progress),0,row, 2, 1); - progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); - progress->set_margin_top(8); - progress->set_margin_bottom(8); + /******************** Separator *************************/ + + + Gtk::Separator* separator = Gtk::manage(new Gtk::Separator()); // Search + separator->set_margin_top(10); + separator->set_margin_bottom(10); + table->attach(*Gtk::manage(separator),0,row,2,1); ++row; @@ -185,7 +185,24 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : scroller->add(*Gtk::manage(icon_view)); scroller->set_hexpand(); scroller->set_vexpand(); - table->attach(*Gtk::manage(scroller),0,row,2,1); + overlay = new Gtk::Overlay(); + overlay->set_hexpand(); + overlay->set_vexpand(); + overlay->add(* scroller); + table->attach(*Gtk::manage(overlay),0,row,2,1); + + ++row; + + /******************** Progress *******************************/ + progress = new Gtk::HBox(); + progress_bar = Gtk::manage(new Gtk::ProgressBar()); + table->attach(*Gtk::manage(progress),0,row, 2, 1); + progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); + progress->set_margin_top(15); + progress->set_margin_bottom(15); + progress->set_margin_left(20); + progress->set_margin_right(20); + ++row; /******************** Tools *******************************/ @@ -289,7 +306,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /**********************************************************/ sensitive = true; - processed = false; search_str = ""; current_desktop = SP_ACTIVE_DESKTOP; current_document = current_desktop->getDocument(); @@ -313,6 +329,10 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); instanceConns.push_back(documentReplacedConn); getSymbolsFilename(); + icons_found = false; + + Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + addSymbolsInDoc(current_document); /* Defaults to current document */ sigc::connection desktopChangeConn = @@ -389,13 +409,14 @@ void SymbolsDialog::rebuild() { add_symbol->set_sensitive( false ); remove_symbol->set_sensitive( false ); } - if (symbol_set->get_active_text() == _("Search all sets")) { + if (search->get_text() != _("Searching...")) { + search_str = ""; + search->set_text(""); + } + icons_found = false; + if (symbol_set->get_active_text() == _("All symbols sets")) { store->clear(); - if (search_str != "" && processed) { - addSymbols(); - } } else { - search->set_text(""); addSymbolsInDoc(symbol_document); } } @@ -816,8 +837,13 @@ void SymbolsDialog::clearSearch() search_str = ""; store->clear(); Glib::ustring current = symbol_set->get_active_text(); - if (current != _("Search all sets")) { - addSymbolsInDoc(symbol_sets[current]); + if (current != _("All symbols sets")) { + icons_found = false; + SPDocument* symbol_document = symbol_sets[current]; + if (current == _("Current Document")) { + symbol_document = current_document; + } + addSymbolsInDoc(symbol_document); } } } @@ -832,120 +858,134 @@ void SymbolsDialog::beforeAddSymbols(GdkEventKey* evt) search->set_text(_("Searching...")); search->set_sensitive(false); Glib::ustring current = symbol_set->get_active_text(); - if (current != _("Search all sets")) { - bool icons_found = false; + if (current != _("All symbols sets")) { Glib::ustring doc_title = symbol_set->get_active_text(); if (!doc_title.empty()) { SPDocument* symbol_document = symbol_sets[doc_title]; - if(symbol_document) { - store->clear(); - icons_found = addSymbolsInDoc(symbol_document); + if (current == _("Current Document")) { + symbol_document = current_document; } + store->clear(); + icons_found = false; + addSymbolsInDoc(symbol_document); } - if (!icons_found) { - //show overlay - } - search->set_text(search_str); - search->set_sensitive(true); - } else if(processed) { - Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackGetSymbols) ); + } else if(all_docs_processed) { addSymbols(); - } else { - Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackGetSymbolsSets) ); } } -bool SymbolsDialog::callbackGetSymbolsSets(){ +bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); - if (search->get_text() != _("Searching...") || current != _("Search all sets")) { - return true; - } - size_t counter = 0; - for(auto const &symbol_document_map : symbol_sets) { - ++counter; - SPDocument* symbol_document = symbol_document_map.second; - if (symbol_document) { - continue; + if (l.size()) { + for (auto symbol:l) { + counter_symbols ++; + gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); + if (symbol_title_char) { + bool found = false; + Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_title.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + if (!found && symbol_desc_char) { + Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); + auto pos = symbol_desc.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + } + if (symbol && (search_str.empty() || found)) { + addSymbol( symbol, doc_title); + icons_found = true; + } + } + progress_bar->set_fraction(((100.0/number_symbols) * counter_symbols)/100.0); + l.erase(l.begin()); + //to get more items and best performance + int modulus = number_symbols > 200 ? 50 : (number_symbols/4); + if (modulus && counter_symbols % modulus == 0 && !l.empty()) { + return true; + } } - symbol_document = getSymbolsSet(symbol_document_map.first).second; - symbol_set->set_active_text(_("Search all sets")); - if (!symbol_document) { - continue; + if (!icons_found && !search_str.empty()) { + Gtk::Image* no_results_icon = new Gtk::Image(getSearchPixbuf()); + no_results_icon->set_halign(Gtk::ALIGN_CENTER ); + no_results_icon->set_valign(Gtk::ALIGN_CENTER ); + Gtk::Label* no_results = new Gtk::Label(); + no_results->set_halign(Gtk::ALIGN_CENTER ); + no_results->set_valign(Gtk::ALIGN_CENTER ); + no_results->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + Gtk::Label* different = new Gtk::Label(); + different->set_halign(Gtk::ALIGN_CENTER ); + different->set_valign(Gtk::ALIGN_CENTER ); + different->set_markup(Glib::ustring("") + Glib::ustring(_("Try a different search")) + Glib::ustring("")); + overlay->add_overlay(* no_results_icon); + overlay->add_overlay(* no_results); + overlay->add_overlay(* different); } - progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); + search->set_text(search_str); + search->set_sensitive(true); return true; - } - addSymbols(); - processed = true; - progress_bar->set_fraction(1.0); - return false; -} - -bool SymbolsDialog::callbackGetSymbols() -{ - if (loading && processed) { - progress_bar->pulse(); + } else if (current == _("All symbols sets") && + search->get_text() == _("Searching...") ) { + size_t counter = 0; + for(auto const &symbol_document_map : symbol_sets) { + ++counter; + SPDocument* symbol_document = symbol_document_map.second; + if (symbol_document) { + continue; + } + symbol_document = getSymbolsSet(symbol_document_map.first).second; + symbol_set->set_active_text(_("All symbols sets")); + if (!symbol_document) { + continue; + } + progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); + return true; + } + progress_bar->set_fraction(1.0); + all_docs_processed = true; + addSymbols(); return true; } - return false; + return true; } -bool SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { - bool icons_found = false; +void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { if (!symbol_document) { - return false; //Search all + return; //Search all } - Glib::ustring doc_title = documentTitle(symbol_document); + doc_title = documentTitle(symbol_document); if (doc_title.empty()) { - return false; - } - std::vector l = symbolsInDoc(symbol_document); - loading = false; - for(auto symbol:l) { - gchar const *symbol_title_char = symbol->title(); - gchar const *symbol_desc_char = symbol->description(); - if (symbol_title_char) { - bool found = false; - Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); - auto pos = symbol_title.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - if (!found && symbol_desc_char) { - Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); - auto pos = symbol_desc.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - } - if (symbol && (search_str.empty() || found)) { - addSymbol( symbol, doc_title); - icons_found = true; - } - } - + doc_title = _("Untitled document"); ; } - loading = false; - return icons_found; + progress_bar->set_fraction(0.0); + counter_symbols = 0; + std::vector container_symbols_tmp = symbolsInDoc(symbol_document); + number_symbols = container_symbols_tmp.size(); + l = container_symbols_tmp; + container_symbols_tmp.clear(); } void SymbolsDialog::addSymbols() { - bool icons_found = false; store->clear(); + icons_found = false; + std::vector container_symbols; for(auto const &symbol_document_map : symbol_sets) { SPDocument* symbol_document = symbol_document_map.second; if (!symbol_document) { continue; } - if(addSymbolsInDoc(symbol_document) && !icons_found) { - icons_found = true; - } - } - if (!icons_found) { - //Show overlay + std::vector container_symbols_tmp = symbolsInDoc(symbol_document); + container_symbols.insert(container_symbols.end(), container_symbols_tmp.begin(), container_symbols_tmp.end()); + container_symbols_tmp.clear(); } - search->set_text(search_str); - search->set_sensitive(true); + counter_symbols = 0; + progress_bar->set_fraction(0.0); + number_symbols = container_symbols.size(); + l = container_symbols; + container_symbols.clear(); } void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { @@ -1091,6 +1131,38 @@ SPDocument* SymbolsDialog::symbolsPreviewDoc() return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); } +/* + * Return search symbol pixbuf + */ +Glib::RefPtr +SymbolsDialog::getSearchPixbuf() +{ + // BUG: must be inside + gchar const *buffer = +"" +" " +" " +" Search Taiga Icon" +" " +" " +" " +""; + + SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); + std::vector l = symbolsInDoc(doc); + int prev_scale_factor = scale_factor; + scale_factor = 10; + Glib::RefPtr pb = drawSymbol(l[0]); + scale_factor = prev_scale_factor; + return pb; +} + void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) { if (this->current_desktop != desktop) { diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index bc6c127a7..586ea2116 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -92,31 +92,26 @@ private: std::vector useInDoc( SPDocument* document); void beforeAddSymbols(GdkEventKey* evt); void addSymbols(); - bool addSymbolsInDoc(SPDocument* document); + void addSymbolsInDoc(SPDocument* document); void clearSearch(); - bool callbackGetSymbolsSets(); - bool callbackGetSymbols(); - + bool callbackSymbols(); gchar const* styleFromUse( gchar const* id, SPDocument* document); - + Glib::ustring doc_title; Glib::RefPtr drawSymbol(SPObject *symbol); - + Glib::RefPtr getSearchPixbuf(); /* Keep track of all symbol template documents */ std::map symbol_sets; - + std::vector l; // Index into sizes which is selected int pack_size; - // Scale factor int scale_factor; - bool sensitive; - - bool loading; - - bool processed; - + bool all_docs_processed; size_t number_docs; + size_t number_symbols; + size_t counter_symbols; + bool icons_found; Glib::RefPtr store; Glib::ustring search_str; Gtk::ComboBoxText* symbol_set; @@ -131,6 +126,7 @@ private: Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; + Gtk::Overlay* overlay; void setTargetDesktop(SPDesktop *desktop); SPDesktop* current_desktop; -- cgit v1.2.3 From 465a6f1db66db8101b22ee14d9a528a836f01e77 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 28 Oct 2017 01:00:20 +0200 Subject: Fix simbols dialog expand, Fix add symbols to document on global search --- src/ui/dialog/symbols.cpp | 163 ++++++++++++++++++++++++++-------------------- src/ui/dialog/symbols.h | 14 ++-- 2 files changed, 103 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index bb544e4c9..9b4d2ae12 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -148,7 +148,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : search = Gtk::manage(new Gtk::SearchEntry()); // Search search->set_tooltip_text(_("Return to start search.")); - search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::beforeAddSymbols)); + search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::beforeSearch)); search->set_margin_left(10); search->set_margin_right(10); search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); @@ -206,8 +206,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; /******************** Tools *******************************/ - Gtk::Button* button; - Gtk::HBox* tools = new Gtk::HBox(); + tools = new Gtk::HBox(); //tools->set_layout( Gtk::BUTTONBOX_END ); scroller->set_hexpand(); @@ -244,24 +243,24 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : auto packMoreImage = Gtk::manage(new Gtk::Image()); packMoreImage->set_from_icon_name("pack-more", Gtk::ICON_SIZE_SMALL_TOOLBAR); - button = Gtk::manage(new Gtk::Button()); - button->add(*packMoreImage); - button->set_tooltip_text(_("Display more icons in row.")); - button->set_relief( Gtk::RELIEF_NONE ); - button->set_focus_on_click( false ); - button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore)); - tools->pack_start(* button, Gtk::PACK_SHRINK); + more = Gtk::manage(new Gtk::Button()); + more->add(*packMoreImage); + more->set_tooltip_text(_("Display more icons in row.")); + more->set_relief( Gtk::RELIEF_NONE ); + more->set_focus_on_click( false ); + more->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore)); + tools->pack_start(* more, Gtk::PACK_SHRINK); auto packLessImage = Gtk::manage(new Gtk::Image()); packLessImage->set_from_icon_name("pack-less", Gtk::ICON_SIZE_SMALL_TOOLBAR); - button = Gtk::manage(new Gtk::Button()); - button->add(*packLessImage); - button->set_tooltip_text(_("Display fewer icons in row.")); - button->set_relief( Gtk::RELIEF_NONE ); - button->set_focus_on_click( false ); - button->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packless)); - tools->pack_start(* button, Gtk::PACK_SHRINK); + fewer = Gtk::manage(new Gtk::Button()); + fewer->add(*packLessImage); + fewer->set_tooltip_text(_("Display fewer icons in row.")); + fewer->set_relief( Gtk::RELIEF_NONE ); + fewer->set_focus_on_click( false ); + fewer->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packless)); + tools->pack_start(* fewer, Gtk::PACK_SHRINK); // Toggle scale to fit on/off auto fit_symbolImage = Gtk::manage(new Gtk::Image()); @@ -396,7 +395,6 @@ void SymbolsDialog::rebuild() { zoom_in->set_sensitive( true); zoom_out->set_sensitive( true ); } - store->clear(); SPDocument* symbol_document = selectedSymbols(true); if( !symbol_document ) { @@ -409,14 +407,15 @@ void SymbolsDialog::rebuild() { add_symbol->set_sensitive( false ); remove_symbol->set_sensitive( false ); } - if (search->get_text() != _("Searching...")) { + if (search->get_text() != _("Searching...") && + search->get_text() != _("Loading documents...") && + search->get_text() != _("Documents done, searchig inside...") ) + { search_str = ""; search->set_text(""); } icons_found = false; - if (symbol_set->get_active_text() == _("All symbols sets")) { - store->clear(); - } else { + if (symbol_set->get_active_text() != _("All symbols sets")) { addSymbolsInDoc(symbol_document); } } @@ -523,7 +522,7 @@ Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { if (symbol_doc) { SPRoot * root = symbol_doc->getRoot(); if (root->title()) { - title = Glib::ustring(root->title()); + title = ellipsize(Glib::ustring(root->title())); } return title; } @@ -725,7 +724,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) if(filename_short == title + ".svg") { symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); if(symbol_doc) { - new_title = symbol_doc->getRoot()->title(); + new_title = ellipsize(symbol_doc->getRoot()->title()); if(new_title.empty()) { new_title = _("Unnamed Symbols"); } @@ -738,7 +737,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) if(filename_short == title + ".vss") { symbol_doc = read_vss(filename, title); if(symbol_doc) { - new_title = symbol_doc->getRoot()->title(); + new_title = ellipsize(symbol_doc->getRoot()->title()); if(new_title.empty()) { new_title = _("Unnamed Symbols"); } @@ -764,7 +763,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) return std::make_pair(new_title, symbol_doc); } -void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector &l) +void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title) { if(!r) return; @@ -774,19 +773,20 @@ void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector & } if ( dynamic_cast(r) ) { - l.push_back(dynamic_cast(r)); + l.push_back(std::make_pair(doc_title,dynamic_cast(r))); } for (auto& child: r->children) { - symbolsInDocRecursive( &child, l ); + symbolsInDocRecursive(&child, l, doc_title); } } -std::vector SymbolsDialog::symbolsInDoc( SPDocument* symbol_document) +std::vector > +SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_title) { - std::vector l; - symbolsInDocRecursive (symbol_document->getRoot(), l ); + std::vector > l; + symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); return l; } @@ -833,7 +833,7 @@ gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) void SymbolsDialog::clearSearch() { - if(search->get_text().empty()) { + if(search->get_text().empty() && sensitive) { search_str = ""; store->clear(); Glib::ustring current = symbol_set->get_active_text(); @@ -848,17 +848,24 @@ void SymbolsDialog::clearSearch() } } -void SymbolsDialog::beforeAddSymbols(GdkEventKey* evt) +void SymbolsDialog::enableWidgets(bool enable) +{ + symbol_set->set_sensitive(enable); + search->set_sensitive(enable); + tools ->set_sensitive(enable); +} + +void SymbolsDialog::beforeSearch(GdkEventKey* evt) { search_str = search->get_text().lowercase(); if (evt->keyval != GDK_KEY_Return) { return; } progress_bar->set_fraction(0.0); - search->set_text(_("Searching...")); - search->set_sensitive(false); + enableWidgets(false); Glib::ustring current = symbol_set->get_active_text(); if (current != _("All symbols sets")) { + search->set_text(_("Searching...")); Glib::ustring doc_title = symbol_set->get_active_text(); if (!doc_title.empty()) { SPDocument* symbol_document = symbol_sets[doc_title]; @@ -869,15 +876,40 @@ void SymbolsDialog::beforeAddSymbols(GdkEventKey* evt) icons_found = false; addSymbolsInDoc(symbol_document); } - } else if(all_docs_processed) { - addSymbols(); + } else { + search->set_text(_("Loading documents...")); } } bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); - if (l.size()) { - for (auto symbol:l) { + if (current == _("All symbols sets") && + search->get_text() == _("Loading documents...") ) + { + size_t counter = 0; + for(auto const &symbol_document_map : symbol_sets) { + ++counter; + SPDocument* symbol_document = symbol_document_map.second; + if (symbol_document) { + continue; + } + symbol_document = getSymbolsSet(symbol_document_map.first).second; + symbol_set->set_active_text(_("All symbols sets")); + if (!symbol_document) { + continue; + } + progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); + return true; + } + progress_bar->set_fraction(1.0); + all_docs_processed = true; + addSymbols(); + search->set_text("Documents done, searchig inside..."); + return true; + } else if (l.size()) { + for (auto symbol_data = l.begin(); symbol_data != l.end();) { + Glib::ustring doc_title = symbol_data->first; + SPSymbol * symbol = symbol_data->second; counter_symbols ++; gchar const *symbol_title_char = symbol->title(); gchar const *symbol_desc_char = symbol->description(); @@ -901,7 +933,7 @@ bool SymbolsDialog::callbackSymbols(){ } } progress_bar->set_fraction(((100.0/number_symbols) * counter_symbols)/100.0); - l.erase(l.begin()); + symbol_data = l.erase(l.begin()); //to get more items and best performance int modulus = number_symbols > 200 ? 50 : (number_symbols/4); if (modulus && counter_symbols % modulus == 0 && !l.empty()) { @@ -924,45 +956,34 @@ bool SymbolsDialog::callbackSymbols(){ overlay->add_overlay(* no_results); overlay->add_overlay(* different); } + bool prev_sensitive = sensitive; + sensitive = false; search->set_text(search_str); - search->set_sensitive(true); - return true; - } else if (current == _("All symbols sets") && - search->get_text() == _("Searching...") ) { - size_t counter = 0; - for(auto const &symbol_document_map : symbol_sets) { - ++counter; - SPDocument* symbol_document = symbol_document_map.second; - if (symbol_document) { - continue; - } - symbol_document = getSymbolsSet(symbol_document_map.first).second; - symbol_set->set_active_text(_("All symbols sets")); - if (!symbol_document) { - continue; - } - progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); - return true; - } - progress_bar->set_fraction(1.0); - all_docs_processed = true; - addSymbols(); + sensitive = prev_sensitive; + enableWidgets(true); return true; } return true; } +Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { + if (data.length() > limit) { + return data.substr(0,limit-3) + "..."; + } + return data; +} + void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { if (!symbol_document) { return; //Search all } - doc_title = documentTitle(symbol_document); + Glib::ustring doc_title = documentTitle(symbol_document); if (doc_title.empty()) { doc_title = _("Untitled document"); ; } progress_bar->set_fraction(0.0); counter_symbols = 0; - std::vector container_symbols_tmp = symbolsInDoc(symbol_document); + std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); number_symbols = container_symbols_tmp.size(); l = container_symbols_tmp; container_symbols_tmp.clear(); @@ -971,14 +992,18 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { void SymbolsDialog::addSymbols() { store->clear(); icons_found = false; - std::vector container_symbols; + std::vector > container_symbols; for(auto const &symbol_document_map : symbol_sets) { SPDocument* symbol_document = symbol_document_map.second; if (!symbol_document) { continue; } - std::vector container_symbols_tmp = symbolsInDoc(symbol_document); - container_symbols.insert(container_symbols.end(), container_symbols_tmp.begin(), container_symbols_tmp.end()); + Glib::ustring doc_title = documentTitle(symbol_document); + if (doc_title.empty()) { + doc_title = _("Untitled document"); ; + } + std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); + container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); container_symbols_tmp.clear(); } counter_symbols = 0; @@ -1155,10 +1180,10 @@ SymbolsDialog::getSearchPixbuf() ""; SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector l = symbolsInDoc(doc); + std::vector > l = symbolsInDoc(doc, "Search Taiga Icon"); int prev_scale_factor = scale_factor; scale_factor = 10; - Glib::RefPtr pb = drawSymbol(l[0]); + Glib::RefPtr pb = drawSymbol(l[0].second); scale_factor = prev_scale_factor; return pb; } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 586ea2116..d252b7c71 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -86,22 +86,23 @@ private: std::pair getSymbolsSet(Glib::ustring title); void addSymbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbolsPreviewDoc(); - void symbolsInDocRecursive(SPObject *r, std::vector &l); - std::vector symbolsInDoc( SPDocument* document); + void symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title); + std::vector > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); void useInDoc(SPObject *r, std::vector &l); std::vector useInDoc( SPDocument* document); - void beforeAddSymbols(GdkEventKey* evt); + void beforeSearch(GdkEventKey* evt); void addSymbols(); void addSymbolsInDoc(SPDocument* document); void clearSearch(); bool callbackSymbols(); + void enableWidgets(bool enable); + Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); gchar const* styleFromUse( gchar const* id, SPDocument* document); - Glib::ustring doc_title; Glib::RefPtr drawSymbol(SPObject *symbol); Glib::RefPtr getSearchPixbuf(); /* Keep track of all symbol template documents */ std::map symbol_sets; - std::vector l; + std::vector > l; // Index into sizes which is selected int pack_size; // Scale factor @@ -123,6 +124,9 @@ private: Gtk::Button* remove_symbol; Gtk::Button* zoom_in; Gtk::Button* zoom_out; + Gtk::Button* more; + Gtk::Button* fewer; + Gtk::HBox* tools; Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; -- cgit v1.2.3 From c9e7774bafe671e2b5c09c70f9f83a6eec8cb1a7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 28 Oct 2017 03:01:52 +0200 Subject: Remove CMake blank line --- src/ui/dialog/symbols.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 9b4d2ae12..e1b013c10 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -220,7 +220,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : add_symbol->set_tooltip_text(_("Add Symbol from the current document.")); add_symbol->set_relief( Gtk::RELIEF_NONE ); add_symbol->set_focus_on_click( false ); - add_symbol->signal_activate().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); + add_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); tools->pack_start(* add_symbol, Gtk::PACK_SHRINK); auto remove_symbolImage = Gtk::manage(new Gtk::Image()); @@ -421,14 +421,15 @@ void SymbolsDialog::rebuild() { } void SymbolsDialog::insertSymbol() { + std::cout << "fgasgggggggggggggg" << std::endl; Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->current_desktop) ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); sp_action_perform (action, NULL); } void SymbolsDialog::revertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->current_desktop ) ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop ) ); sp_action_perform (action, NULL); } -- cgit v1.2.3 From c55b8b44d0b477069231a62507d5cbd968a34935 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 28 Oct 2017 19:19:36 +0200 Subject: Bug fixes previous to overlay implementation --- src/selection-chemistry.cpp | 16 ++-- src/ui/dialog/symbols.cpp | 190 ++++++++++++++++++++++---------------------- src/ui/dialog/symbols.h | 5 +- 3 files changed, 111 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0bd611163..b8a769d1c 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3096,7 +3096,6 @@ void ObjectSet::toSymbol() SPDocument *doc = document(); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - // Check if something is selected. if (isEmpty()) { if (desktop()) @@ -3154,8 +3153,11 @@ void ObjectSet::toSymbol() // 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->setAttribute("class", the_group->getAttribute("class")); Glib::ustring id = the_group->getAttribute("id"); the_group->setAttribute("id", id + "_transform"); @@ -3214,7 +3216,6 @@ void ObjectSet::unSymbol() { SPDocument *doc = document(); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - // Check if something is selected. if (isEmpty()) { if(desktop()) @@ -3236,8 +3237,12 @@ void ObjectSet::unSymbol() // Create new and insert in current layer Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - symbol->parent->getRepr()->appendChild(group); - + //TODO: Better handle if no desktop, currently go to defs without it + if(desktop()) { + desktop()->currentLayer()->getRepr()->appendChild(group); + } else { + symbol->parent->getRepr()->appendChild(group); + } // Move all children of symbol to group std::vector children = symbol->childList(false); @@ -3265,6 +3270,7 @@ void ObjectSet::unSymbol() // Copy relevant attributes group->setAttribute("style", symbol->getAttribute("style")); group->setAttribute("class", symbol->getAttribute("class")); + group->setAttribute("title", symbol->getAttribute("title")); group->setAttribute("inkscape:transform-center-x", symbol->getAttribute("inkscape:transform-center-x")); group->setAttribute("inkscape:transform-center-y", diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index e1b013c10..e0aa4cb23 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -148,9 +148,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : search = Gtk::manage(new Gtk::SearchEntry()); // Search search->set_tooltip_text(_("Return to start search.")); - search->signal_key_press_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::beforeSearch)); + search->signal_key_press_event().connect_notify( sigc::mem_fun(*this, &SymbolsDialog::beforeSearch)); + search->signal_key_release_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::unsensitive)); search->set_margin_left(10); search->set_margin_right(10); + search->set_margin_bottom(6); search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); table->attach(*Gtk::manage(search),0,row,2,1); @@ -396,32 +398,22 @@ void SymbolsDialog::rebuild() { zoom_out->set_sensitive( true ); } store->clear(); - SPDocument* symbol_document = selectedSymbols(true); - if( !symbol_document ) { - // Symbol must be from Current Document (this method of - // checking should be language independent). - symbol_document = current_document; - add_symbol->set_sensitive( true ); - remove_symbol->set_sensitive( true ); - } else { - add_symbol->set_sensitive( false ); - remove_symbol->set_sensitive( false ); - } + SPDocument* symbol_document = selectedSymbols(); + icons_found = false; + //We are not in search all docs if (search->get_text() != _("Searching...") && - search->get_text() != _("Loading documents...") && - search->get_text() != _("Documents done, searchig inside...") ) + search->get_text() != _("Loading documents...") && + search->get_text() != _("Documents done, searchig inside...") ) { search_str = ""; search->set_text(""); } - icons_found = false; - if (symbol_set->get_active_text() != _("All symbols sets")) { + if (symbol_document) { addSymbolsInDoc(symbol_document); } } void SymbolsDialog::insertSymbol() { - std::cout << "fgasgggggggggggggg" << std::endl; Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); sp_action_perform (action, NULL); @@ -443,7 +435,6 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*cont Gtk::TreeModel::Path const & path = *iconArray.begin(); Gtk::ListStore::iterator row = store->get_iter(path); Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; - GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE ); gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() ); } @@ -452,18 +443,24 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*cont void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) { - if ( !symbol_sets[symbol_set->get_active_text()] ) { + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title != _("All symbols sets") && !symbol_sets[symbol_set->get_active_text()] ) { rebuild(); } } void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbol_document = selectedSymbols(); - SPObject* symbol = symbol_document->getObjectById(symbol_id); - - if(symbol && !selection->includes(symbol)) { - icon_view->unselect_all(); + SPDocument* symbol_document = symbol_sets[selectedSymbolTitle()]; + if (!symbol_document) { + //we are in global search so get the original symbol document by title + symbol_document = selectedSymbols(); + } + if (symbol_document) { + SPObject* symbol = symbol_document->getObjectById(symbol_id); + if(symbol && !selection->includes(symbol)) { + icon_view->unselect_all(); + } } } @@ -474,21 +471,25 @@ void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) rebuild(); } -SPDocument* SymbolsDialog::selectedSymbols(bool ignorecurrent) { +SPDocument* SymbolsDialog::selectedSymbols() { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ - Glib::ustring doc_title = selectedSymbolDocTitle(); - if (doc_title.empty()) { - doc_title = symbol_set->get_active_text(); + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title == _("All symbols sets")) { + return NULL; } SPDocument* symbol_document = symbol_sets[doc_title]; if( !symbol_document ) { symbol_document = getSymbolsSet(doc_title).second; // Symbol must be from Current Document (this method of checking should be language independent). if( !symbol_document ) { - if (ignorecurrent) { - return NULL; - } - return current_document; + // Symbol must be from Current Document (this method of + // checking should be language independent). + symbol_document = current_document; + add_symbol->set_sensitive( true ); + remove_symbol->set_sensitive( true ); + } else { + add_symbol->set_sensitive( false ); + remove_symbol->set_sensitive( false ); } } return symbol_document; @@ -506,7 +507,7 @@ Glib::ustring SymbolsDialog::selectedSymbolId() { return Glib::ustring(""); } -Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { +Glib::ustring SymbolsDialog::selectedSymbolTitle() { auto iconArray = icon_view->get_selected_items(); @@ -519,13 +520,17 @@ Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { } Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { - Glib::ustring title = ""; + Glib::ustring title = _("Untitled document"); if (symbol_doc) { SPRoot * root = symbol_doc->getRoot(); if (root->title()) { title = ellipsize(Glib::ustring(root->title())); + return title; } - return title; + } + Glib::ustring current = symbol_set->get_active_text(); + if (current == _("Current Document")) { + return current; } return title; } @@ -534,23 +539,33 @@ void SymbolsDialog::iconChanged() { Glib::ustring symbol_id = selectedSymbolId(); SPDocument* symbol_document = selectedSymbols(); - SPObject* symbol = symbol_document->getObjectById(symbol_id); - - if( symbol ) { - // Find style for use in - // First look for default style stored in - gchar const* style = symbol->getAttribute("inkscape:symbol-style"); - if( !style ) { - // If no default style in , look in documents. + if (!symbol_document) { + //we are in global search so get the original symbol document by title + symbol_document = symbol_sets[selectedSymbolTitle()]; + } + if (symbol_document) { + SPObject* symbol = symbol_document->getObjectById(symbol_id); + + if( symbol ) { if( symbol_document == current_document ) { - style = styleFromUse( symbol_id.c_str(), current_document ); - } else { - style = symbol_document->getReprRoot()->attribute("style"); + // Select the symbol on the canvas so it can be manipulated + current_desktop->selection->set( symbol, false ); + } + // Find style for use in + // First look for default style stored in + gchar const* style = symbol->getAttribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in , look in documents. + if( symbol_document == current_document ) { + style = styleFromUse( symbol_id.c_str(), current_document ); + } else { + style = symbol_document->getReprRoot()->attribute("style"); + } } - } - ClipboardManager *cm = ClipboardManager::get(); - cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); + ClipboardManager *cm = ClipboardManager::get(); + cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); + } } } @@ -725,10 +740,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) if(filename_short == title + ".svg") { symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); if(symbol_doc) { - new_title = ellipsize(symbol_doc->getRoot()->title()); - if(new_title.empty()) { - new_title = _("Unnamed Symbols"); - } + new_title = documentTitle(symbol_doc); } } if(Glib::str_has_suffix(filename, ".svg")) { @@ -738,10 +750,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) if(filename_short == title + ".vss") { symbol_doc = read_vss(filename, title); if(symbol_doc) { - new_title = ellipsize(symbol_doc->getRoot()->title()); - if(new_title.empty()) { - new_title = _("Unnamed Symbols"); - } + new_title = documentTitle(symbol_doc); } } if(Glib::str_has_suffix(filename, ".vss")) { @@ -835,16 +844,16 @@ gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) void SymbolsDialog::clearSearch() { if(search->get_text().empty() && sensitive) { + enableWidgets(false); search_str = ""; store->clear(); - Glib::ustring current = symbol_set->get_active_text(); - if (current != _("All symbols sets")) { + SPDocument* symbol_document = selectedSymbols(); + if (symbol_document) { + //We are not in search all docs icons_found = false; - SPDocument* symbol_document = symbol_sets[current]; - if (current == _("Current Document")) { - symbol_document = current_document; - } addSymbolsInDoc(symbol_document); + } else { + enableWidgets(true); } } } @@ -858,30 +867,30 @@ void SymbolsDialog::enableWidgets(bool enable) void SymbolsDialog::beforeSearch(GdkEventKey* evt) { + sensitive = false; search_str = search->get_text().lowercase(); if (evt->keyval != GDK_KEY_Return) { return; } progress_bar->set_fraction(0.0); enableWidgets(false); - Glib::ustring current = symbol_set->get_active_text(); - if (current != _("All symbols sets")) { + SPDocument* symbol_document = selectedSymbols(); + if (symbol_document) { + //We are not in search all docs search->set_text(_("Searching...")); - Glib::ustring doc_title = symbol_set->get_active_text(); - if (!doc_title.empty()) { - SPDocument* symbol_document = symbol_sets[doc_title]; - if (current == _("Current Document")) { - symbol_document = current_document; - } - store->clear(); - icons_found = false; - addSymbolsInDoc(symbol_document); - } + store->clear(); + icons_found = false; + addSymbolsInDoc(symbol_document); } else { search->set_text(_("Loading documents...")); } } +void SymbolsDialog::unsensitive(GdkEventKey* evt) +{ + sensitive = true; +} + bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); if (current == _("All symbols sets") && @@ -914,8 +923,8 @@ bool SymbolsDialog::callbackSymbols(){ counter_symbols ++; gchar const *symbol_title_char = symbol->title(); gchar const *symbol_desc_char = symbol->description(); + bool found = false; if (symbol_title_char) { - bool found = false; Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); auto pos = symbol_title.rfind(search_str); if (pos != std::string::npos) { @@ -928,11 +937,12 @@ bool SymbolsDialog::callbackSymbols(){ found = true; } } - if (symbol && (search_str.empty() || found)) { - addSymbol( symbol, doc_title); - icons_found = true; - } } + if (symbol && (search_str.empty() || found || (search_str.empty() && !symbol_title_char))) { + addSymbol( symbol, doc_title); + icons_found = true; + } + progress_bar->set_fraction(((100.0/number_symbols) * counter_symbols)/100.0); symbol_data = l.erase(l.begin()); //to get more items and best performance @@ -957,10 +967,9 @@ bool SymbolsDialog::callbackSymbols(){ overlay->add_overlay(* no_results); overlay->add_overlay(* different); } - bool prev_sensitive = sensitive; sensitive = false; search->set_text(search_str); - sensitive = prev_sensitive; + sensitive = true; enableWidgets(true); return true; } @@ -975,13 +984,11 @@ Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { } void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { + if (!symbol_document) { return; //Search all } Glib::ustring doc_title = documentTitle(symbol_document); - if (doc_title.empty()) { - doc_title = _("Untitled document"); ; - } progress_bar->set_fraction(0.0); counter_symbols = 0; std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); @@ -1000,9 +1007,6 @@ void SymbolsDialog::addSymbols() { continue; } Glib::ustring doc_title = documentTitle(symbol_document); - if (doc_title.empty()) { - doc_title = _("Untitled document"); ; - } std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); container_symbols_tmp.clear(); @@ -1025,10 +1029,9 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { } Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); if (doc_title.empty()) { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") +_("Current Document") + Glib::ustring(")")).c_str()))); - } else { - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); + doc_title = _("Current Document"); } + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); Glib::RefPtr pixbuf = drawSymbol( symbol ); if( pixbuf ) { @@ -1125,8 +1128,9 @@ SymbolsDialog::drawSymbol(SPObject *symbol) if( width == 0.0 ) width = 1.0; if( height == 0.0 ) height = 1.0; - if( fit_symbol->get_active() ) - scale = psize / std::max(width, height); + if( fit_symbol->get_active() ) { + scale = psize / ceil(std::max(width, height)); + } else scale = pow( 2.0, scale_factor/2.0 ) * psize / 32.0; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index d252b7c71..a77a265b5 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -76,9 +76,9 @@ private: void defsModified(SPObject *object, guint flags); void selectionChanged(Inkscape::Selection *selection); void documentReplaced(SPDesktop *desktop, SPDocument *document); - SPDocument* selectedSymbols(bool ignorecurrent = false); + SPDocument* selectedSymbols(); Glib::ustring selectedSymbolId(); - Glib::ustring selectedSymbolDocTitle(); + Glib::ustring selectedSymbolTitle(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void getSymbolsFilename(); @@ -91,6 +91,7 @@ private: void useInDoc(SPObject *r, std::vector &l); std::vector useInDoc( SPDocument* document); void beforeSearch(GdkEventKey* evt); + void unsensitive(GdkEventKey* evt); void addSymbols(); void addSymbolsInDoc(SPDocument* document); void clearSearch(); -- cgit v1.2.3 From 625c4435399d3b80902b9cdbd2be3071ca527f77 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 29 Oct 2017 11:18:24 +0100 Subject: Add overlay widgets --- src/ui/dialog/symbols.cpp | 197 +++++++++++++++++++++++++++++++++++++--------- src/ui/dialog/symbols.h | 12 ++- 2 files changed, 167 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index e0aa4cb23..ec1345257 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -108,7 +108,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : preview_document(0), instanceConns() { - /******************** Table *************************/ table = new Gtk::Grid(); table->set_margin_left(3); @@ -155,9 +154,10 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : search->set_margin_bottom(6); search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); table->attach(*Gtk::manage(search),0,row,2,1); + search_str = ""; ++row; - + /********************* Icon View **************************/ SymbolColumns* columns = getColumns(); @@ -192,7 +192,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->set_vexpand(); overlay->add(* scroller); table->attach(*Gtk::manage(overlay),0,row,2,1); - + ++row; /******************** Progress *******************************/ @@ -305,20 +305,47 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : ++row; - /**********************************************************/ sensitive = true; - search_str = ""; + current_desktop = SP_ACTIVE_DESKTOP; current_document = current_desktop->getDocument(); - preview_document = symbolsPreviewDoc(); /* Template to render symbols in */ preview_document->ensureUpToDate(); /* Necessary? */ - key = SPItem::display_key_new(1); renderDrawing.setRoot(preview_document->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); // This might need to be a global variable so setTargetDesktop can modify it SPDefs *defs = current_document->getDefs(); + + /*************************Overlays******************************/ + //Loading + overlay_opacity = new Gtk::Image(getStockPixbuf("overlay", 1000)); + overlay_opacity->set_halign(Gtk::ALIGN_START ); + overlay_opacity->set_valign(Gtk::ALIGN_START ); + //No results + noresults_icon = getStockPixbuf("noresults", 90); + search_icon = getStockPixbuf("search", 90); + overlay_icon = new Gtk::Image(noresults_icon); + overlay_icon->set_halign(Gtk::ALIGN_CENTER ); + overlay_icon->set_valign(Gtk::ALIGN_START ); + overlay_icon->set_margin_top(45); + overlay_title = new Gtk::Label(); + overlay_title->set_halign(Gtk::ALIGN_CENTER ); + overlay_title->set_valign(Gtk::ALIGN_START ); + overlay_title->set_justify(Gtk::JUSTIFY_CENTER); + overlay_title->set_margin_top(155); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc = new Gtk::Label(); + overlay_desc->set_halign(Gtk::ALIGN_CENTER ); + overlay_desc->set_valign(Gtk::ALIGN_START ); + overlay_desc->set_margin_top(180); + overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); + overlay->add_overlay(* overlay_opacity); + overlay->add_overlay(* overlay_icon); + overlay->add_overlay(* overlay_title); + overlay->add_overlay(* overlay_desc); + sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); @@ -796,7 +823,9 @@ SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_titl { std::vector > l; - symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); + if (symbol_document) { + symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); + } return l; } @@ -893,9 +922,42 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); + if (current == _("All symbols sets") && + search->get_text() != _("Loading documents...")) + { + if (!all_docs_processed) { + overlay_opacity->show(); + overlay_icon->set(noresults_icon); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Search over all symbols sets")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("")); + } + } + if (current == _("Current Document") && !icons_found) { + if (!all_docs_processed) { + overlay_icon->set(noresults_icon); + overlay_opacity->show(); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No icons in current document")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You can fill me if you want\nUse add and remove buttons.\nOr drag symbols from other sets")) + Glib::ustring("")); + } + } if (current == _("All symbols sets") && search->get_text() == _("Loading documents...") ) { + overlay_opacity->show(); + if (!all_docs_processed) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Processing all symbols sets")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("")); + overlay_icon->show(); + overlay_title->show(); + overlay_icon->set(search_icon); + overlay_desc->show(); + } size_t counter = 0; for(auto const &symbol_document_map : symbol_sets) { ++counter; @@ -911,12 +973,16 @@ bool SymbolsDialog::callbackSymbols(){ progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); return true; } + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); progress_bar->set_fraction(1.0); all_docs_processed = true; addSymbols(); search->set_text("Documents done, searchig inside..."); return true; } else if (l.size()) { + overlay_opacity->show(); for (auto symbol_data = l.begin(); symbol_data != l.end();) { Glib::ustring doc_title = symbol_data->first; SPSymbol * symbol = symbol_data->second; @@ -952,20 +1018,17 @@ bool SymbolsDialog::callbackSymbols(){ } } if (!icons_found && !search_str.empty()) { - Gtk::Image* no_results_icon = new Gtk::Image(getSearchPixbuf()); - no_results_icon->set_halign(Gtk::ALIGN_CENTER ); - no_results_icon->set_valign(Gtk::ALIGN_CENTER ); - Gtk::Label* no_results = new Gtk::Label(); - no_results->set_halign(Gtk::ALIGN_CENTER ); - no_results->set_valign(Gtk::ALIGN_CENTER ); - no_results->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - Gtk::Label* different = new Gtk::Label(); - different->set_halign(Gtk::ALIGN_CENTER ); - different->set_valign(Gtk::ALIGN_CENTER ); - different->set_markup(Glib::ustring("") + Glib::ustring(_("Try a different search")) + Glib::ustring("")); - overlay->add_overlay(* no_results_icon); - overlay->add_overlay(* no_results); - overlay->add_overlay(* different); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); + overlay_icon->set(noresults_icon); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + } else { + overlay_opacity->hide(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); } sensitive = false; search->set_text(search_str); @@ -995,6 +1058,16 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { number_symbols = container_symbols_tmp.size(); l = container_symbols_tmp; container_symbols_tmp.clear(); + if (!number_symbols) { + overlay_icon->set(noresults_icon); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + } } void SymbolsDialog::addSymbols() { @@ -1016,6 +1089,16 @@ void SymbolsDialog::addSymbols() { number_symbols = container_symbols.size(); l = container_symbols; container_symbols.clear(); + if (!number_symbols) { + overlay_icon->set(noresults_icon); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + } } void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { @@ -1055,7 +1138,7 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { * the temporary document is rendered. */ Glib::RefPtr -SymbolsDialog::drawSymbol(SPObject *symbol) +SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize) { // Create a copy repr of the symbol with id="the_symbol" Inkscape::XML::Document *xml_doc = preview_document->getReprDoc(); @@ -1128,12 +1211,16 @@ SymbolsDialog::drawSymbol(SPObject *symbol) if( width == 0.0 ) width = 1.0; if( height == 0.0 ) height = 1.0; - if( fit_symbol->get_active() ) { - scale = psize / ceil(std::max(width, height)); - } + if( fit_symbol->get_active() ) + scale = psize / ceil(std::max(width, height)); 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)); } @@ -1165,32 +1252,64 @@ SPDocument* SymbolsDialog::symbolsPreviewDoc() * Return search symbol pixbuf */ Glib::RefPtr -SymbolsDialog::getSearchPixbuf() +SymbolsDialog::getStockPixbuf(gchar const * symbol_title, unsigned psize) { - // BUG: must be inside gchar const *buffer = "" +" Inkscape " " " " " +" id=\"search\">" " Search Taiga Icon" +" id=\"search_title\">Search" +" From Taiga Icon Set" " " +" style=\"fill:#dddddd;stroke:none\"" +" d=\"m 296.87191,139.51013 c -42.96864,0 -77.93812,28.58932 -77.93812,63.7203 0,35.13101 34.96894,63.72102 77.93812,63.72102 18.73068,0 35.93889,-5.43504 49.39552,-14.4736 l 50.71196,41.46091 8.86813,-7.2504 -50.55612,-41.33356 c 12.13855,-11.23867 19.51775,-25.99037 19.51775,-42.12437 0,-35.13098 -34.96854,-63.7203 -77.93724,-63.7203 z m 0,10.25413 c 36.19119,0 65.3962,23.87692 65.3962,53.46617 0,29.58969 -29.20519,53.46706 -65.3962,53.46706 -36.19149,0 -65.39616,-23.87737 -65.39616,-53.46706 0,-29.58939 29.20467,-53.46685 65.39616,-53.46685 z\"" +" id=\"search_shape_1\" />" +" " +" " +" Overlay" +" Overlay Square" +" " +" " +" " +" No Results" +" No results" +" " " " " " ""; SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector > l = symbolsInDoc(doc, "Search Taiga Icon"); - int prev_scale_factor = scale_factor; - scale_factor = 10; - Glib::RefPtr pb = drawSymbol(l[0].second); - scale_factor = prev_scale_factor; - return pb; + std::vector > symbols_data = symbolsInDoc(doc, "Search Taiga Icon"); + Glib::RefPtr pixbuf(NULL); + for(auto data:symbols_data) { + Glib::ustring doc_title = data.first; + SPSymbol * symbol = data.second; + if (!strcmp(symbol->getId(),symbol_title)) { + pixbuf = drawSymbol(symbol, psize); + return pixbuf; + } + } + //Fallback if errors + return pixbuf; } void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index a77a265b5..3a007aba8 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -99,12 +99,14 @@ private: void enableWidgets(bool enable); Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); gchar const* styleFromUse( gchar const* id, SPDocument* document); - Glib::RefPtr drawSymbol(SPObject *symbol); - Glib::RefPtr getSearchPixbuf(); + Glib::RefPtr drawSymbol(SPObject *symbol, unsigned force_psize = 0); + Glib::RefPtr getStockPixbuf(gchar const * symbol_title, unsigned psize); /* Keep track of all symbol template documents */ std::map symbol_sets; std::vector > l; // Index into sizes which is selected + Glib::RefPtr noresults_icon; + Glib::RefPtr search_icon; int pack_size; // Scale factor int scale_factor; @@ -128,10 +130,14 @@ private: Gtk::Button* more; Gtk::Button* fewer; Gtk::HBox* tools; + Gtk::Overlay* overlay; + Gtk::Image* overlay_icon; + Gtk::Image* overlay_opacity; + Gtk::Label* overlay_title; + Gtk::Label* overlay_desc; Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; - Gtk::Overlay* overlay; void setTargetDesktop(SPDesktop *desktop); SPDesktop* current_desktop; -- cgit v1.2.3 From 0af8e9ec59bd4bde68da4b74cba74ff986344176 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 29 Oct 2017 22:19:49 +0100 Subject: Add search and no results from stock icons. Improve text. Thanks Maren for the inputs --- src/ui/dialog/symbols.cpp | 109 +++++++++++++++++++++------------------------- src/ui/dialog/symbols.h | 5 ++- 2 files changed, 52 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index ec1345257..082993158 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -319,12 +319,14 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /*************************Overlays******************************/ //Loading - overlay_opacity = new Gtk::Image(getStockPixbuf("overlay", 1000)); + overlay_opacity = new Gtk::Image(); + overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); overlay_opacity->set_halign(Gtk::ALIGN_START ); overlay_opacity->set_valign(Gtk::ALIGN_START ); //No results - noresults_icon = getStockPixbuf("noresults", 90); - search_icon = getStockPixbuf("search", 90); + iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); + overlay_icon = new Gtk::Image(); + overlay_icon->set_from_icon_name("none", iconsize); overlay_icon = new Gtk::Image(noresults_icon); overlay_icon->set_halign(Gtk::ALIGN_CENTER ); overlay_icon->set_valign(Gtk::ALIGN_START ); @@ -478,15 +480,18 @@ void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbol_document = symbol_sets[selectedSymbolTitle()]; - if (!symbol_document) { - //we are in global search so get the original symbol document by title - symbol_document = selectedSymbols(); - } - if (symbol_document) { - SPObject* symbol = symbol_document->getObjectById(symbol_id); - if(symbol && !selection->includes(symbol)) { - icon_view->unselect_all(); + Glib::ustring doc_title = selectedSymbolDocTitle(); + if (!doc_title.empty()) { + SPDocument* symbol_document = symbol_sets[doc_title]; + if (!symbol_document) { + //we are in global search so get the original symbol document by title + symbol_document = selectedSymbols(); + } + if (symbol_document) { + SPObject* symbol = symbol_document->getObjectById(symbol_id); + if(symbol && !selection->includes(symbol)) { + icon_view->unselect_all(); + } } } } @@ -534,7 +539,7 @@ Glib::ustring SymbolsDialog::selectedSymbolId() { return Glib::ustring(""); } -Glib::ustring SymbolsDialog::selectedSymbolTitle() { +Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { auto iconArray = icon_view->get_selected_items(); @@ -568,7 +573,10 @@ void SymbolsDialog::iconChanged() { SPDocument* symbol_document = selectedSymbols(); if (!symbol_document) { //we are in global search so get the original symbol document by title - symbol_document = symbol_sets[selectedSymbolTitle()]; + Glib::ustring doc_title = selectedSymbolDocTitle(); + if (!doc_title.empty()) { + symbol_document = symbol_sets[doc_title]; + } } if (symbol_document) { SPObject* symbol = symbol_document->getObjectById(symbol_id); @@ -927,23 +935,23 @@ bool SymbolsDialog::callbackSymbols(){ { if (!all_docs_processed) { overlay_opacity->show(); - overlay_icon->set(noresults_icon); + overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Search over all symbols sets")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); } } if (current == _("Current Document") && !icons_found) { if (!all_docs_processed) { - overlay_icon->set(noresults_icon); + overlay_icon->set_from_icon_name("none", iconsize); overlay_opacity->show(); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No icons in current document")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You can fill me if you want\nUse add and remove buttons.\nOr drag symbols from other sets")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); } } if (current == _("All symbols sets") && @@ -951,11 +959,11 @@ bool SymbolsDialog::callbackSymbols(){ { overlay_opacity->show(); if (!all_docs_processed) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Processing all symbols sets")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); - overlay_icon->set(search_icon); + overlay_icon->set_from_icon_name("searching", iconsize); overlay_desc->show(); } size_t counter = 0; @@ -983,6 +991,9 @@ bool SymbolsDialog::callbackSymbols(){ return true; } else if (l.size()) { overlay_opacity->show(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); for (auto symbol_data = l.begin(); symbol_data != l.end();) { Glib::ustring doc_title = symbol_data->first; SPSymbol * symbol = symbol_data->second; @@ -1019,16 +1030,13 @@ bool SymbolsDialog::callbackSymbols(){ } if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); - overlay_icon->set(noresults_icon); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); } else { overlay_opacity->hide(); - overlay_icon->hide(); - overlay_title->hide(); - overlay_desc->hide(); } sensitive = false; search->set_text(search_str); @@ -1059,8 +1067,10 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { l = container_symbols_tmp; container_symbols_tmp.clear(); if (!number_symbols) { - overlay_icon->set(noresults_icon); + overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_title->show(); overlay_desc->show(); sensitive = false; @@ -1090,7 +1100,9 @@ void SymbolsDialog::addSymbols() { l = container_symbols; container_symbols.clear(); if (!number_symbols) { - overlay_icon->set(noresults_icon); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); @@ -1249,12 +1261,12 @@ SPDocument* SymbolsDialog::symbolsPreviewDoc() } /* - * Return search symbol pixbuf + * Update image widgets */ -Glib::RefPtr -SymbolsDialog::getStockPixbuf(gchar const * symbol_title, unsigned psize) +Glib::RefPtr +SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) { - gchar const *buffer = +gchar const *buffer = "Inkscape " " " " " -" Search" -" From Taiga Icon Set" -" " -" " -" " " Overlay" " Overlay Square" " " " " -" " -" No Results" -" No results" -" " -" " " " ""; SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector > symbols_data = symbolsInDoc(doc, "Search Taiga Icon"); + std::vector > symbols_data = symbolsInDoc(doc, "Overlay Doc"); Glib::RefPtr pixbuf(NULL); for(auto data:symbols_data) { Glib::ustring doc_title = data.first; SPSymbol * symbol = data.second; - if (!strcmp(symbol->getId(),symbol_title)) { + if (!strcmp(symbol->getId(), icon_title)) { pixbuf = drawSymbol(symbol, psize); return pixbuf; } } - //Fallback if errors return pixbuf; } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 3a007aba8..1bddc5b2c 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -78,7 +78,7 @@ private: void documentReplaced(SPDesktop *desktop, SPDocument *document); SPDocument* selectedSymbols(); Glib::ustring selectedSymbolId(); - Glib::ustring selectedSymbolTitle(); + Glib::ustring selectedSymbolDocTitle(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void getSymbolsFilename(); @@ -100,7 +100,7 @@ private: Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); gchar const* styleFromUse( gchar const* id, SPDocument* document); Glib::RefPtr drawSymbol(SPObject *symbol, unsigned force_psize = 0); - Glib::RefPtr getStockPixbuf(gchar const * symbol_title, unsigned psize); + Glib::RefPtr getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); /* Keep track of all symbol template documents */ std::map symbol_sets; std::vector > l; @@ -138,6 +138,7 @@ private: Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; + Gtk::IconSize iconsize; void setTargetDesktop(SPDesktop *desktop); SPDesktop* current_desktop; -- cgit v1.2.3 From 2c971fd0dd67269a5ecd6c3323071e8b0b08bf1b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 1 Nov 2017 11:23:50 +0100 Subject: Add widget to color and some refactoring --- src/live_effects/lpe-powermask.cpp | 160 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 8 +- src/object-set.h | 2 +- src/selection-chemistry.cpp | 25 +++++- src/verbs.cpp | 10 +++ src/verbs.h | 2 + 6 files changed, 117 insertions(+), 90 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..a0ba42ddf 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,6 +13,7 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" @@ -29,19 +30,17 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") + background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) { registerParameter(&uri); registerParameter(&invert); - registerParameter(&wrap); + //registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_style); - //lock.param_setValue(false); - background_style.param_hide_canvas_text(); + registerParameter(&background_color); } LPEPowerMask::~LPEPowerMask() {} @@ -145,56 +144,57 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if(wrap && is_visible){ - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - elemref->getRepr()->setPosition(-1); - } else { - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - std::vector mask_list = mask->childList(true); - container->setPosition(-1); - Inkscape::GC::release(container); - for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - Inkscape::XML::Node *mask_node = mask_data->getRepr(); - if (! strcmp(mask_data->getId(), box_id.c_str()) || - ! strcmp(mask_data->getId(), g_data_id.c_str())) - { - continue; - } - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_node->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - sp_repr_css_set_property (css, "filter", NULL); - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_node->setAttribute("style", css_str.c_str()); - mask->getRepr()->removeChild(mask_node); - container->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - } - } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); +//Not sure if finaly need to resurrect this +// if(wrap && is_visible){ +// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; +// if((elemref = document->getObjectById(g_data_id))){ +// elemref->getRepr()->setPosition(-1); +// } else { +// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); +// container->setAttribute("id", g_data_id.c_str()); +// mask->appendChildRepr(container); +// std::vector mask_list = mask->childList(true); +// container->setPosition(-1); +// Inkscape::GC::release(container); +// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { +// SPItem * mask_data = SP_ITEM(*iter); +// Inkscape::XML::Node *mask_node = mask_data->getRepr(); +// if (! strcmp(mask_data->getId(), box_id.c_str()) || +// ! strcmp(mask_data->getId(), g_data_id.c_str())) +// { +// continue; +// } +// SPCSSAttr *css = sp_repr_css_attr_new(); +// if(mask_node->attribute("style")) { +// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); +// } +// char const* filter = sp_repr_css_property (css, "filter", NULL); +// if(!filter || !strcmp(filter, filter_uri.c_str())) { +// sp_repr_css_set_property (css, "filter", NULL); +// } +// Glib::ustring css_str; +// sp_repr_css_write_string(css, css_str); +// mask_node->setAttribute("style", css_str.c_str()); +// mask->getRepr()->removeChild(mask_node); +// container->appendChild(mask_node); +// Inkscape::GC::release(mask_node); +// } +// } +// } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } +// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -229,7 +229,28 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - box->setAttribute("style", background_style.param_getSVGValue()); + Glib::ustring style; + gchar c[32]; + unsigned const rgb24 = background_color.get_value() >> 8; + sprintf(c, "#%06x", rgb24); + style = Glib::ustring("fill:") + Glib::ustring(c); + Inkscape::SVGOStringStream os; + os << SP_RGBA32_A_F(background_color.get_value()); + style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, style.c_str()); + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert && is_visible) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + box->setAttribute("style", css_str.c_str()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -255,33 +276,6 @@ LPEPowerMask::doEffect (SPCurve * curve) { } -//void -//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) -//{ -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// if (mask_path && lock) { -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// std::vector mask_path_list = mask_path->childList(true); -// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); -// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; -// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { -// SPObject * mask_data = *iter; -// if (! strcmp(mask_data->getId(), box_id.c_str())){ -// continue; -// } -// SP_ITEM(mask_data)->transform *= postmul.inverse(); -// } -// } -// //cycle through all parameters. Most parameters will not need transformation, but path and point params -// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { -// Parameter * param = *it; -// param->param_transform_multiply(postmul, set); -// } -// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -//} - - - void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +283,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - wrap.param_setValue(false); + //wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..44bf56333 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,10 +6,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -22,16 +23,15 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - BoolParam wrap; + //BoolParam wrap; BoolParam hide_mask; BoolParam background; - TextParam background_style; + ColorPickerParam background_color; Geom::Path mask_box; }; diff --git a/src/object-set.h b/src/object-set.h index a8061593a..2e57966e6 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -422,7 +422,7 @@ public: void tile(bool apply = true); //"Object to Pattern" void untile(); void createBitmapCopy(); - void setMask(bool apply_clip_path, bool apply_to_layer = false, bool skip_undo = false); + void setMask(bool apply_clip_path, bool apply_to_layer = false, bool skip_undo = false, bool inverse = false); void editMask(bool clip); void unsetMask(const bool apply_clip_path, const bool skip_undo = false); void setClipGroup(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0bd611163..24113f976 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -95,6 +95,8 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" #include "live_effects/effect.h" +#include "live_effects/lpe-powerclip.h" +#include "live_effects/lpe-powermask.h" #include "live_effects/parameter/originalpath.h" #include "layer-manager.h" #include "object-set.h" @@ -3862,7 +3864,7 @@ void ObjectSet::setClipGroup() * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask * */ - void ObjectSet::setMask(bool apply_clip_path, bool apply_to_layer, bool skip_undo) + void ObjectSet::setMask(bool apply_clip_path, bool apply_to_layer, bool skip_undo, bool inverse) { if(!desktop() && apply_to_layer) return; @@ -4016,7 +4018,26 @@ void ObjectSet::setClipGroup() } apply_mask_to->setAttribute(attributeName, Glib::ustring("url(#") + mask_id + ')'); - + if (inverse) { + using namespace Inkscape::LivePathEffect; + if (apply_clip_path) { + Effect::createAndApply(POWERCLIP, doc, item); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); + lpe->getRepr()->setAttribute("is_inverse", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("inverse", "true"); + lpe->getRepr()->setAttribute("flatten", "false"); + lpe->getRepr()->setAttribute("hide_clip", "false"); + } else { + Effect::createAndApply(POWERMASK, doc, item); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); + lpe->getRepr()->setAttribute("invert", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("hide_mask", "false"); + lpe->getRepr()->setAttribute("background", "true"); + lpe->getRepr()->setAttribute("background_color", "#ffffffff"); + } + } } for (std::vector::const_iterator i = items_to_delete.begin(); i != items_to_delete.end(); ++i) { diff --git a/src/verbs.cpp b/src/verbs.cpp index c1c108415..962196d06 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1592,6 +1592,9 @@ void ObjectVerb::perform( SPAction *action, void *data) case SP_VERB_OBJECT_SET_MASK: sel->setMask(false, false); break; + case SP_VERB_OBJECT_SET_INVERSE_MASK: + sel->setMask(false, false, false, true); + break; case SP_VERB_OBJECT_EDIT_MASK: sel->editMask(false); break; @@ -1601,6 +1604,9 @@ void ObjectVerb::perform( SPAction *action, void *data) case SP_VERB_OBJECT_SET_CLIPPATH: sel->setMask(true, false); break; + case SP_VERB_OBJECT_SET_INVERSE_CLIPPATH: + sel->setMask(true, false, false, true); + break; case SP_VERB_OBJECT_CREATE_CLIP_GROUP: sel->setClipGroup(); break; @@ -2873,12 +2879,16 @@ Verb *Verb::_base_verbs[] = { INKSCAPE_ICON("object-flip-vertical")), new ObjectVerb(SP_VERB_OBJECT_SET_MASK, "ObjectSetMask", N_("_Set"), N_("Apply mask to selection (using the topmost object as mask)"), NULL), + new ObjectVerb(SP_VERB_OBJECT_SET_INVERSE_MASK, "ObjectSetInverseMask", N_("_Set Inverse (LPE)"), + N_("Apply inverse mask to selection (using the topmost object as mask)"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_MASK, "ObjectEditMask", N_("_Edit"), N_("Edit mask"), INKSCAPE_ICON("path-mask-edit")), new ObjectVerb(SP_VERB_OBJECT_UNSET_MASK, "ObjectUnSetMask", N_("_Release"), N_("Remove mask from selection"), NULL), new ObjectVerb(SP_VERB_OBJECT_SET_CLIPPATH, "ObjectSetClipPath", N_("_Set"), N_("Apply clipping path to selection (using the topmost object as clipping path)"), NULL), + new ObjectVerb(SP_VERB_OBJECT_SET_INVERSE_CLIPPATH, "ObjectSetInverseClipPath", N_("_Set Inverse (LPE)"), + N_("Apply inverse clipping path to selection (using the topmost object as clipping path)"), NULL), new ObjectVerb(SP_VERB_OBJECT_CREATE_CLIP_GROUP, "ObjectCreateClipGroup", N_("Create Cl_ip Group"), N_("Creates a clip group using the selected objects as a base"), NULL), new ObjectVerb(SP_VERB_OBJECT_EDIT_CLIPPATH, "ObjectEditClipPath", N_("_Edit"), diff --git a/src/verbs.h b/src/verbs.h index 7df2d1399..611a8131c 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -192,9 +192,11 @@ enum { SP_VERB_OBJECT_FLIP_HORIZONTAL, SP_VERB_OBJECT_FLIP_VERTICAL, SP_VERB_OBJECT_SET_MASK, + SP_VERB_OBJECT_SET_INVERSE_MASK, SP_VERB_OBJECT_EDIT_MASK, SP_VERB_OBJECT_UNSET_MASK, SP_VERB_OBJECT_SET_CLIPPATH, + SP_VERB_OBJECT_SET_INVERSE_CLIPPATH, SP_VERB_OBJECT_CREATE_CLIP_GROUP, SP_VERB_OBJECT_EDIT_CLIPPATH, SP_VERB_OBJECT_UNSET_CLIPPATH, -- cgit v1.2.3 From 66b464e2f07106e2b270517c13205464727f281f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 1 Nov 2017 22:13:21 +0100 Subject: Added inverse mask and clippath --- src/live_effects/lpe-powermask.cpp | 60 +++++++++++++++++++++----------------- src/live_effects/lpe-powermask.h | 1 + src/selection-chemistry.cpp | 1 + 3 files changed, 35 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index a0ba42ddf..0d48b1b77 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -19,7 +19,6 @@ #include "uri.h" #include "extract-uri.h" #include - // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -41,12 +40,14 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) registerParameter(&hide_mask); registerParameter(&background); registerParameter(&background_color); + previous_color = background_color.get_value(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -60,35 +61,40 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } + if (previous_color != background_color.get_value()) { + previous_color = background_color.get_value(); + setMask(); } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); } } diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 44bf56333..eb2640867 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -33,6 +33,7 @@ private: BoolParam background; ColorPickerParam background_color; Geom::Path mask_box; + guint32 previous_color; }; } //namespace LivePathEffect diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 24113f976..43e7d8af5 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -4028,6 +4028,7 @@ void ObjectSet::setClipGroup() lpe->getRepr()->setAttribute("inverse", "true"); lpe->getRepr()->setAttribute("flatten", "false"); lpe->getRepr()->setAttribute("hide_clip", "false"); + dynamic_cast(lpe)->convertShapes(); } else { Effect::createAndApply(POWERMASK, doc, item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); -- cgit v1.2.3 From cba70f5669c6a38321157fbb84a8511033b7b41e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 2 Nov 2017 21:14:20 +0100 Subject: Remove unrelated code --- src/live_effects/lpe-powermask.cpp | 220 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 9 +- 2 files changed, 114 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 0d48b1b77..05510f258 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,12 +13,12 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" -#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" #include "extract-uri.h" #include + // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -29,25 +29,25 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) + background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") { registerParameter(&uri); registerParameter(&invert); - //registerParameter(&wrap); + registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_color); - previous_color = background_color.get_value(); + registerParameter(&background_style); + //lock.param_setValue(false); + background_style.param_hide_canvas_text(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ - //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -61,40 +61,35 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - if (previous_color != background_color.get_value()) { - previous_color = background_color.get_value(); - setMask(); - } else { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } - } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); SP_ITEM(sp_lpe_item)->mask_ref->detach(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } } @@ -150,57 +145,56 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } -//Not sure if finaly need to resurrect this -// if(wrap && is_visible){ -// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; -// if((elemref = document->getObjectById(g_data_id))){ -// elemref->getRepr()->setPosition(-1); -// } else { -// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); -// container->setAttribute("id", g_data_id.c_str()); -// mask->appendChildRepr(container); -// std::vector mask_list = mask->childList(true); -// container->setPosition(-1); -// Inkscape::GC::release(container); -// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { -// SPItem * mask_data = SP_ITEM(*iter); -// Inkscape::XML::Node *mask_node = mask_data->getRepr(); -// if (! strcmp(mask_data->getId(), box_id.c_str()) || -// ! strcmp(mask_data->getId(), g_data_id.c_str())) -// { -// continue; -// } -// SPCSSAttr *css = sp_repr_css_attr_new(); -// if(mask_node->attribute("style")) { -// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); -// } -// char const* filter = sp_repr_css_property (css, "filter", NULL); -// if(!filter || !strcmp(filter, filter_uri.c_str())) { -// sp_repr_css_set_property (css, "filter", NULL); -// } -// Glib::ustring css_str; -// sp_repr_css_write_string(css, css_str); -// mask_node->setAttribute("style", css_str.c_str()); -// mask->getRepr()->removeChild(mask_node); -// container->appendChild(mask_node); -// Inkscape::GC::release(mask_node); -// } -// } -// } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); + if(wrap && is_visible){ + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + elemref->getRepr()->setPosition(-1); + } else { + Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); + container->setAttribute("id", g_data_id.c_str()); + mask->appendChildRepr(container); + std::vector mask_list = mask->childList(true); + container->setPosition(-1); + Inkscape::GC::release(container); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPItem * mask_data = SP_ITEM(*iter); + Inkscape::XML::Node *mask_node = mask_data->getRepr(); + if (! strcmp(mask_data->getId(), box_id.c_str()) || + ! strcmp(mask_data->getId(), g_data_id.c_str())) + { + continue; + } + SPCSSAttr *css = sp_repr_css_attr_new(); + if(mask_node->attribute("style")) { + sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); + } + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + sp_repr_css_set_property (css, "filter", NULL); + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + mask_node->setAttribute("style", css_str.c_str()); + mask->getRepr()->removeChild(mask_node); + container->appendChild(mask_node); + Inkscape::GC::release(mask_node); + } + } + } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); + } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); } -// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -235,28 +229,7 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - Glib::ustring style; - gchar c[32]; - unsigned const rgb24 = background_color.get_value() >> 8; - sprintf(c, "#%06x", rgb24); - style = Glib::ustring("fill:") + Glib::ustring(c); - Inkscape::SVGOStringStream os; - os << SP_RGBA32_A_F(background_color.get_value()); - style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_attr_add_from_string(css, style.c_str()); - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - if (invert && is_visible) { - sp_repr_css_set_property (css, "filter", filter_uri.c_str()); - } else { - sp_repr_css_set_property (css, "filter", NULL); - } - - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - box->setAttribute("style", css_str.c_str()); + box->setAttribute("style", background_style.param_getSVGValue()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -282,6 +255,33 @@ LPEPowerMask::doEffect (SPCurve * curve) { } +//void +//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) +//{ +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// if (mask_path && lock) { +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// std::vector mask_path_list = mask_path->childList(true); +// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); +// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; +// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { +// SPObject * mask_data = *iter; +// if (! strcmp(mask_data->getId(), box_id.c_str())){ +// continue; +// } +// SP_ITEM(mask_data)->transform *= postmul.inverse(); +// } +// } +// //cycle through all parameters. Most parameters will not need transformation, but path and point params +// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { +// Parameter * param = *it; +// param->param_transform_multiply(postmul, set); +// } +// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); +//} + + + void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +289,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - //wrap.param_setValue(false); + wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index eb2640867..a54424e2f 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,11 +6,10 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ + #include "live_effects/effect.h" -#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" -#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -23,17 +22,17 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - //BoolParam wrap; + BoolParam wrap; BoolParam hide_mask; BoolParam background; - ColorPickerParam background_color; + TextParam background_style; Geom::Path mask_box; - guint32 previous_color; }; } //namespace LivePathEffect -- cgit v1.2.3 From b54fa2d1333e52f5fac87c904b55ce3789a0881e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 2 Nov 2017 21:17:50 +0100 Subject: Allow color widget instead text input in powermask. Simplify the UI --- src/live_effects/lpe-powermask.cpp | 220 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 9 +- 2 files changed, 115 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..0d48b1b77 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,12 +13,12 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" #include "extract-uri.h" #include - // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -29,25 +29,25 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") + background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) { registerParameter(&uri); registerParameter(&invert); - registerParameter(&wrap); + //registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_style); - //lock.param_setValue(false); - background_style.param_hide_canvas_text(); + registerParameter(&background_color); + previous_color = background_color.get_value(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -61,35 +61,40 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } + if (previous_color != background_color.get_value()) { + previous_color = background_color.get_value(); + setMask(); } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); } } @@ -145,56 +150,57 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if(wrap && is_visible){ - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - elemref->getRepr()->setPosition(-1); - } else { - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - std::vector mask_list = mask->childList(true); - container->setPosition(-1); - Inkscape::GC::release(container); - for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - Inkscape::XML::Node *mask_node = mask_data->getRepr(); - if (! strcmp(mask_data->getId(), box_id.c_str()) || - ! strcmp(mask_data->getId(), g_data_id.c_str())) - { - continue; - } - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_node->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - sp_repr_css_set_property (css, "filter", NULL); - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_node->setAttribute("style", css_str.c_str()); - mask->getRepr()->removeChild(mask_node); - container->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - } - } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); +//Not sure if finaly need to resurrect this +// if(wrap && is_visible){ +// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; +// if((elemref = document->getObjectById(g_data_id))){ +// elemref->getRepr()->setPosition(-1); +// } else { +// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); +// container->setAttribute("id", g_data_id.c_str()); +// mask->appendChildRepr(container); +// std::vector mask_list = mask->childList(true); +// container->setPosition(-1); +// Inkscape::GC::release(container); +// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { +// SPItem * mask_data = SP_ITEM(*iter); +// Inkscape::XML::Node *mask_node = mask_data->getRepr(); +// if (! strcmp(mask_data->getId(), box_id.c_str()) || +// ! strcmp(mask_data->getId(), g_data_id.c_str())) +// { +// continue; +// } +// SPCSSAttr *css = sp_repr_css_attr_new(); +// if(mask_node->attribute("style")) { +// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); +// } +// char const* filter = sp_repr_css_property (css, "filter", NULL); +// if(!filter || !strcmp(filter, filter_uri.c_str())) { +// sp_repr_css_set_property (css, "filter", NULL); +// } +// Glib::ustring css_str; +// sp_repr_css_write_string(css, css_str); +// mask_node->setAttribute("style", css_str.c_str()); +// mask->getRepr()->removeChild(mask_node); +// container->appendChild(mask_node); +// Inkscape::GC::release(mask_node); +// } +// } +// } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } +// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -229,7 +235,28 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - box->setAttribute("style", background_style.param_getSVGValue()); + Glib::ustring style; + gchar c[32]; + unsigned const rgb24 = background_color.get_value() >> 8; + sprintf(c, "#%06x", rgb24); + style = Glib::ustring("fill:") + Glib::ustring(c); + Inkscape::SVGOStringStream os; + os << SP_RGBA32_A_F(background_color.get_value()); + style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, style.c_str()); + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert && is_visible) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + box->setAttribute("style", css_str.c_str()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -255,33 +282,6 @@ LPEPowerMask::doEffect (SPCurve * curve) { } -//void -//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) -//{ -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// if (mask_path && lock) { -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// std::vector mask_path_list = mask_path->childList(true); -// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); -// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; -// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { -// SPObject * mask_data = *iter; -// if (! strcmp(mask_data->getId(), box_id.c_str())){ -// continue; -// } -// SP_ITEM(mask_data)->transform *= postmul.inverse(); -// } -// } -// //cycle through all parameters. Most parameters will not need transformation, but path and point params -// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { -// Parameter * param = *it; -// param->param_transform_multiply(postmul, set); -// } -// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -//} - - - void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +289,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - wrap.param_setValue(false); + //wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..eb2640867 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,10 +6,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -22,17 +23,17 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - BoolParam wrap; + //BoolParam wrap; BoolParam hide_mask; BoolParam background; - TextParam background_style; + ColorPickerParam background_color; Geom::Path mask_box; + guint32 previous_color; }; } //namespace LivePathEffect -- cgit v1.2.3 From 08382df305f91a07349031e785500eb7be34872c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 3 Nov 2017 00:14:28 +0100 Subject: Move finctions away object sets --- src/live_effects/lpe-powerclip.cpp | 19 +++++++++++++++++++ src/live_effects/lpe-powerclip.h | 2 ++ src/live_effects/lpe-powermask.cpp | 18 ++++++++++++++++++ src/live_effects/lpe-powermask.h | 3 +++ src/object-set.h | 2 +- src/selection-chemistry.cpp | 26 ++------------------------ src/verbs.cpp | 11 +++++++++-- 7 files changed, 54 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 40a9cdbfb..18276270d 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -395,6 +395,25 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast(*i); + if (lpeitem) { + Effect::createAndApply(POWERCLIP, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("is_inverse", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("inverse", "true"); + lpe->getRepr()->setAttribute("flatten", "false"); + lpe->getRepr()->setAttribute("hide_clip", "false"); + dynamic_cast(lpe)->convertShapes(); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 38485b798..6f99d220f 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -38,6 +38,8 @@ private: bool convert_shapes; }; +void sp_inverse_powerclip(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape #endif diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..b7c88584b 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -303,6 +303,24 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast(*i); + if (lpeitem) { + Effect::createAndApply(POWERMASK, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("invert", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("hide_mask", "false"); + lpe->getRepr()->setAttribute("background", "true"); + lpe->getRepr()->setAttribute("background_color", "#ffffffff"); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..d2d87fd41 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -35,6 +35,9 @@ private: Geom::Path mask_box; }; +void sp_inverse_powermask(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape + #endif diff --git a/src/object-set.h b/src/object-set.h index 2e57966e6..a8061593a 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -422,7 +422,7 @@ public: void tile(bool apply = true); //"Object to Pattern" void untile(); void createBitmapCopy(); - void setMask(bool apply_clip_path, bool apply_to_layer = false, bool skip_undo = false, bool inverse = false); + void setMask(bool apply_clip_path, bool apply_to_layer = false, bool skip_undo = false); void editMask(bool clip); void unsetMask(const bool apply_clip_path, const bool skip_undo = false); void setClipGroup(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 43e7d8af5..0bd611163 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -95,8 +95,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" #include "live_effects/effect.h" -#include "live_effects/lpe-powerclip.h" -#include "live_effects/lpe-powermask.h" #include "live_effects/parameter/originalpath.h" #include "layer-manager.h" #include "object-set.h" @@ -3864,7 +3862,7 @@ void ObjectSet::setClipGroup() * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask * */ - void ObjectSet::setMask(bool apply_clip_path, bool apply_to_layer, bool skip_undo, bool inverse) + void ObjectSet::setMask(bool apply_clip_path, bool apply_to_layer, bool skip_undo) { if(!desktop() && apply_to_layer) return; @@ -4018,27 +4016,7 @@ void ObjectSet::setClipGroup() } apply_mask_to->setAttribute(attributeName, Glib::ustring("url(#") + mask_id + ')'); - if (inverse) { - using namespace Inkscape::LivePathEffect; - if (apply_clip_path) { - Effect::createAndApply(POWERCLIP, doc, item); - Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - lpe->getRepr()->setAttribute("is_inverse", "false"); - lpe->getRepr()->setAttribute("is_visible", "true"); - lpe->getRepr()->setAttribute("inverse", "true"); - lpe->getRepr()->setAttribute("flatten", "false"); - lpe->getRepr()->setAttribute("hide_clip", "false"); - dynamic_cast(lpe)->convertShapes(); - } else { - Effect::createAndApply(POWERMASK, doc, item); - Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - lpe->getRepr()->setAttribute("invert", "false"); - lpe->getRepr()->setAttribute("is_visible", "true"); - lpe->getRepr()->setAttribute("hide_mask", "false"); - lpe->getRepr()->setAttribute("background", "true"); - lpe->getRepr()->setAttribute("background_color", "#ffffffff"); - } - } + } for (std::vector::const_iterator i = items_to_delete.begin(); i != items_to_delete.end(); ++i) { diff --git a/src/verbs.cpp b/src/verbs.cpp index 962196d06..27fc29dd4 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -85,6 +85,9 @@ #include "ui/icon-names.h" #include "ui/tools/node-tool.h" #include "ui/dialog/save-template-dialog.h" +#include "live_effects/effect.h" +#include "live_effects/lpe-powerclip.h" +#include "live_effects/lpe-powermask.h" using Inkscape::DocumentUndo; using Inkscape::UI::Dialog::ActionAlign; @@ -1593,7 +1596,9 @@ void ObjectVerb::perform( SPAction *action, void *data) sel->setMask(false, false); break; case SP_VERB_OBJECT_SET_INVERSE_MASK: - sel->setMask(false, false, false, true); + sel->setMask(false, false); + using Inkscape::LivePathEffect; + sp_inverse_powermask(sp_action_get_selection(action)); break; case SP_VERB_OBJECT_EDIT_MASK: sel->editMask(false); @@ -1605,7 +1610,9 @@ void ObjectVerb::perform( SPAction *action, void *data) sel->setMask(true, false); break; case SP_VERB_OBJECT_SET_INVERSE_CLIPPATH: - sel->setMask(true, false, false, true); + sel->setMask(true, false); + using Inkscape::LivePathEffect; + sp_inverse_powerclip(sp_action_get_selection(action)); break; case SP_VERB_OBJECT_CREATE_CLIP_GROUP: sel->setClipGroup(); -- cgit v1.2.3 From bc776cf2ee8744fb0b49cb3ef9f53e835515624b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 3 Nov 2017 02:17:35 +0100 Subject: Rename wrong named function --- src/live_effects/lpe-powermask.cpp | 2 +- src/verbs.cpp | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index b7c88584b..396a3b3ca 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -303,7 +303,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } -void sp_inverse_powerclip(Inkscape::Selection *sel) { +void sp_inverse_powermask(Inkscape::Selection *sel) { if (!sel->isEmpty()) { auto selList = sel->items(); for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { diff --git a/src/verbs.cpp b/src/verbs.cpp index 27fc29dd4..d0975af16 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1597,8 +1597,7 @@ void ObjectVerb::perform( SPAction *action, void *data) break; case SP_VERB_OBJECT_SET_INVERSE_MASK: sel->setMask(false, false); - using Inkscape::LivePathEffect; - sp_inverse_powermask(sp_action_get_selection(action)); + Inkscape::LivePathEffect::sp_inverse_powermask(sp_action_get_selection(action)); break; case SP_VERB_OBJECT_EDIT_MASK: sel->editMask(false); @@ -1611,8 +1610,7 @@ void ObjectVerb::perform( SPAction *action, void *data) break; case SP_VERB_OBJECT_SET_INVERSE_CLIPPATH: sel->setMask(true, false); - using Inkscape::LivePathEffect; - sp_inverse_powerclip(sp_action_get_selection(action)); + Inkscape::LivePathEffect::sp_inverse_powerclip(sp_action_get_selection(action)); break; case SP_VERB_OBJECT_CREATE_CLIP_GROUP: sel->setClipGroup(); -- cgit v1.2.3 From 2f244b8616ba8df0a81c559eeacc1fd9963c55ff Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 3 Nov 2017 08:18:02 +0100 Subject: Give each filter primitive a name to help in debugging. --- src/display/nr-filter-blend.h | 2 ++ src/display/nr-filter-colormatrix.h | 2 ++ src/display/nr-filter-component-transfer.h | 2 ++ src/display/nr-filter-composite.h | 2 ++ src/display/nr-filter-convolve-matrix.h | 2 ++ src/display/nr-filter-diffuselighting.h | 2 ++ src/display/nr-filter-displacement-map.h | 2 ++ src/display/nr-filter-flood.h | 2 ++ src/display/nr-filter-gaussian.h | 2 ++ src/display/nr-filter-image.h | 2 ++ src/display/nr-filter-merge.h | 2 ++ src/display/nr-filter-morphology.h | 2 ++ src/display/nr-filter-offset.h | 2 ++ src/display/nr-filter-primitive.h | 5 +++++ src/display/nr-filter-specularlighting.h | 2 ++ src/display/nr-filter-tile.h | 2 ++ src/display/nr-filter-turbulence.h | 3 +++ 17 files changed, 38 insertions(+) (limited to 'src') diff --git a/src/display/nr-filter-blend.h b/src/display/nr-filter-blend.h index 5b1295c88..cdabb469b 100644 --- a/src/display/nr-filter-blend.h +++ b/src/display/nr-filter-blend.h @@ -59,6 +59,8 @@ public: virtual void set_input(int input, int slot); void set_mode(FilterBlendMode mode); + virtual Glib::ustring name() { return Glib::ustring("Blend"); } + private: static const std::set _valid_modes; FilterBlendMode _blend_mode; diff --git a/src/display/nr-filter-colormatrix.h b/src/display/nr-filter-colormatrix.h index cc43f4914..a6ba3693e 100644 --- a/src/display/nr-filter-colormatrix.h +++ b/src/display/nr-filter-colormatrix.h @@ -46,6 +46,8 @@ public: virtual void set_value(double value); virtual void set_values(std::vector const &values); + virtual Glib::ustring name() { return Glib::ustring("Color Matrix"); } + public: struct ColorMatrixMatrix { ColorMatrixMatrix(std::vector const &values); diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index 7019dde37..dae230f24 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -46,6 +46,8 @@ public: double amplitude[4]; double exponent[4]; double offset[4]; + + virtual Glib::ustring name() { return Glib::ustring("Component Transfer"); } }; } /* namespace Filters */ diff --git a/src/display/nr-filter-composite.h b/src/display/nr-filter-composite.h index 35756383b..74806ad5e 100644 --- a/src/display/nr-filter-composite.h +++ b/src/display/nr-filter-composite.h @@ -36,6 +36,8 @@ public: void set_operator(FeCompositeOperator op); void set_arithmetic(double k1, double k2, double k3, double k4); + virtual Glib::ustring name() { return Glib::ustring("Composite"); } + private: FeCompositeOperator op; double k1, k2, k3, k4; diff --git a/src/display/nr-filter-convolve-matrix.h b/src/display/nr-filter-convolve-matrix.h index d2e38eb95..3d86129ba 100644 --- a/src/display/nr-filter-convolve-matrix.h +++ b/src/display/nr-filter-convolve-matrix.h @@ -47,6 +47,8 @@ public: void set_edgeMode(FilterConvolveMatrixEdgeMode mode); void set_preserveAlpha(bool pa); + virtual Glib::ustring name() { return Glib::ustring("Convolve Matrix"); } + private: std::vector kernelMatrix; int targetX, targetY; diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 5ce505979..ef7a3011b 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -47,6 +47,8 @@ public: double surfaceScale; guint32 lighting_color; + virtual Glib::ustring name() { return Glib::ustring("Diffuse Lighting"); } + private: SVGICCColor *icc; }; diff --git a/src/display/nr-filter-displacement-map.h b/src/display/nr-filter-displacement-map.h index c4e2400fe..c469f4ced 100644 --- a/src/display/nr-filter-displacement-map.h +++ b/src/display/nr-filter-displacement-map.h @@ -35,6 +35,8 @@ public: virtual void set_scale(double s); virtual void set_channel_selector(int s, FilterDisplacementMapChannelSelector channel); + virtual Glib::ustring name() { return Glib::ustring("Displacement Map"); } + private: double scale; int _input2; diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 826aa981a..1752a4ca4 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -35,6 +35,8 @@ public: virtual void set_color(guint32 c); virtual void set_icc(SVGICCColor *icc_color); + virtual Glib::ustring name() { return Glib::ustring("Flood"); } + private: double opacity; guint32 color; diff --git a/src/display/nr-filter-gaussian.h b/src/display/nr-filter-gaussian.h index 88c38247f..c8314b633 100644 --- a/src/display/nr-filter-gaussian.h +++ b/src/display/nr-filter-gaussian.h @@ -56,6 +56,8 @@ public: */ void set_deviation(double x, double y); + virtual Glib::ustring name() { return Glib::ustring("Gaussian Blur"); } + private: double _deviation_x; double _deviation_y; diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index 147a8ba6c..0ae6ac6ce 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -40,6 +40,8 @@ public: bool from_element; SPItem* SVGElem; + virtual Glib::ustring name() { return Glib::ustring("Image"); } + private: SPDocument *document; char *feImageHref; diff --git a/src/display/nr-filter-merge.h b/src/display/nr-filter-merge.h index b20d663ab..26ef42e4d 100644 --- a/src/display/nr-filter-merge.h +++ b/src/display/nr-filter-merge.h @@ -32,6 +32,8 @@ public: virtual void set_input(int input); virtual void set_input(int input, int slot); + virtual Glib::ustring name() { return Glib::ustring("Merge"); } + private: std::vector _input_image; }; diff --git a/src/display/nr-filter-morphology.h b/src/display/nr-filter-morphology.h index cd7dfe775..97d91b1a6 100644 --- a/src/display/nr-filter-morphology.h +++ b/src/display/nr-filter-morphology.h @@ -39,6 +39,8 @@ public: void set_xradius(double x); void set_yradius(double y); + virtual Glib::ustring name() { return Glib::ustring("Morphology"); } + private: FilterMorphologyOperator Operator; double xradius; diff --git a/src/display/nr-filter-offset.h b/src/display/nr-filter-offset.h index c1ee1d82a..6e02bc1d7 100644 --- a/src/display/nr-filter-offset.h +++ b/src/display/nr-filter-offset.h @@ -33,6 +33,8 @@ public: void set_dx(double amount); void set_dy(double amount); + virtual Glib::ustring name() { return Glib::ustring("Offset"); } + private: double dx, dy; }; diff --git a/src/display/nr-filter-primitive.h b/src/display/nr-filter-primitive.h index a1339cc6c..cba1fdf20 100644 --- a/src/display/nr-filter-primitive.h +++ b/src/display/nr-filter-primitive.h @@ -14,6 +14,8 @@ #include <2geom/forward.h> #include <2geom/rect.h> +#include + #include "display/nr-filter-types.h" #include "svg/svg-length.h" @@ -121,6 +123,9 @@ public: */ void setStyle(SPStyle *style); + // Useful for debugging + virtual Glib::ustring name() { return Glib::ustring("No name"); } + protected: int _input; int _output; diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index ff9cda450..833b2ac3d 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -49,6 +49,8 @@ public: double specularExponent; guint32 lighting_color; + virtual Glib::ustring name() { return Glib::ustring("Specular Lighting"); } + private: SVGICCColor *icc; }; diff --git a/src/display/nr-filter-tile.h b/src/display/nr-filter-tile.h index 239ecff4b..c76302033 100644 --- a/src/display/nr-filter-tile.h +++ b/src/display/nr-filter-tile.h @@ -28,6 +28,8 @@ public: virtual void render_cairo(FilterSlot &slot); virtual void area_enlarge(Geom::IntRect &area, Geom::Affine const &trans); virtual double complexity(Geom::Affine const &ctm); + + virtual Glib::ustring name() { return Glib::ustring("Tile"); } }; } /* namespace Filters */ diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index ee8079133..3960c2f8e 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -54,6 +54,9 @@ public: void set_stitchTiles(bool st); void set_type(FilterTurbulenceType t); void set_updated(bool u); + + virtual Glib::ustring name() { return Glib::ustring("Turbulence"); } + private: TurbulenceGenerator *gen; -- cgit v1.2.3 From 12b60f0fc1171b61f67b1acd4160ca06e13f0898 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 3 Nov 2017 08:22:02 +0100 Subject: Don't use infinite rectangle for tile area as this leads to overflow/underflow problems later. --- src/display/nr-filter-tile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-tile.cpp b/src/display/nr-filter-tile.cpp index c151c8537..ad4e64768 100644 --- a/src/display/nr-filter-tile.cpp +++ b/src/display/nr-filter-tile.cpp @@ -114,8 +114,11 @@ void FilterTile::render_cairo(FilterSlot &slot) void FilterTile::area_enlarge(Geom::IntRect &area, Geom::Affine const &trans) { - // Set to infinite rectangle so we get tile source. It will be clipped later. - area = Geom::IntRect::infinite(); + // Set to very large rectangle so we get tile source. It will be clipped later. + + // Note, setting to infinite using Geom::IntRect::infinite() causes overflow/underflow problems. + Geom::IntCoord max = std::numeric_limits::max()/4; + area = Geom::IntRect(-max,-max,max,max); } double FilterTile::complexity(Geom::Affine const &) -- cgit v1.2.3 From 9867b59558ccb8a9ff639aba73ed9de58d9825cc Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 3 Nov 2017 08:46:16 +0100 Subject: Set primitive filter area in feComposite and feMerge. Needed for tiling. --- src/display/nr-filter-composite.cpp | 3 +++ src/display/nr-filter-merge.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index dc5e4278f..04f81f857 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -79,6 +79,9 @@ void FilterComposite::render_cairo(FilterSlot &slot) cairo_surface_t *out = ink_cairo_surface_create_output(input1, input2); set_cairo_surface_ci(out, ci_fp ); + Geom::Rect vp = filter_primitive_area( slot.get_units() ); + slot.set_primitive_area(_output, vp); // Needed for tiling + if (op == COMPOSITE_ARITHMETIC) { ink_cairo_surface_blend(input1, input2, out, ComposeArithmetic(k1, k2, k3, k4)); } else { diff --git a/src/display/nr-filter-merge.cpp b/src/display/nr-filter-merge.cpp index 2b9a24f25..fc2ce408f 100644 --- a/src/display/nr-filter-merge.cpp +++ b/src/display/nr-filter-merge.cpp @@ -38,6 +38,9 @@ void FilterMerge::render_cairo(FilterSlot &slot) ci_fp = (SPColorInterpolation)_style->color_interpolation_filters.computed; } + Geom::Rect vp = filter_primitive_area( slot.get_units() ); + slot.set_primitive_area(_output, vp); // Needed for tiling + // output is RGBA if at least one input is RGBA bool rgba32 = false; cairo_surface_t *out = NULL; -- cgit v1.2.3 From 7883844354e236e287bf33076190b270366ff8ee Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 3 Nov 2017 19:59:00 +0100 Subject: Minor tweak to symbols search UX --- src/ui/dialog/symbols.cpp | 8 ++++---- src/ui/dialog/symbols.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 082993158..2380ba56f 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -168,7 +168,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : icon_view->set_pixbuf_column( columns->symbol_image ); // Giving the iconview a small minimum size will help users understand // What the dialog does. - icon_view->set_size_request( 100, 200 ); + icon_view->set_size_request( 100, 250 ); std::vector< Gtk::TargetEntry > targets; targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); @@ -191,6 +191,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->set_hexpand(); overlay->set_vexpand(); overlay->add(* scroller); + scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); ++row; @@ -327,7 +328,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); overlay_icon = new Gtk::Image(); overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon = new Gtk::Image(noresults_icon); + overlay_icon = new Gtk::Image(); overlay_icon->set_halign(Gtk::ALIGN_CENTER ); overlay_icon->set_valign(Gtk::ALIGN_START ); overlay_icon->set_margin_top(45); @@ -364,11 +365,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); addSymbolsInDoc(current_document); /* Defaults to current document */ - sigc::connection desktopChangeConn = desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); desk_track.connect(GTK_WIDGET(gobj())); + overlay->hide(); } SymbolsDialog::~SymbolsDialog() @@ -820,7 +821,6 @@ void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector(r) ) { l.push_back(std::make_pair(doc_title,dynamic_cast(r))); } - for (auto& child: r->children) { symbolsInDocRecursive(&child, l, doc_title); } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 1bddc5b2c..13ba9caf9 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -105,8 +105,6 @@ private: std::map symbol_sets; std::vector > l; // Index into sizes which is selected - Glib::RefPtr noresults_icon; - Glib::RefPtr search_icon; int pack_size; // Scale factor int scale_factor; -- cgit v1.2.3 From a97a9d336818d0efc675c0578f8d02136f0836e7 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 3 Nov 2017 23:52:11 +0100 Subject: Add Ignore Gtk::Overlay if GTK=3.0 --- src/ui/dialog/symbols.cpp | 34 +++++++++++++++++++++++++++++----- src/ui/dialog/symbols.h | 3 ++- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 2380ba56f..727fdf4f2 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -108,13 +108,14 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : preview_document(0), instanceConns() { - /******************** Table *************************/ - table = new Gtk::Grid(); + + /******************** Table *************************/ + auto table = new Gtk::Grid(); table->set_margin_left(3); table->set_margin_right(3); table->set_margin_top(4); // panel is a cloked Gtk::VBox - _getContents()->pack_start(* Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; /******************** Symbol Sets *************************/ @@ -125,6 +126,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : symbol_set->append(_("All symbols sets")); symbol_set->set_active_text(_("Current Document")); symbol_set->set_hexpand(); + table->attach(*Gtk::manage(symbol_set),1,row,1,1); sigc::connection connSet = symbol_set->signal_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::rebuild)); @@ -187,13 +189,16 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : scroller->add(*Gtk::manage(icon_view)); scroller->set_hexpand(); scroller->set_vexpand(); +#if GTK_CHECK_VERSION(3,2,4) overlay = new Gtk::Overlay(); overlay->set_hexpand(); overlay->set_vexpand(); overlay->add(* scroller); scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); - +#else + table->attach(*Gtk::manage(scroller),0,row,2,1); +#endif ++row; /******************** Progress *******************************/ @@ -319,6 +324,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : SPDefs *defs = current_document->getDefs(); /*************************Overlays******************************/ +#if GTK_CHECK_VERSION(3,2,4) //Loading overlay_opacity = new Gtk::Image(); overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); @@ -348,7 +354,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->add_overlay(* overlay_icon); overlay->add_overlay(* overlay_title); overlay->add_overlay(* overlay_desc); - +#endif sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); @@ -369,7 +375,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); desk_track.connect(GTK_WIDGET(gobj())); +#if GTK_CHECK_VERSION(3,2,4) overlay->hide(); +#endif } SymbolsDialog::~SymbolsDialog() @@ -930,6 +938,7 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); +#if GTK_CHECK_VERSION(3,2,4) if (current == _("All symbols sets") && search->get_text() != _("Loading documents...")) { @@ -954,17 +963,22 @@ bool SymbolsDialog::callbackSymbols(){ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); } } +#endif if (current == _("All symbols sets") && search->get_text() == _("Loading documents...") ) { +#if GTK_CHECK_VERSION(3,2,4) overlay_opacity->show(); +#endif if (!all_docs_processed) { +#if GTK_CHECK_VERSION(3,2,4) overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); overlay_icon->set_from_icon_name("searching", iconsize); overlay_desc->show(); +#endif } size_t counter = 0; for(auto const &symbol_document_map : symbol_sets) { @@ -981,19 +995,23 @@ bool SymbolsDialog::callbackSymbols(){ progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); return true; } +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->hide(); overlay_title->hide(); overlay_desc->hide(); +#endif progress_bar->set_fraction(1.0); all_docs_processed = true; addSymbols(); search->set_text("Documents done, searchig inside..."); return true; } else if (l.size()) { +#if GTK_CHECK_VERSION(3,2,4) overlay_opacity->show(); overlay_icon->hide(); overlay_title->hide(); overlay_desc->hide(); +#endif for (auto symbol_data = l.begin(); symbol_data != l.end();) { Glib::ustring doc_title = symbol_data->first; SPSymbol * symbol = symbol_data->second; @@ -1028,6 +1046,7 @@ bool SymbolsDialog::callbackSymbols(){ return true; } } +#if GTK_CHECK_VERSION(3,2,4) if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); @@ -1038,6 +1057,7 @@ bool SymbolsDialog::callbackSymbols(){ } else { overlay_opacity->hide(); } +#endif sensitive = false; search->set_text(search_str); sensitive = true; @@ -1067,12 +1087,14 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { l = container_symbols_tmp; container_symbols_tmp.clear(); if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_title->show(); overlay_desc->show(); +#endif sensitive = false; search->set_text(search_str); sensitive = true; @@ -1100,12 +1122,14 @@ void SymbolsDialog::addSymbols() { l = container_symbols; container_symbols.clear(); if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); +#endif sensitive = false; search->set_text(search_str); sensitive = true; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 13ba9caf9..ebd56d5e0 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -128,12 +128,13 @@ private: Gtk::Button* more; Gtk::Button* fewer; Gtk::HBox* tools; +#if GTK_CHECK_VERSION(3,2,4) Gtk::Overlay* overlay; +#endif Gtk::Image* overlay_icon; Gtk::Image* overlay_opacity; Gtk::Label* overlay_title; Gtk::Label* overlay_desc; - Gtk::Grid* table; Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; Gtk::IconSize iconsize; -- cgit v1.2.3 From c51823602c76838600f21683fce839b3938ffc25 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 4 Nov 2017 10:31:30 +0100 Subject: Remove need to restart Inkscape when changing tile multiplier. Increase default and maximum values of tile multiplier. --- src/display/sp-canvas.cpp | 7 ++----- src/ui/dialog/inkscape-preferences.cpp | 5 +++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 17c4cc0d5..7acd645c8 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1755,11 +1755,8 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); - static unsigned tile_multiplier = 0; - if (tile_multiplier == 0) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - tile_multiplier = prefs->getIntLimited("/options/rendering/tile-multiplier", 1, 1, 64); - } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + unsigned tile_multiplier = prefs->getIntLimited("/options/rendering/tile-multiplier", 16, 1, 512); if (_rendermode != Inkscape::RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 09ba06720..0801ae0a1 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1420,8 +1420,9 @@ void InkscapePreferences::initPageRendering() _page_rendering.add_line( false, _("Rendering _cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); // rendering tile multiplier - _rendering_tile_multiplier.init("/options/rendering/tile-multiplier", 1.0, 64.0, 1.0, 4.0, 1.0, true, false); - _page_rendering.add_line( false, _("Rendering tile multiplier:"), _rendering_tile_multiplier, _("requires restart"), _("Set the relative size of tiles used to render the canvas. The larger the value, the bigger the tile size."), false); + _rendering_tile_multiplier.init("/options/rendering/tile-multiplier", 1.0, 512.0, 1.0, 16.0, 16.0, true, false); + _page_rendering.add_line( false, _("Rendering tile multiplier:"), _rendering_tile_multiplier, _(""), + _("Set the relative size of tiles used to render the canvas. The larger the value, the bigger the tile size."), false); /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", -- cgit v1.2.3 From 8f44cbb000a8abc0ada09a3d13f78c33dd510925 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 4 Nov 2017 14:29:26 +0100 Subject: Fix FilterUnits::get_matrix_units2pb() for bounding box case. Fixes scaling in FilterMorphology when bounding box is used. Update FilterOffset to also use function. --- src/display/nr-filter-offset.cpp | 22 ++++------------------ src/display/nr-filter-units.cpp | 15 +++------------ 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 93bab7d39..718dc4e2c 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -42,25 +42,11 @@ void FilterOffset::render_cairo(FilterSlot &slot) Geom::Rect vp = filter_primitive_area( slot.get_units() ); slot.set_primitive_area(_output, vp); // Needed for tiling - // Handle bounding box case - double x = dx; - double y = dy; - if( slot.get_units().get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) { - Geom::OptRect bbox = slot.get_units().get_item_bbox(); - if( bbox ) { - x *= (*bbox).width(); - y *= (*bbox).height(); - } - } - - Geom::Affine trans = slot.get_units().get_matrix_user2pb(); - - Geom::Point offset(x, y); - offset *= trans; - offset[X] -= trans[4]; - offset[Y] -= trans[5]; + Geom::Affine p2pb = slot.get_units().get_matrix_primitiveunits2pb(); + double x = dx * p2pb.expansionX(); + double y = dy * p2pb.expansionY(); - cairo_set_source_surface(ct, in, offset[X], offset[Y]); + cairo_set_source_surface(ct, in, x, y); cairo_paint(ct); cairo_destroy(ct); diff --git a/src/display/nr-filter-units.cpp b/src/display/nr-filter-units.cpp index 369deeb00..e242e3963 100644 --- a/src/display/nr-filter-units.cpp +++ b/src/display/nr-filter-units.cpp @@ -83,24 +83,15 @@ Geom::Affine FilterUnits::get_matrix_user2pb() const { Geom::Affine FilterUnits::get_matrix_units2pb(SPFilterUnits units) const { if ( item_bbox && (units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) ) { + Geom::Affine u2pb = get_matrix_user2pb(); - Geom::Point origo(item_bbox->min()); - origo *= u2pb; - Geom::Point i_end(item_bbox->max()[X], item_bbox->min()[Y]); - i_end *= u2pb; - Geom::Point j_end(item_bbox->min()[X], item_bbox->max()[Y]); - j_end *= u2pb; - - double len_i = sqrt((origo[X] - i_end[X]) * (origo[X] - i_end[X]) - + (origo[Y] - i_end[Y]) * (origo[Y] - i_end[Y])); - double len_j = sqrt((origo[X] - j_end[X]) * (origo[X] - j_end[X]) - + (origo[Y] - j_end[Y]) * (origo[Y] - j_end[Y])); /* TODO: make sure that user coordinate system (0,0) is in correct * place in pixblock coordinates */ - Geom::Scale scaling(1.0 / len_i, 1.0 / len_j); + Geom::Scale scaling(item_bbox->width(), item_bbox->height()); u2pb *= scaling; return u2pb; + } else if (units == SP_FILTER_UNITS_USERSPACEONUSE) { return get_matrix_user2pb(); } else { -- cgit v1.2.3 From 6b568905ae43d8b982719b78bb001903a8e4cfbc Mon Sep 17 00:00:00 2001 From: Maren Hachmann Date: Sat, 4 Nov 2017 16:18:30 +0000 Subject: Fix typo in line spacing tool tip --- src/widgets/text-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 8c7bec75b..9e138bb08 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -2359,7 +2359,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje InkSelectOneAction* act = InkSelectOneAction::create( "TextLineSpacingAction", // Name _("Line Spacing Mode"), // Label - _("How should multiple baselines be spaced?\n Adapative: Line spacing adapts to font size.\n Minimum: Like Adaptive but with a set minimum.\n Even: Evenly spaced.\n Adjustable: No restrictions."), // Tooltip + _("How should multiple baselines be spaced?\n Adaptive: Line spacing adapts to font size.\n Minimum: Like Adaptive, but with a set minimum.\n Even: Evenly spaced.\n Adjustable: No restrictions."), // Tooltip "Not Used", // Icon store ); // Tree store act->use_radio( false ); -- cgit v1.2.3 From 8e1c696fd91a7d3d1740e6e76617a75068245057 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 4 Nov 2017 16:08:32 +0100 Subject: Fix meessage parameter to allow min height request --- src/live_effects/lpe-measure-segments.cpp | 1 + src/live_effects/parameter/message.cpp | 24 ++++++++++++++++++------ src/live_effects/parameter/message.h | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 5ed587922..4bc9278fc 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -139,6 +139,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : helpline_overlap.param_set_increments(1, 1); helpline_overlap.param_set_digits(2); star_ellipse_fix = Geom::identity(); + message.param_set_min_height(95); } LPEMeasureSegments::~LPEMeasureSegments() {} diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp index 39d8f12c7..28e94a900 100644 --- a/src/live_effects/parameter/message.cpp +++ b/src/live_effects/parameter/message.cpp @@ -20,7 +20,8 @@ MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip message(g_strdup(default_message)), defmessage(g_strdup(default_message)) { - + _label = NULL; + _min_min_height = -1; } void @@ -54,6 +55,16 @@ MessageParam::param_getDefaultSVGValue() const return defmessage; } +void +MessageParam::param_set_min_height(int height) +{ + _min_height = height; + if (_label) { + _label->set_size_request(-1, _min_height); + } +} + + Gtk::Widget * MessageParam::param_newWidget() { @@ -61,11 +72,12 @@ MessageParam::param_newWidget() Gtk::Widget * widg_frame = frame->get_label_widget(); widg_frame->set_margin_right(5); widg_frame->set_margin_left(5); - Gtk::Label * label = new Gtk::Label (message, Gtk::ALIGN_END); - label->set_use_underline (true); - label->set_use_markup(); - label->set_line_wrap(true); - Gtk::Widget * widg_label = dynamic_cast (label); + _label = new Gtk::Label (message, Gtk::ALIGN_END); + _label->set_use_underline (true); + _label->set_use_markup(); + _label->set_line_wrap(true); + _label->set_size_request(-1, _min_height); + Gtk::Widget* widg_label = dynamic_cast (_label); widg_label->set_margin_top(8); widg_label->set_margin_bottom(10); widg_label->set_margin_right(6); diff --git a/src/live_effects/parameter/message.h b/src/live_effects/parameter/message.h index 63075cf96..2ac2c791a 100644 --- a/src/live_effects/parameter/message.h +++ b/src/live_effects/parameter/message.h @@ -33,10 +33,12 @@ public: void param_setValue(const gchar * message); virtual void param_set_default(); - + void param_set_min_height(int height); const gchar * get_value() const { return message; }; private: + Gtk::Label * _label; + int _min_height; MessageParam(const MessageParam&); MessageParam& operator=(const MessageParam&); gchar * message; -- cgit v1.2.3 From 3361a26a8f144b4baa95847e7801ed46468b6867 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 4 Nov 2017 16:46:17 +0100 Subject: Fix typo crash building --- src/live_effects/parameter/message.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp index 28e94a900..0e19c07e1 100644 --- a/src/live_effects/parameter/message.cpp +++ b/src/live_effects/parameter/message.cpp @@ -21,7 +21,7 @@ MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip defmessage(g_strdup(default_message)) { _label = NULL; - _min_min_height = -1; + _min_height = -1; } void -- cgit v1.2.3 From d79e73eff64fffc67a971641b5fa0a5b711f3360 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 4 Nov 2017 14:23:08 +0100 Subject: Make color selector visible hover white backgrounds if the selected color is opaque white --- src/ui/widget/color-picker.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 5a62c3c98..5c6820e83 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -33,7 +33,6 @@ ColorPicker::ColorPicker (const Glib::ustring& title, const Glib::ustring& tip, _colorSelectorDialog("dialogs.colorpickerwindow") { setupDialog(title); - set_relief (Gtk::RELIEF_NONE); _preview.show(); add (_preview); set_tooltip_text (tip); -- cgit v1.2.3 From 8d8f6375dcb32493a426ba8901467171fa2627e9 Mon Sep 17 00:00:00 2001 From: Simon Wells Date: Sun, 5 Nov 2017 12:51:54 +1300 Subject: added braces as specified in the coding standard --- src/ui/tools/select-tool.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 3dfb764bb..2468575c6 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -397,11 +397,13 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele next = std::find( cycling_items.begin(), cycling_items.end(), cycling_cur_item ); g_assert (next != cycling_items.end()); next++; - if (next == cycling_items.end()) - if ( cycling_wrap ) + if (next == cycling_items.end()) { + if ( cycling_wrap ) { next = cycling_items.begin(); - else + } else { next--; + } + } } } else { if (! cycling_cur_item) { -- cgit v1.2.3 From a204dbf637510ec05294670562de8cdfe4ab69e7 Mon Sep 17 00:00:00 2001 From: Simon Wells Date: Sun, 5 Nov 2017 12:56:42 +1300 Subject: Change abs to std::abs to fix warnings --- src/extension/internal/emf-inout.cpp | 2 +- src/extension/internal/pdfinput/pdf-parser.cpp | 8 ++++---- src/helper/geom-pathstroke.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 92deb2e19..e47ce48bf 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -1056,7 +1056,7 @@ Emf::pix_to_abs_size(PEMF_CALLBACK_DATA d, double px) void Emf::snap_to_faraway_pair(double *x, double *y) { - if((abs(abs(*x) - faraway)/faraway <= 1e-4) && (abs(abs(*y) - faraway)/faraway <= 1e-4)){ + if((std::abs(std::abs(*x) - faraway)/faraway <= 1e-4) && (std::abs(std::abs(*y) - faraway)/faraway <= 1e-4)){ *x = (*x > 0 ? faraway : -faraway); *y = (*y > 0 ? faraway : -faraway); } diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp index 604b7f807..15bc2d746 100644 --- a/src/extension/internal/pdfinput/pdf-parser.cpp +++ b/src/extension/internal/pdfinput/pdf-parser.cpp @@ -2189,13 +2189,13 @@ void PdfParser::fillPatch(GfxPatch *patch, int nComps, int depth) { int i; for (i = 0; i < nComps; ++i) { - if (abs(patch->color[0][0].c[i] - patch->color[0][1].c[i]) + if (std::abs(patch->color[0][0].c[i] - patch->color[0][1].c[i]) > patchColorDelta || - abs(patch->color[0][1].c[i] - patch->color[1][1].c[i]) + std::abs(patch->color[0][1].c[i] - patch->color[1][1].c[i]) > patchColorDelta || - abs(patch->color[1][1].c[i] - patch->color[1][0].c[i]) + std::abs(patch->color[1][1].c[i] - patch->color[1][0].c[i]) > patchColorDelta || - abs(patch->color[1][0].c[i] - patch->color[0][0].c[i]) + std::abs(patch->color[1][0].c[i] - patch->color[0][0].c[i]) > patchColorDelta) { break; } diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index 50627fd0b..c3e4f8213 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -341,8 +341,8 @@ Geom::Point adjust_circles( Geom::Circle &circle1, Geom::Circle &circle2, Geom:: Geom::Point p0 = points[0].point(); Geom::Point p1 = points[1].point(); // std::cout << " points: " << p0 << "; " << p1 << std::endl; - if( abs( Geom::distance( p0, circle2.center() ) - circle2.radius() ) < - abs( Geom::distance( p1, circle2.center() ) - circle2.radius() ) ) { + if( std::abs( Geom::distance( p0, circle2.center() ) - circle2.radius() ) < + std::abs( Geom::distance( p1, circle2.center() ) - circle2.radius() ) ) { return p0; } else { return p1; -- cgit v1.2.3 From 0ee0c59c2fefac7b98a9b951c06f03786f3d0af2 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Mon, 6 Nov 2017 20:19:35 +0100 Subject: Fixes to Filter Dialog --- src/ui/dialog/filter-effects-dialog.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index bef37215a..e60785f57 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1749,7 +1749,6 @@ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) _in_drag(0), _observer(new Inkscape::XML::SignalObserver) { - d.signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK); @@ -1926,7 +1925,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrset_text(_(FPInputConverter.get_label((FilterPrimitiveInput)i).c_str())); const int x = text_start_x + get_input_type_width() * i; cr->save(); - cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); gdk_cairo_set_source_rgba(cr->cobj(), &bg_color); + cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); cr->fill_preserve(); gdk_cairo_set_source_rgba(cr->cobj(), &fg_color); - cr->move_to(x+get_input_type_width(), 0); + cr->move_to(x + get_input_type_width(), 5); cr->rotate_degrees(90); _vertical_layout->show_in_cairo_context(cr); @@ -1974,6 +1972,8 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrstroke(); cr->restore(); } + cr->rectangle(vis.get_x(), 0, vis.get_width(), vis.get_height()); + cairo_clip(cr->cobj()); } int row_index = 0; @@ -1993,6 +1993,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrget_device_manager(); auto device = dm->get_client_pointer(); #endif + cairo_set_line_width (cr->cobj(),0.5); get_bin_window()->get_device_position(device, mx, my, mask); // Outline the bottom of the connection area @@ -2001,7 +2002,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrcobj(), &mid_color); - cr->move_to(x, y + h); + cr->move_to(vis.get_x(), y + h); cr->line_to(outline_x, y + h); // Side outline cr->line_to(outline_x, y - 1); @@ -2023,7 +2024,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); gdk_cairo_set_source_rgba(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? + (inside && mask & GDK_BUTTON1_MASK) ? &mid_color : &mid_color_active); @@ -2052,7 +2053,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); gdk_cairo_set_source_rgba(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? + (inside && mask & GDK_BUTTON1_MASK) ? &mid_color : &mid_color_active); @@ -2078,7 +2079,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtrsave(); gdk_cairo_set_source_rgba(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? + (inside && mask & GDK_BUTTON1_MASK) ? &mid_color : &mid_color_active); @@ -2628,8 +2629,8 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL); // Initialize widget hierarchy - auto hpaned = Gtk::manage(new Gtk::Paned); - _primitive_box = Gtk::manage(new Gtk::Paned); + auto hpaned = Gtk::manage(new Gtk::Paned()); + _primitive_box = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL)); _sw_infobox = Gtk::manage(new Gtk::ScrolledWindow); Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); @@ -2659,7 +2660,7 @@ FilterEffectsDialog::FilterEffectsDialog() _infobox_desc.set_valign(Gtk::ALIGN_START); _infobox_desc.set_justify(Gtk::JUSTIFY_LEFT); _infobox_desc.set_line_wrap(true); - _infobox_desc.set_size_request(200, -1); + _infobox_desc.set_size_request(300, -1); vb_desc->pack_start(_infobox_desc, true, true); @@ -2667,7 +2668,7 @@ FilterEffectsDialog::FilterEffectsDialog() infobox->pack_start(*vb_desc, true, true); //_sw_infobox->set_size_request(-1, -1); - _sw_infobox->set_size_request(200, -1); + _sw_infobox->set_size_request(300, -1); _sw_infobox->add(*infobox); //vb_prims->set_size_request(-1, 50); -- cgit v1.2.3 From 97f5dce9b826bcb8cf57b99e9961c725db3e7063 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 7 Nov 2017 02:06:23 +0100 Subject: Fixes to CPU --- src/ui/dialog/symbols.cpp | 11 ++++++++--- src/ui/dialog/symbols.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 727fdf4f2..51d801d6a 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -368,8 +368,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : getSymbolsFilename(); icons_found = false; - Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - addSymbolsInDoc(current_document); /* Defaults to current document */ sigc::connection desktopChangeConn = desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); @@ -385,6 +383,7 @@ SymbolsDialog::~SymbolsDialog() for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { it->disconnect(); } + idleconn.disconnect(); instanceConns.clear(); desk_track.disconnect(); } @@ -447,6 +446,8 @@ void SymbolsDialog::rebuild() { search->set_text(""); } if (symbol_document) { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); addSymbolsInDoc(symbol_document); } } @@ -895,6 +896,8 @@ void SymbolsDialog::clearSearch() SPDocument* symbol_document = selectedSymbols(); if (symbol_document) { //We are not in search all docs + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); icons_found = false; addSymbolsInDoc(symbol_document); } else { @@ -920,6 +923,8 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) progress_bar->set_fraction(0.0); enableWidgets(false); SPDocument* symbol_document = selectedSymbols(); + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); if (symbol_document) { //We are not in search all docs search->set_text(_("Searching...")); @@ -1062,7 +1067,7 @@ bool SymbolsDialog::callbackSymbols(){ search->set_text(search_str); sensitive = true; enableWidgets(true); - return true; + return false; } return true; } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index ebd56d5e0..a4d1f93fb 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -144,7 +144,9 @@ private: DesktopTracker desk_track; SPDocument* current_document; SPDocument* preview_document; /* Document to render single symbol */ - + + sigc::connection idleconn; + /* For rendering the template drawing */ unsigned key; Inkscape::Drawing renderDrawing; -- cgit v1.2.3 From 2659ce5a325688a3db9900d6d662e92048f0539e Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 7 Nov 2017 13:55:26 -0500 Subject: Misc. typos Found using `codespell -q 3 -w --skip="*.svg,*.po,*.ts,./share/tutorials,./src/libavoid,./packaging/win32/languages,./man,./src/2geom" -I ../inkscape-whitelist.txt` whereby whitelist file contained: ``` dum iff glight substract te upto ``` --- src/axis-manip.h | 4 +- src/box3d.cpp | 2 +- src/desktop.cpp | 2 +- src/display/drawing-context.cpp | 2 +- src/display/drawing-item.cpp | 2 +- src/display/drawing-pattern.h | 2 +- src/display/nr-filter-displacement-map.cpp | 2 +- src/display/nr-filter-gaussian.cpp | 2 +- src/display/nr-filter-image.cpp | 2 +- src/display/nr-filter-skeleton.cpp | 4 +- src/display/nr-filter-skeleton.h | 4 +- src/display/nr-filter.h | 2 +- src/display/nr-light.h | 12 ++-- src/display/sodipodi-ctrlrect.cpp | 2 +- src/document-subset.cpp | 2 +- src/document-undo.cpp | 2 +- src/document.h | 2 +- src/event-log.h | 6 +- src/extension/dbus/document-interface.cpp | 2 +- src/extension/dbus/document-interface.h | 2 +- src/extension/dbus/document-interface.xml | 2 +- src/extension/dbus/proposed-interface.xml | 2 +- src/extension/dependency.h | 2 +- src/extension/error-file.cpp | 4 +- src/extension/execution-env.cpp | 2 +- src/extension/execution-env.h | 2 +- src/extension/extension.cpp | 2 +- src/extension/implementation/script.cpp | 8 +-- src/extension/init.cpp | 2 +- src/extension/internal/bluredge.cpp | 2 +- src/extension/internal/cairo-render-context.cpp | 4 +- src/extension/internal/gimpgrad.cpp | 8 +-- src/extension/internal/grid.cpp | 2 +- src/extension/internal/image-resolution.cpp | 2 +- src/extension/internal/javafx-out.cpp | 2 +- src/extension/internal/odf.cpp | 4 +- src/extension/internal/text_reassemble.c | 2 +- src/extension/internal/text_reassemble.h | 2 +- src/extension/param/parameter.h | 2 +- src/extension/plugins/grid2/grid.cpp | 2 +- src/extension/system.cpp | 2 +- src/helper/geom-nodetype.h | 2 +- src/helper/geom-satellite.cpp | 2 +- src/helper/geom-satellite.h | 4 +- src/helper/pixbuf-ops.cpp | 2 +- src/helper/stock-items.cpp | 2 +- src/inkview.cpp | 4 +- src/io/base64stream.cpp | 2 +- src/io/resource.cpp | 4 +- src/layer-model.cpp | 2 +- src/libcroco/cr-parser.c | 78 ++++++++++++------------ src/live_effects/effect.cpp | 8 +-- src/live_effects/lpe-bool.cpp | 2 +- src/live_effects/lpe-dynastroke.cpp | 4 +- src/live_effects/lpe-embrodery-stitch-ordering.h | 2 +- src/live_effects/lpe-embrodery-stitch.cpp | 2 +- src/live_effects/lpe-envelope.cpp | 2 +- src/live_effects/lpe-fillet-chamfer.cpp | 6 +- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/lpe-lattice2.cpp | 2 +- src/live_effects/lpe-ruler.cpp | 2 +- src/live_effects/lpe-sketch.cpp | 2 +- src/live_effects/lpe-vonkoch.cpp | 2 +- src/live_effects/lpe-vonkoch.h | 2 +- src/live_effects/lpeobject-reference.h | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/live_effects/parameter/satellitesarray.h | 10 +-- src/persp3d-reference.h | 2 +- src/preferences.cpp | 2 +- src/rdf.cpp | 4 +- src/resource-manager.cpp | 6 +- src/selection-chemistry.cpp | 4 +- src/selection-chemistry.h | 2 +- src/shortcuts.cpp | 2 +- src/snap-enums.h | 2 +- src/sp-text.cpp | 2 +- src/sp-tref.cpp | 2 +- src/sp-use.cpp | 2 +- src/splivarot.cpp | 4 +- src/style-internal.h | 6 +- src/style.cpp | 4 +- src/svg-profile.h | 2 +- src/svg-view-slideshow.h | 2 +- src/ui/clipboard.cpp | 2 +- src/ui/dialog/align-and-distribute.cpp | 2 +- src/ui/dialog/align-and-distribute.h | 2 +- src/ui/dialog/dock-behavior.h | 2 +- src/ui/dialog/document-properties.cpp | 2 +- src/ui/dialog/extension-editor.cpp | 2 +- src/ui/dialog/filedialog.h | 2 +- src/ui/dialog/filedialogimpl-gtkmm.cpp | 6 +- src/ui/dialog/filedialogimpl-gtkmm.h | 2 +- src/ui/dialog/filedialogimpl-win32.cpp | 4 +- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/input.cpp | 2 +- src/ui/dialog/ocaldialogs.cpp | 4 +- src/ui/dialog/polar-arrange-tab.cpp | 2 +- src/ui/dialog/print-colors-preview-dialog.cpp | 2 +- src/ui/dialog/styledialog.cpp | 4 +- src/ui/dialog/xml-tree.cpp | 4 +- src/ui/tool/node.cpp | 12 ++-- src/ui/tool/path-manipulator.cpp | 2 +- src/ui/tools/gradient-tool.cpp | 2 +- src/ui/tools/measure-tool.cpp | 2 +- src/ui/widget/color-notebook.cpp | 2 +- src/ui/widget/font-variants.cpp | 2 +- src/ui/widget/object-composite-settings.cpp | 2 +- src/ui/widget/panel.h | 2 +- src/uri.cpp | 2 +- src/uri.h | 2 +- src/widgets/ege-adjustment-action.cpp | 2 +- src/widgets/ege-adjustment-action.h | 2 +- src/widgets/fill-style.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/paint-selector.cpp | 2 +- src/widgets/sp-color-selector.cpp | 2 +- src/widgets/stroke-marker-selector.h | 2 +- src/widgets/stroke-style.cpp | 2 +- src/widgets/text-toolbar.cpp | 2 +- src/xml/rebase-hrefs.cpp | 2 +- 121 files changed, 210 insertions(+), 210 deletions(-) (limited to 'src') diff --git a/src/axis-manip.h b/src/axis-manip.h index 28875b2f5..032ee04ba 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -216,7 +216,7 @@ inline Box3D::Axis third_axis_direction (Box3D::Axis plane) { return (Box3D::Axis) (plane ^ 0x7); } -/* returns the first/second axis direction occuring in the (possibly compound) expression 'dirs' */ +/* returns the first/second axis direction occurring in the (possibly compound) expression 'dirs' */ inline Box3D::Axis extract_first_axis_direction (Box3D::Axis dirs) { if (dirs & Box3D::X) return Box3D::X; if (dirs & Box3D::Y) return Box3D::Y; @@ -231,7 +231,7 @@ inline Box3D::Axis orth_plane_or_axis (Box3D::Axis axis) { return (Box3D::Axis) (Box3D::XYZ ^ axis); } -/* returns an axis direction perpendicular to the ones occuring in the (possibly compound) expression 'dirs' */ +/* returns an axis direction perpendicular to the ones occurring in the (possibly compound) expression 'dirs' */ inline Box3D::Axis get_perpendicular_axis_direction (Box3D::Axis dirs) { if (!(dirs & Box3D::X)) return Box3D::X; if (!(dirs & Box3D::Y)) return Box3D::Y; diff --git a/src/box3d.cpp b/src/box3d.cpp index 98f49e52a..af1d00b0f 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -962,7 +962,7 @@ box3d_recompute_z_orders (SPBox3D *box) { break; default: /* - * For each VP F, check wether the half-line from the corner3 to F crosses the line segment + * For each VP F, check whether the half-line from the corner3 to F crosses the line segment * joining the other two VPs. If this is the case, it determines the "central" corner from * which the visible sides can be deduced. Otherwise, corner3 is the central corner. */ diff --git a/src/desktop.cpp b/src/desktop.cpp index 2d1aa8829..1264e0184 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -188,7 +188,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid SPCanvasGroup *root = canvas->getRoot(); - /* Setup adminstrative layers */ + /* Setup administrative layers */ acetate = sp_canvas_item_new (root, GNOME_TYPE_CANVAS_ACETATE, NULL); g_signal_connect (G_OBJECT (acetate), "event", G_CALLBACK (sp_desktop_root_handler), this); main = (SPCanvasGroup *) sp_canvas_item_new (root, SP_TYPE_CANVAS_GROUP, NULL); diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp index 319136e06..1a1f20425 100644 --- a/src/display/drawing-context.cpp +++ b/src/display/drawing-context.cpp @@ -41,7 +41,7 @@ DrawingContext::Save::~Save() void DrawingContext::Save::save(DrawingContext &dc) { if (_dc) { - // TODO: it might be better to treat this occurence as a bug + // TODO: it might be better to treat this occurrence as a bug _dc->restore(); } _dc = &dc; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index c4af81efc..43db4f259 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -99,7 +99,7 @@ void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { * you always need to delete the item views of children before deleting * the view of the parent. Do not call delete on things returned from show() * - this will cause dangling pointers inside the SPItem and lead to a crash. - * Use the corresponing hide() method. + * Use the corresponding hide() method. * * Outside of the SP tree, you should not use any references after the root node * has been deleted. diff --git a/src/display/drawing-pattern.h b/src/display/drawing-pattern.h index dc1f93ed1..43e0e97e1 100644 --- a/src/display/drawing-pattern.h +++ b/src/display/drawing-pattern.h @@ -39,7 +39,7 @@ public: */ void setPatternToUserTransform(Geom::Affine const &new_trans); /** - * Set the tile rect position and dimentions in content coordinate system + * Set the tile rect position and dimensions in content coordinate system */ void setTileRect(Geom::Rect const &tile_rect); /** diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp index 1b979fa6c..c0d1ae411 100644 --- a/src/display/nr-filter-displacement-map.cpp +++ b/src/display/nr-filter-displacement-map.cpp @@ -145,7 +145,7 @@ void FilterDisplacementMap::area_enlarge(Geom::IntRect &area, Geom::Affine const double scalex = scale/2.*(std::fabs(trans[0])+std::fabs(trans[1])); double scaley = scale/2.*(std::fabs(trans[2])+std::fabs(trans[3])); - //FIXME: no +2 should be there!... (noticable only for big scales at big zoom factor) + //FIXME: no +2 should be there!... (noticeable only for big scales at big zoom factor) area.expandBy(scalex+2, scaley+2); } diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 24960af78..cdd01e75e 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -616,7 +616,7 @@ void FilterGaussian::render_cairo(FilterSlot &slot) // Decide which filter to use for X and Y // This threshold was determined by trial-and-error for one specific machine, // so there's a good chance that it's not optimal. - // Whatever you do, don't go below 1 (and preferrably not even below 2), as + // Whatever you do, don't go below 1 (and preferably not even below 2), as // the IIR filter gets unstable there. bool use_IIR_x = deviation_x > 3; bool use_IIR_y = deviation_y > 3; diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index af89d98e0..7e859314a 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -144,7 +144,7 @@ void FilterImage::render_cairo(FilterSlot &slot) * (See http://www.w3.org/TR/xmlbase/#resolution .) */ gchar *fullname = feImageHref; if ( !g_file_test( fullname, G_FILE_TEST_EXISTS ) ) { - // Try to load from relative postion combined with document base + // Try to load from relative position combined with document base if( document ) { fullname = g_build_filename( document->getBase(), feImageHref, NULL ); } diff --git a/src/display/nr-filter-skeleton.cpp b/src/display/nr-filter-skeleton.cpp index 86ab8141e..491c7f52a 100644 --- a/src/display/nr-filter-skeleton.cpp +++ b/src/display/nr-filter-skeleton.cpp @@ -1,14 +1,14 @@ /* * Filter primitive renderer skeleton class * You can create your new filter primitive renderer by replacing - * all occurences of Skeleton, skeleton and SKELETON with your filter + * all occurrences of Skeleton, skeleton and SKELETON with your filter * type, like gaussian or blend in respective case. * * This can be accomplished with the following sed command: * sed -e "s/Skeleton/Name/g" -e "s/skeleton/name/" -e "s/SKELETON/NAME/" * nr-filter-skeleton.cpp >nr-filter-name.cpp * - * (on one line, replace occurences of 'name' with your filter name) + * (on one line, replace occurrences of 'name' with your filter name) * * Remember to convert the .h file too. The sed command is same for both * files. diff --git a/src/display/nr-filter-skeleton.h b/src/display/nr-filter-skeleton.h index e17c244c1..6c92a4a09 100644 --- a/src/display/nr-filter-skeleton.h +++ b/src/display/nr-filter-skeleton.h @@ -4,14 +4,14 @@ /* * Filter primitive renderer skeleton class * You can create your new filter primitive renderer by replacing - * all occurences of Skeleton, skeleton and SKELETON with your filter + * all occurrences of Skeleton, skeleton and SKELETON with your filter * type, like gaussian or blend in respective case. * * This can be accomplished with the following sed command: * sed -e "s/Skeleton/Name/g" -e "s/skeleton/name/" -e "s/SKELETON/NAME/" * nr-filter-skeleton.h >nr-filter-name.h * - * (on one line, replace occurences of 'name' with your filter name) + * (on one line, replace occurrences of 'name' with your filter name) * * Remember to convert the .cpp file too. The sed command is same for both * files. diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 211d8ddd9..7028f2e81 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -40,7 +40,7 @@ public: * New primitive is placed so that it will be executed after all filter * primitives defined beforehand for this filter object. * Should this filter not have enough space for a new primitive, the filter - * is enlarged to accomodate the new filter element. It may be enlarged by + * is enlarged to accommodate the new filter element. It may be enlarged by * more that one element. * Returns a handle (non-negative integer) to the filter primitive created. * Returns -1, if type is not valid filter primitive type or filter diff --git a/src/display/nr-light.h b/src/display/nr-light.h index 94b573761..57c421f4a 100644 --- a/src/display/nr-light.h +++ b/src/display/nr-light.h @@ -42,14 +42,14 @@ class DistantLight { /** * Computes the light vector of the distant light * - * \param v a Fvector referece where we store the result + * \param v a Fvector reference where we store the result */ void light_vector(NR::Fvector &v); /** * Computes the light components of the distant light * - * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B + * \param lc a Fvector reference where we store the result, X=R, Y=G, Z=B */ void light_components(NR::Fvector &lc); @@ -77,7 +77,7 @@ class PointLight { * x, y and z are given in the arena_item coordinate, they are used as * is * - * \param v a Fvector referece where we store the result + * \param v a Fvector reference where we store the result * \param x x coordinate of the current point * \param y y coordinate of the current point * \param z z coordinate of the current point @@ -87,7 +87,7 @@ class PointLight { /** * Computes the light components of the distant light * - * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B + * \param lc a Fvector reference where we store the result, X=R, Y=G, Z=B */ void light_components(NR::Fvector &lc); @@ -118,7 +118,7 @@ class SpotLight { * x, y and z are given in the arena_item coordinate, they are used as * is * - * \param v a Fvector referece where we store the result + * \param v a Fvector reference where we store the result * \param x x coordinate of the current point * \param y y coordinate of the current point * \param z z coordinate of the current point @@ -129,7 +129,7 @@ class SpotLight { * Computes the light components of the distant light at the current * point. We only need the light vector to compute theses * - * \param lc a Fvector referece where we store the result, X=R, Y=G, Z=B + * \param lc a Fvector reference where we store the result, X=R, Y=G, Z=B * \param L the light vector of the current point */ void light_components(NR::Fvector &lc, const NR::Fvector &L); diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index 075e04e6d..a35f07c3d 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -212,7 +212,7 @@ void CtrlRect::render(SPCanvasBuf *buf) cairo_stroke_preserve(buf->ct); } - cairo_new_path( buf->ct ); // Clear path or get wierd artifacts. + cairo_new_path( buf->ct ); // Clear path or get weird artifacts. cairo_restore(buf->ct); } } diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 649b1a406..02607d527 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -65,7 +65,7 @@ struct DocumentSubset::Relations : public GC::Managed, } if ( first == last ) { - // compare to the single possiblity left + // compare to the single possibility left int pos = sp_object_compare_position(*last, obj); if ( pos < 0 ) { ++last; diff --git a/src/document-undo.cpp b/src/document-undo.cpp index f36010602..a66fb0ee8 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -34,7 +34,7 @@ * Gtk spinbutton) from the UI into a single undoable step. * * For controls implemented by Sodipodi itself, implementing undo as a - * single step is usually done in a more efficent way. Most controls have + * single step is usually done in a more efficient way. Most controls have * the abstract model of grab, drag, release, and change user * action. During the grab phase, all modifications are done to the * SPObject directly - i.e. they do not change XML tree, and thus do not diff --git a/src/document.h b/src/document.h index b60561c32..12f6cb724 100644 --- a/src/document.h +++ b/src/document.h @@ -312,7 +312,7 @@ private: * * 1. There is reference request dictionary, that contains * objects (styles) needing certain id. Object::build checks - * final id against it, and invokes necesary methods + * final id against it, and invokes necessary methods * * 2. Removing referenced object is simply prohibited - * needs analyse, how we can deal with situations, where diff --git a/src/event-log.h b/src/event-log.h index 6d4112a5a..c4c78d1dd 100644 --- a/src/event-log.h +++ b/src/event-log.h @@ -25,7 +25,7 @@ namespace Inkscape { class EventLogPrivate; /** - * A simple log for maintaining a history of commited, undone and redone events along with their + * A simple log for maintaining a history of committed, undone and redone events along with their * type. It implements the UndoStackObserver and should be registered with a * CompositeUndoStackObserver for each document. The event log is then notified on all commit, undo * and redo events and will store a representation of them in an internal Gtk::TreeStore. @@ -34,7 +34,7 @@ class EventLogPrivate; * as its children. * * If a Gtk::TreeView is connected to the event log, the TreeView's selection and its nodes - * expanded/collapsed state will be updated as events are commited, undone and redone. Whenever + * expanded/collapsed state will be updated as events are committed, undone and redone. Whenever * this happens, the event log will block the TreeView's callbacks to prevent circular updates. */ class EventLog : public UndoStackObserver, public sigc::trackable @@ -135,7 +135,7 @@ private: const_iterator _getUndoEvent() const; //< returns the current undoable event or NULL if none const_iterator _getRedoEvent() const; //< returns the current redoable event or NULL if none - void _clearUndo(); //< erase all previously commited events + void _clearUndo(); //< erase all previously committed events void _clearRedo(); //< erase all previously undone events void checkForVirginity(); //< marks the document as untouched if undo/redo reaches a previously saved state diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 513ec2f5c..c85281aa4 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -151,7 +151,7 @@ get_name_from_object (SPObject * obj) /* * Some verbs (cut, paste) only work on the active layer. - * This makes sure that the document that is about to recive a command is active. + * This makes sure that the document that is about to receive a command is active. */ void desktop_ensure_active (SPDesktop* desk) { diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h index 27460de52..0150dae7e 100644 --- a/src/extension/dbus/document-interface.h +++ b/src/extension/dbus/document-interface.h @@ -125,7 +125,7 @@ document_interface_node (DocumentInterface *doc_interface, gchar *svgtype, /**************************************************************************** - ENVIORNMENT FUNCTIONS + ENVIRONMENT FUNCTIONS ****************************************************************************/ gdouble document_interface_document_get_width (DocumentInterface *doc_interface); diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml index 7481c0893..2287e9c32 100644 --- a/src/extension/dbus/document-interface.xml +++ b/src/extension/dbus/document-interface.xml @@ -763,7 +763,7 @@ c - Get the path value of an object. Equivilent to calling get_attribte() with argument "d". Will not turn object into a path if it is not already. + Get the path value of an object. Equivalent to calling get_attribte() with argument "d". Will not turn object into a path if it is not already. Paths diff --git a/src/extension/dbus/proposed-interface.xml b/src/extension/dbus/proposed-interface.xml index ac74b64f9..2a45c1d52 100644 --- a/src/extension/dbus/proposed-interface.xml +++ b/src/extension/dbus/proposed-interface.xml @@ -105,7 +105,7 @@ - A single letter denoting what type of node is beeing appended. + A single letter denoting what type of node is being appended. diff --git a/src/extension/dependency.h b/src/extension/dependency.h index 8f5dcc0c8..5e58fe06b 100644 --- a/src/extension/dependency.h +++ b/src/extension/dependency.h @@ -39,7 +39,7 @@ class Dependency { /** \brief All of the possible locations to look for the dependency. */ enum location_t { - LOCATION_PATH, /**< Look in the PATH for this depdendency */ + LOCATION_PATH, /**< Look in the PATH for this dependency */ LOCATION_EXTENSIONS, /**< Look in the extensions directory */ LOCATION_ABSOLUTE, /**< This dependency is already defined in absolute terms */ LOCATION_CNT /**< Number of locations to look */ diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp index 063e43f42..20dcc0f5f 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -50,7 +50,7 @@ ErrorFileNotice::ErrorFileNotice (void) : { // \FIXME change this - /* This is some filler text, needs to change before relase */ + /* This is some filler text, needs to change before release */ Glib::ustring dialog_text(_("One or more extensions failed to load\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: ")); gchar * ext_error_file = Inkscape::IO::Resource::log_path(EXTENSION_ERROR_LOG_FILENAME); dialog_text += ext_error_file; @@ -59,7 +59,7 @@ ErrorFileNotice::ErrorFileNotice (void) : auto vbox = get_content_area(); - /* This is some filler text, needs to change before relase */ + /* This is some filler text, needs to change before release */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); checkbutton = Gtk::manage(new Gtk::CheckButton(_("Show dialog on startup"))); vbox->pack_start(*checkbutton, true, false, 5); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 624813863..f75b06937 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -97,7 +97,7 @@ ExecutionEnv::genDocCache (void) { return; } -/** \brief Destory a document cache +/** \brief Destroy a document cache Just delete it. */ diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h index 795f5a65a..a57c7b8c9 100644 --- a/src/extension/execution-env.h +++ b/src/extension/execution-env.h @@ -69,7 +69,7 @@ private: bool _show_errors; public: - /** \brief Create a new context for exection of an effect + /** \brief Create a new context for execution of an effect \param effect The effect to execute \param doc The document to execute the effect on \param docCache The implementation cache of the document. May be diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index d9ea5eca7..240d28a59 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -365,7 +365,7 @@ Extension::get_name (void) mark to the world that it has been deactivated. It also removes the current implementation and replaces it with a standard one. This makes it so that we don't have to continually check if there is an - implementation, but we are gauranteed to have a benign one. + implementation, but we are guaranteed to have a benign one. \warning It is important to note that there is no 'activate' function. Running this function is irreversable. diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 2901655f1..eb98711bc 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -426,7 +426,7 @@ ImplementationDocumentCache *Script::newDocCache( Inkscape::Extension::Extension /** \return A dialog for preferences - \brief A stub funtion right now + \brief A stub function right now \param module Module who's preferences need getting \param filename Hey, the file you're getting might be important @@ -442,7 +442,7 @@ Gtk::Widget *Script::prefs_input(Inkscape::Extension::Input *module, /** \return A dialog for preferences - \brief A stub funtion right now + \brief A stub function right now \param module Module whose preferences need getting This function should really do something, right now it doesn't. @@ -602,8 +602,8 @@ void Script::save(Inkscape::Extension::Output *module, /** \return none - \brief This function uses an extention as a effect on a document. - \param module Extention to effect with. + \brief This function uses an extension as an effect on a document. + \param module Extension to effect with. \param doc Document to run through the effect. This function is a little bit trickier than the previous two. It diff --git a/src/extension/init.cpp b/src/extension/init.cpp index 699c0382f..17c07ae1d 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -113,7 +113,7 @@ using namespace Inkscape::IO::Resource; namespace Inkscape { namespace Extension { -/** This is the extention that all files are that are pulled from +/** This is the extension that all files are that are pulled from the extension directory and parsed */ #define SP_MODULE_EXTENSION "inx" diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index d1fe357da..1040ef194 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -36,7 +36,7 @@ namespace Internal { /** \brief A function to allocated anything -- just an example here \param module Unused - \return Whether the load was sucessful + \return Whether the load was successful */ bool BlurEdge::load (Inkscape::Extension::Extension */*module*/) diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 3edb58a13..972081c0d 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -606,7 +606,7 @@ CairoRenderContext::popLayer(void) clip_ctx->setImageTarget(CAIRO_FORMAT_A8); clip_ctx->setClipMode(CLIP_MODE_MASK); // Raster // This code ties the clipping to the document coordinates. It doesn't allow - // for a clipped object intially drawn off the page and then translated onto + // for a clipped object initially drawn off the page and then translated onto // the page. if (!clip_ctx->setupSurface(_width, _height)) { TRACE(("clip: setupSurface failed\n")); @@ -1482,7 +1482,7 @@ CairoRenderContext::_prepareRenderText() } /* We need CairoPaintOrder as markers are rendered in a separate step and may be rendered - * inbetween fill and stroke. + * in between fill and stroke. */ bool CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox, CairoPaintOrder order) diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp index 8c348dfbb..e6a429d34 100644 --- a/src/extension/internal/gimpgrad.cpp +++ b/src/extension/internal/gimpgrad.cpp @@ -35,7 +35,7 @@ namespace Internal { /** \brief A function to allocate anything -- just an example here \param module Unused - \return Whether the load was sucessful + \return Whether the load was successful */ bool GimpGrad::load (Inkscape::Extension::Extension */*module*/) { @@ -106,10 +106,10 @@ static Glib::ustring stop_svg(ColorRGBA const in_color, double const location) of entries just reading until it fails. The other small piece of trickery here is that GIMP gradients define - a left possition, right possition and middle possition. SVG gradients - have no middle possition in them. In order to handle this case the + a left position, right position and middle position. SVG gradients + have no middle position in them. In order to handle this case the left and right colors are averaged in a linear manner and the middle - possition is used for that color. + position is used for that color. That is another point, the GIMP gradients support many different types of gradients -- linear being the most simple. This plugin assumes diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 9e730f5e5..649859ee5 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -42,7 +42,7 @@ namespace Internal { /** \brief A function to allocated anything -- just an example here \param module Unused - \return Whether the load was sucessful + \return Whether the load was successful */ bool Grid::load (Inkscape::Extension::Extension */*module*/) diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index 57142bbdd..558276999 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -414,7 +414,7 @@ void ImageResolution::readmagick(char const *fn) { x_ = image.xResolution(); y_ = image.yResolution(); -// TODO: find out why the hell the following convertion is necessary +// TODO: find out why the hell the following conversion is necessary if (type == "BMP") { x_ = Inkscape::Util::Quantity::convert(x_, "in", "cm"); y_ = Inkscape::Util::Quantity::convert(y_, "in", "cm"); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index d7ad7e6f7..56ea46808 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -82,7 +82,7 @@ static void err(const char *fmt, ...) * tree and finds all of the opacities and multiplies them. * * We use this for our "flat" object output. If the code is modified - * to reflect a tree of , then this will be unneccessary. + * to reflect a tree of , then this will be unnecessary. */ static double effective_opacity(const SPStyle *style) { diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index f885ef5e5..db18dd2ca 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -6,7 +6,7 @@ * within Inkscape. Although the initial implementations will be very lossy * due to the differences in the models of SVG and ODF, they will hopefully * improve greatly with time. People should consider this to be a framework - * that can be continously upgraded for ever improving fidelity. Potential + * that can be continuously upgraded for ever improving fidelity. Potential * developers should especially look in preprocess() and writeTree() to see how * the SVG tree is scanned, read, translated, and then written to ODF. * @@ -1400,7 +1400,7 @@ bool OdfOutput::processStyle(SPItem *item, const Glib::ustring &id, const Glib:: } } - // Dont need a new style + // Don't need a new style if (styleMatch) { return false; diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c index b23176ed5..b191d4ea2 100644 --- a/src/extension/internal/text_reassemble.c +++ b/src/extension/internal/text_reassemble.c @@ -63,7 +63,7 @@ Optional compiler switches for development: -DDBG_TR_INPUT draw input text and their bounding rectangles in SVG output -DTEST build the test program -DDBG_LOOP force the test program to cycle 5 times. Useful for finding - memory leaks. Ouput file is overwritten each time. + memory leaks. Output file is overwritten each time. File: text_reassemble.c diff --git a/src/extension/internal/text_reassemble.h b/src/extension/internal/text_reassemble.h index 6c1acafe5..1c6c17c78 100644 --- a/src/extension/internal/text_reassemble.h +++ b/src/extension/internal/text_reassemble.h @@ -231,7 +231,7 @@ typedef struct { \brief List of all members of a single complex. */ typedef struct { - int *members; /**< array of immediate children (for TR_PARA_* these are indicies + int *members; /**< array of immediate children (for TR_PARA_* these are indices for TR_TEXT or TR_LINE complexes also in cxi. For TR_TEXT and TR_LINE these are indices to the actual text in tpi.) */ uint32_t space; /**< storage slots allocated */ diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index 96cc055d8..b1825d444 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -158,7 +158,7 @@ public: const static int GUI_PARAM_WIDGETS_SPACING = 4; /** Recommended indentation width of parameters (in px) */ const static int GUI_INDENTATION = 12; - /** Recommended maximum line lenght for wrapping textual parameters (in chars) */ + /** Recommended maximum line length for wrapping textual parameters (in chars) */ const static int GUI_MAX_LINE_LENGTH = 60; diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index 233d4e522..256bb8dc2 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -42,7 +42,7 @@ namespace Internal { /** \brief A function to allocated anything -- just an example here \param module Unused - \return Whether the load was sucessful + \return Whether the load was successful */ bool Grid::load (Inkscape::Extension::Extension */*module*/) diff --git a/src/extension/system.cpp b/src/extension/system.cpp index afa8346df..e5b83cd20 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -323,7 +323,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension, doc->changeUriAndHrefs(saved_uri); } doc->setModifiedSinceSave(saved_modified); - // free used ressources + // free used resources g_free(saved_output_extension); g_free(saved_dataloss); g_free(saved_uri); diff --git a/src/helper/geom-nodetype.h b/src/helper/geom-nodetype.h index 2d299d545..0272318a2 100644 --- a/src/helper/geom-nodetype.h +++ b/src/helper/geom-nodetype.h @@ -32,7 +32,7 @@ typedef enum { NODE_CUSP, /** This node continuously joins two segments, with continuous *unit* tangent. */ NODE_SMOOTH, -/** This node is symmetric. I.e. continously joins two segments with continuous derivative */ +/** This node is symmetric. I.e. continuously joins two segments with continuous derivative */ NODE_SYMM } NodeType; diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index 8a92273d0..e3f4eb90f 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -113,7 +113,7 @@ double Satellite::radToLen( return len; } -///Convert a satelite length -point position where fillet/chamfer knot be on original curve- to a arc radius of fillet/chamfer +///Convert a satellite length -point position where fillet/chamfer knot be on original curve- to a arc radius of fillet/chamfer double Satellite::lenToRad( double const A, Geom::Curve const &curve_in, Geom::Curve const &curve_out, diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h index b8ca2a490..198a95c9f 100644 --- a/src/helper/geom-satellite.h +++ b/src/helper/geom-satellite.h @@ -79,8 +79,8 @@ public: void setSatelliteType(gchar const *A); gchar const *getSatelliteTypeGchar() const; SatelliteType satellite_type; - //The value stored could be a time value of the satellite in the curve or a lenght of distance to the node from the satellite - //"is_time" tell is if is a time or lenght value + //The value stored could be a time value of the satellite in the curve or a length of distance to the node from the satellite + //"is_time" tells us if it's a time or length value bool is_time; bool selected; bool has_mirror; diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 8d7202111..8881f54a5 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -58,7 +58,7 @@ static void hide_other_items_recursively(SPObject *o, SPItem *i, unsigned dkey) // The following is a mutation of the flood fill code, the marker preview, and random other samplings. -// The dpi settings dont do anything yet, but I want them to, and was wanting to keep reasonably close +// The dpi settings don't do anything yet, but I want them to, and was wanting to keep reasonably close // to the call for the interface to the png writing. bool sp_export_jpg_file(SPDocument *doc, gchar const *filename, diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 647e42916..930640a6c 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -171,7 +171,7 @@ sp_gradient_load_from_svg(gchar const *name, SPDocument *current_doc) // get_stock_item returns a pointer to an instance of the desired stock object in the current doc // if necessary it will import the object. Copes with name clashes through use of the inkscape:stockid property -// This should be set to be the same as the id in the libary file. +// This should be set to be the same as the id in the library file. SPObject *get_stock_item(gchar const *urn, gboolean stock) { diff --git a/src/inkview.cpp b/src/inkview.cpp index 0b2b07f42..5b27e9168 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -60,8 +60,8 @@ public: // this list contains all arguments that are not recognized as an option (so needs to be checked) Glib::OptionGroup::vecustrings filenames; - bool fullscreen = false; // wether to launch in fullscreen mode - bool recursive = false; // wether to search folders for SVG files recursively + bool fullscreen = false; // whether to launch in fullscreen mode + bool recursive = false; // whether to search folders for SVG files recursively int timer = 0; // time (in seconds) after which the next image of the slideshow is automatically loaded double scale = 1; // scale factor for images // (currently only applied to the first image - others are resized to window dimensions) diff --git a/src/io/base64stream.cpp b/src/io/base64stream.cpp index 28c819347..c0c5e1a02 100644 --- a/src/io/base64stream.cpp +++ b/src/io/base64stream.cpp @@ -268,7 +268,7 @@ void Base64OutputStream::flush() { if (closed) return; - //dont flush here. do it on close() + //don't flush here. do it on close() destination.flush(); } diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 3f970dfa1..13da37d7a 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -134,7 +134,7 @@ Glib::ustring get_path_ustring(Domain domain, Type type, char const *filename) } /* - * Same as get_path, but checks for file's existance and falls back + * Same as get_path, but checks for file's existence and falls back * from USER to SYSTEM modes. * * type - The type of file to get, such as extension, template, ui etc @@ -214,7 +214,7 @@ Glib::ustring get_filename(Glib::ustring path, Glib::ustring filename) * domain - Optional domain (overload), will check return domains if not. * type - The type of files, e.g. TEMPLATES * path - Instead of Domain and Type, specify the path to get the files from. - * extentions - A list of extensions to return, e.g. xml, svg + * extensions - A list of extensions to return, e.g. xml, svg * exclusions - A list of names to exclude e.g. default.xml */ std::vector get_filenames(Type type, std::vector extensions, std::vector exclusions) diff --git a/src/layer-model.cpp b/src/layer-model.cpp index b941e43b1..3de96e0d1 100644 --- a/src/layer-model.cpp +++ b/src/layer-model.cpp @@ -138,7 +138,7 @@ void LayerModel::toggleLockOtherLayers(SPObject *object) { bool othersLocked = false; std::vector layers; for ( SPObject* obj = Inkscape::next_layer(currentRoot(), object); obj; obj = Inkscape::next_layer(currentRoot(), obj) ) { - // Dont lock any ancestors, since that would in turn lock the layer as well + // Don't lock any ancestors, since that would in turn lock the layer as well if (!obj->isAncestorOf(object)) { layers.push_back(obj); othersLocked |= !SP_ITEM(obj)->isLocked(); diff --git a/src/libcroco/cr-parser.c b/src/libcroco/cr-parser.c index 449533c6e..6d1e64d28 100644 --- a/src/libcroco/cr-parser.c +++ b/src/libcroco/cr-parser.c @@ -169,7 +169,7 @@ if ((status) != CR_OK) \ *@a_is_exception: in case of error, if is TRUE, the status *is set to CR_PARSING_ERROR before goto error. If is false, the *real low level status is kept and will be returned by the - *upper level function that called this macro. Usally,this must + *upper level function that called this macro. Usually, this must *be set to FALSE. * *same as CHECK_PARSING_STATUS() but this one pushes an error @@ -557,7 +557,7 @@ cr_parser_push_error (CRParser * a_this, *@param a_this the current instance of #CRParser. *@param a_clear_errs whether to clear the error stack *after the dump or not. - *@return CR_OK upon successfull completion, an error code + *@return CR_OK upon successful completion, an error code *otherwise. */ static enum CRStatus @@ -615,7 +615,7 @@ cr_parser_clear_errors (CRParser * a_this) *Same as cr_parser_try_to_skip_spaces() but this one skips *spaces and comments. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_try_to_skip_spaces_and_comments (CRParser * a_this) @@ -752,7 +752,7 @@ cr_parser_parse_stylesheet_core (CRParser * a_this) *in chapter 4.1 in the css2 spec. *at-rule : ATKEYWORD S* any* [ block | ';' S* ]; *@param a_this the current instance of #CRParser. - *@return CR_OK upon successfull completion, an error code + *@return CR_OK upon successful completion, an error code *otherwise. */ static enum CRStatus @@ -828,7 +828,7 @@ cr_parser_parse_atrule_core (CRParser * a_this) *4.1 of the css2 spec. *ruleset ::= selector? '{' S* declaration? [ ';' S* declaration? ]* '}' S*; *@param a_this the current instance of #CRParser. - *@return CR_OK upon successfull completion, an error code otherwise. + *@return CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_ruleset_core (CRParser * a_this) @@ -916,7 +916,7 @@ cr_parser_parse_ruleset_core (CRParser * a_this) *grammar. *selector : any+; *@param a_this the current instance of #CRParser. - *@return CR_OK upon successfull completion, an error code + *@return CR_OK upon successful completion, an error code *otherwise. */ static enum CRStatus @@ -1081,7 +1081,7 @@ cr_parser_parse_declaration_core (CRParser * a_this) *in chapter 4.1. *value ::= [ any | block | ATKEYWORD S* ]+; *@param a_this the current instance of #CRParser. - *@return CR_OK upon successfull completion, an error code otherwise. + *@return CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_value_core (CRParser * a_this) @@ -1162,7 +1162,7 @@ cr_parser_parse_value_core (CRParser * a_this) * | FUNCTION | DASHMATCH | '(' any* ')' | '[' any* ']' ] S*; * *@param a_this the current instance of #CRParser. - *@return CR_OK upon successfull completion, an error code otherwise. + *@return CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_any_core (CRParser * a_this) @@ -1319,7 +1319,7 @@ cr_parser_parse_any_core (CRParser * a_this) *@param a_this the "this pointer" of the current instance of *#CRParser . *@param a_sel out parameter. The successfully parsed attribute selector. - *@return CR_OK upon successfull completion, an error code otherwise. + *@return CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_attribute_selector (CRParser * a_this, @@ -1458,7 +1458,7 @@ cr_parser_parse_attribute_selector (CRParser * a_this, *new instance of GString and set it content to the parsed property. *If not, the property is just appended to a_property's previous content. *In both cases, it is up to the caller to free a_property. - *@return CR_OK upon successfull completion, CR_PARSING_ERROR if the + *@return CR_OK upon successful completion, CR_PARSING_ERROR if the *next construction was not a "property", or an error code. */ static enum CRStatus @@ -1504,7 +1504,7 @@ cr_parser_parse_property (CRParser * a_this, * *TODO: handle parsing of 'RGB' * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term) @@ -1666,7 +1666,7 @@ cr_parser_parse_term (CRParser * a_this, CRTerm ** a_term) *and where pseudo is: *pseudo ::= ':' [ IDENT | FUNCTION S* IDENT S* ')' ] * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) @@ -1934,7 +1934,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel) *Parses a "selector" as defined by the css2 spec in appendix D.1: *selector ::= simple_selector [ combinator simple_selector ]* * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_simple_sels (CRParser * a_this, @@ -2136,7 +2136,7 @@ cr_parser_parse_selector (CRParser * a_this, *function ::= FUNCTION S* expr ')' S* *FUNCTION ::= ident'(' * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_function (CRParser * a_this, @@ -2222,7 +2222,7 @@ cr_parser_parse_function (CRParser * a_this, * URI ::= url\({w}{string}{w}\) * |url\({w}([!#$%&*-~]|{nonascii}|{escape})*{w}\) * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_uri (CRParser * a_this, CRString ** a_str) @@ -2241,10 +2241,10 @@ cr_parser_parse_uri (CRParser * a_this, CRString ** a_str) /** * cr_parser_parse_string: *@a_this: the current instance of #CRParser. - *@a_start: out parameter. Upon successfull completion, + *@a_start: out parameter. Upon successful completion, *points to the beginning of the string, points to an undefined value *otherwise. - *@a_end: out parameter. Upon successfull completion, points to + *@a_end: out parameter. Upon successful completion, points to *the beginning of the string, points to an undefined value otherwise. * *Parses a string type as defined in css spec [4.1.1]: @@ -2253,7 +2253,7 @@ cr_parser_parse_uri (CRParser * a_this, CRString ** a_str) *string1 ::= \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\" *string2 ::= \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\' * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_string (CRParser * a_this, CRString ** a_str) @@ -2280,7 +2280,7 @@ cr_parser_parse_string (CRParser * a_this, CRString ** a_str) *the function just appends the parsed string to the one passed. *In both cases it is up to the caller to free *a_str. * - *@return CR_OK upon successfull completion, an error code + *@return CR_OK upon successful completion, an error code *otherwise. */ static enum CRStatus @@ -2313,7 +2313,7 @@ cr_parser_parse_ident (CRParser * a_this, CRString ** a_str) *@param a_end out parameter. A pointer to the first character of *the successfully parsed string. * - *@return CR_OK upon successfull completion, an error code otherwise. + *@return CR_OK upon successful completion, an error code otherwise. */ static enum CRStatus cr_parser_parse_stylesheet (CRParser * a_this) @@ -2760,7 +2760,7 @@ cr_parser_parse_stylesheet (CRParser * a_this) *coming the input stream given in parameter. * *Returns the newly created instance of #CRParser, - *or NULL if an error occured. + *or NULL if an error occurred. */ CRParser * cr_parser_new (CRTknzr * a_tknzr) @@ -2872,7 +2872,7 @@ cr_parser_new_from_file (const guchar * a_file_uri, enum CREncoding a_enc) * *Sets a SAC document handler to the parser. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_set_sac_handler (CRParser * a_this, CRDocHandler * a_handler) @@ -2897,7 +2897,7 @@ cr_parser_set_sac_handler (CRParser * a_this, CRDocHandler * a_handler) * *Gets the SAC document handler. * - *Returns CR_OK upon successfull completion, an error code + *Returns CR_OK upon successful completion, an error code *otherwise. */ enum CRStatus @@ -2917,7 +2917,7 @@ cr_parser_get_sac_handler (CRParser * a_this, CRDocHandler ** a_handler) *Sets the SAC handler associated to the current instance *of #CRParser to the default SAC handler. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_set_default_sac_handler (CRParser * a_this) @@ -2946,7 +2946,7 @@ cr_parser_set_default_sac_handler (CRParser * a_this) * @a_this: the current instance of #CRParser. * @a_use_core_grammar: where to parse against the css core grammar. * - * Returns CR_OK upon succesful completion, an error code otherwise. + * Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_set_use_core_grammar (CRParser * a_this, @@ -2962,9 +2962,9 @@ cr_parser_set_use_core_grammar (CRParser * a_this, /** * cr_parser_get_use_core_grammar: * @a_this: the current instance of #CRParser. - * @a_use_core_grammar: wether to use the core grammar or not. + * @a_use_core_grammar: whether to use the core grammar or not. * - * Returns CR_OK upon succesful completion, an error code otherwise. + * Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_get_use_core_grammar (CRParser const * a_this, @@ -2986,7 +2986,7 @@ cr_parser_get_use_core_grammar (CRParser const * a_this, * *Parses a the given in parameter. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_file (CRParser * a_this, @@ -3178,7 +3178,7 @@ cr_parser_parse_prio (CRParser * a_this, CRString ** a_prio) *Parses a "declaration" as defined by the css2 spec in appendix D.1: *declaration ::= [property ':' S* expr prio?]? * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_declaration (CRParser * a_this, @@ -3272,7 +3272,7 @@ cr_parser_parse_declaration (CRParser * a_this, *chapter 4.1 of the css2 spec. *statement : ruleset | at-rule; * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_statement_core (CRParser * a_this) @@ -3336,7 +3336,7 @@ cr_parser_parse_statement_core (CRParser * a_this) *See the documentation of #CRDocHandler (the SAC handler) to know *when which SAC handler is called. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_ruleset (CRParser * a_this) @@ -3552,7 +3552,7 @@ cr_parser_parse_ruleset (CRParser * a_this) *import ::= *\@import [STRING|URI] S* [ medium [ ',' S* medium]* ]? ';' S* * - *Returns CR_OK upon sucessfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_import (CRParser * a_this, @@ -3713,7 +3713,7 @@ cr_parser_parse_import (CRParser * a_this, *to notify media productions. See #CRDocHandler to know the callback called *during \@media parsing. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_media (CRParser * a_this) @@ -3883,7 +3883,7 @@ cr_parser_parse_media (CRParser * a_this) *encounters a construction that must *be reported to the calling application. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_page (CRParser * a_this) @@ -4134,7 +4134,7 @@ cr_parser_parse_page (CRParser * a_this) *appendix D.1: *charset ::= CHARSET_SYM S* STRING S* ';' * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_charset (CRParser * a_this, CRString ** a_value, @@ -4225,7 +4225,7 @@ cr_parser_parse_charset (CRParser * a_this, CRString ** a_value, * *This function will call SAC handlers whenever it is necessary. * - *Returns CR_OK upon successfull completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse_font_face (CRParser * a_this) @@ -4382,7 +4382,7 @@ cr_parser_parse_font_face (CRParser * a_this) *input previously associated to the current instance of *#CRParser. * - *Returns CR_OK upon succesful completion, an error code otherwise. + *Returns CR_OK upon successful completion, an error code otherwise. */ enum CRStatus cr_parser_parse (CRParser * a_this) @@ -4432,7 +4432,7 @@ cr_parser_set_tknzr (CRParser * a_this, CRTknzr * a_tknzr) * *Getter of the parser's underlying tokenizer * - *Returns CR_OK upon succesful completion, an error code + *Returns CR_OK upon successful completion, an error code *otherwise */ enum CRStatus @@ -4452,7 +4452,7 @@ cr_parser_get_tknzr (CRParser * a_this, CRTknzr ** a_tknzr) * *Gets the current parsing location. * - *Returns CR_OK upon succesful completion, an error code + *Returns CR_OK upon successful completion, an error code *otherwise. */ enum CRStatus diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5674e29dc..f4aad4f53 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -835,13 +835,13 @@ Effect::defaultParamSet() bool valid = prefs->getEntry(pref_path).isValid(); const gchar * set_or_upd; Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); if (valid) { set_or_upd = _("Update"); def = Glib::ustring(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); } else { set_or_upd = _("Set"); - ove = Glib::ustring(_("Default value overrided: None\n")); + ove = Glib::ustring(_("Default value overridden: None\n")); } Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(param->param_getSVGValue()); Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); @@ -892,7 +892,7 @@ Effect::setDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar * set->set_label((Glib::ustring)label); unset->set_sensitive(true); Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(value) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(value) + Glib::ustring("\n"); Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } @@ -906,7 +906,7 @@ Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar set->set_label((Glib::ustring)label); unset->set_sensitive(false); Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: None\n")); + Glib::ustring ove = Glib::ustring(_("Default value overridden: None\n")); Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } diff --git a/src/live_effects/lpe-bool.cpp b/src/live_effects/lpe-bool.cpp index 2930414b3..6299b282b 100644 --- a/src/live_effects/lpe-bool.cpp +++ b/src/live_effects/lpe-bool.cpp @@ -121,7 +121,7 @@ sp_pathvector_boolop_slice_intersect(Geom::PathVector const &pathva, Geom::PathV // (i) filter the descr_cmd of the result path with this bool vector // // The main inefficieny here is step (e) because I use a winding function of the area-shape which goes - // through teh complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. + // through the complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. // It is tricky to improve this without building into the livarot code. // One way might be to decide at the intersection points which edges touching the intersection points are // in by making a loop through all edges on the intersection vertex. Since this is a directed non intersecting diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 33e754a8a..d0655d9bd 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -22,7 +22,7 @@ namespace Inkscape { namespace LivePathEffect { //TODO: growfor/fadefor can be expressed in unit of width. -//TODO: make round/sharp end choices independant for start and end. +//TODO: make round/sharp end choices independent for start and end. //TODO: define more styles like in calligtool. //TODO: allow fancy ends. @@ -166,7 +166,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p // General formula: n1 = w*u with ||u||=1 and u.v = -dw/dt Piecewise dw = derivative(w); Piecewise ncomp = sqrt(dot(v,v)-dw*dw,.1,3); - //FIXME: is force continuity usefull? compatible with corners? + //FIXME: is force continuity useful? compatible with corners? // std::cout<<"ici\n"; n1 = -dw*v + ncomp*rot90(v); n1 = w*force_continuity(unitVector(n1),.1); diff --git a/src/live_effects/lpe-embrodery-stitch-ordering.h b/src/live_effects/lpe-embrodery-stitch-ordering.h index b2b5d36db..c307ec555 100644 --- a/src/live_effects/lpe-embrodery-stitch-ordering.h +++ b/src/live_effects/lpe-embrodery-stitch-ordering.h @@ -195,7 +195,7 @@ struct OrderingGroupConnection { Connect(1, toIn); } - // Connect one of the conection endpoints to the given point + // Connect one of the connection endpoints to the given point void Connect(int index, OrderingGroupPoint *point) { assert(point); diff --git a/src/live_effects/lpe-embrodery-stitch.cpp b/src/live_effects/lpe-embrodery-stitch.cpp index f2342032b..282419fd8 100644 --- a/src/live_effects/lpe-embrodery-stitch.cpp +++ b/src/live_effects/lpe-embrodery-stitch.cpp @@ -345,7 +345,7 @@ PathVector LPEEmbroderyStitch::doEffect_path(PathVector const &path_in) Piecewise > pwOneEqdist = arc_length_parametrization(pwOne); Interval pwdomain = pwOneEqdist.domain(); - // Compute the points of teh shortened piece + // Compute the points of the shortened piece Coord len = pwdomain.max() - pwdomain.min(); Coord offs = 0.5 * (show_stitch_gap < 0.5 * len ? show_stitch_gap : 0.5 * len); Point p1 = pwOneEqdist.valueAt(pwdomain.min() + offs); diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 8528ab14d..688841617 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -205,7 +205,7 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise > const & pwd output /= 2.; return output; - /*Of course, the result is not perfect, but on a graphical point of view, this is sufficent.*/ + /*Of course, the result is not perfect, but on a graphical point of view, this is sufficient.*/ } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 2b052ace1..fb78c2065 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -131,7 +131,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) } //we add the last satellite on open path because _pathvector_satellites is related to nodes, not curves //so maybe in the future we can need this last satellite in other effects - //dont remove for this effect because _pathvector_satellites class has methods when the path is modiffied + //don't remove for this effect because _pathvector_satellites class has methods when the path is modiffied //and we want one method for all uses if (!path_it->closed()) { Satellite satellite(satellite_type); @@ -323,7 +323,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) //mandatory call satellites_param.setEffectType(effectType()); Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(sp_curve->get_pathvector()); - //if are diferent sizes call to recalculate + //if are different sizes call to recalculate //TODO: Update the satellite data in paths modified, Satellites satellites = satellites_param.data(); if (satellites.empty()) { @@ -468,7 +468,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) Satellite satellite = satellites[path][next_index]; if (Geom::are_near((*curve_it1).initialPoint(), (*curve_it1).finalPoint())) { _degenerate_hide = true; - g_warning("Knots hidded if consecutive nodes has the same position."); + g_warning("Knots hidden if consecutive nodes has the same position."); return path_in; } if (!curve) { //curve == 0 diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 22c548c1d..b21181ffc 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -520,7 +520,7 @@ collectPathsAndWidths (SPLPEItem const *lpeitem, Geom::PathVector &paths, std::v Geom::PathVector subpaths = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); for (unsigned i=0; istyle->stroke_width.computed); } } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e827491c0..e8642d4e7 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -103,7 +103,7 @@ Geom::Piecewise > LPELattice2::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) { PathVector pathv = path_from_piecewise(pwd2_in,0.001); - //this is because strange problems whith sb2 and LineSegment + //this is because strange problems with sb2 and LineSegment PathVector cubic = pathv_to_cubicbezier(pathv); Geom::Piecewise > const &pwd2_in_linear_and_cubic = paths_to_pw(cubic); D2 sb2; diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 7ba5a7913..7726af176 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -171,7 +171,7 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise > const & pwd2_i if (border_marks == BORDERMARK_END || border_marks == BORDERMARK_BOTH){ Point A = pwd2_in.lastValue(); Point n = rot90(unit_vector(speed.lastValue()))*sign; - //speed.lastValue() is somtimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... + //speed.lastValue() is sometimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... //TODO: Find a better fix!! (How do we know if the path was closed?) if ( A == pwd2_in.firstValue() && speed.segs.size() > 1 && diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3376b7e5..dfb860de8 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -107,7 +107,7 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : tgtlength_rdm.param_set_range(0, 1.); tgt_places_rdmness.param_set_range(0, 1.); //this is not very smart, but required to avoid having lot of tangents stacked on short components. - //Nota: we could specify a density instead of an absolute number, but this would be scale dependant. + //Note: we could specify a density instead of an absolute number, but this would be scale dependent. concatenate_before_pwd2 = true; #endif } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index b9fd8908a..f04c243f6 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -169,7 +169,7 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) } -//Usefull?? +//Useful?? //void //LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) /*{ diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index bffbebd54..c0cb7ce42 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -55,7 +55,7 @@ public: virtual void doBeforeEffect(SPLPEItem const* item); - //Usefull?? + //Useful?? // protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index 374e715ec..baee35614 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -32,7 +32,7 @@ public: SPObject *owner; - // concerning the LPEObject that is refered to: + // concerning the LPEObject that is referred to: char *lpeobject_href; Inkscape::XML::Node *lpeobject_repr; LivePathEffectObject *lpeobject; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index bd6608737..f89fad3ee 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -343,7 +343,7 @@ PathParam::set_new_value (Geom::Piecewise > const & newpa * * If write_to_svg = true : * The new path data is written to SVG. In this case the signal_path_changed signal - * is not directly emited in this method, because writing to SVG + * is not directly emitted in this method, because writing to SVG * triggers the LPEObject to which this belongs to call Effect::setParameter which calls * PathParam::readSVGValue, which finally emits the signal_path_changed signal. * If write_to_svg = false : diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 5ae372ac2..3039eb432 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -5,14 +5,14 @@ * Inkscape::LivePathEffectParameters * Copyright (C) Jabiertxo Arraiza Cenoz * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time + * Also to ScislaC for pointing me to the idea + * Also su_v for his constructive feedback and time * To Nathan Hurst for his review and help on refactor - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours + * and finally to Liam P. White for his big help on coding, + * that saved me a lot of hours * * - * This parameter act as bridge from pathVectorSatellites class to serialize it as a LPE + * This parameter acts as a bridge from pathVectorSatellites class to serialize it as a LPE * parameter * * Released under GNU GPL, read the file 'COPYING' for more information diff --git a/src/persp3d-reference.h b/src/persp3d-reference.h index cce497d94..871b29623 100644 --- a/src/persp3d-reference.h +++ b/src/persp3d-reference.h @@ -35,7 +35,7 @@ public: SPObject *owner; - // concerning the Persp3D (we only use SPBox3D) that is refered to: + // concerning the Persp3D (we only use SPBox3D) that is referred to: char *persp_href; Inkscape::XML::Node *persp_repr; Persp3D *persp; diff --git a/src/preferences.cpp b/src/preferences.cpp index b02e71e46..958e879f8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -774,7 +774,7 @@ void Preferences::_setRawValue(Glib::ustring const &path, Glib::ustring const &v node->setAttribute(attr_key.c_str(), value.c_str()); } -// The _extract* methods are where the actual wrok is done - they define how preferences are stored +// The _extract* methods are where the actual work is done - they define how preferences are stored // in the XML file. bool Preferences::_extractBool(Entry const &v) diff --git a/src/rdf.cpp b/src/rdf.cpp index 938dc60c6..c70c32e51 100644 --- a/src/rdf.cpp +++ b/src/rdf.cpp @@ -1100,7 +1100,7 @@ struct rdf_license_t *RDFImpl::getLicense(SPDocument *document) return license_by_uri; } else if (license_by_uri != NULL) { - // Only cc:license property, set structure for backward compatiblity + // Only cc:license property, set structure for backward compatibility setLicense(document, license_by_uri); return license_by_uri; @@ -1224,7 +1224,7 @@ void rdf_add_from_preferences(SPDocument *doc) return; } - // If there is already some metadata in the doc (from a template) dont add default metadata + // If there is already some metadata in the doc (from a template) don't add default metadata for (struct rdf_work_entity_t *entity = rdf_work_entities; entity && entity->name; entity++) { if ( entity->editable == RDF_EDIT_GENERIC && rdf_get_work_entity (doc, entity)) { diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index 4901cf424..af81298e3 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -130,7 +130,7 @@ public: /** * Try to parse href into a local filename using standard methods. * - * @return true if successfull. + * @return true if successful. */ bool extractFilepath( Glib::ustring const &href, std::string &uri ); @@ -138,7 +138,7 @@ public: * Try to parse href into a local filename using some non-standard methods. * This means the href is likely invalid and should be rewritten. * - * @return true if successfull. + * @return true if successful. */ bool reconstructFilepath( Glib::ustring const &href, std::string &uri ); @@ -362,7 +362,7 @@ bool ResourceManagerImpl::fixupBrokenLinks(SPDocument *doc) SPObject *updated = doc->getObjectByRepr(ir); if (updated) { - // force immediate update of dependant attributes + // force immediate update of dependent attributes updated->updateRepr(); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index b8a769d1c..efc378845 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1,5 +1,5 @@ /** @file - * Miscellanous operations on selected items. + * Miscellaneous operations on selected items. */ /* Authors: * Lauris Kaplinski @@ -1998,7 +1998,7 @@ std::vector sp_get_same_fill_or_stroke_color(SPItem *sel, std::vectorstyle->fill) : &(iter->style->stroke); match = false; - if (sel_paint->isColor() && iter_paint->isColor() // color == color comparision doesnt seem to work here. + if (sel_paint->isColor() && iter_paint->isColor() // color == color comparison doesn't seem to work here. && (sel_paint->value.color.toRGBA32(1.0) == iter_paint->value.color.toRGBA32(1.0))) { match = true; } else if (sel_paint->isPaintserver() && iter_paint->isPaintserver()) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index c82c5a4a5..82fc473b9 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -2,7 +2,7 @@ #define SEEN_SELECTION_CHEMISTRY_H /* - * Miscellanous operations on selected items + * Miscellaneous operations on selected items * * Authors: * Lauris Kaplinski diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 0a1e0c4a9..d49bdc29d 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -291,7 +291,7 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) /* * Get a list of keyboard shortcut files names and paths from the system and users paths - * Dont add the users custom keyboards file + * Don't add the users custom keyboards file */ void sp_shortcut_get_file_names(std::vector *names, std::vector *paths) { using namespace Inkscape::IO::Resource; diff --git a/src/snap-enums.h b/src/snap-enums.h index ab82aaf37..64a147ea9 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -48,7 +48,7 @@ enum SnapSourceType { // When adding source types here, then also update Inkscap SNAPSOURCE_IMG_CORNER, SNAPSOURCE_TEXT_ANCHOR, SNAPSOURCE_OTHER_HANDLE, // eg. the handle of a gradient or of a connector (ie not being tied to a stroke) - SNAPSOURCE_GRID_PITCH, // eg. when pasting or alt-dragging in the selector tool; not realy a snap source + SNAPSOURCE_GRID_PITCH, // eg. when pasting or alt-dragging in the selector tool; not really a snap source }; enum SnapTargetType { diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 3d9a41fe3..bbc711c96 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -517,7 +517,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio // If both shape_inside and inline_size are set, shape_inside wins out. // We construct a rectange with one dimension set by the computed value of 'inline-size' - // and the other dimension set to infinity. Text is layed out starting at the 'x' and 'y' + // and the other dimension set to infinity. Text is laid out starting at the 'x' and 'y' // attribute values. This is handled elsewhere. double inline_size = style->inline_size.computed; diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 2655e219b..dd44c5855 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -238,7 +238,7 @@ gchar* SPTRef::description() const { } -/* For the sigc::connection changes (i.e. when the object being refered to changes) */ +/* For the sigc::connection changes (i.e. when the object being referred to changes) */ static void sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 61e8002bb..0af7c7ebc 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -386,7 +386,7 @@ Geom::Affine SPUse::get_root_transform() { /** * Returns the transform that leads to the use from its immediate original. - * Does not inlcude the original's transform if any. + * Does not include the original's transform if any. */ Geom::Affine SPUse::get_parent_transform() { Geom::Affine t(Geom::identity()); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 3410a2635..f6544872f 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -744,7 +744,7 @@ BoolOpErrors Inkscape::ObjectSet::pathBoolOp(bool_op bop, const bool skip_undo, // that's why you needed the nesting // ConvertToFormeNested() dumped all the subpath in a single Path "res", so we need // to get the path for each part of the polygon. that's why you need the nesting info: - // to know in wich subpath to add a subpath + // to know in which subpath to add a subpath resPath=res->SubPathsWithNesting(nbRP, true, nbNest, nesting, conts); // cleaning @@ -864,7 +864,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine if (marker_item->getRepr()) { Inkscape::XML::Node *m_repr = marker_item->getRepr()->duplicate(xml_doc); g_repr->appendChild(m_repr); - //There is a special group to markers whith this reverse the order in clussion + //There is a special group to markers with this reverse the order in clussion m_repr->setPosition(0); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); marker_item->doWriteTransform(tr); diff --git a/src/style-internal.h b/src/style-internal.h index d8d2a37bc..5c22c093d 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -103,12 +103,12 @@ enum SPStyleSrc { * The C structures that these classes are evolved from were designed to be embedded in to the * style structure (i.e they are "internal" and thus have an "I" in the SPI prefix). However, * they should be reasonably stand-alone and can provide some functionality outside of the style - * stucture (i.e. reading and writing style strings). Some properties do need access to other + * structure (i.e. reading and writing style strings). Some properties do need access to other * properties from the same object (e.g. SPILength sometimes needs to know font size) to - * calculate 'computed' values. Inheritence, of course, requires access to the parent object's + * calculate 'computed' values. Inheritance, of course, requires access to the parent object's * style class. * - * The only real outside dependancy is SPObject... which is needed in the cases of SPIPaint and + * The only real outside dependency is SPObject... which is needed in the cases of SPIPaint and * SPIFilter for setting up the "href". (Currently, SPDocument is needed but this dependency * should be removed as an "href" only needs the SPDocument for attaching an external document to * the XML tree [see uri-references.cpp]. If SPDocument is really needed, it can be obtained from diff --git a/src/style.cpp b/src/style.cpp index 608cca1e6..a417e4331 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -610,7 +610,7 @@ SPStyle::read( SPObject *object, Inkscape::XML::Node *repr ) { // Shorthands are not allowed as presentation properites. Note: text-decoration and // font-variant are converted to shorthands in CSS 3 but can still be read as a - // non-shorthand for compatability with older renders, so they should not be in this list. + // non-shorthand for compatibility with older renders, so they should not be in this list. // We could add a flag to SPIBase to avoid string comparison. if( _properties[i]->name.compare( "font" ) != 0 && _properties[i]->name.compare( "marker" ) != 0 ) { @@ -2039,7 +2039,7 @@ css_quote(Glib::ustring &val) quote = true; } if( it == val.begin() && !g_ascii_isalpha(*it) ) { - // A non-ASCII/non-alpha initial value on any indentifier needs quotes. + // A non-ASCII/non-alpha initial value on any identifier needs quotes. // (Actually it's a bit more complicated but as it never hurts to quote...) quote = true; } diff --git a/src/svg-profile.h b/src/svg-profile.h index 8945ee313..0baaf08e5 100644 --- a/src/svg-profile.h +++ b/src/svg-profile.h @@ -133,7 +133,7 @@ private: This function first find which integer the bit is in by dividing by \c BITS_IN_INT and then which bit in the integer by getting the modulus. The selected integer is - the \c |= with a \c 1 shifted left by the possition. + the \c |= with a \c 1 shifted left by the position. */ inline void set (const unsigned int pos) { unsigned int array_pos = pos / BITS_IN_INT; diff --git a/src/svg-view-slideshow.h b/src/svg-view-slideshow.h index 02159ed6b..bd0881021 100644 --- a/src/svg-view-slideshow.h +++ b/src/svg-view-slideshow.h @@ -45,7 +45,7 @@ private: std::vector _slides; // list of filenames for each slide int _current; // index of the currently displayed slide SPDocument *_doc; // parsed SPDocument of the currently displayed slide - bool _fullscreen; // is window fullscreen? (also controls wether to launch in fullscreen mode) + bool _fullscreen; // is window fullscreen? (also controls whether to launch in fullscreen mode) int _timer; // time after which slides are automatically changed (in seconds) double _scale; // scale factor for images GtkWidget *_view; // the canvas to which the images are drawn diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 33ad4401c..dbeee644c 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -656,7 +656,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) /** * Get all objects id from the clipboard. * @return A vector containing all IDs or empty if no shape or text item was found. - * type. Set to "*" to retrive all elements of the types vector inside, feel free to populate more + * type. Set to "*" to retrieve all elements of the types vector inside, feel free to populate more */ std::vector ClipboardManagerImpl::getElementsOfType(SPDesktop *desktop, gchar const* type) { diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 27bfa681f..52f31e046 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -275,7 +275,7 @@ public : private : virtual void on_button_click() { - //Retreive selected objects + //Retrieve selected objects SPDesktop *desktop = _dialog.getDesktop(); if (!desktop) return; diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index acb3d02ed..ce45fcccd 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -185,7 +185,7 @@ private : virtual void on_button_click() { - //Retreive selected objects + //Retrieve selected objects SPDesktop *desktop = _dialog.getDesktop(); if (!desktop) return; diff --git a/src/ui/dialog/dock-behavior.h b/src/ui/dialog/dock-behavior.h index de7386ad9..15429f1c9 100644 --- a/src/ui/dialog/dock-behavior.h +++ b/src/ui/dialog/dock-behavior.h @@ -70,7 +70,7 @@ private: /** Internal helpers */ Gtk::Paned *_getPaned(); //< gives the parent pane, if the dock item has one - void _requestHeight(int height); //< tries to resize the dock item to the requested hieght + void _requestHeight(int height); //< tries to resize the dock item to the requested height /** Internal signal handlers */ void _onHide(); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 2765e63f4..baf70ea82 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1217,7 +1217,7 @@ void DocumentProperties::changeEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. SPObject* child = obj->firstChild(); - //TODO: shouldnt we get all children instead of simply the first child? + //TODO: shouldn't we get all children instead of simply the first child? if (child && child->getRepr()){ const gchar* content = child->getRepr()->content(); diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 248f4f67f..a710a2fb4 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -116,7 +116,7 @@ ExtensionEditor::setExtensionIter(const Gtk::TreeModel::iterator &iter) } /** - * Called every time a new extention is selected + * Called every time a new extension is selected * * This function is set up to handle the signal for a changed extension * from the tree view in the left pane. It figure out which extension diff --git a/src/ui/dialog/filedialog.h b/src/ui/dialog/filedialog.h index 175031bcf..8ee63e654 100644 --- a/src/ui/dialog/filedialog.h +++ b/src/ui/dialog/filedialog.h @@ -352,7 +352,7 @@ public: virtual Glib::ustring getDestinationUnits() = 0; /** - * Return the destination DPI image resulution, if bitmap + * Return the destination DPI image resolution, if bitmap */ virtual double getDestinationDPI() = 0; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 64f6c98c6..86ad8649d 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -694,7 +694,7 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window &parentWindow, const Gl set_local_only(false); - /* Initalize to Autodetect */ + /* Initialize to Autodetect */ extension = NULL; /* No filename to start out with */ myFilename = ""; @@ -956,7 +956,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl set_local_only(false); - /* Initalize to Autodetect */ + /* Initialize to Autodetect */ extension = NULL; /* No filename to start out with */ myFilename = ""; @@ -1438,7 +1438,7 @@ FileExportDialogImpl::FileExportDialogImpl(Gtk::Window &parentWindow, const Glib set_local_only(false); - /* Initalize to Autodetect */ + /* Initialize to Autodetect */ extension = NULL; /* No filename to start out with */ myFilename = ""; diff --git a/src/ui/dialog/filedialogimpl-gtkmm.h b/src/ui/dialog/filedialogimpl-gtkmm.h index 7501b5e14..82ca75065 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.h +++ b/src/ui/dialog/filedialogimpl-gtkmm.h @@ -446,7 +446,7 @@ public: { return destUnitsSpinner.getUnitAbbr(); } /** - * Return the destination DPI image resulution, if bitmap + * Return the destination DPI image resolution, if bitmap */ double getDestinationDPI() { return destDPISpinner.getValue(); } diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 7f0bf58c5..7aca8e242 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -146,7 +146,7 @@ FileOpenDialogImplWin32::FileOpenDialogImplWin32(Gtk::Window &parent, const gchar *title) : FileDialogBaseWin32(parent, dir, title, fileTypes, "dialogs.open") { - // Initalize to Autodetect + // Initialize to Autodetect _extension = NULL; // Set our dialog type (open, import, etc...) @@ -1329,7 +1329,7 @@ void FileOpenDialogImplWin32::render_preview() GetBValue(background) / 255.0); context->paint(); - //----- Draw the drop shaddow -----// + //----- Draw the drop shadow -----// // Left Edge x = frameX + shaddowOffsetX - halfBlurRadius; diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index abae8ea70..ad035aa8d 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -130,7 +130,7 @@ FontSubstitution::show(Glib::ustring out, std::vector &l) * * Return a list of SPItems where fonts have been substituted. * - * Walk thru all the objects ... + * Walk through all the objects ... * a. Build up a list of the objects with fonts defined in the style attribute * b. Build up a list of the objects rendered fonts - taken for the objects layout/spans * If there are fonts in a. that are not in b. then those fonts have been substituted. diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index c16e60c5f..96e6acb3c 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -215,7 +215,7 @@ } - /// Make sure the top and left of the grid dont move by compensating for align values. + /// Make sure the top and left of the grid don't move by compensating for align values. if (RowHeightButton.get_active()){ grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign)); } diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 5b316936d..5a27056f3 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -559,7 +559,7 @@ Glib::RefPtr InputDialogImpl::getPix(PixId id) } -// Now that we've defined the *Impl class, we can do the method to aquire one. +// Now that we've defined the *Impl class, we can do the method to acquire one. InputDialog &InputDialog::getInstance() { InputDialog *dialog = new InputDialogImpl(); diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 72a2814ed..13ce4e4cd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -84,7 +84,7 @@ ExportDialog::ExportDialog(Gtk::Window &parentWindow, * and a Entry to take the filename * Later put the extension selection and checkbox (?) */ - /* Initalize to Autodetect */ + /* Initialize to Autodetect */ /* extension = NULL; */ @@ -1063,7 +1063,7 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types const Glib::ustring &title) : FileDialogBase(title, parent_window) { - // Initalize to Autodetect + // Initialize to Autodetect extension = NULL; // No filename to start out with Glib::ustring search_keywords = ""; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 75e1a56b8..2f18d5c0d 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -183,7 +183,7 @@ static Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle /** * Returns the selected anchor point in document coordinates. If anchor - * is 0 to 8, then a bounding box point has been choosen. If it is 9 however + * is 0 to 8, then a bounding box point has been chosen. If it is 9 however * the rotational center is chosen. * @todo still using a hack to get the real coordinate space (subtracting document height * and inverting axes) diff --git a/src/ui/dialog/print-colors-preview-dialog.cpp b/src/ui/dialog/print-colors-preview-dialog.cpp index ef5c1b6f6..5e96a8e61 100644 --- a/src/ui/dialog/print-colors-preview-dialog.cpp +++ b/src/ui/dialog/print-colors-preview-dialog.cpp @@ -19,7 +19,7 @@ namespace UI { namespace Dialog { //Yes, I know we shouldn't hardcode CMYK. This class needs to be refactored -// in order to accomodate spot colors and color components defined using +// in order to accommodate spot colors and color components defined using // ICC colors. --Juca void PrintColorsPreviewDialog::toggle_cyan(){ diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 60138fa89..5ca085094 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -191,7 +191,7 @@ StyleDialog::TreeStore::row_draggable_vfunc(const Gtk::TreeModel::Path& path) co /** - * Allow dropping only inbetween other selectors. + * Allow dropping only in between other selectors. */ bool StyleDialog::TreeStore::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest, @@ -750,7 +750,7 @@ void StyleDialog::_removeFromSelector(Gtk::TreeModel::Row row) /** * @brief StyleDialog::_getIdList * @param sel - * @return This function returns a comma seperated list of ids for objects in input vector. + * @return This function returns a comma separated list of ids for objects in input vector. * It is used in creating an 'id' selector. It relies on objects having 'id's. */ Glib::ustring StyleDialog::_getIdList(std::vector sel) diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index c245890bc..5747c7726 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -1004,7 +1004,7 @@ void XmlTree::cmd_delete_attr() SPObject *updated = current_document->getObjectByRepr(selected_repr); if (updated) { - // force immediate update of dependant attributes + // force immediate update of dependent attributes updated->updateRepr(); } @@ -1028,7 +1028,7 @@ void XmlTree::cmd_set_attr() SPObject *updated = current_document->getObjectByRepr(selected_repr); if (updated) { - // force immediate update of dependant attributes + // force immediate update of dependent attributes updated->updateRepr(); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 4f42400d4..67768571d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -168,7 +168,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //move the handler and its oposite the same proportion + //move the handler and its opposite the same proportion if(_pm()._isBSpline()){ setPosition(_pm()._bsplineHandleReposition(this, false)); bspline_weight = _pm()._bsplineHandlePosition(this, false); @@ -186,7 +186,7 @@ void Handle::move(Geom::Point const &new_pos) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //move the handler and its oposite the same proportion + //move the handler and its opposite the same proportion if(_pm()._isBSpline()){ setPosition(_pm()._bsplineHandleReposition(this, false)); bspline_weight = _pm()._bsplineHandlePosition(this, false); @@ -213,7 +213,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - // moves the handler and its oposite the same proportion + // moves the handler and its opposite the same proportion if(_pm()._isBSpline()){ setPosition(_pm()._bsplineHandleReposition(this, false)); bspline_weight = _pm()._bsplineHandlePosition(this, false); @@ -307,7 +307,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } -//this function moves the handler and its oposite to the default proportion of DEFAULT_START_POWER +//this function moves the handler and its opposite to the default proportion of DEFAULT_START_POWER void Handle::handle_2button_press(){ if(_pm()._isBSpline()){ setPosition(_pm()._bsplineHandleReposition(this, DEFAULT_START_POWER)); @@ -364,7 +364,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - // moves the handler and its oposite in X fixed positions depending on parameter "steps with control" + // moves the handler and its opposite in X fixed positions depending on parameter "steps with control" // by default in live BSpline if(_pm()._isBSpline()){ setPosition(new_pos); @@ -478,7 +478,7 @@ Glib::ustring Handle::_getTip(unsigned state) const { char const *more; // a trick to mark as bspline if the node has no strength, we are going to use it later - // to show the appropiate messages. We cannot do it in any different way becasue the function is constant + // to show the appropriate messages. We cannot do it in any different way because the function is constant Handle *h = const_cast(this); bool isBSpline = _pm()._isBSpline(); bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate(); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 2c99e7fc8..f39afb8c4 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1688,7 +1688,7 @@ void PathManipulator::_updateOutlineOnZoomChange() if (_show_path_direction) _updateOutline(); } -/** Compute the radius from the edge of the path where clicks chould initiate a curve drag +/** Compute the radius from the edge of the path where clicks should initiate a curve drag * or segment selection, in window coordinates. */ double PathManipulator::_getStrokeTolerance() { diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 1735a78df..81d2f6a5b 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -636,7 +636,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } } else if (this->item_to_select) { if (over_line && line) { - // Clicked on an existing gradient line, dont change selection. This stops + // Clicked on an existing gradient line, don't change selection. This stops // possible change in selection during a double click with overlapping objects } else { // no dragging, select clicked item if any diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 24295e7cf..bd2964d94 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1236,7 +1236,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, sp_canvas_item_destroy(measure_tmp_items[idx]); } measure_tmp_items.clear(); - //TODO:Calculate the measure area for current lenght and origin + //TODO:Calculate the measure area for current length and origin // and use canvas->requestRedraw. In the calculation need a gap for outside text // maybe this remove the trash lines on measure use Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index ba333d0ed..bd4b21bdb 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -289,7 +289,7 @@ void ColorNotebook::_updateICCButtons() /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured color, - which means the paper can get too wet due to an excessive ammount of ink. This may lead to several + which means the paper can get too wet due to an excessive amount of ink. This may lead to several issues such as misalignment and poor quality of printing in general.*/ if (ink_sum > 3.2) diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp index d1755a6d5..f6c81df3b 100644 --- a/src/ui/widget/font-variants.cpp +++ b/src/ui/widget/font-variants.cpp @@ -563,7 +563,7 @@ namespace Widget { if( (it = table_copy.find("zero")) != table_copy.end() ) table_copy.erase( it ); std::string ott_list = "OpenType tables not included above: "; for(it = table_copy.begin(); it != table_copy.end(); ++it) { - // std::cout << "Other: " << it->first << " Occurances: " << it->second << std::endl; + // std::cout << "Other: " << it->first << " Occurrences: " << it->second << std::endl; ott_list += it->first; ott_list += ", "; } diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index ca33a845c..5f5b801d1 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -67,7 +67,7 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co show_all_children(); - // These signals dont properly detect change in desktop, rely on owner dialog to call setSubject() from setTargetDesktop() + // These signals don't properly detect change in desktop, rely on owner dialog to call setSubject() from setTargetDesktop() //_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_activate), this ); //_desktop_activated = g_signal_connect ( G_OBJECT (INKSCAPE), "deactivate_desktop", G_CALLBACK (&ObjectCompositeSettings::_on_desktop_deactivate), this ); } diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index b5498498d..06b65dfbc 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -104,7 +104,7 @@ public: void setDefaultResponse(int response_id); void setResponseSensitive(int response_id, bool setting); - /* Return signals. Signals emited by PanelDialog. */ + /* Return signals. Signals emitted by PanelDialog. */ virtual sigc::signal &signalDocumentReplaced(); virtual sigc::signal &signalActivateDesktop(); virtual sigc::signal &signalDeactiveDesktop(); diff --git a/src/uri.cpp b/src/uri.cpp index 219792b6e..881b322b4 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -158,7 +158,7 @@ const std::string URI::getFullPath(std::string const &base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } - // Check the existance of the file + // Check the existence of the file if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { path.clear(); diff --git a/src/uri.h b/src/uri.h index 7b57e1ae9..f0b59780e 100644 --- a/src/uri.h +++ b/src/uri.h @@ -53,7 +53,7 @@ public: /** * Determines if the URI represented is 'relative' as per RFC 2396. * - * Relative URI references are distinguished by not begining with a + * Relative URI references are distinguished by not beginning with a * scheme name. * * @return \c true if the URI is relative, \c false if it is absolute. diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp index 597c697cb..3d46fd81d 100644 --- a/src/widgets/ege-adjustment-action.cpp +++ b/src/widgets/ege-adjustment-action.cpp @@ -779,7 +779,7 @@ static void value_changed_cb( GtkSpinButton* spin, EgeAdjustmentAction* act ) if (GTK_IS_EDITABLE(spin) && gtk_editable_get_selection_bounds (GTK_EDITABLE(spin), &start, &end) && start != end) { // #167846, #363000 If the spin button has a selection, its probably - // because we got here from a Tab key from another spin, if so dont defocus + // because we got here from a Tab key from another spin, if so don't defocus return; } ege_adjustment_action_defocus( act ); diff --git a/src/widgets/ege-adjustment-action.h b/src/widgets/ege-adjustment-action.h index 8cfaa3e52..5cb21a481 100644 --- a/src/widgets/ege-adjustment-action.h +++ b/src/widgets/ege-adjustment-action.h @@ -96,7 +96,7 @@ GType ege_adjustment_action_get_type( void ); /* * Note: This normally could be implemented via a GType property for the class to construct, - * but gtkmm classes implemented in C++ only will often not funciton properly. + * but gtkmm classes implemented in C++ only will often not function properly. * */ diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 8946eb4b3..c61a857e7 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -733,7 +733,7 @@ void FillNStroke::updateFromPaint() if (!pattern) { /* No Pattern in paint selector should mean that we just - * changed mode - dont do jack. + * changed mode - don't do jack. */ } else { diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 196264315..976423aaf 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -669,7 +669,7 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool } if (n > 1) { - // Mulitple stops selected + // Multiple stops selected GtkListStore *store = (GtkListStore *)gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box)); if (!store) { return; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 4457b712d..840a64f95 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -572,7 +572,7 @@ sp_paint_selector_clear_frame(SPPaintSelector *psel) if (psel->selector) { //This is a hack to work around GtkNotebook bug in ColorSelector. Is sends signal switch-page on destroy - //The widget is hidden firts so it can recognize that it should not process signals from notebook child + //The widget is hidden first so it can recognize that it should not process signals from notebook child gtk_widget_set_visible(psel->selector, false); gtk_widget_destroy(psel->selector); psel->selector = NULL; diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 159350012..8a30b276b 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -248,7 +248,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole gboolean grabbed = held && !_held; gboolean released = !held && _held; - // Store these before emmiting any signals + // Store these before emitting any signals _held = held; if ( colorDifferent ) { diff --git a/src/widgets/stroke-marker-selector.h b/src/widgets/stroke-marker-selector.h index 24389526c..fb68aad58 100644 --- a/src/widgets/stroke-marker-selector.h +++ b/src/widgets/stroke-marker-selector.h @@ -66,7 +66,7 @@ private: class MarkerColumns : public Gtk::TreeModel::ColumnRecord { public: Gtk::TreeModelColumn label; - Gtk::TreeModelColumn marker; // ustring doesnt work here on windows due to unicode + Gtk::TreeModelColumn marker; // ustring doesn't work here on windows due to unicode Gtk::TreeModelColumn stock; Gtk::TreeModelColumn image; Gtk::TreeModelColumn history; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 3115a32db..fba6157e2 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -578,7 +578,7 @@ StrokeStyle::forkMarker(SPObject *marker, int loc, SPItem *item) /* * Optimization when all the references to this marker are from this item - * then we can reuse it and dont need to fork + * then we can reuse it and don't need to fork */ Glib::ustring urlId = Glib::ustring::format("url(#", marker->getRepr()->attribute("id"), ")"); unsigned int refs = 0; diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 8c7bec75b..2eab6e809 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -1654,7 +1654,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // If unit is set to 'px', use the preferred display unit (if absolute). line_height_unit = prefs->getInt("/tools/text/lineheight/display_unit", SP_CSS_UNIT_PT); - // But not if prefered unit is relative + // But not if preferred unit is relative if (line_height_unit != SP_CSS_UNIT_NONE && line_height_unit != SP_CSS_UNIT_EM && line_height_unit != SP_CSS_UNIT_EX && diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index c023dc670..e2af1afe2 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -174,7 +174,7 @@ std::string Inkscape::XML::calc_abs_doc_base(gchar const *doc_base) * It's probably not worth trying to address this until we're using proper * relative URL/IRI href processing (with liburiparser). * - * (Note that one possibile difficulty with `..' is symlinks.) */ + * (Note that one possible difficulty with `..' is symlinks.) */ std::string ret; if (!doc_base) { -- cgit v1.2.3 From 13cd1abbb6a366ca3a3ade2712fd3ce440adf9e6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 8 Nov 2017 00:27:29 +0100 Subject: Working on CPU issues --- src/ui/dialog/symbols.cpp | 68 +++++++++++++++++++++++------------------------ src/ui/dialog/symbols.h | 1 - 2 files changed, 34 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 51d801d6a..9c4f13946 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -343,13 +343,13 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay_title->set_valign(Gtk::ALIGN_START ); overlay_title->set_justify(Gtk::JUSTIFY_CENTER); overlay_title->set_margin_top(155); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc = new Gtk::Label(); overlay_desc->set_halign(Gtk::ALIGN_CENTER ); overlay_desc->set_valign(Gtk::ALIGN_START ); overlay_desc->set_margin_top(180); overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); overlay->add_overlay(* overlay_opacity); overlay->add_overlay(* overlay_icon); overlay->add_overlay(* overlay_title); @@ -943,42 +943,33 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) bool SymbolsDialog::callbackSymbols(){ Glib::ustring current = symbol_set->get_active_text(); + #if GTK_CHECK_VERSION(3,2,4) - if (current == _("All symbols sets") && - search->get_text() != _("Loading documents...")) +if (current == _("All symbols sets") && search->get_text() != _("Loading documents...") && !l.size()) { - if (!all_docs_processed) { - overlay_opacity->show(); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); - } - } - if (current == _("Current Document") && !icons_found) { - if (!all_docs_processed) { - overlay_icon->set_from_icon_name("none", iconsize); - overlay_opacity->show(); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + if (!all_docs_processed ) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); + } else { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); } + overlay_opacity->show(); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + return false; } #endif - if (current == _("All symbols sets") && - search->get_text() == _("Loading documents...") ) - { + if (current == _("All symbols sets") && search->get_text() == _("Loading documents...")) { #if GTK_CHECK_VERSION(3,2,4) overlay_opacity->show(); #endif if (!all_docs_processed) { #if GTK_CHECK_VERSION(3,2,4) - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); overlay_icon->set_from_icon_name("searching", iconsize); @@ -1053,8 +1044,8 @@ bool SymbolsDialog::callbackSymbols(){ } #if GTK_CHECK_VERSION(3,2,4) if (!icons_found && !search_str.empty()) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->show(); @@ -1094,9 +1085,8 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { if (!number_symbols) { #if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); + overlay_opacity->show(); overlay_icon->show(); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_title->show(); overlay_desc->show(); #endif @@ -1105,6 +1095,16 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { sensitive = true; enableWidgets(true); } +#if GTK_CHECK_VERSION(3,2,4) + Glib::ustring current = symbol_set->get_active_text(); + if (!number_symbols && (current != _("Current Document") || !search_str.empty())) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + } else if (!number_symbols) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); + } +#endif } void SymbolsDialog::addSymbols() { @@ -1129,8 +1129,8 @@ void SymbolsDialog::addSymbols() { if (!number_symbols) { #if GTK_CHECK_VERSION(3,2,4) overlay_icon->set_from_icon_name("none", iconsize); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index a4d1f93fb..8255877b8 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -138,7 +138,6 @@ private: Gtk::ScrolledWindow *scroller; Gtk::ToggleButton* fit_symbol; Gtk::IconSize iconsize; - void setTargetDesktop(SPDesktop *desktop); SPDesktop* current_desktop; DesktopTracker desk_track; -- cgit v1.2.3 From 1ead5fb28fa719125fa7a1893e1efa3db6a937c4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 8 Nov 2017 01:12:53 +0100 Subject: Reducing the risk of ocureences of 100% CPU bug --- src/ui/dialog/symbols.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 9c4f13946..f018261c6 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -446,8 +446,6 @@ void SymbolsDialog::rebuild() { search->set_text(""); } if (symbol_document) { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); addSymbolsInDoc(symbol_document); } } @@ -896,8 +894,6 @@ void SymbolsDialog::clearSearch() SPDocument* symbol_document = selectedSymbols(); if (symbol_document) { //We are not in search all docs - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); icons_found = false; addSymbolsInDoc(symbol_document); } else { @@ -923,8 +919,6 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) progress_bar->set_fraction(0.0); enableWidgets(false); SPDocument* symbol_document = selectedSymbols(); - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); if (symbol_document) { //We are not in search all docs search->set_text(_("Searching...")); @@ -932,6 +926,8 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) icons_found = false; addSymbolsInDoc(symbol_document); } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); search->set_text(_("Loading documents...")); } } @@ -1094,6 +1090,10 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { search->set_text(search_str); sensitive = true; enableWidgets(true); + idleconn.disconnect(); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); } #if GTK_CHECK_VERSION(3,2,4) Glib::ustring current = symbol_set->get_active_text(); @@ -1135,6 +1135,7 @@ void SymbolsDialog::addSymbols() { overlay_title->show(); overlay_desc->show(); #endif + idleconn.disconnect(); sensitive = false; search->set_text(search_str); sensitive = true; -- cgit v1.2.3 From d042ff18f4b4f4123794f457856552c5ebf8cd2e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 8 Nov 2017 01:59:30 +0100 Subject: Fixes CPU problems --- src/ui/dialog/symbols.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index f018261c6..52f22103f 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -447,6 +447,9 @@ void SymbolsDialog::rebuild() { } if (symbol_document) { addSymbolsInDoc(symbol_document); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); } } @@ -897,6 +900,8 @@ void SymbolsDialog::clearSearch() icons_found = false; addSymbolsInDoc(symbol_document); } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); enableWidgets(true); } } -- cgit v1.2.3 From 24db09e6b2d18dedd76bca079be820ab1364298c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 8 Nov 2017 21:59:16 +0100 Subject: Refactor and order of document list --- src/ui/dialog/symbols.cpp | 363 ++++++++++++++++++++++------------------------ src/ui/dialog/symbols.h | 5 +- 2 files changed, 179 insertions(+), 189 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 52f22103f..c04b8bcc2 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -69,7 +69,8 @@ namespace Inkscape { namespace UI { namespace Dialog { - +const Glib::ustring CURRENTDOC = _("Current Document"); +const Glib::ustring ALLDOCS = _("All symbols sets"); // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html class SymbolColumns : public Gtk::TreeModel::ColumnRecord { @@ -122,9 +123,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::Label* label_set = new Gtk::Label(_("Symbol set: ")); table->attach(*Gtk::manage(label_set),0,row,1,1); symbol_set = new Gtk::ComboBoxText(); // Fill in later - symbol_set->append(_("Current Document")); - symbol_set->append(_("All symbols sets")); - symbol_set->set_active_text(_("Current Document")); + symbol_set->append(CURRENTDOC); + symbol_set->append(ALLDOCS); + symbol_set->set_active_text(CURRENTDOC); symbol_set->set_hexpand(); table->attach(*Gtk::manage(symbol_set),1,row,1,1); @@ -196,6 +197,31 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->add(* scroller); scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); + + /*************************Overlays******************************/ + overlay_opacity = new Gtk::Image(); + overlay_opacity->set_halign(Gtk::ALIGN_START ); + overlay_opacity->set_valign(Gtk::ALIGN_START ); + //No results + iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); + overlay_icon = new Gtk::Image(); + overlay_icon->set_halign(Gtk::ALIGN_CENTER ); + overlay_icon->set_valign(Gtk::ALIGN_START ); + overlay_icon->set_margin_top(45); + overlay_title = new Gtk::Label(); + overlay_title->set_halign(Gtk::ALIGN_CENTER ); + overlay_title->set_valign(Gtk::ALIGN_START ); + overlay_title->set_justify(Gtk::JUSTIFY_CENTER); + overlay_title->set_margin_top(155); + overlay_desc = new Gtk::Label(); + overlay_desc->set_halign(Gtk::ALIGN_CENTER ); + overlay_desc->set_valign(Gtk::ALIGN_START ); + overlay_desc->set_margin_top(180); + overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); + overlay->add_overlay(* overlay_opacity); + overlay->add_overlay(* overlay_icon); + overlay->add_overlay(* overlay_title); + overlay->add_overlay(* overlay_desc); #else table->attach(*Gtk::manage(scroller),0,row,2,1); #endif @@ -322,38 +348,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : // This might need to be a global variable so setTargetDesktop can modify it SPDefs *defs = current_document->getDefs(); - - /*************************Overlays******************************/ #if GTK_CHECK_VERSION(3,2,4) - //Loading - overlay_opacity = new Gtk::Image(); overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); - overlay_opacity->set_halign(Gtk::ALIGN_START ); - overlay_opacity->set_valign(Gtk::ALIGN_START ); - //No results - iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); - overlay_icon = new Gtk::Image(); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon = new Gtk::Image(); - overlay_icon->set_halign(Gtk::ALIGN_CENTER ); - overlay_icon->set_valign(Gtk::ALIGN_START ); - overlay_icon->set_margin_top(45); - overlay_title = new Gtk::Label(); - overlay_title->set_halign(Gtk::ALIGN_CENTER ); - overlay_title->set_valign(Gtk::ALIGN_START ); - overlay_title->set_justify(Gtk::JUSTIFY_CENTER); - overlay_title->set_margin_top(155); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc = new Gtk::Label(); - overlay_desc->set_halign(Gtk::ALIGN_CENTER ); - overlay_desc->set_valign(Gtk::ALIGN_START ); - overlay_desc->set_margin_top(180); - overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); - overlay->add_overlay(* overlay_opacity); - overlay->add_overlay(* overlay_icon); - overlay->add_overlay(* overlay_title); - overlay->add_overlay(* overlay_desc); #endif sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); @@ -373,9 +369,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); instanceConns.push_back( desktopChangeConn ); desk_track.connect(GTK_WIDGET(gobj())); -#if GTK_CHECK_VERSION(3,2,4) - overlay->hide(); -#endif } SymbolsDialog::~SymbolsDialog() @@ -448,11 +441,67 @@ void SymbolsDialog::rebuild() { if (symbol_document) { addSymbolsInDoc(symbol_document); } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + showOverlay(); + } +} +void SymbolsDialog::showOverlay() { +#if GTK_CHECK_VERSION(3,2,4) +Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); + if (current == ALLDOCS && + search->get_text() != _("Loading documents...") && + !l.size()) + { + if (!all_docs_processed ) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); + } else if (!icons_found && !search_str.empty()) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); + } else { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); + } + } else if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { + if (!all_docs_processed) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); + overlay_icon->show(); + overlay_title->show(); + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_desc->show(); + } + } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + } else if (!number_symbols && current == CURRENTDOC) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); + } else if (!icons_found && !search_str.empty()) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + } + overlay_opacity->show(); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + if (l.size()) { + overlay_opacity->show(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); } +#endif } +void SymbolsDialog::hideOverlay() { +#if GTK_CHECK_VERSION(3,2,4) + overlay_opacity->hide(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); +#endif +} void SymbolsDialog::insertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); @@ -484,7 +533,7 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*cont void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) { Glib::ustring doc_title = symbol_set->get_active_text(); - if (doc_title != _("All symbols sets") && !symbol_sets[symbol_set->get_active_text()] ) { + if (doc_title != ALLDOCS && !symbol_sets[doc_title] ) { rebuild(); } } @@ -517,7 +566,7 @@ void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) SPDocument* SymbolsDialog::selectedSymbols() { /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ Glib::ustring doc_title = symbol_set->get_active_text(); - if (doc_title == _("All symbols sets")) { + if (doc_title == ALLDOCS) { return NULL; } SPDocument* symbol_document = symbol_sets[doc_title]; @@ -563,19 +612,17 @@ Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { } Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { - Glib::ustring title = _("Untitled document"); if (symbol_doc) { SPRoot * root = symbol_doc->getRoot(); if (root->title()) { - title = ellipsize(Glib::ustring(root->title())); - return title; + return ellipsize(Glib::ustring(root->title()), 33); } } Glib::ustring current = symbol_set->get_active_text(); - if (current == _("Current Document")) { + if (current == CURRENTDOC) { return current; } - return title; + return _("Untitled document"); } void SymbolsDialog::iconChanged() { @@ -749,7 +796,6 @@ void SymbolsDialog::getSymbolsFilename() { title = _("Unnamed Symbols"); } symbol_sets[title]= NULL; - symbol_set->append(title); ++number_docs; } #ifdef WITH_LIBVISIO @@ -761,11 +807,13 @@ void SymbolsDialog::getSymbolsFilename() { title = _("Unnamed Symbols"); } symbol_sets[title]= NULL; - symbol_set->append(title); ++number_docs; } #endif } + for(auto const &symbol_document_map : symbol_sets) { + symbol_set->append(symbol_document_map.first); + } } /* Hunts preference directories for symbol files */ @@ -773,12 +821,20 @@ std::pair SymbolsDialog::getSymbolsSet(Glib::ustring title) { if (symbol_sets[title]) { + sensitive = false; + symbol_set->remove_all(); + symbol_set->append(CURRENTDOC); + symbol_set->append(ALLDOCS); + for(auto const &symbol_document_map : symbol_sets) { + symbol_set->append(symbol_document_map.first); + } + symbol_set->set_active_text(new_title); + sensitive = true; return std::make_pair(title, symbol_sets[title]); } using namespace Inkscape::IO::Resource; SPDocument* symbol_doc = NULL; Glib::ustring new_title; - size_t i = 0; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { std::size_t pos = filename.find_last_of("/\\"); if (pos != std::string::npos) { @@ -787,35 +843,33 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); if(symbol_doc) { new_title = documentTitle(symbol_doc); + break; } } - if(Glib::str_has_suffix(filename, ".svg")) { - i++; - } #ifdef WITH_LIBVISIO if(filename_short == title + ".vss") { symbol_doc = read_vss(filename, title); if(symbol_doc) { new_title = documentTitle(symbol_doc); + break; } } - if(Glib::str_has_suffix(filename, ".vss")) { - i++; - } #endif - if(symbol_doc) { - symbol_sets.erase(title); - symbol_sets[new_title]= symbol_doc; - sensitive = false; - symbol_set->remove_text(i+1); - symbol_set->insert (i+1, new_title); - symbol_set->set_active(i+1); - symbol_set->set_active_text(new_title); - sensitive = true; - break; - } } } + if(symbol_doc) { + symbol_sets.erase(title); + symbol_sets[new_title] = symbol_doc; + sensitive = false; + symbol_set->remove_all(); + symbol_set->append(CURRENTDOC); + symbol_set->append(ALLDOCS); + for(auto const &symbol_document_map : symbol_sets) { + symbol_set->append(symbol_document_map.first); + } + symbol_set->set_active_text(new_title); + sensitive = true; + } return std::make_pair(new_title, symbol_doc); } @@ -900,8 +954,7 @@ void SymbolsDialog::clearSearch() icons_found = false; addSymbolsInDoc(symbol_document); } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + showOverlay(); enableWidgets(true); } } @@ -932,7 +985,7 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) addSymbolsInDoc(symbol_document); } else { idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackAllSymbols)); search->set_text(_("Loading documents...")); } } @@ -943,72 +996,8 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) } bool SymbolsDialog::callbackSymbols(){ - Glib::ustring current = symbol_set->get_active_text(); - -#if GTK_CHECK_VERSION(3,2,4) -if (current == _("All symbols sets") && search->get_text() != _("Loading documents...") && !l.size()) - { - if (!all_docs_processed ) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); - } else { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); - } - overlay_opacity->show(); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); - return false; - } -#endif - if (current == _("All symbols sets") && search->get_text() == _("Loading documents...")) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_opacity->show(); -#endif - if (!all_docs_processed) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); - overlay_icon->show(); - overlay_title->show(); - overlay_icon->set_from_icon_name("searching", iconsize); - overlay_desc->show(); -#endif - } - size_t counter = 0; - for(auto const &symbol_document_map : symbol_sets) { - ++counter; - SPDocument* symbol_document = symbol_document_map.second; - if (symbol_document) { - continue; - } - symbol_document = getSymbolsSet(symbol_document_map.first).second; - symbol_set->set_active_text(_("All symbols sets")); - if (!symbol_document) { - continue; - } - progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); - return true; - } -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->hide(); - overlay_title->hide(); - overlay_desc->hide(); -#endif - progress_bar->set_fraction(1.0); - all_docs_processed = true; - addSymbols(); - search->set_text("Documents done, searchig inside..."); - return true; - } else if (l.size()) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_opacity->show(); - overlay_icon->hide(); - overlay_title->hide(); - overlay_desc->hide(); -#endif + if (l.size()) { + showOverlay(); for (auto symbol_data = l.begin(); symbol_data != l.end();) { Glib::ustring doc_title = symbol_data->first; SPSymbol * symbol = symbol_data->second; @@ -1043,18 +1032,11 @@ if (current == _("All symbols sets") && search->get_text() != _("Loading documen return true; } } -#if GTK_CHECK_VERSION(3,2,4) if (!icons_found && !search_str.empty()) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); + showOverlay(); } else { - overlay_opacity->hide(); + hideOverlay(); } -#endif sensitive = false; search->set_text(search_str); sensitive = true; @@ -1064,9 +1046,40 @@ if (current == _("All symbols sets") && search->get_text() != _("Loading documen return true; } +bool SymbolsDialog::callbackAllSymbols(){ + Glib::ustring current = symbol_set->get_active_text(); + if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { + size_t counter = 0; + std::map symbol_sets_tmp = symbol_sets; + for(auto const &symbol_document_map : symbol_sets_tmp) { + ++counter; + SPDocument* symbol_document = symbol_document_map.second; + if (symbol_document) { + continue; + } + symbol_document = getSymbolsSet(symbol_document_map.first).second; + symbol_set->set_active_text(ALLDOCS); + if (!symbol_document) { + continue; + } + progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); + return true; + } + symbol_sets_tmp.clear(); + hideOverlay(); + progress_bar->set_fraction(1.0); + all_docs_processed = true; + addSymbols(); + search->set_text("Documents done, searchig inside..."); + return false; + } + return true; +} + Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { if (data.length() > limit) { - return data.substr(0,limit-3) + "..."; + data = data.substr(0, limit-3); + return data + "..."; } return data; } @@ -1079,72 +1092,47 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { Glib::ustring doc_title = documentTitle(symbol_document); progress_bar->set_fraction(0.0); counter_symbols = 0; - std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); - number_symbols = container_symbols_tmp.size(); - l = container_symbols_tmp; - container_symbols_tmp.clear(); + l = symbolsInDoc(symbol_document, doc_title); + number_symbols = l.size(); if (!number_symbols) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->set_from_icon_name("none", iconsize); - overlay_opacity->show(); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); -#endif sensitive = false; search->set_text(search_str); sensitive = true; enableWidgets(true); idleconn.disconnect(); + showOverlay(); } else { idleconn.disconnect(); idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); } -#if GTK_CHECK_VERSION(3,2,4) - Glib::ustring current = symbol_set->get_active_text(); - if (!number_symbols && (current != _("Current Document") || !search_str.empty())) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - } else if (!number_symbols) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); - } -#endif } void SymbolsDialog::addSymbols() { store->clear(); icons_found = false; - std::vector > container_symbols; for(auto const &symbol_document_map : symbol_sets) { SPDocument* symbol_document = symbol_document_map.second; if (!symbol_document) { continue; } Glib::ustring doc_title = documentTitle(symbol_document); - std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); - container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); - container_symbols_tmp.clear(); + std::vector > l_tmp = symbolsInDoc(symbol_document, doc_title); + l.insert(l.end(), std::make_move_iterator(l_tmp.begin()), std::make_move_iterator(l_tmp.end())); + l_tmp.clear(); } counter_symbols = 0; progress_bar->set_fraction(0.0); - number_symbols = container_symbols.size(); - l = container_symbols; - container_symbols.clear(); + number_symbols = l.size(); if (!number_symbols) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->set_from_icon_name("none", iconsize); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); -#endif + showOverlay(); idleconn.disconnect(); sensitive = false; search->set_text(search_str); sensitive = true; enableWidgets(true); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); } } @@ -1157,19 +1145,18 @@ void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { if( !title ) { title = id; } - Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); if (doc_title.empty()) { - doc_title = _("Current Document"); + doc_title = CURRENTDOC; } - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); + Glib::ustring symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")"); Glib::RefPtr pixbuf = drawSymbol( symbol ); if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); - (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = symbol_title; - (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(doc_title); - (*row)[columns->symbol_image] = pixbuf; + (*row)[columns->symbol_id] = Glib::ustring( id ); + (*row)[columns->symbol_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", symbol_title.c_str()) )); + (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "SymbolDoc", doc_title.c_str()) )); + (*row)[columns->symbol_image] = pixbuf; } delete columns; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 8255877b8..2fcdcfe72 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -94,10 +94,13 @@ private: void unsensitive(GdkEventKey* evt); void addSymbols(); void addSymbolsInDoc(SPDocument* document); + void showOverlay(); + void hideOverlay(); void clearSearch(); bool callbackSymbols(); + bool callbackAllSymbols(); void enableWidgets(bool enable); - Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); + Glib::ustring ellipsize(Glib::ustring data, size_t limit); gchar const* styleFromUse( gchar const* id, SPDocument* document); Glib::RefPtr drawSymbol(SPObject *symbol, unsigned force_psize = 0); Glib::RefPtr getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); -- cgit v1.2.3 From 434bc94a17b4912e31e78cd7913e169bff1295d9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 8 Nov 2017 23:47:43 +0100 Subject: Now symbols are sorted --- src/ui/dialog/symbols.cpp | 33 ++++++++++++++++++++------------- src/ui/dialog/symbols.h | 6 +++--- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index c04b8bcc2..aef7948d8 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -828,7 +828,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) for(auto const &symbol_document_map : symbol_sets) { symbol_set->append(symbol_document_map.first); } - symbol_set->set_active_text(new_title); + symbol_set->set_active_text(title); sensitive = true; return std::make_pair(title, symbol_sets[title]); } @@ -873,7 +873,7 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) return std::make_pair(new_title, symbol_doc); } -void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title) +void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::map > &l, Glib::ustring doc_title) { if(!r) return; @@ -882,19 +882,24 @@ void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector(r) ) { - l.push_back(std::make_pair(doc_title,dynamic_cast(r))); + if ( dynamic_cast(r) && r->title()) { + Glib::ustring current = symbol_set->get_active_text(); + if (current == ALLDOCS) { + l[doc_title + r->title()] = std::make_pair(doc_title,dynamic_cast(r)); + } else { + l[r->title()] = std::make_pair(doc_title,dynamic_cast(r)); + } } for (auto& child: r->children) { symbolsInDocRecursive(&child, l, doc_title); } } -std::vector > +std::map > SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_title) { - std::vector > l; + std::map > l; if (symbol_document) { symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); } @@ -999,8 +1004,8 @@ bool SymbolsDialog::callbackSymbols(){ if (l.size()) { showOverlay(); for (auto symbol_data = l.begin(); symbol_data != l.end();) { - Glib::ustring doc_title = symbol_data->first; - SPSymbol * symbol = symbol_data->second; + Glib::ustring doc_title = symbol_data->second.first; + SPSymbol * symbol = symbol_data->second.second; counter_symbols ++; gchar const *symbol_title_char = symbol->title(); gchar const *symbol_desc_char = symbol->description(); @@ -1116,8 +1121,10 @@ void SymbolsDialog::addSymbols() { continue; } Glib::ustring doc_title = documentTitle(symbol_document); - std::vector > l_tmp = symbolsInDoc(symbol_document, doc_title); - l.insert(l.end(), std::make_move_iterator(l_tmp.begin()), std::make_move_iterator(l_tmp.end())); + std::map > l_tmp = symbolsInDoc(symbol_document, doc_title); + for(auto &p : l_tmp ) { + l[p.first] = p.second; + } l_tmp.clear(); } counter_symbols = 0; @@ -1310,11 +1317,11 @@ gchar const *buffer = ""; SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector > symbols_data = symbolsInDoc(doc, "Overlay Doc"); + std::map > symbols_data = symbolsInDoc(doc, "Overlay Doc"); Glib::RefPtr pixbuf(NULL); for(auto data:symbols_data) { - Glib::ustring doc_title = data.first; - SPSymbol * symbol = data.second; + Glib::ustring doc_title = data.second.first; + SPSymbol * symbol = data.second.second; if (!strcmp(symbol->getId(), icon_title)) { pixbuf = drawSymbol(symbol, psize); return pixbuf; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 2fcdcfe72..f387dde51 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -86,8 +86,8 @@ private: std::pair getSymbolsSet(Glib::ustring title); void addSymbol( SPObject* symbol, Glib::ustring doc_title); SPDocument* symbolsPreviewDoc(); - void symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title); - std::vector > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); + void symbolsInDocRecursive (SPObject *r, std::map > &l, Glib::ustring doc_title); + std::map > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); void useInDoc(SPObject *r, std::vector &l); std::vector useInDoc( SPDocument* document); void beforeSearch(GdkEventKey* evt); @@ -106,7 +106,7 @@ private: Glib::RefPtr getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); /* Keep track of all symbol template documents */ std::map symbol_sets; - std::vector > l; + std::map > l; // Index into sizes which is selected int pack_size; // Scale factor -- cgit v1.2.3 From 0af722a0a0eaef1b1f2bb096935af2c6645c9719 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 10 Nov 2017 01:58:44 +0100 Subject: Start working on Eduard improvements --- src/ui/dialog/symbols.cpp | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index aef7948d8..44f161184 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -432,8 +432,8 @@ void SymbolsDialog::rebuild() { icons_found = false; //We are not in search all docs if (search->get_text() != _("Searching...") && - search->get_text() != _("Loading documents...") && - search->get_text() != _("Documents done, searchig inside...") ) + search->get_text() != _("Loading all symbols...") && + search->get_text() != _("Searching....") ) { search_str = ""; search->set_text(""); @@ -446,22 +446,25 @@ void SymbolsDialog::rebuild() { } void SymbolsDialog::showOverlay() { #if GTK_CHECK_VERSION(3,2,4) -Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); + Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); + overlay_icon->set_from_icon_name("none", iconsize); if (current == ALLDOCS && - search->get_text() != _("Loading documents...") && + search->get_text() != _("Loading all symbols...") && !l.size()) { if (!all_docs_processed ) { + overlay_icon->set_from_icon_name("search", iconsize); overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("First search can be slow.")) + Glib::ustring("")); } else if (!icons_found && !search_str.empty()) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a different search term.")) + Glib::ustring("")); } else { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); + overlay_icon->set_from_icon_name("search", iconsize); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("")) + Glib::ustring("")); } - } else if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { + } else if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { if (!all_docs_processed) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); @@ -472,16 +475,15 @@ Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()) } } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); } else if (!number_symbols && current == CURRENTDOC) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document\nChoose a different symbol set\nor add a new symbol.")) + Glib::ustring("")); } else if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); } overlay_opacity->show(); - overlay_icon->set_from_icon_name("none", iconsize); overlay_icon->show(); overlay_title->show(); overlay_desc->show(); @@ -826,7 +828,9 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) symbol_set->append(CURRENTDOC); symbol_set->append(ALLDOCS); for(auto const &symbol_document_map : symbol_sets) { - symbol_set->append(symbol_document_map.first); + if (CURRENTDOC != symbol_document_map.first) { + symbol_set->append(symbol_document_map.first); + } } symbol_set->set_active_text(title); sensitive = true; @@ -865,7 +869,9 @@ SymbolsDialog::getSymbolsSet(Glib::ustring title) symbol_set->append(CURRENTDOC); symbol_set->append(ALLDOCS); for(auto const &symbol_document_map : symbol_sets) { - symbol_set->append(symbol_document_map.first); + if (CURRENTDOC != symbol_document_map.first) { + symbol_set->append(symbol_document_map.first); + } } symbol_set->set_active_text(new_title); sensitive = true; @@ -991,7 +997,7 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) } else { idleconn.disconnect(); idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackAllSymbols)); - search->set_text(_("Loading documents...")); + search->set_text(_("Loading all symbols...")); } } @@ -1053,7 +1059,7 @@ bool SymbolsDialog::callbackSymbols(){ bool SymbolsDialog::callbackAllSymbols(){ Glib::ustring current = symbol_set->get_active_text(); - if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { + if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { size_t counter = 0; std::map symbol_sets_tmp = symbol_sets; for(auto const &symbol_document_map : symbol_sets_tmp) { @@ -1075,7 +1081,7 @@ bool SymbolsDialog::callbackAllSymbols(){ progress_bar->set_fraction(1.0); all_docs_processed = true; addSymbols(); - search->set_text("Documents done, searchig inside..."); + search->set_text("Searching...."); return false; } return true; -- cgit v1.2.3 From 5ec782085c8ad17039591316e00140da6609b0ef Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 10 Nov 2017 19:47:09 +0100 Subject: Add eduard improvements --- src/ui/dialog/symbols.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 44f161184..1fcede8f1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -453,15 +453,15 @@ void SymbolsDialog::showOverlay() { !l.size()) { if (!all_docs_processed ) { - overlay_icon->set_from_icon_name("search", iconsize); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("First search can be slow.")) + Glib::ustring("")); } else if (!icons_found && !search_str.empty()) { overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a different search term.")) + Glib::ustring("")); } else { - overlay_icon->set_from_icon_name("search", iconsize); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("")); overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("")) + Glib::ustring("")); } } else if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { -- cgit v1.2.3 From c78c92430c6a07adf448fe9ff8105f2935aa1d5e Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 9 Nov 2017 19:03:26 +0100 Subject: Add lock margins to document settings --- src/ui/dialog/symbols.cpp.orig | 1364 ++++++++++++++++++++++++++++++++++++++++ src/ui/dialog/symbols.cpp.rej | 384 +++++++++++ src/ui/dialog/symbols.h.orig | 172 +++++ src/ui/dialog/symbols.h.rej | 19 + src/ui/widget/page-sizer.cpp | 45 +- src/ui/widget/page-sizer.h | 26 +- 6 files changed, 1994 insertions(+), 16 deletions(-) create mode 100644 src/ui/dialog/symbols.cpp.orig create mode 100644 src/ui/dialog/symbols.cpp.rej create mode 100644 src/ui/dialog/symbols.h.orig create mode 100644 src/ui/dialog/symbols.h.rej (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp.orig b/src/ui/dialog/symbols.cpp.orig new file mode 100644 index 000000000..52f22103f --- /dev/null +++ b/src/ui/dialog/symbols.cpp.orig @@ -0,0 +1,1364 @@ +/** + * @file + * Symbols dialog. + */ +/* Authors: + * Copyright (C) 2012 Tavmjong Bah + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include +#include + +#include "path-prefix.h" +#include "io/sys.h" +#include "io/resource.h" + +#include "ui/cache/svg_preview_cache.h" +#include "ui/clipboard.h" +#include "ui/icon-names.h" + +#include "symbols.h" + +#include "selection.h" +#include "desktop.h" + +#include "document.h" +#include "inkscape.h" +#include "sp-root.h" +#include "sp-use.h" +#include "sp-defs.h" +#include "sp-symbol.h" + +#ifdef WITH_LIBVISIO + #include + + // TODO: Drop this check when librevenge is widespread. + #if WITH_LIBVISIO01 + #include + + using librevenge::RVNGFileStream; + using librevenge::RVNGString; + using librevenge::RVNGStringVector; + using librevenge::RVNGPropertyList; + using librevenge::RVNGSVGDrawingGenerator; + #else + #include + + typedef WPXFileStream RVNGFileStream; + typedef libvisio::VSDStringVector RVNGStringVector; + #endif +#endif + +#include "verbs.h" +#include "helper/action.h" +#include + +namespace Inkscape { +namespace UI { + +namespace Dialog { + +// See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html +class SymbolColumns : public Gtk::TreeModel::ColumnRecord +{ +public: + + Gtk::TreeModelColumn symbol_id; + Gtk::TreeModelColumn symbol_title; + Gtk::TreeModelColumn symbol_doc_title; + Gtk::TreeModelColumn< Glib::RefPtr > symbol_image; + + + SymbolColumns() { + add(symbol_id); + add(symbol_title); + add(symbol_doc_title); + add(symbol_image); + } +}; + +SymbolColumns* SymbolsDialog::getColumns() +{ + SymbolColumns* columns = new SymbolColumns(); + return columns; +} + +/** + * Constructor + */ +SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : + UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), + store(Gtk::ListStore::create(*getColumns())), + icon_view(0), + current_desktop(0), + desk_track(), + current_document(0), + preview_document(0), + instanceConns() +{ + + /******************** Table *************************/ + auto table = new Gtk::Grid(); + table->set_margin_left(3); + table->set_margin_right(3); + table->set_margin_top(4); + // panel is a cloked Gtk::VBox + _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); + guint row = 0; + + /******************** Symbol Sets *************************/ + Gtk::Label* label_set = new Gtk::Label(_("Symbol set: ")); + table->attach(*Gtk::manage(label_set),0,row,1,1); + symbol_set = new Gtk::ComboBoxText(); // Fill in later + symbol_set->append(_("Current Document")); + symbol_set->append(_("All symbols sets")); + symbol_set->set_active_text(_("Current Document")); + symbol_set->set_hexpand(); + + table->attach(*Gtk::manage(symbol_set),1,row,1,1); + sigc::connection connSet = symbol_set->signal_changed().connect( + sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + instanceConns.push_back(connSet); + + ++row; + + /******************** Separator *************************/ + + + Gtk::Separator* separator = Gtk::manage(new Gtk::Separator()); // Search + separator->set_margin_top(10); + separator->set_margin_bottom(10); + table->attach(*Gtk::manage(separator),0,row,2,1); + + ++row; + + /******************** Search *************************/ + + + search = Gtk::manage(new Gtk::SearchEntry()); // Search + search->set_tooltip_text(_("Return to start search.")); + search->signal_key_press_event().connect_notify( sigc::mem_fun(*this, &SymbolsDialog::beforeSearch)); + search->signal_key_release_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::unsensitive)); + search->set_margin_left(10); + search->set_margin_right(10); + search->set_margin_bottom(6); + search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); + table->attach(*Gtk::manage(search),0,row,2,1); + search_str = ""; + + ++row; + + + /********************* Icon View **************************/ + SymbolColumns* columns = getColumns(); + + icon_view = new Gtk::IconView(static_cast >(store)); + //icon_view->set_text_column( columns->symbol_id ); + icon_view->set_tooltip_column( 1 ); + icon_view->set_pixbuf_column( columns->symbol_image ); + // Giving the iconview a small minimum size will help users understand + // What the dialog does. + icon_view->set_size_request( 100, 250 ); + + std::vector< Gtk::TargetEntry > targets; + targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); + + icon_view->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); + icon_view->signal_drag_data_get().connect( + sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); + + sigc::connection connIconChanged; + connIconChanged = icon_view->signal_selection_changed().connect( + sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); + instanceConns.push_back(connIconChanged); + + scroller = new Gtk::ScrolledWindow(); + scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); + scroller->add(*Gtk::manage(icon_view)); + scroller->set_hexpand(); + scroller->set_vexpand(); +#if GTK_CHECK_VERSION(3,2,4) + overlay = new Gtk::Overlay(); + overlay->set_hexpand(); + overlay->set_vexpand(); + overlay->add(* scroller); + scroller->set_size_request(100, 250); + table->attach(*Gtk::manage(overlay),0,row,2,1); +#else + table->attach(*Gtk::manage(scroller),0,row,2,1); +#endif + ++row; + + /******************** Progress *******************************/ + progress = new Gtk::HBox(); + progress_bar = Gtk::manage(new Gtk::ProgressBar()); + table->attach(*Gtk::manage(progress),0,row, 2, 1); + progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); + progress->set_margin_top(15); + progress->set_margin_bottom(15); + progress->set_margin_left(20); + progress->set_margin_right(20); + + ++row; + + /******************** Tools *******************************/ + tools = new Gtk::HBox(); + + //tools->set_layout( Gtk::BUTTONBOX_END ); + scroller->set_hexpand(); + table->attach(*Gtk::manage(tools),0,row,2,1); + + auto add_symbol_image = Gtk::manage(new Gtk::Image()); + add_symbol_image->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + add_symbol = Gtk::manage(new Gtk::Button()); + add_symbol->add(*add_symbol_image); + add_symbol->set_tooltip_text(_("Add Symbol from the current document.")); + add_symbol->set_relief( Gtk::RELIEF_NONE ); + add_symbol->set_focus_on_click( false ); + add_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); + tools->pack_start(* add_symbol, Gtk::PACK_SHRINK); + + auto remove_symbolImage = Gtk::manage(new Gtk::Image()); + remove_symbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + remove_symbol = Gtk::manage(new Gtk::Button()); + remove_symbol->add(*remove_symbolImage); + remove_symbol->set_tooltip_text(_("Remove Symbol from the current document.")); + remove_symbol->set_relief( Gtk::RELIEF_NONE ); + remove_symbol->set_focus_on_click( false ); + remove_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol)); + tools->pack_start(* remove_symbol, Gtk::PACK_SHRINK); + + Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); + tools->pack_start(* Gtk::manage(spacer)); + + // Pack size (controls display area) + pack_size = 2; // Default 32px + + auto packMoreImage = Gtk::manage(new Gtk::Image()); + packMoreImage->set_from_icon_name("pack-more", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + more = Gtk::manage(new Gtk::Button()); + more->add(*packMoreImage); + more->set_tooltip_text(_("Display more icons in row.")); + more->set_relief( Gtk::RELIEF_NONE ); + more->set_focus_on_click( false ); + more->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore)); + tools->pack_start(* more, Gtk::PACK_SHRINK); + + auto packLessImage = Gtk::manage(new Gtk::Image()); + packLessImage->set_from_icon_name("pack-less", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + fewer = Gtk::manage(new Gtk::Button()); + fewer->add(*packLessImage); + fewer->set_tooltip_text(_("Display fewer icons in row.")); + fewer->set_relief( Gtk::RELIEF_NONE ); + fewer->set_focus_on_click( false ); + fewer->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packless)); + tools->pack_start(* fewer, Gtk::PACK_SHRINK); + + // Toggle scale to fit on/off + auto fit_symbolImage = Gtk::manage(new Gtk::Image()); + fit_symbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + fit_symbol = Gtk::manage(new Gtk::ToggleButton()); + fit_symbol->add(*fit_symbolImage); + fit_symbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); + fit_symbol->set_relief( Gtk::RELIEF_NONE ); + fit_symbol->set_focus_on_click( false ); + fit_symbol->set_active( true ); + fit_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); + tools->pack_start(* fit_symbol, Gtk::PACK_SHRINK); + + // Render size (scales symbols within display area) + scale_factor = 0; // Default 1:1 * pack_size/pack_size default + auto zoom_outImage = Gtk::manage(new Gtk::Image()); + zoom_outImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + zoom_out = Gtk::manage(new Gtk::Button()); + zoom_out->add(*zoom_outImage); + zoom_out->set_tooltip_text(_("Make symbols smaller by zooming out.")); + zoom_out->set_relief( Gtk::RELIEF_NONE ); + zoom_out->set_focus_on_click( false ); + zoom_out->set_sensitive( false ); + zoom_out->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); + tools->pack_start(* zoom_out, Gtk::PACK_SHRINK); + + auto zoom_inImage = Gtk::manage(new Gtk::Image()); + zoom_inImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR); + + zoom_in = Gtk::manage(new Gtk::Button()); + zoom_in->add(*zoom_inImage); + zoom_in->set_tooltip_text(_("Make symbols bigger by zooming in.")); + zoom_in->set_relief( Gtk::RELIEF_NONE ); + zoom_in->set_focus_on_click( false ); + zoom_in->set_sensitive( false ); + zoom_in->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin)); + tools->pack_start(* zoom_in, Gtk::PACK_SHRINK); + + ++row; + + sensitive = true; + + current_desktop = SP_ACTIVE_DESKTOP; + current_document = current_desktop->getDocument(); + preview_document = symbolsPreviewDoc(); /* Template to render symbols in */ + preview_document->ensureUpToDate(); /* Necessary? */ + key = SPItem::display_key_new(1); + renderDrawing.setRoot(preview_document->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); + + // This might need to be a global variable so setTargetDesktop can modify it + SPDefs *defs = current_document->getDefs(); + + /*************************Overlays******************************/ +#if GTK_CHECK_VERSION(3,2,4) + //Loading + overlay_opacity = new Gtk::Image(); + overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); + overlay_opacity->set_halign(Gtk::ALIGN_START ); + overlay_opacity->set_valign(Gtk::ALIGN_START ); + //No results + iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); + overlay_icon = new Gtk::Image(); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_icon = new Gtk::Image(); + overlay_icon->set_halign(Gtk::ALIGN_CENTER ); + overlay_icon->set_valign(Gtk::ALIGN_START ); + overlay_icon->set_margin_top(45); + overlay_title = new Gtk::Label(); + overlay_title->set_halign(Gtk::ALIGN_CENTER ); + overlay_title->set_valign(Gtk::ALIGN_START ); + overlay_title->set_justify(Gtk::JUSTIFY_CENTER); + overlay_title->set_margin_top(155); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc = new Gtk::Label(); + overlay_desc->set_halign(Gtk::ALIGN_CENTER ); + overlay_desc->set_valign(Gtk::ALIGN_START ); + overlay_desc->set_margin_top(180); + overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); + overlay->add_overlay(* overlay_opacity); + overlay->add_overlay(* overlay_icon); + overlay->add_overlay(* overlay_title); + overlay->add_overlay(* overlay_desc); +#endif + sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); + instanceConns.push_back(defsModifiedConn); + + sigc::connection selectionChangedConn = current_desktop->selection->connectChanged( + sigc::mem_fun(*this, &SymbolsDialog::selectionChanged)); + instanceConns.push_back(selectionChangedConn); + + sigc::connection documentReplacedConn = current_desktop->connectDocumentReplaced( + sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); + instanceConns.push_back(documentReplacedConn); + getSymbolsFilename(); + icons_found = false; + + addSymbolsInDoc(current_document); /* Defaults to current document */ + sigc::connection desktopChangeConn = + desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); + instanceConns.push_back( desktopChangeConn ); + desk_track.connect(GTK_WIDGET(gobj())); +#if GTK_CHECK_VERSION(3,2,4) + overlay->hide(); +#endif +} + +SymbolsDialog::~SymbolsDialog() +{ + for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { + it->disconnect(); + } + idleconn.disconnect(); + instanceConns.clear(); + desk_track.disconnect(); +} + +SymbolsDialog& SymbolsDialog::getInstance() +{ + return *new SymbolsDialog(); +} + +void SymbolsDialog::packless() { + if(pack_size < 4) { + pack_size++; + rebuild(); + } +} + +void SymbolsDialog::packmore() { + if(pack_size > 0) { + pack_size--; + rebuild(); + } +} + +void SymbolsDialog::zoomin() { + if(scale_factor < 4) { + scale_factor++; + rebuild(); + } +} + +void SymbolsDialog::zoomout() { + if(scale_factor > -8) { + scale_factor--; + rebuild(); + } +} + +void SymbolsDialog::rebuild() { + + if (!sensitive) { + return; + } + + if( fit_symbol->get_active() ) { + zoom_in->set_sensitive( false ); + zoom_out->set_sensitive( false ); + } else { + zoom_in->set_sensitive( true); + zoom_out->set_sensitive( true ); + } + store->clear(); + SPDocument* symbol_document = selectedSymbols(); + icons_found = false; + //We are not in search all docs + if (search->get_text() != _("Searching...") && + search->get_text() != _("Loading documents...") && + search->get_text() != _("Documents done, searchig inside...") ) + { + search_str = ""; + search->set_text(""); + } + if (symbol_document) { + addSymbolsInDoc(symbol_document); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + } +} + +void SymbolsDialog::insertSymbol() { + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); + sp_action_perform (action, NULL); +} + +void SymbolsDialog::revertSymbol() { + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop ) ); + sp_action_perform (action, NULL); +} + +void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) +{ + auto iconArray = icon_view->get_selected_items(); + + if( iconArray.empty() ) { + //std::cout << " iconArray empty: huh? " << std::endl; + } else { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; + GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE ); + gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() ); + } + +} + +void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) +{ + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title != _("All symbols sets") && !symbol_sets[symbol_set->get_active_text()] ) { + rebuild(); + } +} + +void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { + Glib::ustring symbol_id = selectedSymbolId(); + Glib::ustring doc_title = selectedSymbolDocTitle(); + if (!doc_title.empty()) { + SPDocument* symbol_document = symbol_sets[doc_title]; + if (!symbol_document) { + //we are in global search so get the original symbol document by title + symbol_document = selectedSymbols(); + } + if (symbol_document) { + SPObject* symbol = symbol_document->getObjectById(symbol_id); + if(symbol && !selection->includes(symbol)) { + icon_view->unselect_all(); + } + } + } +} + +void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) +{ + current_desktop = desktop; + current_document = document; + rebuild(); +} + +SPDocument* SymbolsDialog::selectedSymbols() { + /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title == _("All symbols sets")) { + return NULL; + } + SPDocument* symbol_document = symbol_sets[doc_title]; + if( !symbol_document ) { + symbol_document = getSymbolsSet(doc_title).second; + // Symbol must be from Current Document (this method of checking should be language independent). + if( !symbol_document ) { + // Symbol must be from Current Document (this method of + // checking should be language independent). + symbol_document = current_document; + add_symbol->set_sensitive( true ); + remove_symbol->set_sensitive( true ); + } else { + add_symbol->set_sensitive( false ); + remove_symbol->set_sensitive( false ); + } + } + return symbol_document; +} + +Glib::ustring SymbolsDialog::selectedSymbolId() { + + auto iconArray = icon_view->get_selected_items(); + + if( !iconArray.empty() ) { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + return (*row)[getColumns()->symbol_id]; + } + return Glib::ustring(""); +} + +Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { + + auto iconArray = icon_view->get_selected_items(); + + if( !iconArray.empty() ) { + Gtk::TreeModel::Path const & path = *iconArray.begin(); + Gtk::ListStore::iterator row = store->get_iter(path); + return (*row)[getColumns()->symbol_doc_title]; + } + return Glib::ustring(""); +} + +Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { + Glib::ustring title = _("Untitled document"); + if (symbol_doc) { + SPRoot * root = symbol_doc->getRoot(); + if (root->title()) { + title = ellipsize(Glib::ustring(root->title())); + return title; + } + } + Glib::ustring current = symbol_set->get_active_text(); + if (current == _("Current Document")) { + return current; + } + return title; +} + +void SymbolsDialog::iconChanged() { + + Glib::ustring symbol_id = selectedSymbolId(); + SPDocument* symbol_document = selectedSymbols(); + if (!symbol_document) { + //we are in global search so get the original symbol document by title + Glib::ustring doc_title = selectedSymbolDocTitle(); + if (!doc_title.empty()) { + symbol_document = symbol_sets[doc_title]; + } + } + if (symbol_document) { + SPObject* symbol = symbol_document->getObjectById(symbol_id); + + if( symbol ) { + if( symbol_document == current_document ) { + // Select the symbol on the canvas so it can be manipulated + current_desktop->selection->set( symbol, false ); + } + // Find style for use in + // First look for default style stored in + gchar const* style = symbol->getAttribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in , look in documents. + if( symbol_document == current_document ) { + style = styleFromUse( symbol_id.c_str(), current_document ); + } else { + style = symbol_document->getReprRoot()->attribute("style"); + } + } + + ClipboardManager *cm = ClipboardManager::get(); + cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); + } + } +} + +#ifdef WITH_LIBVISIO + +#if WITH_LIBVISIO01 +// Extend libvisio's native RVNGSVGDrawingGenerator with support for extracting stencil names (to be used as ID/title) +class REVENGE_API RVNGSVGDrawingGenerator_WithTitle : public RVNGSVGDrawingGenerator { + public: + RVNGSVGDrawingGenerator_WithTitle(RVNGStringVector &output, RVNGStringVector &titles, const RVNGString &nmSpace) + : RVNGSVGDrawingGenerator(output, nmSpace) + , _titles(titles) + {} + + void startPage(const RVNGPropertyList &propList) + { + RVNGSVGDrawingGenerator::startPage(propList); + if (propList["draw:name"]) { + _titles.append(propList["draw:name"]->getStr()); + } else { + _titles.append(""); + } + } + + private: + RVNGStringVector &_titles; +}; +#endif + +// Read Visio stencil files +SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { + gchar *fullname; + #ifdef WIN32 + // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows + // therefore attempt to convert uri to the system codepage + // even if this is not possible the alternate short (8.3) file name will be used if available + fullname = g_win32_locale_filename_from_utf8(filename.c_str()); + #else + filename.copy(fullname, filename.length()); + #endif + + RVNGFileStream input(fullname); + g_free(fullname); + + if (!libvisio::VisioDocument::isSupported(&input)) { + return NULL; + } + + RVNGStringVector output; + RVNGStringVector titles; +#if WITH_LIBVISIO01 + RVNGSVGDrawingGenerator_WithTitle generator(output, titles, "svg"); + + if (!libvisio::VisioDocument::parseStencils(&input, &generator)) { +#else + if (!libvisio::VisioDocument::generateSVGStencils(&input, output)) { +#endif + return NULL; + } + + if (output.empty()) { + return NULL; + } + + // prepare a valid title for the symbol file + Glib::ustring title = Glib::Markup::escape_text(name); + // prepare a valid id prefix for symbols libvisio doesn't give us a name for + Glib::RefPtr regex1 = Glib::Regex::create("[^a-zA-Z0-9_-]"); + Glib::ustring id = regex1->replace(name, 0, "_", Glib::REGEX_MATCH_PARTIAL); + + Glib::ustring tmpSVGOutput; + tmpSVGOutput += "\n"; + tmpSVGOutput += "\n"; + tmpSVGOutput += " "; + tmpSVGOutput += title; + tmpSVGOutput += "\n"; + tmpSVGOutput += " \n"; + + // Each "symbol" is in its own SVG file, we wrap with and merge into one file. + for (unsigned i=0; ireplace(titles[i].cstr(), 0, "_", Glib::REGEX_MATCH_PARTIAL); + } else { + ss << id << "_" << i; + } + + tmpSVGOutput += " \n"; + +#if WITH_LIBVISIO01 + if (titles.size() == output.size() && titles[i] != "") { + tmpSVGOutput += " " + Glib::ustring(RVNGString::escapeXML(titles[i].cstr()).cstr()) + "\n"; + } +#endif + + std::istringstream iss( output[i].cstr() ); + std::string line; + while( std::getline( iss, line ) ) { + if( line.find( "svg:svg" ) == std::string::npos ) { + tmpSVGOutput += " " + line + "\n"; + } + } + + tmpSVGOutput += " \n"; + } + + tmpSVGOutput += " \n"; + tmpSVGOutput += "\n"; + + return SPDocument::createNewDocFromMem( tmpSVGOutput.c_str(), strlen( tmpSVGOutput.c_str()), 0 ); + +} +#endif + +/* Hunts preference directories for symbol files */ +void SymbolsDialog::getSymbolsFilename() { + + using namespace Inkscape::IO::Resource; + Glib::ustring title; + number_docs = 0; + for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { + if(Glib::str_has_suffix(filename, ".svg")) { + //TODO: find a way to get real title without loading all SPDocument + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbol_sets[title]= NULL; + symbol_set->append(title); + ++number_docs; + } +#ifdef WITH_LIBVISIO + if(Glib::str_has_suffix(filename, ".vss")) { + std::size_t found = filename.find_last_of("/\\"); + filename = filename.substr(found+1); + title = filename.erase(filename.rfind('.')); + if(title.empty()) { + title = _("Unnamed Symbols"); + } + symbol_sets[title]= NULL; + symbol_set->append(title); + ++number_docs; + } +#endif + } +} + +/* Hunts preference directories for symbol files */ +std::pair +SymbolsDialog::getSymbolsSet(Glib::ustring title) +{ + if (symbol_sets[title]) { + return std::make_pair(title, symbol_sets[title]); + } + using namespace Inkscape::IO::Resource; + SPDocument* symbol_doc = NULL; + Glib::ustring new_title; + size_t i = 0; + for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { + std::size_t pos = filename.find_last_of("/\\"); + if (pos != std::string::npos) { + Glib::ustring filename_short = filename.substr(pos+1); + if(filename_short == title + ".svg") { + symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); + if(symbol_doc) { + new_title = documentTitle(symbol_doc); + } + } + if(Glib::str_has_suffix(filename, ".svg")) { + i++; + } +#ifdef WITH_LIBVISIO + if(filename_short == title + ".vss") { + symbol_doc = read_vss(filename, title); + if(symbol_doc) { + new_title = documentTitle(symbol_doc); + } + } + if(Glib::str_has_suffix(filename, ".vss")) { + i++; + } +#endif + if(symbol_doc) { + symbol_sets.erase(title); + symbol_sets[new_title]= symbol_doc; + sensitive = false; + symbol_set->remove_text(i+1); + symbol_set->insert (i+1, new_title); + symbol_set->set_active(i+1); + symbol_set->set_active_text(new_title); + sensitive = true; + break; + } + } + } + return std::make_pair(new_title, symbol_doc); +} + +void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title) +{ + if(!r) return; + + // Stop multiple counting of same symbol + if ( dynamic_cast(r) ) { + return; + } + + if ( dynamic_cast(r) ) { + l.push_back(std::make_pair(doc_title,dynamic_cast(r))); + } + for (auto& child: r->children) { + symbolsInDocRecursive(&child, l, doc_title); + } +} + +std::vector > +SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_title) +{ + + std::vector > l; + if (symbol_document) { + symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); + } + return l; +} + +void SymbolsDialog::useInDoc (SPObject *r, std::vector &l) +{ + + if ( dynamic_cast(r) ) { + l.push_back(dynamic_cast(r)); + } + + for (auto& child: r->children) { + useInDoc( &child, l ); + } +} + +std::vector SymbolsDialog::useInDoc( SPDocument* useDocument) { + std::vector l; + useInDoc (useDocument->getRoot(), l); + return l; +} + +// Returns style from first element found that references id. +// This is a last ditch effort to find a style. +gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) { + + gchar const* style = 0; + std::vector l = useInDoc( document ); + for( auto use:l ) { + if ( use ) { + gchar const *href = use->getRepr()->attribute("xlink:href"); + if( href ) { + Glib::ustring href2(href); + Glib::ustring id2(id); + id2 = "#" + id2; + if( !href2.compare(id2) ) { + style = use->getRepr()->attribute("style"); + break; + } + } + } + } + return style; +} + +void SymbolsDialog::clearSearch() +{ + if(search->get_text().empty() && sensitive) { + enableWidgets(false); + search_str = ""; + store->clear(); + SPDocument* symbol_document = selectedSymbols(); + if (symbol_document) { + //We are not in search all docs + icons_found = false; + addSymbolsInDoc(symbol_document); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + enableWidgets(true); + } + } +} + +void SymbolsDialog::enableWidgets(bool enable) +{ + symbol_set->set_sensitive(enable); + search->set_sensitive(enable); + tools ->set_sensitive(enable); +} + +void SymbolsDialog::beforeSearch(GdkEventKey* evt) +{ + sensitive = false; + search_str = search->get_text().lowercase(); + if (evt->keyval != GDK_KEY_Return) { + return; + } + progress_bar->set_fraction(0.0); + enableWidgets(false); + SPDocument* symbol_document = selectedSymbols(); + if (symbol_document) { + //We are not in search all docs + search->set_text(_("Searching...")); + store->clear(); + icons_found = false; + addSymbolsInDoc(symbol_document); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + search->set_text(_("Loading documents...")); + } +} + +void SymbolsDialog::unsensitive(GdkEventKey* evt) +{ + sensitive = true; +} + +bool SymbolsDialog::callbackSymbols(){ + Glib::ustring current = symbol_set->get_active_text(); + +#if GTK_CHECK_VERSION(3,2,4) +if (current == _("All symbols sets") && search->get_text() != _("Loading documents...") && !l.size()) + { + if (!all_docs_processed ) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); + } else { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); + } + overlay_opacity->show(); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + return false; + } +#endif + if (current == _("All symbols sets") && search->get_text() == _("Loading documents...")) { +#if GTK_CHECK_VERSION(3,2,4) + overlay_opacity->show(); +#endif + if (!all_docs_processed) { +#if GTK_CHECK_VERSION(3,2,4) + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); + overlay_icon->show(); + overlay_title->show(); + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_desc->show(); +#endif + } + size_t counter = 0; + for(auto const &symbol_document_map : symbol_sets) { + ++counter; + SPDocument* symbol_document = symbol_document_map.second; + if (symbol_document) { + continue; + } + symbol_document = getSymbolsSet(symbol_document_map.first).second; + symbol_set->set_active_text(_("All symbols sets")); + if (!symbol_document) { + continue; + } + progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); + return true; + } +#if GTK_CHECK_VERSION(3,2,4) + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); +#endif + progress_bar->set_fraction(1.0); + all_docs_processed = true; + addSymbols(); + search->set_text("Documents done, searchig inside..."); + return true; + } else if (l.size()) { +#if GTK_CHECK_VERSION(3,2,4) + overlay_opacity->show(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); +#endif + for (auto symbol_data = l.begin(); symbol_data != l.end();) { + Glib::ustring doc_title = symbol_data->first; + SPSymbol * symbol = symbol_data->second; + counter_symbols ++; + gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); + bool found = false; + if (symbol_title_char) { + Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); + auto pos = symbol_title.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + if (!found && symbol_desc_char) { + Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); + auto pos = symbol_desc.rfind(search_str); + if (pos != std::string::npos) { + found = true; + } + } + } + if (symbol && (search_str.empty() || found || (search_str.empty() && !symbol_title_char))) { + addSymbol( symbol, doc_title); + icons_found = true; + } + + progress_bar->set_fraction(((100.0/number_symbols) * counter_symbols)/100.0); + symbol_data = l.erase(l.begin()); + //to get more items and best performance + int modulus = number_symbols > 200 ? 50 : (number_symbols/4); + if (modulus && counter_symbols % modulus == 0 && !l.empty()) { + return true; + } + } +#if GTK_CHECK_VERSION(3,2,4) + if (!icons_found && !search_str.empty()) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_icon->set_from_icon_name("none", iconsize); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + } else { + overlay_opacity->hide(); + } +#endif + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + return false; + } + return true; +} + +Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { + if (data.length() > limit) { + return data.substr(0,limit-3) + "..."; + } + return data; +} + +void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { + + if (!symbol_document) { + return; //Search all + } + Glib::ustring doc_title = documentTitle(symbol_document); + progress_bar->set_fraction(0.0); + counter_symbols = 0; + std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); + number_symbols = container_symbols_tmp.size(); + l = container_symbols_tmp; + container_symbols_tmp.clear(); + if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) + overlay_icon->set_from_icon_name("none", iconsize); + overlay_opacity->show(); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); +#endif + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + idleconn.disconnect(); + } else { + idleconn.disconnect(); + idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + } +#if GTK_CHECK_VERSION(3,2,4) + Glib::ustring current = symbol_set->get_active_text(); + if (!number_symbols && (current != _("Current Document") || !search_str.empty())) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + } else if (!number_symbols) { + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); + } +#endif +} + +void SymbolsDialog::addSymbols() { + store->clear(); + icons_found = false; + std::vector > container_symbols; + for(auto const &symbol_document_map : symbol_sets) { + SPDocument* symbol_document = symbol_document_map.second; + if (!symbol_document) { + continue; + } + Glib::ustring doc_title = documentTitle(symbol_document); + std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); + container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); + container_symbols_tmp.clear(); + } + counter_symbols = 0; + progress_bar->set_fraction(0.0); + number_symbols = container_symbols.size(); + l = container_symbols; + container_symbols.clear(); + if (!number_symbols) { +#if GTK_CHECK_VERSION(3,2,4) + overlay_icon->set_from_icon_name("none", iconsize); + overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); + overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); +#endif + idleconn.disconnect(); + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + } +} + +void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { + + SymbolColumns* columns = getColumns(); + + gchar const *id = symbol->getRepr()->attribute("id"); + gchar const *title = symbol->title(); // From title element + if( !title ) { + title = id; + } + Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); + if (doc_title.empty()) { + doc_title = _("Current Document"); + } + symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); + Glib::RefPtr pixbuf = drawSymbol( symbol ); + + if( pixbuf ) { + Gtk::ListStore::iterator row = store->append(); + (*row)[columns->symbol_id] = Glib::ustring( id ); + (*row)[columns->symbol_title] = symbol_title; + (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(doc_title); + (*row)[columns->symbol_image] = pixbuf; + } + + delete columns; +} + +/* + * Returns image of symbol. + * + * Symbols normally are not visible. They must be referenced by a + * element. A temporary document is created with a dummy + * element and a element that references the symbol + * element. Each real symbol is swapped in for the dummy symbol and + * the temporary document is rendered. + */ +Glib::RefPtr +SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize) +{ + // Create a copy repr of the symbol with id="the_symbol" + Inkscape::XML::Document *xml_doc = preview_document->getReprDoc(); + Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc); + repr->setAttribute("id", "the_symbol"); + + // Replace old "the_symbol" in preview_document by new. + Inkscape::XML::Node *root = preview_document->getReprRoot(); + SPObject *symbol_old = preview_document->getObjectById("the_symbol"); + if (symbol_old) { + symbol_old->deleteObject(false); + } + + // First look for default style stored in + gchar const* style = repr->attribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in , look in documents. + if( symbol->document == current_document ) { + gchar const *id = symbol->getRepr()->attribute("id"); + style = styleFromUse( id, symbol->document ); + } else { + style = symbol->document->getReprRoot()->attribute("style"); + } + } + // Last ditch effort to provide some default styling + if( !style ) style = "fill:#bbbbbb;stroke:#808080"; + + // This is for display in Symbols dialog only + if( style ) repr->setAttribute( "style", style ); + + // BUG: Symbols don't work if defined outside of . Causes Inkscape + // crash when trying to read in such a file. + root->appendChild(repr); + //defsrepr->appendChild(repr); + Inkscape::GC::release(repr); + + // Uncomment this to get the preview_document documents saved (useful for debugging) + // FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w"); + // sp_repr_save_stream(preview_document->getReprDoc(), fp); + // fclose (fp); + + // Make sure preview_document is up-to-date. + preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + preview_document->ensureUpToDate(); + + // Make sure we have symbol in preview_document + SPObject *object_temp = preview_document->getObjectById( "the_use" ); + preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + preview_document->ensureUpToDate(); + + SPItem *item = dynamic_cast(object_temp); + g_assert(item != NULL); + unsigned psize = SYMBOL_ICON_SIZES[pack_size]; + + Glib::RefPtr pixbuf(NULL); + // We could use cache here, but it doesn't really work with the structure + // of this user interface and we've already cached the pixbuf in the gtklist + + // Find object's bbox in document. + // Note symbols can have own viewport... ignore for now. + //Geom::OptRect dbox = item->geometricBounds(); + Geom::OptRect dbox = item->documentVisualBounds(); + + if (dbox) { + /* Scale symbols to fit */ + double scale = 1.0; + double width = dbox->width(); + double height = dbox->height(); + + if( width == 0.0 ) width = 1.0; + if( height == 0.0 ) height = 1.0; + + if( fit_symbol->get_active() ) + scale = psize / ceil(std::max(width, height)); + 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)); + } + + return pixbuf; +} + +/* + * Return empty doc to render symbols in. + * Symbols are by default not rendered so a element is + * provided. + */ +SPDocument* SymbolsDialog::symbolsPreviewDoc() +{ + // BUG: must be inside + gchar const *buffer = +"" +" " +" " +" " +" " +""; + return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); +} + +/* + * Update image widgets + */ +Glib::RefPtr +SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) +{ +gchar const *buffer = +"" +" Inkscape " +" " +" " +" Overlay" +" Overlay Square" +" " +" " +" " +""; + + SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); + std::vector > symbols_data = symbolsInDoc(doc, "Overlay Doc"); + Glib::RefPtr pixbuf(NULL); + for(auto data:symbols_data) { + Glib::ustring doc_title = data.first; + SPSymbol * symbol = data.second; + if (!strcmp(symbol->getId(), icon_title)) { + pixbuf = drawSymbol(symbol, psize); + return pixbuf; + } + } + return pixbuf; +} + +void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) +{ + if (this->current_desktop != desktop) { + this->current_desktop = desktop; + if( !symbol_sets[symbol_set->get_active_text()] ) { + // Symbol set is from Current document, update + rebuild(); + } + } +} + +} //namespace Dialogs +} //namespace UI +} //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-basic-offset:2 + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/symbols.cpp.rej b/src/ui/dialog/symbols.cpp.rej new file mode 100644 index 000000000..fe32c8bad --- /dev/null +++ b/src/ui/dialog/symbols.cpp.rej @@ -0,0 +1,384 @@ +--- src/ui/dialog/symbols.cpp ++++ src/ui/dialog/symbols.cpp +@@ -348,38 +374,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : + + // This might need to be a global variable so setTargetDesktop can modify it + SPDefs *defs = current_document->getDefs(); +- +- /*************************Overlays******************************/ + #if GTK_CHECK_VERSION(3,2,4) +- //Loading +- overlay_opacity = new Gtk::Image(); + overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); +- overlay_opacity->set_halign(Gtk::ALIGN_START ); +- overlay_opacity->set_valign(Gtk::ALIGN_START ); +- //No results +- iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); +- overlay_icon = new Gtk::Image(); +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_icon = new Gtk::Image(); +- overlay_icon->set_halign(Gtk::ALIGN_CENTER ); +- overlay_icon->set_valign(Gtk::ALIGN_START ); +- overlay_icon->set_margin_top(45); +- overlay_title = new Gtk::Label(); +- overlay_title->set_halign(Gtk::ALIGN_CENTER ); +- overlay_title->set_valign(Gtk::ALIGN_START ); +- overlay_title->set_justify(Gtk::JUSTIFY_CENTER); +- overlay_title->set_margin_top(155); +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); +- overlay_desc = new Gtk::Label(); +- overlay_desc->set_halign(Gtk::ALIGN_CENTER ); +- overlay_desc->set_valign(Gtk::ALIGN_START ); +- overlay_desc->set_margin_top(180); +- overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); +- overlay->add_overlay(* overlay_opacity); +- overlay->add_overlay(* overlay_icon); +- overlay->add_overlay(* overlay_title); +- overlay->add_overlay(* overlay_desc); + #endif + sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); + instanceConns.push_back(defsModifiedConn); +@@ -394,16 +390,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : + getSymbolsFilename(); + icons_found = false; + +- Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); +- + addSymbolsInDoc(current_document); /* Defaults to current document */ + sigc::connection desktopChangeConn = + desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); + instanceConns.push_back( desktopChangeConn ); + desk_track.connect(GTK_WIDGET(gobj())); +-#if GTK_CHECK_VERSION(3,2,4) +- overlay->hide(); +-#endif + } + + SymbolsDialog::~SymbolsDialog() +@@ -411,6 +402,7 @@ SymbolsDialog::~SymbolsDialog() + for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { + it->disconnect(); + } ++ idleconn.disconnect(); + instanceConns.clear(); + desk_track.disconnect(); + } +@@ -474,9 +466,68 @@ void SymbolsDialog::rebuild() { + } + if (symbol_document) { + addSymbolsInDoc(symbol_document); ++ } else { ++ showOverlay(); + } + } ++void SymbolsDialog::showOverlay() { ++#if GTK_CHECK_VERSION(3,2,4) ++Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); ++ if (current == ALLDOCS && ++ search->get_text() != _("Loading documents...") && ++ !l.size()) ++ { ++ if (!all_docs_processed ) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); ++ } else if (!icons_found && !search_str.empty()) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found ...")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); ++ } else { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); ++ } ++ } else if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { ++ if (!all_docs_processed) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); ++ overlay_icon->show(); ++ overlay_title->show(); ++ overlay_icon->set_from_icon_name("searching", iconsize); ++ overlay_desc->show(); ++ } ++ } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); ++ } else if (!number_symbols && current == CURRENTDOC) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); ++ } else if (!icons_found && !search_str.empty()) { ++ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); ++ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); ++ } ++ overlay_opacity->show(); ++ overlay_icon->set_from_icon_name("none", iconsize); ++ overlay_icon->show(); ++ overlay_title->show(); ++ overlay_desc->show(); ++ if (l.size()) { ++ overlay_opacity->show(); ++ overlay_icon->hide(); ++ overlay_title->hide(); ++ overlay_desc->hide(); ++ } ++#endif ++} + ++void SymbolsDialog::hideOverlay() { ++#if GTK_CHECK_VERSION(3,2,4) ++ overlay_opacity->hide(); ++ overlay_icon->hide(); ++ overlay_title->hide(); ++ overlay_desc->hide(); ++#endif ++} + void SymbolsDialog::insertSymbol() { + Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); +@@ -934,6 +995,7 @@ void SymbolsDialog::clearSearch() + icons_found = false; + addSymbolsInDoc(symbol_document); + } else { ++ showOverlay(); + enableWidgets(true); + } + } +@@ -963,6 +1025,8 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) + icons_found = false; + addSymbolsInDoc(symbol_document); + } else { ++ idleconn.disconnect(); ++ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackAllSymbols)); + search->set_text(_("Loading documents...")); + } + } +@@ -973,84 +1037,11 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) + } + + bool SymbolsDialog::callbackSymbols(){ +- Glib::ustring current = symbol_set->get_active_text(); +-#if GTK_CHECK_VERSION(3,2,4) +- if (current == _("All symbols sets") && +- search->get_text() != _("Loading documents...")) +- { +- if (!all_docs_processed) { +- overlay_opacity->show(); +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_icon->show(); +- overlay_title->show(); +- overlay_desc->show(); +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); +- } +- } +- if (current == _("Current Document") && !icons_found) { +- if (!all_docs_processed) { +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_opacity->show(); +- overlay_icon->show(); +- overlay_title->show(); +- overlay_desc->show(); +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); +- } +- } +-#endif +- if (current == _("All symbols sets") && +- search->get_text() == _("Loading documents...") ) +- { +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_opacity->show(); +-#endif +- if (!all_docs_processed) { +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); +- overlay_icon->show(); +- overlay_title->show(); +- overlay_icon->set_from_icon_name("searching", iconsize); +- overlay_desc->show(); +-#endif +- } +- size_t counter = 0; +- for(auto const &symbol_document_map : symbol_sets) { +- ++counter; +- SPDocument* symbol_document = symbol_document_map.second; +- if (symbol_document) { +- continue; +- } +- symbol_document = getSymbolsSet(symbol_document_map.first).second; +- symbol_set->set_active_text(_("All symbols sets")); +- if (!symbol_document) { +- continue; +- } +- progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); +- return true; +- } +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_icon->hide(); +- overlay_title->hide(); +- overlay_desc->hide(); +-#endif +- progress_bar->set_fraction(1.0); +- all_docs_processed = true; +- addSymbols(); +- search->set_text("Documents done, searchig inside..."); +- return true; +- } else if (l.size()) { +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_opacity->show(); +- overlay_icon->hide(); +- overlay_title->hide(); +- overlay_desc->hide(); +-#endif ++ if (l.size()) { ++ showOverlay(); + for (auto symbol_data = l.begin(); symbol_data != l.end();) { +- Glib::ustring doc_title = symbol_data->first; +- SPSymbol * symbol = symbol_data->second; ++ Glib::ustring doc_title = symbol_data->second.first; ++ SPSymbol * symbol = symbol_data->second.second; + counter_symbols ++; + gchar const *symbol_title_char = symbol->title(); + gchar const *symbol_desc_char = symbol->description(); +@@ -1082,30 +1073,54 @@ bool SymbolsDialog::callbackSymbols(){ + return true; + } + } +-#if GTK_CHECK_VERSION(3,2,4) + if (!icons_found && !search_str.empty()) { +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_icon->show(); +- overlay_title->show(); +- overlay_desc->show(); ++ showOverlay(); + } else { +- overlay_opacity->hide(); ++ hideOverlay(); + } +-#endif + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); +- return true; ++ return false; ++ } ++ return true; ++} ++ ++bool SymbolsDialog::callbackAllSymbols(){ ++ Glib::ustring current = symbol_set->get_active_text(); ++ if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { ++ size_t counter = 0; ++ std::map symbol_sets_tmp = symbol_sets; ++ for(auto const &symbol_document_map : symbol_sets_tmp) { ++ ++counter; ++ SPDocument* symbol_document = symbol_document_map.second; ++ if (symbol_document) { ++ continue; ++ } ++ symbol_document = getSymbolsSet(symbol_document_map.first).second; ++ symbol_set->set_active_text(ALLDOCS); ++ if (!symbol_document) { ++ continue; ++ } ++ progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); ++ return true; ++ } ++ symbol_sets_tmp.clear(); ++ hideOverlay(); ++ progress_bar->set_fraction(1.0); ++ all_docs_processed = true; ++ addSymbols(); ++ search->set_text("Documents done, searchig inside..."); ++ return false; + } + return true; + } + + Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { + if (data.length() > limit) { +- return data.substr(0,limit-3) + "..."; ++ data = data.substr(0, limit-3); ++ return data + "..."; + } + return data; + } +@@ -1118,58 +1133,49 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { + Glib::ustring doc_title = documentTitle(symbol_document); + progress_bar->set_fraction(0.0); + counter_symbols = 0; +- std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); +- number_symbols = container_symbols_tmp.size(); +- l = container_symbols_tmp; +- container_symbols_tmp.clear(); ++ l = symbolsInDoc(symbol_document, doc_title); ++ number_symbols = l.size(); + if (!number_symbols) { +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_icon->show(); +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); +- overlay_title->show(); +- overlay_desc->show(); +-#endif + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); ++ idleconn.disconnect(); ++ showOverlay(); ++ } else { ++ idleconn.disconnect(); ++ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + } + } + + void SymbolsDialog::addSymbols() { + store->clear(); + icons_found = false; +- std::vector > container_symbols; + for(auto const &symbol_document_map : symbol_sets) { + SPDocument* symbol_document = symbol_document_map.second; + if (!symbol_document) { + continue; + } + Glib::ustring doc_title = documentTitle(symbol_document); +- std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); +- container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); +- container_symbols_tmp.clear(); ++ std::map > l_tmp = symbolsInDoc(symbol_document, doc_title); ++ for(auto &p : l_tmp ) { ++ l[p.first] = p.second; ++ } ++ l_tmp.clear(); + } + counter_symbols = 0; + progress_bar->set_fraction(0.0); +- number_symbols = container_symbols.size(); +- l = container_symbols; +- container_symbols.clear(); ++ number_symbols = l.size(); + if (!number_symbols) { +-#if GTK_CHECK_VERSION(3,2,4) +- overlay_icon->set_from_icon_name("none", iconsize); +- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); +- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); +- overlay_icon->show(); +- overlay_title->show(); +- overlay_desc->show(); +-#endif ++ showOverlay(); ++ idleconn.disconnect(); + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); ++ } else { ++ idleconn.disconnect(); ++ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); + } + } + diff --git a/src/ui/dialog/symbols.h.orig b/src/ui/dialog/symbols.h.orig new file mode 100644 index 000000000..8255877b8 --- /dev/null +++ b/src/ui/dialog/symbols.h.orig @@ -0,0 +1,172 @@ +/** @file + * @brief Symbols dialog + */ +/* Authors: + * Tavmjong Bah, Martin Owens + * + * Copyright (C) 2012 Tavmjong Bah + * 2013 Martin Owens + * 2017 Jabiertxo Arraiza + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H +#define INKSCAPE_UI_DIALOG_SYMBOLS_H +#include + +#include "display/drawing.h" +#include "ui/dialog/desktop-tracker.h" +#include "ui/widget/panel.h" +#include "sp-symbol.h" +#include "sp-use.h" +#include + +class SPObject; + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class SymbolColumns; // For Gtk::ListStore + +/** + * A dialog that displays selectable symbols and allows users to drag or paste + * those symbols from the dialog into the document. + * + * Symbol documents are loaded from the preferences paths and displayed in a + * drop-down list to the user. The user then selects which of the symbols + * documents they want to get symbols from. The first document in the list is + * always the current document. + * + * This then updates an icon-view with all the symbols available. Selecting one + * puts it onto the clipboard. Dragging it or pasting it onto the canvas copies + * the symbol from the symbol document, into the current document and places a + * new & context, Gtk::SelectionData& selection_data, guint info, guint time); + void getSymbolsFilename(); + Glib::ustring documentTitle(SPDocument* doc); + std::pair getSymbolsSet(Glib::ustring title); + void addSymbol( SPObject* symbol, Glib::ustring doc_title); + SPDocument* symbolsPreviewDoc(); + void symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title); + std::vector > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); + void useInDoc(SPObject *r, std::vector &l); + std::vector useInDoc( SPDocument* document); + void beforeSearch(GdkEventKey* evt); + void unsensitive(GdkEventKey* evt); + void addSymbols(); + void addSymbolsInDoc(SPDocument* document); + void clearSearch(); + bool callbackSymbols(); + void enableWidgets(bool enable); + Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); + gchar const* styleFromUse( gchar const* id, SPDocument* document); + Glib::RefPtr drawSymbol(SPObject *symbol, unsigned force_psize = 0); + Glib::RefPtr getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); + /* Keep track of all symbol template documents */ + std::map symbol_sets; + std::vector > l; + // Index into sizes which is selected + int pack_size; + // Scale factor + int scale_factor; + bool sensitive; + bool all_docs_processed; + size_t number_docs; + size_t number_symbols; + size_t counter_symbols; + bool icons_found; + Glib::RefPtr store; + Glib::ustring search_str; + Gtk::ComboBoxText* symbol_set; + Gtk::ProgressBar* progress_bar; + Gtk::HBox* progress; + Gtk::SearchEntry* search; + Gtk::IconView* icon_view; + Gtk::Button* add_symbol; + Gtk::Button* remove_symbol; + Gtk::Button* zoom_in; + Gtk::Button* zoom_out; + Gtk::Button* more; + Gtk::Button* fewer; + Gtk::HBox* tools; +#if GTK_CHECK_VERSION(3,2,4) + Gtk::Overlay* overlay; +#endif + Gtk::Image* overlay_icon; + Gtk::Image* overlay_opacity; + Gtk::Label* overlay_title; + Gtk::Label* overlay_desc; + Gtk::ScrolledWindow *scroller; + Gtk::ToggleButton* fit_symbol; + Gtk::IconSize iconsize; + void setTargetDesktop(SPDesktop *desktop); + SPDesktop* current_desktop; + DesktopTracker desk_track; + SPDocument* current_document; + SPDocument* preview_document; /* Document to render single symbol */ + + sigc::connection idleconn; + + /* For rendering the template drawing */ + unsigned key; + Inkscape::Drawing renderDrawing; + + std::vector instanceConns; +}; + +} //namespace Dialogs +} //namespace UI +} //namespace Inkscape + + +#endif // INKSCAPE_UI_DIALOG_SYMBOLS_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/symbols.h.rej b/src/ui/dialog/symbols.h.rej new file mode 100644 index 000000000..72cb5b299 --- /dev/null +++ b/src/ui/dialog/symbols.h.rej @@ -0,0 +1,19 @@ +--- src/ui/dialog/symbols.h ++++ src/ui/dialog/symbols.h +@@ -141,13 +144,14 @@ private: + Gtk::ScrolledWindow *scroller; + Gtk::ToggleButton* fit_symbol; + Gtk::IconSize iconsize; +- + void setTargetDesktop(SPDesktop *desktop); + SPDesktop* current_desktop; + DesktopTracker desk_track; + SPDocument* current_document; + SPDocument* preview_document; /* Document to render single symbol */ +- ++ ++ sigc::connection idleconn; ++ + /* For rendering the template drawing */ + unsigned key; + Inkscape::Drawing renderDrawing; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 7427ad4e2..06d54b682 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -219,6 +219,7 @@ PageSizer::PageSizer(Registry & _wr) _dimensionUnits( _("U_nits:"), "units", _wr ), _dimensionWidth( _("_Width:"), _("Width of paper"), "width", _dimensionUnits, _wr ), _dimensionHeight( _("_Height:"), _("Height of paper"), "height", _dimensionUnits, _wr ), + _marginLock( _("L_ock"), _("Lock margins"), "lock-margins", _wr ), _marginTop( _("T_op margin:"), _("Top margin"), "fit-margin-top", _wr ), _marginLeft( _("L_eft:"), _("Left margin"), "fit-margin-left", _wr), _marginRight( _("Ri_ght:"), _("Right margin"), "fit-margin-right", _wr), @@ -376,27 +377,33 @@ PageSizer::PageSizer(Registry & _wr) _marginTop.set_halign(Gtk::ALIGN_CENTER); _marginTop.set_hexpand(); _marginTop.set_vexpand(); - _marginTable.attach(_marginTop, 0, 0, 2, 1); + + _marginTable.attach(_marginTop, 0, 0, 3, 1); - _marginLeft.set_halign(Gtk::ALIGN_START); + _marginLeft.set_halign(Gtk::ALIGN_CENTER); _marginLeft.set_hexpand(); _marginLeft.set_vexpand(); _marginTable.attach(_marginLeft, 0, 1, 1, 1); - - _marginRight.set_halign(Gtk::ALIGN_END); + + _marginLock.set_halign(Gtk::ALIGN_CENTER); + _marginLock.set_hexpand(); + _marginLock.set_vexpand(); + _marginTable.attach(_marginLock, 1, 1, 1, 1); + + _marginRight.set_halign(Gtk::ALIGN_CENTER); _marginRight.set_hexpand(); _marginRight.set_vexpand(); - _marginTable.attach(_marginRight, 1, 1, 1, 1); - + _marginTable.attach(_marginRight, 2, 1, 1, 1); + _marginBottom.set_halign(Gtk::ALIGN_CENTER); _marginBottom.set_hexpand(); _marginBottom.set_vexpand(); - _marginTable.attach(_marginBottom, 0, 2, 2, 1); + _marginTable.attach(_marginBottom, 0, 2, 3, 1); _fitPageButton.set_halign(Gtk::ALIGN_CENTER); _fitPageButton.set_hexpand(); _fitPageButton.set_vexpand(); - _marginTable.attach(_fitPageButton, 0, 3, 2, 1); + _marginTable.attach(_fitPageButton, 0, 3, 3, 1); _fitPageButton.set_use_underline(); _fitPageButton.set_label(_("_Resize page to drawing or selection (Ctrl+Shift+R)")); @@ -474,6 +481,10 @@ PageSizer::init () _changedvy_connection = _viewboxY.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvw_connection = _viewboxW.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); _changedvh_connection = _viewboxH.signal_value_changed().connect (sigc::mem_fun (*this, &PageSizer::on_viewbox_changed)); + _changedmt_connection = _marginTop.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginTop)); + _changedmb_connection = _marginBottom.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginBottom)); + _changedml_connection = _marginLeft.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginLeft)); + _changedmr_connection = _marginRight.signal_value_changed().connect (sigc::bind(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginRight)); show_all_children(); } @@ -892,6 +903,24 @@ PageSizer::on_viewbox_changed() } } +/** + * Callback for viewbox widgets + */ +void +PageSizer::on_margin_changed(RegisteredScalar* widg) +{ + double value = widg->getValue(); + if (_widgetRegistry->isUpdating()) return; + if (_marginLock.get_active() && !_marginLocked) { + _marginLocked = true; + _marginLeft.setValue(value); + _marginRight.setValue(value); + _marginTop.setValue(value); + _marginBottom.setValue(value); + _marginLocked = false; + } +} + } // namespace Widget } // namespace UI } // namespace Inkscape diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 329ecfc6d..7cf8bacfd 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -161,7 +161,11 @@ public: * of the ui widgets to match the xml). */ void updateFitMarginsUI(Inkscape::XML::Node *nv_repr); - + + /** + * Updates the margin widgets. If lock widget is active + */ + void on_margin_changed(RegisteredScalar* widg); /** * Updates the scale widgets. (Just changes the values of the ui widgets.) */ @@ -225,13 +229,15 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; - Gtk::Grid _marginTable; - RegisteredScalar _marginTop; - RegisteredScalar _marginLeft; - RegisteredScalar _marginRight; - RegisteredScalar _marginBottom; - Gtk::Button _fitPageButton; - bool _lockMarginUpdate; + Gtk::Grid _marginTable; + RegisteredCheckButton _marginLock; + RegisteredScalar _marginTop; + RegisteredScalar _marginLeft; + RegisteredScalar _marginRight; + RegisteredScalar _marginBottom; + Gtk::Button _fitPageButton; + bool _lockMarginUpdate; + bool _marginLocked; // Document scale Gtk::Frame _scaleFrame; @@ -265,6 +271,10 @@ protected: sigc::connection _changedvy_connection; sigc::connection _changedvw_connection; sigc::connection _changedvh_connection; + sigc::connection _changedmt_connection; + sigc::connection _changedmb_connection; + sigc::connection _changedml_connection; + sigc::connection _changedmr_connection; Registry *_widgetRegistry; -- cgit v1.2.3 From 474fa8bbdb6112ca6e97cc9824a209f1626f5626 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 9 Nov 2017 19:04:39 +0100 Subject: Removing regects --- src/ui/dialog/symbols.cpp.orig | 1364 ---------------------------------------- src/ui/dialog/symbols.cpp.rej | 384 ----------- src/ui/dialog/symbols.h.orig | 172 ----- src/ui/dialog/symbols.h.rej | 19 - 4 files changed, 1939 deletions(-) delete mode 100644 src/ui/dialog/symbols.cpp.orig delete mode 100644 src/ui/dialog/symbols.cpp.rej delete mode 100644 src/ui/dialog/symbols.h.orig delete mode 100644 src/ui/dialog/symbols.h.rej (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp.orig b/src/ui/dialog/symbols.cpp.orig deleted file mode 100644 index 52f22103f..000000000 --- a/src/ui/dialog/symbols.cpp.orig +++ /dev/null @@ -1,1364 +0,0 @@ -/** - * @file - * Symbols dialog. - */ -/* Authors: - * Copyright (C) 2012 Tavmjong Bah - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include - -#include -#include -#include - -#include "path-prefix.h" -#include "io/sys.h" -#include "io/resource.h" - -#include "ui/cache/svg_preview_cache.h" -#include "ui/clipboard.h" -#include "ui/icon-names.h" - -#include "symbols.h" - -#include "selection.h" -#include "desktop.h" - -#include "document.h" -#include "inkscape.h" -#include "sp-root.h" -#include "sp-use.h" -#include "sp-defs.h" -#include "sp-symbol.h" - -#ifdef WITH_LIBVISIO - #include - - // TODO: Drop this check when librevenge is widespread. - #if WITH_LIBVISIO01 - #include - - using librevenge::RVNGFileStream; - using librevenge::RVNGString; - using librevenge::RVNGStringVector; - using librevenge::RVNGPropertyList; - using librevenge::RVNGSVGDrawingGenerator; - #else - #include - - typedef WPXFileStream RVNGFileStream; - typedef libvisio::VSDStringVector RVNGStringVector; - #endif -#endif - -#include "verbs.h" -#include "helper/action.h" -#include - -namespace Inkscape { -namespace UI { - -namespace Dialog { - -// See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html -class SymbolColumns : public Gtk::TreeModel::ColumnRecord -{ -public: - - Gtk::TreeModelColumn symbol_id; - Gtk::TreeModelColumn symbol_title; - Gtk::TreeModelColumn symbol_doc_title; - Gtk::TreeModelColumn< Glib::RefPtr > symbol_image; - - - SymbolColumns() { - add(symbol_id); - add(symbol_title); - add(symbol_doc_title); - add(symbol_image); - } -}; - -SymbolColumns* SymbolsDialog::getColumns() -{ - SymbolColumns* columns = new SymbolColumns(); - return columns; -} - -/** - * Constructor - */ -SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : - UI::Widget::Panel("", prefsPath, SP_VERB_DIALOG_SYMBOLS), - store(Gtk::ListStore::create(*getColumns())), - icon_view(0), - current_desktop(0), - desk_track(), - current_document(0), - preview_document(0), - instanceConns() -{ - - /******************** Table *************************/ - auto table = new Gtk::Grid(); - table->set_margin_left(3); - table->set_margin_right(3); - table->set_margin_top(4); - // panel is a cloked Gtk::VBox - _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); - guint row = 0; - - /******************** Symbol Sets *************************/ - Gtk::Label* label_set = new Gtk::Label(_("Symbol set: ")); - table->attach(*Gtk::manage(label_set),0,row,1,1); - symbol_set = new Gtk::ComboBoxText(); // Fill in later - symbol_set->append(_("Current Document")); - symbol_set->append(_("All symbols sets")); - symbol_set->set_active_text(_("Current Document")); - symbol_set->set_hexpand(); - - table->attach(*Gtk::manage(symbol_set),1,row,1,1); - sigc::connection connSet = symbol_set->signal_changed().connect( - sigc::mem_fun(*this, &SymbolsDialog::rebuild)); - instanceConns.push_back(connSet); - - ++row; - - /******************** Separator *************************/ - - - Gtk::Separator* separator = Gtk::manage(new Gtk::Separator()); // Search - separator->set_margin_top(10); - separator->set_margin_bottom(10); - table->attach(*Gtk::manage(separator),0,row,2,1); - - ++row; - - /******************** Search *************************/ - - - search = Gtk::manage(new Gtk::SearchEntry()); // Search - search->set_tooltip_text(_("Return to start search.")); - search->signal_key_press_event().connect_notify( sigc::mem_fun(*this, &SymbolsDialog::beforeSearch)); - search->signal_key_release_event().connect_notify(sigc::mem_fun(*this, &SymbolsDialog::unsensitive)); - search->set_margin_left(10); - search->set_margin_right(10); - search->set_margin_bottom(6); - search->signal_search_changed().connect(sigc::mem_fun(*this, &SymbolsDialog::clearSearch)); - table->attach(*Gtk::manage(search),0,row,2,1); - search_str = ""; - - ++row; - - - /********************* Icon View **************************/ - SymbolColumns* columns = getColumns(); - - icon_view = new Gtk::IconView(static_cast >(store)); - //icon_view->set_text_column( columns->symbol_id ); - icon_view->set_tooltip_column( 1 ); - icon_view->set_pixbuf_column( columns->symbol_image ); - // Giving the iconview a small minimum size will help users understand - // What the dialog does. - icon_view->set_size_request( 100, 250 ); - - std::vector< Gtk::TargetEntry > targets; - targets.push_back(Gtk::TargetEntry( "application/x-inkscape-paste")); - - icon_view->enable_model_drag_source (targets, Gdk::BUTTON1_MASK, Gdk::ACTION_COPY); - icon_view->signal_drag_data_get().connect( - sigc::mem_fun(*this, &SymbolsDialog::iconDragDataGet)); - - sigc::connection connIconChanged; - connIconChanged = icon_view->signal_selection_changed().connect( - sigc::mem_fun(*this, &SymbolsDialog::iconChanged)); - instanceConns.push_back(connIconChanged); - - scroller = new Gtk::ScrolledWindow(); - scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); - scroller->add(*Gtk::manage(icon_view)); - scroller->set_hexpand(); - scroller->set_vexpand(); -#if GTK_CHECK_VERSION(3,2,4) - overlay = new Gtk::Overlay(); - overlay->set_hexpand(); - overlay->set_vexpand(); - overlay->add(* scroller); - scroller->set_size_request(100, 250); - table->attach(*Gtk::manage(overlay),0,row,2,1); -#else - table->attach(*Gtk::manage(scroller),0,row,2,1); -#endif - ++row; - - /******************** Progress *******************************/ - progress = new Gtk::HBox(); - progress_bar = Gtk::manage(new Gtk::ProgressBar()); - table->attach(*Gtk::manage(progress),0,row, 2, 1); - progress->pack_start(* progress_bar, Gtk::PACK_EXPAND_WIDGET); - progress->set_margin_top(15); - progress->set_margin_bottom(15); - progress->set_margin_left(20); - progress->set_margin_right(20); - - ++row; - - /******************** Tools *******************************/ - tools = new Gtk::HBox(); - - //tools->set_layout( Gtk::BUTTONBOX_END ); - scroller->set_hexpand(); - table->attach(*Gtk::manage(tools),0,row,2,1); - - auto add_symbol_image = Gtk::manage(new Gtk::Image()); - add_symbol_image->set_from_icon_name("symbol-add", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - add_symbol = Gtk::manage(new Gtk::Button()); - add_symbol->add(*add_symbol_image); - add_symbol->set_tooltip_text(_("Add Symbol from the current document.")); - add_symbol->set_relief( Gtk::RELIEF_NONE ); - add_symbol->set_focus_on_click( false ); - add_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::insertSymbol)); - tools->pack_start(* add_symbol, Gtk::PACK_SHRINK); - - auto remove_symbolImage = Gtk::manage(new Gtk::Image()); - remove_symbolImage->set_from_icon_name("symbol-remove", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - remove_symbol = Gtk::manage(new Gtk::Button()); - remove_symbol->add(*remove_symbolImage); - remove_symbol->set_tooltip_text(_("Remove Symbol from the current document.")); - remove_symbol->set_relief( Gtk::RELIEF_NONE ); - remove_symbol->set_focus_on_click( false ); - remove_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::revertSymbol)); - tools->pack_start(* remove_symbol, Gtk::PACK_SHRINK); - - Gtk::Label* spacer = Gtk::manage(new Gtk::Label("")); - tools->pack_start(* Gtk::manage(spacer)); - - // Pack size (controls display area) - pack_size = 2; // Default 32px - - auto packMoreImage = Gtk::manage(new Gtk::Image()); - packMoreImage->set_from_icon_name("pack-more", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - more = Gtk::manage(new Gtk::Button()); - more->add(*packMoreImage); - more->set_tooltip_text(_("Display more icons in row.")); - more->set_relief( Gtk::RELIEF_NONE ); - more->set_focus_on_click( false ); - more->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packmore)); - tools->pack_start(* more, Gtk::PACK_SHRINK); - - auto packLessImage = Gtk::manage(new Gtk::Image()); - packLessImage->set_from_icon_name("pack-less", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - fewer = Gtk::manage(new Gtk::Button()); - fewer->add(*packLessImage); - fewer->set_tooltip_text(_("Display fewer icons in row.")); - fewer->set_relief( Gtk::RELIEF_NONE ); - fewer->set_focus_on_click( false ); - fewer->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::packless)); - tools->pack_start(* fewer, Gtk::PACK_SHRINK); - - // Toggle scale to fit on/off - auto fit_symbolImage = Gtk::manage(new Gtk::Image()); - fit_symbolImage->set_from_icon_name("symbol-fit", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - fit_symbol = Gtk::manage(new Gtk::ToggleButton()); - fit_symbol->add(*fit_symbolImage); - fit_symbol->set_tooltip_text(_("Toggle 'fit' symbols in icon space.")); - fit_symbol->set_relief( Gtk::RELIEF_NONE ); - fit_symbol->set_focus_on_click( false ); - fit_symbol->set_active( true ); - fit_symbol->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::rebuild)); - tools->pack_start(* fit_symbol, Gtk::PACK_SHRINK); - - // Render size (scales symbols within display area) - scale_factor = 0; // Default 1:1 * pack_size/pack_size default - auto zoom_outImage = Gtk::manage(new Gtk::Image()); - zoom_outImage->set_from_icon_name("symbol-smaller", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - zoom_out = Gtk::manage(new Gtk::Button()); - zoom_out->add(*zoom_outImage); - zoom_out->set_tooltip_text(_("Make symbols smaller by zooming out.")); - zoom_out->set_relief( Gtk::RELIEF_NONE ); - zoom_out->set_focus_on_click( false ); - zoom_out->set_sensitive( false ); - zoom_out->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomout)); - tools->pack_start(* zoom_out, Gtk::PACK_SHRINK); - - auto zoom_inImage = Gtk::manage(new Gtk::Image()); - zoom_inImage->set_from_icon_name("symbol-bigger", Gtk::ICON_SIZE_SMALL_TOOLBAR); - - zoom_in = Gtk::manage(new Gtk::Button()); - zoom_in->add(*zoom_inImage); - zoom_in->set_tooltip_text(_("Make symbols bigger by zooming in.")); - zoom_in->set_relief( Gtk::RELIEF_NONE ); - zoom_in->set_focus_on_click( false ); - zoom_in->set_sensitive( false ); - zoom_in->signal_clicked().connect(sigc::mem_fun(*this, &SymbolsDialog::zoomin)); - tools->pack_start(* zoom_in, Gtk::PACK_SHRINK); - - ++row; - - sensitive = true; - - current_desktop = SP_ACTIVE_DESKTOP; - current_document = current_desktop->getDocument(); - preview_document = symbolsPreviewDoc(); /* Template to render symbols in */ - preview_document->ensureUpToDate(); /* Necessary? */ - key = SPItem::display_key_new(1); - renderDrawing.setRoot(preview_document->getRoot()->invoke_show(renderDrawing, key, SP_ITEM_SHOW_DISPLAY )); - - // This might need to be a global variable so setTargetDesktop can modify it - SPDefs *defs = current_document->getDefs(); - - /*************************Overlays******************************/ -#if GTK_CHECK_VERSION(3,2,4) - //Loading - overlay_opacity = new Gtk::Image(); - overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); - overlay_opacity->set_halign(Gtk::ALIGN_START ); - overlay_opacity->set_valign(Gtk::ALIGN_START ); - //No results - iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); - overlay_icon = new Gtk::Image(); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon = new Gtk::Image(); - overlay_icon->set_halign(Gtk::ALIGN_CENTER ); - overlay_icon->set_valign(Gtk::ALIGN_START ); - overlay_icon->set_margin_top(45); - overlay_title = new Gtk::Label(); - overlay_title->set_halign(Gtk::ALIGN_CENTER ); - overlay_title->set_valign(Gtk::ALIGN_START ); - overlay_title->set_justify(Gtk::JUSTIFY_CENTER); - overlay_title->set_margin_top(155); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc = new Gtk::Label(); - overlay_desc->set_halign(Gtk::ALIGN_CENTER ); - overlay_desc->set_valign(Gtk::ALIGN_START ); - overlay_desc->set_margin_top(180); - overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); - overlay->add_overlay(* overlay_opacity); - overlay->add_overlay(* overlay_icon); - overlay->add_overlay(* overlay_title); - overlay->add_overlay(* overlay_desc); -#endif - sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); - instanceConns.push_back(defsModifiedConn); - - sigc::connection selectionChangedConn = current_desktop->selection->connectChanged( - sigc::mem_fun(*this, &SymbolsDialog::selectionChanged)); - instanceConns.push_back(selectionChangedConn); - - sigc::connection documentReplacedConn = current_desktop->connectDocumentReplaced( - sigc::mem_fun(*this, &SymbolsDialog::documentReplaced)); - instanceConns.push_back(documentReplacedConn); - getSymbolsFilename(); - icons_found = false; - - addSymbolsInDoc(current_document); /* Defaults to current document */ - sigc::connection desktopChangeConn = - desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); - instanceConns.push_back( desktopChangeConn ); - desk_track.connect(GTK_WIDGET(gobj())); -#if GTK_CHECK_VERSION(3,2,4) - overlay->hide(); -#endif -} - -SymbolsDialog::~SymbolsDialog() -{ - for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); - } - idleconn.disconnect(); - instanceConns.clear(); - desk_track.disconnect(); -} - -SymbolsDialog& SymbolsDialog::getInstance() -{ - return *new SymbolsDialog(); -} - -void SymbolsDialog::packless() { - if(pack_size < 4) { - pack_size++; - rebuild(); - } -} - -void SymbolsDialog::packmore() { - if(pack_size > 0) { - pack_size--; - rebuild(); - } -} - -void SymbolsDialog::zoomin() { - if(scale_factor < 4) { - scale_factor++; - rebuild(); - } -} - -void SymbolsDialog::zoomout() { - if(scale_factor > -8) { - scale_factor--; - rebuild(); - } -} - -void SymbolsDialog::rebuild() { - - if (!sensitive) { - return; - } - - if( fit_symbol->get_active() ) { - zoom_in->set_sensitive( false ); - zoom_out->set_sensitive( false ); - } else { - zoom_in->set_sensitive( true); - zoom_out->set_sensitive( true ); - } - store->clear(); - SPDocument* symbol_document = selectedSymbols(); - icons_found = false; - //We are not in search all docs - if (search->get_text() != _("Searching...") && - search->get_text() != _("Loading documents...") && - search->get_text() != _("Documents done, searchig inside...") ) - { - search_str = ""; - search->set_text(""); - } - if (symbol_document) { - addSymbolsInDoc(symbol_document); - } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - } -} - -void SymbolsDialog::insertSymbol() { - Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); - sp_action_perform (action, NULL); -} - -void SymbolsDialog::revertSymbol() { - Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop ) ); - sp_action_perform (action, NULL); -} - -void SymbolsDialog::iconDragDataGet(const Glib::RefPtr& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) -{ - auto iconArray = icon_view->get_selected_items(); - - if( iconArray.empty() ) { - //std::cout << " iconArray empty: huh? " << std::endl; - } else { - Gtk::TreeModel::Path const & path = *iconArray.begin(); - Gtk::ListStore::iterator row = store->get_iter(path); - Glib::ustring symbol_id = (*row)[getColumns()->symbol_id]; - GdkAtom dataAtom = gdk_atom_intern( "application/x-inkscape-paste", FALSE ); - gtk_selection_data_set( data.gobj(), dataAtom, 9, (guchar*)symbol_id.c_str(), symbol_id.length() ); - } - -} - -void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) -{ - Glib::ustring doc_title = symbol_set->get_active_text(); - if (doc_title != _("All symbols sets") && !symbol_sets[symbol_set->get_active_text()] ) { - rebuild(); - } -} - -void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { - Glib::ustring symbol_id = selectedSymbolId(); - Glib::ustring doc_title = selectedSymbolDocTitle(); - if (!doc_title.empty()) { - SPDocument* symbol_document = symbol_sets[doc_title]; - if (!symbol_document) { - //we are in global search so get the original symbol document by title - symbol_document = selectedSymbols(); - } - if (symbol_document) { - SPObject* symbol = symbol_document->getObjectById(symbol_id); - if(symbol && !selection->includes(symbol)) { - icon_view->unselect_all(); - } - } - } -} - -void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) -{ - current_desktop = desktop; - current_document = document; - rebuild(); -} - -SPDocument* SymbolsDialog::selectedSymbols() { - /* OK, we know symbol name... now we need to copy it to clipboard, bon chance! */ - Glib::ustring doc_title = symbol_set->get_active_text(); - if (doc_title == _("All symbols sets")) { - return NULL; - } - SPDocument* symbol_document = symbol_sets[doc_title]; - if( !symbol_document ) { - symbol_document = getSymbolsSet(doc_title).second; - // Symbol must be from Current Document (this method of checking should be language independent). - if( !symbol_document ) { - // Symbol must be from Current Document (this method of - // checking should be language independent). - symbol_document = current_document; - add_symbol->set_sensitive( true ); - remove_symbol->set_sensitive( true ); - } else { - add_symbol->set_sensitive( false ); - remove_symbol->set_sensitive( false ); - } - } - return symbol_document; -} - -Glib::ustring SymbolsDialog::selectedSymbolId() { - - auto iconArray = icon_view->get_selected_items(); - - if( !iconArray.empty() ) { - Gtk::TreeModel::Path const & path = *iconArray.begin(); - Gtk::ListStore::iterator row = store->get_iter(path); - return (*row)[getColumns()->symbol_id]; - } - return Glib::ustring(""); -} - -Glib::ustring SymbolsDialog::selectedSymbolDocTitle() { - - auto iconArray = icon_view->get_selected_items(); - - if( !iconArray.empty() ) { - Gtk::TreeModel::Path const & path = *iconArray.begin(); - Gtk::ListStore::iterator row = store->get_iter(path); - return (*row)[getColumns()->symbol_doc_title]; - } - return Glib::ustring(""); -} - -Glib::ustring SymbolsDialog::documentTitle(SPDocument* symbol_doc) { - Glib::ustring title = _("Untitled document"); - if (symbol_doc) { - SPRoot * root = symbol_doc->getRoot(); - if (root->title()) { - title = ellipsize(Glib::ustring(root->title())); - return title; - } - } - Glib::ustring current = symbol_set->get_active_text(); - if (current == _("Current Document")) { - return current; - } - return title; -} - -void SymbolsDialog::iconChanged() { - - Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbol_document = selectedSymbols(); - if (!symbol_document) { - //we are in global search so get the original symbol document by title - Glib::ustring doc_title = selectedSymbolDocTitle(); - if (!doc_title.empty()) { - symbol_document = symbol_sets[doc_title]; - } - } - if (symbol_document) { - SPObject* symbol = symbol_document->getObjectById(symbol_id); - - if( symbol ) { - if( symbol_document == current_document ) { - // Select the symbol on the canvas so it can be manipulated - current_desktop->selection->set( symbol, false ); - } - // Find style for use in - // First look for default style stored in - gchar const* style = symbol->getAttribute("inkscape:symbol-style"); - if( !style ) { - // If no default style in , look in documents. - if( symbol_document == current_document ) { - style = styleFromUse( symbol_id.c_str(), current_document ); - } else { - style = symbol_document->getReprRoot()->attribute("style"); - } - } - - ClipboardManager *cm = ClipboardManager::get(); - cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); - } - } -} - -#ifdef WITH_LIBVISIO - -#if WITH_LIBVISIO01 -// Extend libvisio's native RVNGSVGDrawingGenerator with support for extracting stencil names (to be used as ID/title) -class REVENGE_API RVNGSVGDrawingGenerator_WithTitle : public RVNGSVGDrawingGenerator { - public: - RVNGSVGDrawingGenerator_WithTitle(RVNGStringVector &output, RVNGStringVector &titles, const RVNGString &nmSpace) - : RVNGSVGDrawingGenerator(output, nmSpace) - , _titles(titles) - {} - - void startPage(const RVNGPropertyList &propList) - { - RVNGSVGDrawingGenerator::startPage(propList); - if (propList["draw:name"]) { - _titles.append(propList["draw:name"]->getStr()); - } else { - _titles.append(""); - } - } - - private: - RVNGStringVector &_titles; -}; -#endif - -// Read Visio stencil files -SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { - gchar *fullname; - #ifdef WIN32 - // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows - // therefore attempt to convert uri to the system codepage - // even if this is not possible the alternate short (8.3) file name will be used if available - fullname = g_win32_locale_filename_from_utf8(filename.c_str()); - #else - filename.copy(fullname, filename.length()); - #endif - - RVNGFileStream input(fullname); - g_free(fullname); - - if (!libvisio::VisioDocument::isSupported(&input)) { - return NULL; - } - - RVNGStringVector output; - RVNGStringVector titles; -#if WITH_LIBVISIO01 - RVNGSVGDrawingGenerator_WithTitle generator(output, titles, "svg"); - - if (!libvisio::VisioDocument::parseStencils(&input, &generator)) { -#else - if (!libvisio::VisioDocument::generateSVGStencils(&input, output)) { -#endif - return NULL; - } - - if (output.empty()) { - return NULL; - } - - // prepare a valid title for the symbol file - Glib::ustring title = Glib::Markup::escape_text(name); - // prepare a valid id prefix for symbols libvisio doesn't give us a name for - Glib::RefPtr regex1 = Glib::Regex::create("[^a-zA-Z0-9_-]"); - Glib::ustring id = regex1->replace(name, 0, "_", Glib::REGEX_MATCH_PARTIAL); - - Glib::ustring tmpSVGOutput; - tmpSVGOutput += "\n"; - tmpSVGOutput += "\n"; - tmpSVGOutput += " "; - tmpSVGOutput += title; - tmpSVGOutput += "\n"; - tmpSVGOutput += " \n"; - - // Each "symbol" is in its own SVG file, we wrap with and merge into one file. - for (unsigned i=0; ireplace(titles[i].cstr(), 0, "_", Glib::REGEX_MATCH_PARTIAL); - } else { - ss << id << "_" << i; - } - - tmpSVGOutput += " \n"; - -#if WITH_LIBVISIO01 - if (titles.size() == output.size() && titles[i] != "") { - tmpSVGOutput += " " + Glib::ustring(RVNGString::escapeXML(titles[i].cstr()).cstr()) + "\n"; - } -#endif - - std::istringstream iss( output[i].cstr() ); - std::string line; - while( std::getline( iss, line ) ) { - if( line.find( "svg:svg" ) == std::string::npos ) { - tmpSVGOutput += " " + line + "\n"; - } - } - - tmpSVGOutput += " \n"; - } - - tmpSVGOutput += " \n"; - tmpSVGOutput += "\n"; - - return SPDocument::createNewDocFromMem( tmpSVGOutput.c_str(), strlen( tmpSVGOutput.c_str()), 0 ); - -} -#endif - -/* Hunts preference directories for symbol files */ -void SymbolsDialog::getSymbolsFilename() { - - using namespace Inkscape::IO::Resource; - Glib::ustring title; - number_docs = 0; - for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - if(Glib::str_has_suffix(filename, ".svg")) { - //TODO: find a way to get real title without loading all SPDocument - std::size_t found = filename.find_last_of("/\\"); - filename = filename.substr(found+1); - title = filename.erase(filename.rfind('.')); - if(title.empty()) { - title = _("Unnamed Symbols"); - } - symbol_sets[title]= NULL; - symbol_set->append(title); - ++number_docs; - } -#ifdef WITH_LIBVISIO - if(Glib::str_has_suffix(filename, ".vss")) { - std::size_t found = filename.find_last_of("/\\"); - filename = filename.substr(found+1); - title = filename.erase(filename.rfind('.')); - if(title.empty()) { - title = _("Unnamed Symbols"); - } - symbol_sets[title]= NULL; - symbol_set->append(title); - ++number_docs; - } -#endif - } -} - -/* Hunts preference directories for symbol files */ -std::pair -SymbolsDialog::getSymbolsSet(Glib::ustring title) -{ - if (symbol_sets[title]) { - return std::make_pair(title, symbol_sets[title]); - } - using namespace Inkscape::IO::Resource; - SPDocument* symbol_doc = NULL; - Glib::ustring new_title; - size_t i = 0; - for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { - std::size_t pos = filename.find_last_of("/\\"); - if (pos != std::string::npos) { - Glib::ustring filename_short = filename.substr(pos+1); - if(filename_short == title + ".svg") { - symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); - if(symbol_doc) { - new_title = documentTitle(symbol_doc); - } - } - if(Glib::str_has_suffix(filename, ".svg")) { - i++; - } -#ifdef WITH_LIBVISIO - if(filename_short == title + ".vss") { - symbol_doc = read_vss(filename, title); - if(symbol_doc) { - new_title = documentTitle(symbol_doc); - } - } - if(Glib::str_has_suffix(filename, ".vss")) { - i++; - } -#endif - if(symbol_doc) { - symbol_sets.erase(title); - symbol_sets[new_title]= symbol_doc; - sensitive = false; - symbol_set->remove_text(i+1); - symbol_set->insert (i+1, new_title); - symbol_set->set_active(i+1); - symbol_set->set_active_text(new_title); - sensitive = true; - break; - } - } - } - return std::make_pair(new_title, symbol_doc); -} - -void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title) -{ - if(!r) return; - - // Stop multiple counting of same symbol - if ( dynamic_cast(r) ) { - return; - } - - if ( dynamic_cast(r) ) { - l.push_back(std::make_pair(doc_title,dynamic_cast(r))); - } - for (auto& child: r->children) { - symbolsInDocRecursive(&child, l, doc_title); - } -} - -std::vector > -SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_title) -{ - - std::vector > l; - if (symbol_document) { - symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); - } - return l; -} - -void SymbolsDialog::useInDoc (SPObject *r, std::vector &l) -{ - - if ( dynamic_cast(r) ) { - l.push_back(dynamic_cast(r)); - } - - for (auto& child: r->children) { - useInDoc( &child, l ); - } -} - -std::vector SymbolsDialog::useInDoc( SPDocument* useDocument) { - std::vector l; - useInDoc (useDocument->getRoot(), l); - return l; -} - -// Returns style from first element found that references id. -// This is a last ditch effort to find a style. -gchar const* SymbolsDialog::styleFromUse( gchar const* id, SPDocument* document) { - - gchar const* style = 0; - std::vector l = useInDoc( document ); - for( auto use:l ) { - if ( use ) { - gchar const *href = use->getRepr()->attribute("xlink:href"); - if( href ) { - Glib::ustring href2(href); - Glib::ustring id2(id); - id2 = "#" + id2; - if( !href2.compare(id2) ) { - style = use->getRepr()->attribute("style"); - break; - } - } - } - } - return style; -} - -void SymbolsDialog::clearSearch() -{ - if(search->get_text().empty() && sensitive) { - enableWidgets(false); - search_str = ""; - store->clear(); - SPDocument* symbol_document = selectedSymbols(); - if (symbol_document) { - //We are not in search all docs - icons_found = false; - addSymbolsInDoc(symbol_document); - } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - enableWidgets(true); - } - } -} - -void SymbolsDialog::enableWidgets(bool enable) -{ - symbol_set->set_sensitive(enable); - search->set_sensitive(enable); - tools ->set_sensitive(enable); -} - -void SymbolsDialog::beforeSearch(GdkEventKey* evt) -{ - sensitive = false; - search_str = search->get_text().lowercase(); - if (evt->keyval != GDK_KEY_Return) { - return; - } - progress_bar->set_fraction(0.0); - enableWidgets(false); - SPDocument* symbol_document = selectedSymbols(); - if (symbol_document) { - //We are not in search all docs - search->set_text(_("Searching...")); - store->clear(); - icons_found = false; - addSymbolsInDoc(symbol_document); - } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - search->set_text(_("Loading documents...")); - } -} - -void SymbolsDialog::unsensitive(GdkEventKey* evt) -{ - sensitive = true; -} - -bool SymbolsDialog::callbackSymbols(){ - Glib::ustring current = symbol_set->get_active_text(); - -#if GTK_CHECK_VERSION(3,2,4) -if (current == _("All symbols sets") && search->get_text() != _("Loading documents...") && !l.size()) - { - if (!all_docs_processed ) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); - } else { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); - } - overlay_opacity->show(); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); - return false; - } -#endif - if (current == _("All symbols sets") && search->get_text() == _("Loading documents...")) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_opacity->show(); -#endif - if (!all_docs_processed) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); - overlay_icon->show(); - overlay_title->show(); - overlay_icon->set_from_icon_name("searching", iconsize); - overlay_desc->show(); -#endif - } - size_t counter = 0; - for(auto const &symbol_document_map : symbol_sets) { - ++counter; - SPDocument* symbol_document = symbol_document_map.second; - if (symbol_document) { - continue; - } - symbol_document = getSymbolsSet(symbol_document_map.first).second; - symbol_set->set_active_text(_("All symbols sets")); - if (!symbol_document) { - continue; - } - progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); - return true; - } -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->hide(); - overlay_title->hide(); - overlay_desc->hide(); -#endif - progress_bar->set_fraction(1.0); - all_docs_processed = true; - addSymbols(); - search->set_text("Documents done, searchig inside..."); - return true; - } else if (l.size()) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_opacity->show(); - overlay_icon->hide(); - overlay_title->hide(); - overlay_desc->hide(); -#endif - for (auto symbol_data = l.begin(); symbol_data != l.end();) { - Glib::ustring doc_title = symbol_data->first; - SPSymbol * symbol = symbol_data->second; - counter_symbols ++; - gchar const *symbol_title_char = symbol->title(); - gchar const *symbol_desc_char = symbol->description(); - bool found = false; - if (symbol_title_char) { - Glib::ustring symbol_title = Glib::ustring(symbol_title_char).lowercase(); - auto pos = symbol_title.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - if (!found && symbol_desc_char) { - Glib::ustring symbol_desc = Glib::ustring(symbol_desc_char).lowercase(); - auto pos = symbol_desc.rfind(search_str); - if (pos != std::string::npos) { - found = true; - } - } - } - if (symbol && (search_str.empty() || found || (search_str.empty() && !symbol_title_char))) { - addSymbol( symbol, doc_title); - icons_found = true; - } - - progress_bar->set_fraction(((100.0/number_symbols) * counter_symbols)/100.0); - symbol_data = l.erase(l.begin()); - //to get more items and best performance - int modulus = number_symbols > 200 ? 50 : (number_symbols/4); - if (modulus && counter_symbols % modulus == 0 && !l.empty()) { - return true; - } - } -#if GTK_CHECK_VERSION(3,2,4) - if (!icons_found && !search_str.empty()) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - overlay_icon->set_from_icon_name("none", iconsize); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); - } else { - overlay_opacity->hide(); - } -#endif - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); - return false; - } - return true; -} - -Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { - if (data.length() > limit) { - return data.substr(0,limit-3) + "..."; - } - return data; -} - -void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { - - if (!symbol_document) { - return; //Search all - } - Glib::ustring doc_title = documentTitle(symbol_document); - progress_bar->set_fraction(0.0); - counter_symbols = 0; - std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); - number_symbols = container_symbols_tmp.size(); - l = container_symbols_tmp; - container_symbols_tmp.clear(); - if (!number_symbols) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->set_from_icon_name("none", iconsize); - overlay_opacity->show(); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); -#endif - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); - idleconn.disconnect(); - } else { - idleconn.disconnect(); - idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - } -#if GTK_CHECK_VERSION(3,2,4) - Glib::ustring current = symbol_set->get_active_text(); - if (!number_symbols && (current != _("Current Document") || !search_str.empty())) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - } else if (!number_symbols) { - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); - } -#endif -} - -void SymbolsDialog::addSymbols() { - store->clear(); - icons_found = false; - std::vector > container_symbols; - for(auto const &symbol_document_map : symbol_sets) { - SPDocument* symbol_document = symbol_document_map.second; - if (!symbol_document) { - continue; - } - Glib::ustring doc_title = documentTitle(symbol_document); - std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); - container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); - container_symbols_tmp.clear(); - } - counter_symbols = 0; - progress_bar->set_fraction(0.0); - number_symbols = container_symbols.size(); - l = container_symbols; - container_symbols.clear(); - if (!number_symbols) { -#if GTK_CHECK_VERSION(3,2,4) - overlay_icon->set_from_icon_name("none", iconsize); - overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); - overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); - overlay_icon->show(); - overlay_title->show(); - overlay_desc->show(); -#endif - idleconn.disconnect(); - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); - } -} - -void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { - - SymbolColumns* columns = getColumns(); - - gchar const *id = symbol->getRepr()->attribute("id"); - gchar const *title = symbol->title(); // From title element - if( !title ) { - title = id; - } - Glib::ustring symbol_title = Glib::Markup::escape_text(Glib::ustring( g_dpgettext2(NULL, "Symbol", title) )); - if (doc_title.empty()) { - doc_title = _("Current Document"); - } - symbol_title = symbol_title + Glib::Markup::escape_text(Glib::ustring(g_dpgettext2(NULL, "Symbol", (Glib::ustring(" (") + doc_title + Glib::ustring(")")).c_str()))); - Glib::RefPtr pixbuf = drawSymbol( symbol ); - - if( pixbuf ) { - Gtk::ListStore::iterator row = store->append(); - (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = symbol_title; - (*row)[columns->symbol_doc_title] = Glib::Markup::escape_text(doc_title); - (*row)[columns->symbol_image] = pixbuf; - } - - delete columns; -} - -/* - * Returns image of symbol. - * - * Symbols normally are not visible. They must be referenced by a - * element. A temporary document is created with a dummy - * element and a element that references the symbol - * element. Each real symbol is swapped in for the dummy symbol and - * the temporary document is rendered. - */ -Glib::RefPtr -SymbolsDialog::drawSymbol(SPObject *symbol, unsigned force_psize) -{ - // Create a copy repr of the symbol with id="the_symbol" - Inkscape::XML::Document *xml_doc = preview_document->getReprDoc(); - Inkscape::XML::Node *repr = symbol->getRepr()->duplicate(xml_doc); - repr->setAttribute("id", "the_symbol"); - - // Replace old "the_symbol" in preview_document by new. - Inkscape::XML::Node *root = preview_document->getReprRoot(); - SPObject *symbol_old = preview_document->getObjectById("the_symbol"); - if (symbol_old) { - symbol_old->deleteObject(false); - } - - // First look for default style stored in - gchar const* style = repr->attribute("inkscape:symbol-style"); - if( !style ) { - // If no default style in , look in documents. - if( symbol->document == current_document ) { - gchar const *id = symbol->getRepr()->attribute("id"); - style = styleFromUse( id, symbol->document ); - } else { - style = symbol->document->getReprRoot()->attribute("style"); - } - } - // Last ditch effort to provide some default styling - if( !style ) style = "fill:#bbbbbb;stroke:#808080"; - - // This is for display in Symbols dialog only - if( style ) repr->setAttribute( "style", style ); - - // BUG: Symbols don't work if defined outside of . Causes Inkscape - // crash when trying to read in such a file. - root->appendChild(repr); - //defsrepr->appendChild(repr); - Inkscape::GC::release(repr); - - // Uncomment this to get the preview_document documents saved (useful for debugging) - // FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w"); - // sp_repr_save_stream(preview_document->getReprDoc(), fp); - // fclose (fp); - - // Make sure preview_document is up-to-date. - preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - preview_document->ensureUpToDate(); - - // Make sure we have symbol in preview_document - SPObject *object_temp = preview_document->getObjectById( "the_use" ); - preview_document->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - preview_document->ensureUpToDate(); - - SPItem *item = dynamic_cast(object_temp); - g_assert(item != NULL); - unsigned psize = SYMBOL_ICON_SIZES[pack_size]; - - Glib::RefPtr pixbuf(NULL); - // We could use cache here, but it doesn't really work with the structure - // of this user interface and we've already cached the pixbuf in the gtklist - - // Find object's bbox in document. - // Note symbols can have own viewport... ignore for now. - //Geom::OptRect dbox = item->geometricBounds(); - Geom::OptRect dbox = item->documentVisualBounds(); - - if (dbox) { - /* Scale symbols to fit */ - double scale = 1.0; - double width = dbox->width(); - double height = dbox->height(); - - if( width == 0.0 ) width = 1.0; - if( height == 0.0 ) height = 1.0; - - if( fit_symbol->get_active() ) - scale = psize / ceil(std::max(width, height)); - 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)); - } - - return pixbuf; -} - -/* - * Return empty doc to render symbols in. - * Symbols are by default not rendered so a element is - * provided. - */ -SPDocument* SymbolsDialog::symbolsPreviewDoc() -{ - // BUG: must be inside - gchar const *buffer = -"" -" " -" " -" " -" " -""; - return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); -} - -/* - * Update image widgets - */ -Glib::RefPtr -SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) -{ -gchar const *buffer = -"" -" Inkscape " -" " -" " -" Overlay" -" Overlay Square" -" " -" " -" " -""; - - SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector > symbols_data = symbolsInDoc(doc, "Overlay Doc"); - Glib::RefPtr pixbuf(NULL); - for(auto data:symbols_data) { - Glib::ustring doc_title = data.first; - SPSymbol * symbol = data.second; - if (!strcmp(symbol->getId(), icon_title)) { - pixbuf = drawSymbol(symbol, psize); - return pixbuf; - } - } - return pixbuf; -} - -void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) -{ - if (this->current_desktop != desktop) { - this->current_desktop = desktop; - if( !symbol_sets[symbol_set->get_active_text()] ) { - // Symbol set is from Current document, update - rebuild(); - } - } -} - -} //namespace Dialogs -} //namespace UI -} //namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-basic-offset:2 - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/symbols.cpp.rej b/src/ui/dialog/symbols.cpp.rej deleted file mode 100644 index fe32c8bad..000000000 --- a/src/ui/dialog/symbols.cpp.rej +++ /dev/null @@ -1,384 +0,0 @@ ---- src/ui/dialog/symbols.cpp -+++ src/ui/dialog/symbols.cpp -@@ -348,38 +374,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : - - // This might need to be a global variable so setTargetDesktop can modify it - SPDefs *defs = current_document->getDefs(); -- -- /*************************Overlays******************************/ - #if GTK_CHECK_VERSION(3,2,4) -- //Loading -- overlay_opacity = new Gtk::Image(); - overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); -- overlay_opacity->set_halign(Gtk::ALIGN_START ); -- overlay_opacity->set_valign(Gtk::ALIGN_START ); -- //No results -- iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); -- overlay_icon = new Gtk::Image(); -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_icon = new Gtk::Image(); -- overlay_icon->set_halign(Gtk::ALIGN_CENTER ); -- overlay_icon->set_valign(Gtk::ALIGN_START ); -- overlay_icon->set_margin_top(45); -- overlay_title = new Gtk::Label(); -- overlay_title->set_halign(Gtk::ALIGN_CENTER ); -- overlay_title->set_valign(Gtk::ALIGN_START ); -- overlay_title->set_justify(Gtk::JUSTIFY_CENTER); -- overlay_title->set_margin_top(155); -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -- overlay_desc = new Gtk::Label(); -- overlay_desc->set_halign(Gtk::ALIGN_CENTER ); -- overlay_desc->set_valign(Gtk::ALIGN_START ); -- overlay_desc->set_margin_top(180); -- overlay_desc->set_justify(Gtk::JUSTIFY_CENTER); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("")); -- overlay->add_overlay(* overlay_opacity); -- overlay->add_overlay(* overlay_icon); -- overlay->add_overlay(* overlay_title); -- overlay->add_overlay(* overlay_desc); - #endif - sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); - instanceConns.push_back(defsModifiedConn); -@@ -394,16 +390,11 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : - getSymbolsFilename(); - icons_found = false; - -- Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); -- - addSymbolsInDoc(current_document); /* Defaults to current document */ - sigc::connection desktopChangeConn = - desk_track.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); - instanceConns.push_back( desktopChangeConn ); - desk_track.connect(GTK_WIDGET(gobj())); --#if GTK_CHECK_VERSION(3,2,4) -- overlay->hide(); --#endif - } - - SymbolsDialog::~SymbolsDialog() -@@ -411,6 +402,7 @@ SymbolsDialog::~SymbolsDialog() - for (std::vector::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { - it->disconnect(); - } -+ idleconn.disconnect(); - instanceConns.clear(); - desk_track.disconnect(); - } -@@ -474,9 +466,68 @@ void SymbolsDialog::rebuild() { - } - if (symbol_document) { - addSymbolsInDoc(symbol_document); -+ } else { -+ showOverlay(); - } - } -+void SymbolsDialog::showOverlay() { -+#if GTK_CHECK_VERSION(3,2,4) -+Glib::ustring current = Glib::Markup::escape_text(symbol_set->get_active_text()); -+ if (current == ALLDOCS && -+ search->get_text() != _("Loading documents...") && -+ !l.size()) -+ { -+ if (!all_docs_processed ) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time,\n search will be slow.\nPlease wait ...")) + Glib::ustring("")); -+ } else if (!icons_found && !search_str.empty()) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found ...")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); -+ } else { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("All symbol sets ...")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("We have all symbols preloaded,\n search is faster now ...")) + Glib::ustring("")); -+ } -+ } else if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { -+ if (!all_docs_processed) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("")+ Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); -+ overlay_icon->show(); -+ overlay_title->show(); -+ overlay_icon->set_from_icon_name("searching", iconsize); -+ overlay_desc->show(); -+ } -+ } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -+ } else if (!number_symbols && current == CURRENTDOC) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols found")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("No symbols in current document.\nYou could create in the current document\n or add into from other different symbol set.")) + Glib::ustring("")); -+ } else if (!icons_found && !search_str.empty()) { -+ overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -+ overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -+ } -+ overlay_opacity->show(); -+ overlay_icon->set_from_icon_name("none", iconsize); -+ overlay_icon->show(); -+ overlay_title->show(); -+ overlay_desc->show(); -+ if (l.size()) { -+ overlay_opacity->show(); -+ overlay_icon->hide(); -+ overlay_title->hide(); -+ overlay_desc->hide(); -+ } -+#endif -+} - -+void SymbolsDialog::hideOverlay() { -+#if GTK_CHECK_VERSION(3,2,4) -+ overlay_opacity->hide(); -+ overlay_icon->hide(); -+ overlay_title->hide(); -+ overlay_desc->hide(); -+#endif -+} - void SymbolsDialog::insertSymbol() { - Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); - SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop) ); -@@ -934,6 +995,7 @@ void SymbolsDialog::clearSearch() - icons_found = false; - addSymbolsInDoc(symbol_document); - } else { -+ showOverlay(); - enableWidgets(true); - } - } -@@ -963,6 +1025,8 @@ void SymbolsDialog::beforeSearch(GdkEventKey* evt) - icons_found = false; - addSymbolsInDoc(symbol_document); - } else { -+ idleconn.disconnect(); -+ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackAllSymbols)); - search->set_text(_("Loading documents...")); - } - } -@@ -973,84 +1037,11 @@ void SymbolsDialog::unsensitive(GdkEventKey* evt) - } - - bool SymbolsDialog::callbackSymbols(){ -- Glib::ustring current = symbol_set->get_active_text(); --#if GTK_CHECK_VERSION(3,2,4) -- if (current == _("All symbols sets") && -- search->get_text() != _("Loading documents...")) -- { -- if (!all_docs_processed) { -- overlay_opacity->show(); -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_icon->show(); -- overlay_title->show(); -- overlay_desc->show(); -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); -- } -- } -- if (current == _("Current Document") && !icons_found) { -- if (!all_docs_processed) { -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_opacity->show(); -- overlay_icon->show(); -- overlay_title->show(); -- overlay_desc->show(); -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -- } -- } --#endif -- if (current == _("All symbols sets") && -- search->get_text() == _("Loading documents...") ) -- { --#if GTK_CHECK_VERSION(3,2,4) -- overlay_opacity->show(); --#endif -- if (!all_docs_processed) { --#if GTK_CHECK_VERSION(3,2,4) -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("")); -- overlay_icon->show(); -- overlay_title->show(); -- overlay_icon->set_from_icon_name("searching", iconsize); -- overlay_desc->show(); --#endif -- } -- size_t counter = 0; -- for(auto const &symbol_document_map : symbol_sets) { -- ++counter; -- SPDocument* symbol_document = symbol_document_map.second; -- if (symbol_document) { -- continue; -- } -- symbol_document = getSymbolsSet(symbol_document_map.first).second; -- symbol_set->set_active_text(_("All symbols sets")); -- if (!symbol_document) { -- continue; -- } -- progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); -- return true; -- } --#if GTK_CHECK_VERSION(3,2,4) -- overlay_icon->hide(); -- overlay_title->hide(); -- overlay_desc->hide(); --#endif -- progress_bar->set_fraction(1.0); -- all_docs_processed = true; -- addSymbols(); -- search->set_text("Documents done, searchig inside..."); -- return true; -- } else if (l.size()) { --#if GTK_CHECK_VERSION(3,2,4) -- overlay_opacity->show(); -- overlay_icon->hide(); -- overlay_title->hide(); -- overlay_desc->hide(); --#endif -+ if (l.size()) { -+ showOverlay(); - for (auto symbol_data = l.begin(); symbol_data != l.end();) { -- Glib::ustring doc_title = symbol_data->first; -- SPSymbol * symbol = symbol_data->second; -+ Glib::ustring doc_title = symbol_data->second.first; -+ SPSymbol * symbol = symbol_data->second.second; - counter_symbols ++; - gchar const *symbol_title_char = symbol->title(); - gchar const *symbol_desc_char = symbol->description(); -@@ -1082,30 +1073,54 @@ bool SymbolsDialog::callbackSymbols(){ - return true; - } - } --#if GTK_CHECK_VERSION(3,2,4) - if (!icons_found && !search_str.empty()) { -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_icon->show(); -- overlay_title->show(); -- overlay_desc->show(); -+ showOverlay(); - } else { -- overlay_opacity->hide(); -+ hideOverlay(); - } --#endif - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); -- return true; -+ return false; -+ } -+ return true; -+} -+ -+bool SymbolsDialog::callbackAllSymbols(){ -+ Glib::ustring current = symbol_set->get_active_text(); -+ if (current == ALLDOCS && search->get_text() == _("Loading documents...")) { -+ size_t counter = 0; -+ std::map symbol_sets_tmp = symbol_sets; -+ for(auto const &symbol_document_map : symbol_sets_tmp) { -+ ++counter; -+ SPDocument* symbol_document = symbol_document_map.second; -+ if (symbol_document) { -+ continue; -+ } -+ symbol_document = getSymbolsSet(symbol_document_map.first).second; -+ symbol_set->set_active_text(ALLDOCS); -+ if (!symbol_document) { -+ continue; -+ } -+ progress_bar->set_fraction(((100.0/number_docs) * counter)/100.0); -+ return true; -+ } -+ symbol_sets_tmp.clear(); -+ hideOverlay(); -+ progress_bar->set_fraction(1.0); -+ all_docs_processed = true; -+ addSymbols(); -+ search->set_text("Documents done, searchig inside..."); -+ return false; - } - return true; - } - - Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { - if (data.length() > limit) { -- return data.substr(0,limit-3) + "..."; -+ data = data.substr(0, limit-3); -+ return data + "..."; - } - return data; - } -@@ -1118,58 +1133,49 @@ void SymbolsDialog::addSymbolsInDoc(SPDocument* symbol_document) { - Glib::ustring doc_title = documentTitle(symbol_document); - progress_bar->set_fraction(0.0); - counter_symbols = 0; -- std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); -- number_symbols = container_symbols_tmp.size(); -- l = container_symbols_tmp; -- container_symbols_tmp.clear(); -+ l = symbolsInDoc(symbol_document, doc_title); -+ number_symbols = l.size(); - if (!number_symbols) { --#if GTK_CHECK_VERSION(3,2,4) -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_icon->show(); -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -- overlay_title->show(); -- overlay_desc->show(); --#endif - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); -+ idleconn.disconnect(); -+ showOverlay(); -+ } else { -+ idleconn.disconnect(); -+ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - } - } - - void SymbolsDialog::addSymbols() { - store->clear(); - icons_found = false; -- std::vector > container_symbols; - for(auto const &symbol_document_map : symbol_sets) { - SPDocument* symbol_document = symbol_document_map.second; - if (!symbol_document) { - continue; - } - Glib::ustring doc_title = documentTitle(symbol_document); -- std::vector > container_symbols_tmp = symbolsInDoc(symbol_document, doc_title); -- container_symbols.insert(container_symbols.end(), std::make_move_iterator(container_symbols_tmp.begin()), std::make_move_iterator(container_symbols_tmp.end())); -- container_symbols_tmp.clear(); -+ std::map > l_tmp = symbolsInDoc(symbol_document, doc_title); -+ for(auto &p : l_tmp ) { -+ l[p.first] = p.second; -+ } -+ l_tmp.clear(); - } - counter_symbols = 0; - progress_bar->set_fraction(0.0); -- number_symbols = container_symbols.size(); -- l = container_symbols; -- container_symbols.clear(); -+ number_symbols = l.size(); - if (!number_symbols) { --#if GTK_CHECK_VERSION(3,2,4) -- overlay_icon->set_from_icon_name("none", iconsize); -- overlay_title->set_markup(Glib::ustring("") + Glib::ustring(_("No results found")) + Glib::ustring("")); -- overlay_desc->set_markup(Glib::ustring("") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("")); -- overlay_icon->show(); -- overlay_title->show(); -- overlay_desc->show(); --#endif -+ showOverlay(); -+ idleconn.disconnect(); - sensitive = false; - search->set_text(search_str); - sensitive = true; - enableWidgets(true); -+ } else { -+ idleconn.disconnect(); -+ idleconn = Glib::signal_idle().connect( sigc::mem_fun(*this, &SymbolsDialog::callbackSymbols)); - } - } - diff --git a/src/ui/dialog/symbols.h.orig b/src/ui/dialog/symbols.h.orig deleted file mode 100644 index 8255877b8..000000000 --- a/src/ui/dialog/symbols.h.orig +++ /dev/null @@ -1,172 +0,0 @@ -/** @file - * @brief Symbols dialog - */ -/* Authors: - * Tavmjong Bah, Martin Owens - * - * Copyright (C) 2012 Tavmjong Bah - * 2013 Martin Owens - * 2017 Jabiertxo Arraiza - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_UI_DIALOG_SYMBOLS_H -#define INKSCAPE_UI_DIALOG_SYMBOLS_H -#include - -#include "display/drawing.h" -#include "ui/dialog/desktop-tracker.h" -#include "ui/widget/panel.h" -#include "sp-symbol.h" -#include "sp-use.h" -#include - -class SPObject; - -namespace Inkscape { -namespace UI { -namespace Dialog { - -class SymbolColumns; // For Gtk::ListStore - -/** - * A dialog that displays selectable symbols and allows users to drag or paste - * those symbols from the dialog into the document. - * - * Symbol documents are loaded from the preferences paths and displayed in a - * drop-down list to the user. The user then selects which of the symbols - * documents they want to get symbols from. The first document in the list is - * always the current document. - * - * This then updates an icon-view with all the symbols available. Selecting one - * puts it onto the clipboard. Dragging it or pasting it onto the canvas copies - * the symbol from the symbol document, into the current document and places a - * new & context, Gtk::SelectionData& selection_data, guint info, guint time); - void getSymbolsFilename(); - Glib::ustring documentTitle(SPDocument* doc); - std::pair getSymbolsSet(Glib::ustring title); - void addSymbol( SPObject* symbol, Glib::ustring doc_title); - SPDocument* symbolsPreviewDoc(); - void symbolsInDocRecursive (SPObject *r, std::vector > &l, Glib::ustring doc_title); - std::vector > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); - void useInDoc(SPObject *r, std::vector &l); - std::vector useInDoc( SPDocument* document); - void beforeSearch(GdkEventKey* evt); - void unsensitive(GdkEventKey* evt); - void addSymbols(); - void addSymbolsInDoc(SPDocument* document); - void clearSearch(); - bool callbackSymbols(); - void enableWidgets(bool enable); - Glib::ustring ellipsize(Glib::ustring data, size_t limit = 40); - gchar const* styleFromUse( gchar const* id, SPDocument* document); - Glib::RefPtr drawSymbol(SPObject *symbol, unsigned force_psize = 0); - Glib::RefPtr getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); - /* Keep track of all symbol template documents */ - std::map symbol_sets; - std::vector > l; - // Index into sizes which is selected - int pack_size; - // Scale factor - int scale_factor; - bool sensitive; - bool all_docs_processed; - size_t number_docs; - size_t number_symbols; - size_t counter_symbols; - bool icons_found; - Glib::RefPtr store; - Glib::ustring search_str; - Gtk::ComboBoxText* symbol_set; - Gtk::ProgressBar* progress_bar; - Gtk::HBox* progress; - Gtk::SearchEntry* search; - Gtk::IconView* icon_view; - Gtk::Button* add_symbol; - Gtk::Button* remove_symbol; - Gtk::Button* zoom_in; - Gtk::Button* zoom_out; - Gtk::Button* more; - Gtk::Button* fewer; - Gtk::HBox* tools; -#if GTK_CHECK_VERSION(3,2,4) - Gtk::Overlay* overlay; -#endif - Gtk::Image* overlay_icon; - Gtk::Image* overlay_opacity; - Gtk::Label* overlay_title; - Gtk::Label* overlay_desc; - Gtk::ScrolledWindow *scroller; - Gtk::ToggleButton* fit_symbol; - Gtk::IconSize iconsize; - void setTargetDesktop(SPDesktop *desktop); - SPDesktop* current_desktop; - DesktopTracker desk_track; - SPDocument* current_document; - SPDocument* preview_document; /* Document to render single symbol */ - - sigc::connection idleconn; - - /* For rendering the template drawing */ - unsigned key; - Inkscape::Drawing renderDrawing; - - std::vector instanceConns; -}; - -} //namespace Dialogs -} //namespace UI -} //namespace Inkscape - - -#endif // INKSCAPE_UI_DIALOG_SYMBOLS_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/symbols.h.rej b/src/ui/dialog/symbols.h.rej deleted file mode 100644 index 72cb5b299..000000000 --- a/src/ui/dialog/symbols.h.rej +++ /dev/null @@ -1,19 +0,0 @@ ---- src/ui/dialog/symbols.h -+++ src/ui/dialog/symbols.h -@@ -141,13 +144,14 @@ private: - Gtk::ScrolledWindow *scroller; - Gtk::ToggleButton* fit_symbol; - Gtk::IconSize iconsize; -- - void setTargetDesktop(SPDesktop *desktop); - SPDesktop* current_desktop; - DesktopTracker desk_track; - SPDocument* current_document; - SPDocument* preview_document; /* Document to render single symbol */ -- -+ -+ sigc::connection idleconn; -+ - /* For rendering the template drawing */ - unsigned key; - Inkscape::Drawing renderDrawing; -- cgit v1.2.3