diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-11-10 18:57:54 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-11-10 18:57:54 +0000 |
| commit | dc6c4dc337aa2ad766cada2eb06fe4c186a89d14 (patch) | |
| tree | 3fc8d3fd109b7c89751183b8be880e856be5ff34 /src/ui | |
| parent | Merge branch 'master' into powerpencil (diff) | |
| parent | Removing regects (diff) | |
| download | inkscape-dc6c4dc337aa2ad766cada2eb06fe4c186a89d14.tar.gz inkscape-dc6c4dc337aa2ad766cada2eb06fe4c186a89d14.zip | |
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/ui')
34 files changed, 919 insertions, 342 deletions
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<Glib::ustring> 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/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::RefPtr<Cair auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; - gdk_rgba_parse(&bg_color, "f0f0f0"); // Fix bg as a light gray + gdk_rgba_parse(&bg_color, "#f0f0f0"); // Fix bg as a light gray gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); GdkRGBA mid_color = {(bg_color.red + fg_color.red)/2.0, @@ -1935,7 +1934,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair (bg_color.alpha + fg_color.alpha)/2.0}; GdkRGBA bg_color_active, fg_color_active; - gdk_rgba_parse(&bg_color, "f0f0f0"); // Fix bg as a light gray gtk_style_context_get_color(sc, GTK_STATE_FLAG_ACTIVE, &fg_color_active); GdkRGBA mid_color_active = {(bg_color_active.red + fg_color_active.red)/2.0, @@ -1959,12 +1957,12 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair _vertical_layout->set_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::RefPtr<Cair cr->stroke(); 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::RefPtr<Cair auto dm = display->get_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::RefPtr<Cair gdk_cairo_set_source_rgba(cr->cobj(), &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::RefPtr<Cair cr->save(); 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::RefPtr<Cair cr->save(); 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::RefPtr<Cair cr->save(); 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); 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<SPItem*> &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/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 4aaa0cbe4..79d8b7411 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1460,8 +1460,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", 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<Gdk::Pixbuf> 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<SPObject*> sel) diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 558b0b19e..1fcede8f1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -17,18 +17,10 @@ #include <locale> #include <sstream> -#include <gtkmm/buttonbox.h> -#include <gtkmm/label.h> -#include <gtkmm/togglebutton.h> -#include <gtkmm/grid.h> -#include <gtkmm/scrolledwindow.h> -#include <gtkmm/comboboxtext.h> -#include <gtkmm/iconview.h> -#include <gtkmm/liststore.h> #include <glibmm/regex.h> #include <glibmm/stringutils.h> #include <glibmm/markup.h> -#include <glibmm/i18n.h> + #include "path-prefix.h" #include "io/sys.h" #include "io/resource.h" @@ -71,12 +63,14 @@ #include "verbs.h" #include "helper/action.h" +#include <glibmm/i18n.h> 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 { @@ -84,11 +78,14 @@ public: Gtk::TreeModelColumn<Glib::ustring> symbol_id; Gtk::TreeModelColumn<Glib::ustring> symbol_title; + Gtk::TreeModelColumn<Glib::ustring> symbol_doc_title; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > symbol_image; + SymbolColumns() { add(symbol_id); add(symbol_title); + add(symbol_doc_title); add(symbol_image); } }; @@ -105,96 +102,171 @@ 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() { - /******************** Table *************************/ + /******************** 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* 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( + 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(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); + 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(); - iconView = new Gtk::IconView(static_cast<Glib::RefPtr<Gtk::TreeModel> >(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<Glib::RefPtr<Gtk::TreeModel> >(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, 250 ); 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); - 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->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); + + /*************************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 + ++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 *******************************/ - Gtk::Button* button; - Gtk::HBox* tools = new Gtk::HBox(); + tools = new Gtk::HBox(); //tools->set_layout( Gtk::BUTTONBOX_END ); 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_clicked().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_clicked().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)); @@ -205,97 +277,98 @@ 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 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); + 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; - /**********************************************************/ - currentDesktop = SP_ACTIVE_DESKTOP; - currentDocument = currentDesktop->getDocument(); - - previewDocument = symbols_preview_doc(); /* Template to render symbols in */ - previewDocument->ensureUpToDate(); /* Necessary? */ + 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(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(); +#if GTK_CHECK_VERSION(3,2,4) + overlay_opacity->set(getOverlay(overlay_opacity, "overlay", 1000)); +#endif sigc::connection defsModifiedConn = defs->connectModified(sigc::mem_fun(*this, &SymbolsDialog::defsModified)); instanceConns.push_back(defsModifiedConn); - 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 */ - + getSymbolsFilename(); + icons_found = false; + + addSymbolsInDoc(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 ); - - deskTrack.connect(GTK_WIDGET(gobj())); + desk_track.connect(GTK_WIDGET(gobj())); } SymbolsDialog::~SymbolsDialog() @@ -303,8 +376,9 @@ SymbolsDialog::~SymbolsDialog() for (std::vector<sigc::connection>::iterator it = instanceConns.begin(); it != instanceConns.end(); ++it) { it->disconnect(); } + idleconn.disconnect(); instanceConns.clear(); - deskTrack.disconnect(); + desk_track.disconnect(); } SymbolsDialog& SymbolsDialog::getInstance() @@ -342,46 +416,109 @@ void SymbolsDialog::zoomout() { void SymbolsDialog::rebuild() { - if( fitSymbol->get_active() ) { - zoomIn->set_sensitive( false ); - zoomOut->set_sensitive( false ); - } else { - zoomIn->set_sensitive( true); - zoomOut->set_sensitive( true ); + 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(); - 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 = selectedSymbols(); + icons_found = false; + //We are not in search all docs + if (search->get_text() != _("Searching...") && + search->get_text() != _("Loading all symbols...") && + search->get_text() != _("Searching....") ) + { + search_str = ""; + search->set_text(""); + } + if (symbol_document) { + addSymbolsInDoc(symbol_document); } else { - addSymbol->set_sensitive( false ); - removeSymbol->set_sensitive( false ); + showOverlay(); + } +} +void SymbolsDialog::showOverlay() { +#if GTK_CHECK_VERSION(3,2,4) + 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 all symbols...") && + !l.size()) + { + if (!all_docs_processed ) { + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("First search can be slow.")) + Glib::ustring("</span>")); + } else if (!icons_found && !search_str.empty()) { + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term.")) + Glib::ustring("</span>")); + } else { + overlay_icon->set_from_icon_name("searching", iconsize); + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Search in all symbol sets ...")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("")) + Glib::ustring("</span>")); + } + } else if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { + if (!all_docs_processed) { + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("Loading all symbol sets ...")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">")+ 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_from_icon_name("searching", iconsize); + overlay_desc->show(); + } + } else if (!number_symbols && (current != CURRENTDOC || !search_str.empty())) { + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("Try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); + } else if (!number_symbols && current == CURRENTDOC) { + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\"size=\"large\">") + Glib::ustring(_("No symbols found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("No symbols in current document\nChoose a different symbol set\nor add a new symbol.")) + Glib::ustring("</span>")); + } else if (!icons_found && !search_str.empty()) { + overlay_title->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"large\">") + Glib::ustring(_("No results found")) + Glib::ustring("</span>")); + overlay_desc->set_markup(Glib::ustring("<span foreground=\"#333333\" size=\"small\">") + Glib::ustring(_("You could try a different search term,\nor switch to a different symbol set.")) + Glib::ustring("</span>")); + } + overlay_opacity->show(); + overlay_icon->show(); + overlay_title->show(); + overlay_desc->show(); + if (l.size()) { + overlay_opacity->show(); + overlay_icon->hide(); + overlay_title->hide(); + overlay_desc->hide(); } - add_symbols( symbolDocument ); +#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 *) this->currentDesktop) ); + 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->currentDesktop ) ); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) current_desktop ) ); sp_action_perform (action, NULL); } void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*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; @@ -389,7 +526,6 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*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() ); } @@ -398,43 +534,64 @@ void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*cont void SymbolsDialog::defsModified(SPObject * /*object*/, guint /*flags*/) { - if ( !symbolSets[symbolSet->get_active_text()] ) { + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title != ALLDOCS && !symbol_sets[doc_title] ) { rebuild(); } } void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbolDocument = selectedSymbols(); - SPObject* symbol = symbolDocument->getObjectById(symbol_id); - - if(symbol && !selection->includes(symbol)) { - iconView->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(); + } + } } } void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) { - currentDesktop = desktop; - currentDocument = 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 symbolSetString = symbolSet->get_active_text(); - - SPDocument* symbolDocument = symbolSets[symbolSetString]; - if( !symbolDocument ) { + Glib::ustring doc_title = symbol_set->get_active_text(); + if (doc_title == ALLDOCS) { + 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). - return currentDocument; + 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 symbolDocument; + return symbol_document; } 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(); @@ -444,27 +601,66 @@ Glib::ustring SymbolsDialog::selectedSymbolId() { 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) { + if (symbol_doc) { + SPRoot * root = symbol_doc->getRoot(); + if (root->title()) { + return ellipsize(Glib::ustring(root->title()), 33); + } + } + Glib::ustring current = symbol_set->get_active_text(); + if (current == CURRENTDOC) { + return current; + } + return _("Untitled document"); +} + void SymbolsDialog::iconChanged() { Glib::ustring symbol_id = selectedSymbolId(); - SPDocument* symbolDocument = selectedSymbols(); - SPObject* symbol = symbolDocument->getObjectById(symbol_id); - - if( symbol ) { - // Find style for use in <use> - // First look for default style stored in <symbol> - gchar const* style = symbol->getAttribute("inkscape:symbol-style"); - if( !style ) { - // If no default style in <symbol>, look in documents. - if( symbolDocument == currentDocument ) { - style = style_from_use( symbol_id.c_str(), currentDocument ); - } else { - style = symbolDocument->getReprRoot()->attribute("style"); + 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 <use> + // First look for default style stored in <symbol> + gchar const* style = symbol->getAttribute("inkscape:symbol-style"); + if( !style ) { + // If no default style in <symbol>, 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, symbolDocument == currentDocument); + ClipboardManager *cm = ClipboardManager::get(); + cm->copySymbol(symbol->getRepr(), style, symbol_document == current_document); + } } } @@ -587,37 +783,103 @@ SPDocument* read_vss(Glib::ustring filename, Glib::ustring name ) { #endif /* Hunts preference directories for symbol files */ -void SymbolsDialog::get_symbols() { +void SymbolsDialog::getSymbolsFilename() { using namespace Inkscape::IO::Resource; - SPDocument* symbol_doc = NULL; Glib::ustring title; - + number_docs = 0; for(auto &filename: get_filenames(SYMBOLS, {".svg", ".vss"})) { if(Glib::str_has_suffix(filename, ".svg")) { - symbol_doc = SPDocument::createNewDoc(filename.c_str(), FALSE); - if(symbol_doc) { - title = symbol_doc->getRoot()->title(); - if(title.empty()) { - title = _("Unnamed Symbols"); - } + //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; + ++number_docs; } #ifdef WITH_LIBVISIO if(Glib::str_has_suffix(filename, ".vss")) { - Glib::ustring title = filename.erase(filename.rfind('.')); - symbol_doc = read_vss(filename, title); + 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; + ++number_docs; } #endif - if(symbol_doc) { - symbolSets[title]= symbol_doc; - symbolSet->append(title); + } + for(auto const &symbol_document_map : symbol_sets) { + symbol_set->append(symbol_document_map.first); + } +} + +/* Hunts preference directories for symbol files */ +std::pair<Glib::ustring, SPDocument*> +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) { + if (CURRENTDOC != symbol_document_map.first) { + symbol_set->append(symbol_document_map.first); + } + } + symbol_set->set_active_text(title); + sensitive = true; + return std::make_pair(title, symbol_sets[title]); + } + using namespace Inkscape::IO::Resource; + SPDocument* symbol_doc = NULL; + Glib::ustring new_title; + 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); + break; + } + } +#ifdef WITH_LIBVISIO + if(filename_short == title + ".vss") { + symbol_doc = read_vss(filename, title); + if(symbol_doc) { + new_title = documentTitle(symbol_doc); + break; + } + } +#endif + } + } + 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) { + if (CURRENTDOC != symbol_document_map.first) { + symbol_set->append(symbol_document_map.first); } + } + symbol_set->set_active_text(new_title); + sensitive = true; } + return std::make_pair(new_title, symbol_doc); } -void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector<SPSymbol*> &l) +void SymbolsDialog::symbolsInDocRecursive (SPObject *r, std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > &l, Glib::ustring doc_title) { if(!r) return; @@ -626,24 +888,31 @@ void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector<SPSymbol* return; } - if ( dynamic_cast<SPSymbol *>(r) ) { - l.push_back(dynamic_cast<SPSymbol *>(r)); + if ( dynamic_cast<SPSymbol *>(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<SPSymbol *>(r)); + } else { + l[r->title()] = std::make_pair(doc_title,dynamic_cast<SPSymbol *>(r)); + } } - for (auto& child: r->children) { - symbols_in_doc_recursive( &child, l ); + symbolsInDocRecursive(&child, l, doc_title); } } -std::vector<SPSymbol*> SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) +std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > +SymbolsDialog::symbolsInDoc( SPDocument* symbol_document, Glib::ustring doc_title) { - std::vector<SPSymbol*> l; - symbols_in_doc_recursive (symbolDocument->getRoot(), l ); + std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > l; + if (symbol_document) { + symbolsInDocRecursive (symbol_document->getRoot(), l , doc_title); + } return l; } -void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector<SPUse*> &l) +void SymbolsDialog::useInDoc (SPObject *r, std::vector<SPUse*> &l) { if ( dynamic_cast<SPUse *>(r) ) { @@ -651,23 +920,22 @@ void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector<SPUse*> &l) } for (auto& child: r->children) { - use_in_doc_recursive( &child, l ); + useInDoc( &child, l ); } } -std::vector<SPUse*> SymbolsDialog::use_in_doc( SPDocument* useDocument ) { - +std::vector<SPUse*> SymbolsDialog::useInDoc( SPDocument* useDocument) { std::vector<SPUse*> l; - use_in_doc_recursive (useDocument->getRoot(), l); + useInDoc (useDocument->getRoot(), l); return l; } // Returns style from first <use> 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<SPUse*> l = use_in_doc( document ); + std::vector<SPUse*> l = useInDoc( document ); for( auto use:l ) { if ( use ) { gchar const *href = use->getRepr()->attribute("xlink:href"); @@ -685,17 +953,203 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen return style; } -void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) { +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 { + showOverlay(); + 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::callbackAllSymbols)); + search->set_text(_("Loading all symbols...")); + } +} + +void SymbolsDialog::unsensitive(GdkEventKey* evt) +{ + sensitive = true; +} + +bool SymbolsDialog::callbackSymbols(){ + if (l.size()) { + showOverlay(); + for (auto symbol_data = l.begin(); symbol_data != l.end();) { + 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(); + 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 (!icons_found && !search_str.empty()) { + showOverlay(); + } else { + hideOverlay(); + } + sensitive = false; + search->set_text(search_str); + sensitive = true; + enableWidgets(true); + return false; + } + return true; +} + +bool SymbolsDialog::callbackAllSymbols(){ + Glib::ustring current = symbol_set->get_active_text(); + if (current == ALLDOCS && search->get_text() == _("Loading all symbols...")) { + size_t counter = 0; + std::map<Glib::ustring, SPDocument*> 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("Searching...."); + return false; + } + return true; +} + +Glib::ustring SymbolsDialog::ellipsize(Glib::ustring data, size_t limit) { + if (data.length() > limit) { + data = data.substr(0, limit-3); + return data + "..."; + } + 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; + l = symbolsInDoc(symbol_document, doc_title); + number_symbols = l.size(); + if (!number_symbols) { + 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)); + } +} - std::vector<SPSymbol*> l = symbols_in_doc( symbolDocument ); - for(auto symbol:l) { - if (symbol) { - add_symbol( symbol ); +void SymbolsDialog::addSymbols() { + store->clear(); + icons_found = false; + 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::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > 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 = l.size(); + if (!number_symbols) { + 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)); } } -void SymbolsDialog::add_symbol( SPObject* symbol ) { +void SymbolsDialog::addSymbol( SPObject* symbol, Glib::ustring doc_title) { SymbolColumns* columns = getColumns(); @@ -704,14 +1158,18 @@ void SymbolsDialog::add_symbol( SPObject* symbol ) { if( !title ) { title = id; } - - Glib::RefPtr<Gdk::Pixbuf> pixbuf = draw_symbol( symbol ); + if (doc_title.empty()) { + doc_title = CURRENTDOC; + } + Glib::ustring symbol_title = Glib::ustring(title) + Glib::ustring(" (") + doc_title + Glib::ustring(")"); + Glib::RefPtr<Gdk::Pixbuf> pixbuf = drawSymbol( 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_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; @@ -727,16 +1185,16 @@ void SymbolsDialog::add_symbol( SPObject* symbol ) { * the temporary document is rendered. */ Glib::RefPtr<Gdk::Pixbuf> -SymbolsDialog::draw_symbol(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 = 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); } @@ -745,9 +1203,9 @@ SymbolsDialog::draw_symbol(SPObject *symbol) gchar const* style = repr->attribute("inkscape:symbol-style"); if( !style ) { // If no default style in <symbol>, 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"); } @@ -764,19 +1222,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<SPItem *>(object_temp); g_assert(item != NULL); @@ -800,11 +1258,16 @@ SymbolsDialog::draw_symbol(SPObject *symbol) if( width == 0.0 ) width = 1.0; if( height == 0.0 ) height = 1.0; - if( fitSymbol->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; + if (force_psize > 0) { + psize = force_psize; + scale = psize / ceil(std::max(width, height)); + } + pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); } @@ -816,7 +1279,7 @@ SymbolsDialog::draw_symbol(SPObject *symbol) * Symbols are by default not rendered so a <use> element is * provided. */ -SPDocument* SymbolsDialog::symbols_preview_doc() +SPDocument* SymbolsDialog::symbolsPreviewDoc() { // BUG: <symbol> must be inside <defs> gchar const *buffer = @@ -829,15 +1292,55 @@ SPDocument* SymbolsDialog::symbols_preview_doc() " </defs>" " <use id=\"the_use\" xlink:href=\"#the_symbol\"/>" "</svg>"; - return SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); } +/* + * Update image widgets + */ +Glib::RefPtr<Gdk::Pixbuf> +SymbolsDialog::getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize) +{ +gchar const *buffer = +"<svg xmlns=\"http://www.w3.org/2000/svg\"" +" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" +" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" +" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" +" <title>Inkscape</title> " +" <defs id=\"defs\">" +" <symbol" +" id=\"overlay\">" +" <title" +" id=\"overlay_title\">Overlay</title>" +" <desc" +" id=\"overlay_desc\">Overlay Square</desc>" +" <path" +" style=\"fill:#ffffff;opacity:0.75;stroke:none\"" +" d=\"M 0,1 H 1 V 2 H 0 Z\"" +" id=\"overlay_shape_1\" />" +" </symbol>" +" </defs>" +"</svg>"; + + SPDocument* doc = SPDocument::createNewDocFromMem( buffer, strlen(buffer), FALSE ); + std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > symbols_data = symbolsInDoc(doc, "Overlay Doc"); + Glib::RefPtr<Gdk::Pixbuf> pixbuf(NULL); + for(auto data:symbols_data) { + Glib::ustring doc_title = data.second.first; + SPSymbol * symbol = data.second.second; + if (!strcmp(symbol->getId(), icon_title)) { + pixbuf = drawSymbol(symbol, psize); + return pixbuf; + } + } + return pixbuf; +} + 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 747e5c6c9..f387dde51 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -6,19 +6,20 @@ * * 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 <gtkmm.h> #include "display/drawing.h" #include "ui/dialog/desktop-tracker.h" #include "ui/widget/panel.h" #include "sp-symbol.h" #include "sp-use.h" - #include <vector> class SPObject; @@ -77,46 +78,77 @@ private: void documentReplaced(SPDesktop *desktop, SPDocument *document); SPDocument* selectedSymbols(); Glib::ustring selectedSymbolId(); + Glib::ustring selectedSymbolDocTitle(); void iconChanged(); void iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& selection_data, guint info, guint time); - - void get_symbols(); - void add_symbols( SPDocument* symbol_document ); - void add_symbol( SPObject* symbol_document ); - SPDocument* symbols_preview_doc(); - - void symbols_in_doc_recursive(SPObject *r, std::vector<SPSymbol*> &l); - std::vector<SPSymbol*> symbols_in_doc( SPDocument* document ); - void use_in_doc_recursive(SPObject *r, std::vector<SPUse*> &l); - std::vector<SPUse*> use_in_doc( SPDocument* document ); - gchar const* style_from_use( gchar const* id, SPDocument* document); - - Glib::RefPtr<Gdk::Pixbuf> draw_symbol(SPObject *symbol); - + void getSymbolsFilename(); + Glib::ustring documentTitle(SPDocument* doc); + std::pair<Glib::ustring, SPDocument*> getSymbolsSet(Glib::ustring title); + void addSymbol( SPObject* symbol, Glib::ustring doc_title); + SPDocument* symbolsPreviewDoc(); + void symbolsInDocRecursive (SPObject *r, std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > &l, Glib::ustring doc_title); + std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > symbolsInDoc( SPDocument* document, Glib::ustring doc_title); + void useInDoc(SPObject *r, std::vector<SPUse*> &l); + std::vector<SPUse*> useInDoc( SPDocument* document); + void beforeSearch(GdkEventKey* evt); + 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); + gchar const* styleFromUse( gchar const* id, SPDocument* document); + Glib::RefPtr<Gdk::Pixbuf> drawSymbol(SPObject *symbol, unsigned force_psize = 0); + Glib::RefPtr<Gdk::Pixbuf> getOverlay(Gtk::Image* image, gchar const * icon_title, unsigned psize); /* Keep track of all symbol template documents */ - std::map<Glib::ustring, SPDocument*> symbolSets; - + std::map<Glib::ustring, SPDocument*> symbol_sets; + std::map<Glib::ustring, std::pair<Glib::ustring, SPSymbol*> > 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<Gtk::ListStore> store; - Gtk::ComboBoxText* symbolSet; - Gtk::IconView* iconView; - Gtk::Button* addSymbol; - Gtk::Button* removeSymbol; - Gtk::Button* zoomIn; - Gtk::Button* zoomOut; - Gtk::ToggleButton* fitSymbol; - + 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* 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 */ + + sigc::connection idleconn; + /* For rendering the template drawing */ unsigned key; Inkscape::Drawing renderDrawing; 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<Handle *>(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/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) { 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/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); 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/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<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginTop)); + _changedmb_connection = _marginBottom.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginBottom)); + _changedml_connection = _marginLeft.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(sigc::mem_fun (*this, &PageSizer::on_margin_changed), &_marginLeft)); + _changedmr_connection = _marginRight.signal_value_changed().connect (sigc::bind<RegisteredScalar*>(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; 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<void, SPDesktop *, SPDocument *> &signalDocumentReplaced(); virtual sigc::signal<void, SPDesktop *> &signalActivateDesktop(); virtual sigc::signal<void, SPDesktop *> &signalDeactiveDesktop(); |
