diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-10-29 21:19:49 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-10-29 21:19:49 +0000 |
| commit | 0af8e9ec59bd4bde68da4b74cba74ff986344176 (patch) | |
| tree | 8ac191be82349bff57ec9a7da4b0f31876ff0ff8 | |
| parent | Merge branch 'master' into SymbolsSearch (diff) | |
| download | inkscape-0af8e9ec59bd4bde68da4b74cba74ff986344176.tar.gz inkscape-0af8e9ec59bd4bde68da4b74cba74ff986344176.zip | |
Add search and no results from stock icons. Improve text. Thanks Maren for the inputs
| -rw-r--r-- | share/icons/none.svg | 32 | ||||
| -rw-r--r-- | share/icons/searching.svg | 76 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 109 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.h | 5 |
4 files changed, 160 insertions, 62 deletions
diff --git a/share/icons/none.svg b/share/icons/none.svg new file mode 100644 index 000000000..719498dc3 --- /dev/null +++ b/share/icons/none.svg @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg1" + width="16" + height="16" + > + <defs id="defs3"> + </defs> + <g + id="none"> + <rect + height="16" + id="rect9056-0" + style="color:#000000;fill:none;stroke-width:0" + width="16" + x="0" + y="0" /> + <path + style="fill:#e7e7e7;fill-rule:evenodd;stroke:none;" + d="M 2.457032,1.83008 1.830078,2.45703 7.373047,8 1.830078,13.54101 2.457032,14.16992 8,8.62695 13.542969,14.16992 14.169922,13.54101 8.626953,8 14.169922,2.45703 13.542969,1.83008 8,7.37305 Z" + id="rect7924" + /> + </g> +</svg> diff --git a/share/icons/searching.svg b/share/icons/searching.svg new file mode 100644 index 000000000..0bc5b57bc --- /dev/null +++ b/share/icons/searching.svg @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://web.resource.org/cc/" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="svg1" + width="16" + height="16" + > + <metadata> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title>Taiga</dc:title> + <dc:date>24-10-2016</dc:date> + <dc:creator> + <cc:Agent> + <dc:title>Taiga</dc:title> + </cc:Agent> + </dc:creator> + <dc:rights> + <cc:Agent> + <dc:title>CC</dc:title> + </cc:Agent> + </dc:rights> + <dc:publisher> + <cc:Agent> + <dc:title>Taiga</dc:title> + </cc:Agent> + </dc:publisher> + <dc:description>http://taiga.io</dc:description> + <dc:source>http://taiga.io</dc:source> + <cc:license + rdf:resource="http://creativecommons.org/licenses/by/3.0/" /> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/by/3.0/"> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Reproduction" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Distribution" /> + <cc:requires + rdf:resource="http://creativecommons.org/ns#Notice" /> + <cc:requires + rdf:resource="http://creativecommons.org/ns#Attribution" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /> + </cc:License> + </rdf:RDF> + </metadata> + <defs id="defs3"> + </defs> + <g + id="searching"> + <path + d="m 6.914463,1.41365 c -3.005658,0 -5.451776,2.43867 -5.451776,5.43532 0,2.99666 2.446078,5.43538 5.451776,5.43538 1.310212,0 2.513927,-0.46362 3.45522,-1.23458 l 3.547304,3.53658 0.620326,-0.61845 -3.536404,-3.52572 c 0.849092,-0.95867 1.365268,-2.21699 1.365268,-3.59321 0,-2.99665 -2.44605,-5.43532 -5.451714,-5.43532 z m 0,0.87467 c 2.531574,0 4.574468,2.03669 4.574468,4.56065 0,2.52399 -2.042905,4.56073 -4.574468,4.56073 -2.531597,0 -4.574466,-2.03674 -4.574466,-4.56073 0,-2.52396 2.042869,-4.56071 4.574466,-4.56071 z" + id="path10677" + style="color:#000000;fill:#e7e7e7;stroke:none;" + /> + <rect + height="16" + id="rect9056-0" + style="color:#000000;fill:none;stroke-width:0" + width="16" + x="0" + y="0" /> + </g> +</svg> 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("Search over all symbols sets")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("</span>")); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("Searching in all symbol sets ...")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("</span>")); } } 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No icons in current document")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You can fill me if you want\nUse add and remove buttons.\nOr drag symbols from other sets")) + Glib::ustring("</span>")); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); } } 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("Processing all symbols sets")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("This process is slow first time.\nFuture searches dont need this process.\nKeep waiting!")) + Glib::ustring("</span>")); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("When run for the first time, search will be slow.\nPlease wait ...")) + Glib::ustring("</span>")); 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); - overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("Try a another search or select other set")) + Glib::ustring("</span>")); - overlay_icon->set(noresults_icon); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); + 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); 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("<span foreground=\"#333333\" size=\"x-large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"medium\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); 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<Gdk::Pixbuf> -SymbolsDialog::getStockPixbuf(gchar const * symbol_title, unsigned psize) +Glib::RefPtr<Gdk::Pixbuf> +SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) { - gchar const *buffer = +gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\"" " xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" " xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" @@ -1262,53 +1274,30 @@ SymbolsDialog::getStockPixbuf(gchar const * symbol_title, unsigned psize) " <title>Inkscape</title> " " <defs id=\"defs\">" " <symbol" -" id=\"search\">" -" <title" -" id=\"search_title\">Search</title>" -" <desc" -" id=\"search_desc\">From Taiga Icon Set</desc>" -" <path" -" 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\" />" -" </symbol>" -" <symbol" " id=\"overlay\">" " <title" " id=\"overlay_title\">Overlay</title>" " <desc" " id=\"overlay_desc\">Overlay Square</desc>" " <path" -" style=\"fill:#ffffff;opacity:0.85;stroke:none\"" +" style=\"fill:#ffffff;opacity:0.75;stroke:none\"" " d=\"M 0,1 H 1 V 2 H 0 Z\"" " id=\"overlay_shape_1\" />" " </symbol>" -" <symbol" -" id=\"noresults\">" -" <title" -" id=\"noresults_title\">No Results</title>" -" <desc" -" id=\"noresults_desc\">No results</desc>" -" <path" -" style=\"fill:#dddddd;stroke:none\"" -" d=\"m 248.84804,147.6408 -8.67664,8.6772 62.23539,62.23544 -62.23539,62.23538 8.67664,8.67722 62.2354,-62.23596 62.23599,62.23596 8.67665,-8.67722 -62.23541,-62.23538 62.23541,-62.23596 -8.67665,-8.67668 -62.23599,62.2354 z\"" -" id=\"noresults_shape_1\" />" -" </symbol>" " </defs>" "</svg>"; SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); - std::vector<std::pair<Glib::ustring, SPSymbol*> > symbols_data = symbolsInDoc(doc, "Search Taiga Icon"); + std::vector<std::pair<Glib::ustring, SPSymbol*> > symbols_data = symbolsInDoc(doc, "Overlay Doc"); Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL); for(auto data:symbols_data) { Glib::ustring doc_title = data.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<Gdk::DragContext>& 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<Gdk::Pixbuf> drawSymbol(SPObject *symbol, unsigned force_psize = 0); - Glib::RefPtr<Gdk::Pixbuf> getStockPixbuf(gchar const * symbol_title, unsigned psize); + Glib::RefPtr<Gdk::Pixbuf> getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); /* Keep track of all symbol template documents */ std::map<Glib::ustring, SPDocument*> symbol_sets; std::vector<std::pair<Glib::ustring, SPSymbol*> > 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; |
