Find / Replace dialog
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Wishlist
|
John Smith |
Bug Description
A unified find/replace dialog that merges the 3 find/replace dialogs.
Can find and/or replace text, styles, attributes fonts etc.
John Smith (john-smithi) wrote : | #1 |
su_v (suv-lp) wrote : | #2 |
Changed in inkscape: | |
importance: | Undecided → Wishlist |
su_v (suv-lp) wrote : | #3 |
Feature requests with regard to refined selection methods:
Bug #170378 “Select All by Stroke or Fill Color”
Bug #171685 “Smart Select”
Bug #456180 “find dialog doesn't allow to search for attribute values”
Bug #722625 “Select objects by type, e.g. select all text objects”
Selection sets:
Bug #170286 “sets (named selections)”
Bug #314896 “Selection sets”
Feature requests with regard to 'Replace':
Bug #170259 “Add text search and replace feature”
Bug #171007 “Font Find and replace added to the Text dialog”
Bug #171962 “XML Editor - Search/Replace”
Bug #172028 “Replace Object(s)”
Other possibly related requests (mostly related to changing aspects of color on a selection of objects, or individual font style properties):
Bug #171181 “group colour/color changes, brightness, contrast, HSV, more”
Bug #171589 “dialog for adjusting colors in selection (HSL, brightness/
Bug #345586 “changing font property for multiple objects”
Bug #516108 “Tool to re-map and delete a gradient”
su_v (suv-lp) wrote : | #4 |
Requests to improve existing 'Edit > Find…':
Bug #456180 “find dialog doesn't allow to search for attribute values”
Bug #480847 “Search objects tool: checkboxes should be unchecked as default”
Bug #831012 “Selecting line width with the Find Dialog, it could bee really god”
Bug #592323 “dockable text and font settings” (comment #2)
John Smith (john-smithi) wrote : | #5 |
Thanks for poiting out all the relevant re
John Smith (john-smithi) wrote : | #6 |
Thanks for pointing out all the relevant request relating to Edit > Find, there certainly are a few requests ...
I've attempted to improve the find dialog and include as many of those requests as i can.
So what i did was take the current Edit > Find dialog and added the following functionality ...
1. Merged in the Replace text functionality (Bug #170259)
2. Merge in the Find and Replace font functionality (Bug #171007)
3. Added Case sensitivity and Exact match functionality
4. Added find/replace history
5. Made it a dockable dialog (Bug #592323)
6. Added search by attribute (Bug #456180)
No existing functionality has been removed from the Find dialog.
su_v (suv-lp) wrote : | #7 |
> No existing functionality has been removed from the Find dialog.
Some quick notes/questions:
- Usage:
How do I quickly select all circles to move them onto a new layer (object type)?
How do I select all objects with a certain (sub)string in their IDs to group them (ID)?
How do I identify all objects which have a clip-path or a mask, or a path effect applied (attribute name)?
- 'Search in > Attribute/Style':
Does it search in the content of all attributes of all objects within the scope? Currently this is separated into two search entries: 'Attribute' only searches in attribute names, 'Style' only searches the content of the 'style' attribute of all objects within the current scope.
How does one select objects by attribute names, partial or full match? (e.g. those with attributes in a custom namespace; or those with attributes like 'clip-path', 'mask' or 'inkscape:
Would it be intended to allow to search for matches of certain attribute values? (e.g. select all objects which refer to the same clip-path by partial id, but ignore partial matches in other attributes; or select by the value of rx or ry of ellipses; …)
- Fonts of text objects created in Inkscape are stored in two properties of the style attribute ('font-family', '-inkscape-
- If 'Font' is singled out as individual property of the style attribute, shouldn't there be separate explicit find (and replace) functions for other style properties? Like fill and stroke attributes (color for each of them; stroke width, line type (dashes), (start, mid, end) markers for stroke), opacity for object, fill and stroke, …?
John Smith (john-smithi) wrote : | #8 |
- 909328.FindReplace.png Edit (58.8 KiB, image/png)
@~suv
Based on your suggestions I've modified the dialog so you can select the object properties (style, attribute name, attribute value, id, fonts etc) separately.
Please check the attached screenshot, showing all the functionality.
> How do I quickly select all circles to move them onto a new layer (object type)?
The object types (including circles) are available under "More options" (see attached).
The idea was to balance having a simple dialog with advanced functionality, so the most common fields are visible and the less used fields available when needed.
> How do I select all objects with a certain (sub)string in their IDs to group them (ID)?
Find: '(sub)string' + 'Search in > Properties' + 'ID' checkbox selects those objects.
>How do I identify all objects which have a clip-path or a mask, or a path effect applied (attribute name)?
Find: 'path-effect' + 'Search in > Properties' + 'Attribute Name' checkbox selects those objects.
> 'Search in > Attribute/Style': Does it search in the content of all attributes of all objects within the scope?
Yes it searches in the attribute name or attribute value depending on the checkboxes you have on
You can refine your search results for multiple attributes - Search for an attribute, then search within 'Selection' on a different attribute.
> How does one select objects by attribute names, partial or full match? (e.g. those with attributes in a custom namespace; or those with attributes like 'clip-path', 'mask' or 'inkscape:
Find: 'path-effect' with 'Search in > Properties' and 'Attribute Name' checkbox on (default) selects those objects.
'Exact match' checkbox for partial or full name match.
> Would it be intended to allow to search for matches of certain attribute values? (e.g. select all objects which refer to the same clip-path by partial id, but ignore partial matches in other attributes; or select by the value of rx or ry of ellipses; …)
Yes i've added the ability to search by attribute value as well - checkbox 'Attribute Value'
> what happens if I enter a font family name, and choose 'Search in >Attribute/Style' - will the search fail or does it not matter whether one uses 'Style/Attribute' or 'Font' for 'Search in'?
The font search searches inside the style but only for the 2 styles 'font-family' and '-inkscape-
So a search for 'Arial' will probably get the same result in 'Style' and 'Font', but a search for '96px' will only get matches in 'Style'.
> If 'Font' is singled out as individual property of the style attribute, shouldn't there be separate explicit find (and replace) functions for other style properties?
I included 'Font' because there was demand from users and a specific extension for it.
We can easily add (fill and stroke) or remove (font) properties as well.
Being able to find/replace on Styles and Attribute Value gives the users complete power to modify anything, some more specific requests it covers are:
* Bug #170378 “Select All by Stroke or Fill Color” - Yes you can do this
* Bug #171685 “Smart Select” Yes you can change the color of all the 'orange' objects to 'blue'
* Change the font size / font style for all objects at onc...
jazzynico (jazzynico) wrote : | #9 |
This one is starting to be a bit complex, with lots of related reports. I suggest that we use the existing blueprint (https:/
tags: | added: ui |
Changed in inkscape: | |
assignee: | nobody → John Smith (john-smithi) |
John Smith (john-smithi) wrote : | #10 |
- 909328.patch Edit (43.7 KiB, text/plain)
Here is a patch that covers quite a few of the ideas in the blueprint (thanks for the link jazzynico).
From the blueprint - not touched since 2008 ;)
> Inkscape should provide several presets for those who just want to do very simple replacements: replace text to text, replace color to color etc. (this will eliminate at least two existing extension effects).
This is exactly what i have tried to do ... this patch certainly doesn't provide a full 'regex' type solution as proposed, but you can find/replace on any attribute of any object so it does bring a lot of power to the users.
I think it makes a sizable step forward from the current interface.
Take a look, and decide if its worth pursing.
John Smith (john-smithi) wrote : | #11 |
- 909328.v2.patch Edit (916 bytes, text/plain)
Agreed, that looks like a good idea ~suv. Heres a patch for that.
Or, we could even give 'System Info' its only page in the left panel.
John Smith (john-smithi) wrote : | #12 |
Please ignore comment above, different issue.
jazzynico (jazzynico) wrote : | #13 |
Apparently, some recent changes in the trunk broke the patch.
John, would you be willing to take a look?
Changed in inkscape: | |
status: | New → In Progress |
John Smith (john-smithi) wrote : | #14 |
- 909328.v2.patch Edit (42.8 KiB, text/plain)
Updated patch attached.
Currently you can find/replace any attribute on any object, with a few common requested 'presets' included.
Please let me know any ideas to improve or simplify this dialog.
su_v (suv-lp) wrote : | #15 |
First tests (Find only) look good to me. Couple of quick questions:
1) Remnants of prior search
After a prior search, I still had a text string in the 'Find' entry, but I wanted to quickly select all paths (within nested groups), and deactivated the prior single checked property 'Attribute name':
> Find: "clip"
> Replace:
>
> Search for text in
> [x] Properties
>
> Properties:
> all deactivated
>
> Object Types:
> [x] Paths
Expected result: 633 items found
(all paths in 'icons.svg' (within nested groups) are found and selected)
Actual result: "Not Found"
(the string "foo" seems to get matched, but against which property?)
-> if all properties are deactivated, should not any find string be ignored?
2) Usability 'Object types':
After having searched for e.g. all objects of a certain type only, it happens very easily to have no 'Object Type' activated at all (and nothing gets found anymore), e.g. when the special type is deactivated, but 'All Types' not explicitly activated again.
Could there be some kind of check that 'All Types' gets activated by default if none of the other types is selected (when 'Find' is pressed), or are there other types -not listed- which are still considered for the search (not obvious to the user)?
John Smith (john-smithi) wrote : | #16 |
- 909328.v3.patch Edit (45.1 KiB, text/plain)
1) > but I wanted to quickly select all paths
The Find text is now re-selected after a search, so you can quickly press the 'Delete' key to remove previous text.
> if all properties are deactivated, should not any find string be ignored ?
Yes this works, but for consistency i suggest we disable the Find/Replace buttons if either - no properties are selected, or no objects are selected. Searching for text 'something' inside properties 'nothing' should logically give nothing ?
> the string "foo" seems to get matched, but against which property?
Should not get a match against anything. Can you check in the XML Editor if "foo" is in any attribute ? I can't reproduce this.
> 2) Could there be some kind of check that 'All Types' gets activated by default
How about we disable the Find/Replace buttons if no objects are selected with status 'No objects selected' ?
Patch for above suggestions tested on Ubuntu 11.10 and attached.
John Smith (john-smithi) wrote : | #17 |
- 909328.v4.patch Edit (54.9 KiB, text/plain)
Patch modified to compile after header cleanup.
Added saving of past searches to preferences file.
jazzynico (jazzynico) wrote : | #18 |
Tested successfully on Ubuntu 11.04, Inkscape 11002.
Another great UI improvement by John!
su_v (suv-lp) wrote : | #19 |
Testing the patch with Inkscape 0.48+devel r11002 in OS X Lion (GTK+/X11 2.24.10), I get repeated console warnings after having used the dialog once (opened, searched, closed), when opening and closing new document windows from within the same inkscape process:
(inkscape:14092): Gtk-WARNING **: gtkwidget.c:5683: widget not within a GtkWindow
These warnings are not present when repeating the same steps with unpatched r11001.
Related gtk-2-24 source:
<http://
su_v (suv-lp) wrote : | #20 |
- 909328-fatal-warnings-bt-full-r11002-64bit-osx.txt Edit (14.7 KiB, text/plain)
backtrace with 'G_DEBUG=
John Smith (john-smithi) wrote : | #21 |
- 909328.v5.patch Edit (54.8 KiB, text/plain)
Thanks @suv, have fixed the warnings in this patch.
Let me know if you think it is worth committing.
Kris (kris-degussem) wrote : | #22 |
See also bug #937288
Kris (kris-degussem) wrote : | #23 |
Oh sorry, neglect my previous comment. Wrong place.
Kris (kris-degussem) wrote : | #24 |
John, I'm still having the errors when compiling on vista 64 bit that I let you know by mail:
-------
Make error line 289: problem compiling: src/ui/
on 'bool Inkscape:
bool, bool)':
src/ui/
e
src/ui/
m_text_
src/ui/
e
src/ui/
m_style_
src/ui/
e
src/ui/
src/ui/
rameter]
src/ui/
m_attrvalue_
src/ui/
e
src/ui/
src/ui/
meter]
-------
I also ran cppcheck on the file and a memory leak for "text" is reported on line 546. This warning/error is not truely valid, though I would rewrite line 541 to 548 from:
-------
const gchar* text = g_strdup(
GSList *in = l;
GSList *out = NULL;
if (strlen (text) == 0) {
return in;
}
-------
into the following:
-------
Glib::ustring tmpstring = entry_find.
if (tmpstring.empty())
{
return l;
}
const gchar* text = g_strdup(
GSList *in = l;
GSList *out = NULL;
-------
John Smith (john-smithi) wrote : | #25 |
- 909328.v6.patch Edit (55.2 KiB, text/plain)
@Kris, sorry about the build error, it seems strcasestr function is not available on Windows.
I have fixed that in this patch, it now builds and runs on Windows 7.
I have also modified the code to remove the potential leak (comment #24) you mentioned.
LucaDC (lucadc) wrote : | #26 |
Builds on Windows XP too.
It's a great improvement, indeed!
One note: perhaps it would be better to unselect all when after pressing the "Find" button nothing matching is found. Now the current selection is preserved and this could lead to thinking that it's the result of the search.
su_v (suv-lp) wrote : | #27 |
@LucaDC - when searching within the current selection, this might not be helpful (else you have to repeat all steps to arrive at the current selection again)
LucaDC (lucadc) wrote : | #28 |
Ok, now I see there is a Scope selection. This is a nice feature I didn't see.
Anyway, IMHO the current behavior is not intuitive: maybe, to keep the functionality, this could happen when searching in the Selection scope, but remove the selection if the search is done in All scope.
LucaDC (lucadc) wrote : | #29 |
And remove the selection in the Current Layer scope too (because you never lose the layer).
Kris (kris-degussem) wrote : | #30 |
- inkscapeFind.JPG Edit (51.6 KiB, image/jpeg)
This new functionality indeed may have a great impact.
Comments:
- what was not in comment 24: probably a call to "g_free(text)" is needed on line 642.
- regarding my former work on Bug #170765, my attention was drawn on the new options: is it possible to add mnemonics for the "Properties" and "Object types"?
- There is a space in front of the "...". As far as I can see the default is not to have a space. However, what is the guideline here do we want this symbol? At least in the object properties dialog I c++-ified, it is missing.
- see attachment: with the current selection for colours the two top left rectangles should be selected (is correctly done): however, regarding callbacks:
+ entering a replacement in the edit box does not enable the "Replace" button on my system
+ clicking on the minus at the left of "options" does not resize the dialog to its smaller size (at least when the dialog is floating)
+ I would propose to use the canvas selection callback for updating the "xx objects found" label: if deselected no comment, etc. Is more informing as the user might delete objects that comply with one of the find options. Hence, the info in the label is not valid anymore.
John Smith (john-smithi) wrote : | #31 |
- 909328.v7.patch Edit (55.6 KiB, text/plain)
Thanks for all the suggestions, an updated patch is attached.
@LucaDC - good idea, if nothing is found for All or Current Layer, then selected objects are unselected
@Kris
> a call to "g_free(text)" is needed on line 642
Thanks added
>a space in front of the "..."
Have removed the space and "..."
> does not enable the "Replace" button on my system
Replace button is disabled when you check on the "Attribute Name" property. I thought it was a bit too dangerous replacing attribute names. Do you think there a valid use case for replacing attribute names ?
> clicking on the minus at the left of "options" does not resize the dialog to its smaller size
Yes this a common problem, that occurs in several dialogs (Object Properties and Document Properties->Page), unfortunately i dont know how to fix this. Any place where this works correctly ?
> use the canvas selection callback for updating the "xx objects found" label
Sorry not quite understanding this. Do you suggest we update the "xx objects found" label when the selection on canvas changes ? Even when the user changes the selection ?
Kris (kris-degussem) wrote : | #32 |
>> use the canvas selection callback for updating the "xx objects found" label
>Sorry not quite understanding this. Do you suggest we update the "xx objects found" label when the selection on canvas changes ? Even when the user changes the selection ?
What I intended is that when the amount of selected objects changes (because of an action of the user), the label should be blanked. Reasons:
- one or more objects that meet the selection criteria can have been deleted in the mean time. The info shown in the user interface should in my humble opinion allways be correct (which is not when an object is deleted and the label not updated)
- for complex documents, one might get confused whether the current selection is still the selection of objects that meet the selection criteria
- actually, when the user is informed on the number of objects that agree the selection criteria just after he presses the search button, it is all right: the objects are selected at this moment and this number of objects is also shown in the statusbar (along with the object type).
Therefore, I would use the desktop tracker to empty the label when the selection changes (e.g. no selection, other objects selected, etc.). Look for example in the code of the object attributes dialog for connectChanged (property of the desktop tracker) and selectChangedConn.
Kris (kris-degussem) wrote : | #33 |
> Do you think there a valid use case for replacing attribute names ?
No. I have to admit that I'm not an svg specialist nor a graphics specialist, so I have only a limited view on niche applications.
By the way: thanks for the documentation of the dialog so far. I do not know a dedicated page so far on Inkscape documentation through doxygen, so therefore I wanted to add a little explanation. The /** */ comments are added in front of a single function to document it. To add a note in the code about several members functions or private variables, /* */ will do. /** */ can not be used for multiple consecutive functions or data members in the code, so might generate wrong HTML output. (I downloaded the GUI and the package on windows from http://
John Smith (john-smithi) wrote : | #34 |
- 909328.v8.patch Edit (56.3 KiB, text/plain)
@Kris
>I would use the desktop tracker to empty the label when the selection changes
Thanks for the suggestion. Understood i have added that in this version.
Kris (kris-degussem) wrote : | #35 |
Nice result. Would like to see it committed.
Though it is a whishlist item, I noticed that not all occurrences of a string in a text box are replace. For example the string:
dfgdfg dfg
with replacement string:
blabla
Results in:
blabladfg dfg
Where I would expect to see:
blablablabla blabla
Or am I missing something in the options?
One UI suggestion that depends on the radio button "search in". If "Text" is selected, it might be better not to show the options for "Object types" (in favor) and "Properties" (do not know yet because of the font option).
John Smith (john-smithi) wrote : | #36 |
> not all occurrences of a string in a text box are replace
Yes this is true. Often applications have Find / Replace / Replace All options.
How should we handle this, add a checkbox for "Replace All" or another button "Replace All" , or just Replace All by default ?
John Smith (john-smithi) wrote : | #37 |
- 909328.v9.patch Edit (57.5 KiB, text/plain)
Patch that also "replaces all" instances of text, as the default.
If there is no further concerns, i will commit this to the trunk.
su_v (suv-lp) wrote : | #38 |
- 909328-options-GtkBox-layout-1.png Edit (23.6 KiB, image/png)
Minor detail/question:
Would it be possible to make the layout of the 'Properties' frame as compact with regard to vertical spacing as 'General' and 'Object Types'?
(I didn't find anything obvious in the widget tree which sets the vertical spacing between the two GtkHBoxes - obviously the other two option frames use two GtkVboxes in a GtkHBox, and the GtkCheckButtons inside those GtkVBox containers are more tightly arranged with regard to vertical spacing than two GtkHBoxes in a GtkVBox)
John Smith (john-smithi) wrote : | #39 |
@suv, yes i will get the 'Properties' frame to have the same padding as the other frames, and commit the code shortly.
John Smith (john-smithi) wrote : | #40 |
Committed as r11117.
Will need testing as it uses some gtkmm 2.24+ functions in Gtk::ComboBoxText.
John Smith (john-smithi) wrote : | #41 |
Additional commit r11119 to fix build error.
https:/
Changed in inkscape: | |
status: | In Progress → Fix Committed |
Kris (kris-degussem) wrote : | #42 |
I made some minor adjustments to the user messages, e.g. differentiation whether one or more objects are found.
However, after working a bit with the dialog, I'm not happy about the usage of the term "object" and I wonder whether it should be "match". The reason is that it is not the object that is replaced (the same object is still there after the modification), but its property (in general the "match" is replaced) is replaced.
What do other people think? Is there even a better native word for match or object?
John Smith (john-smithi) wrote : | #43 |
The term "object" does make sense when Finding, and this term is also used on the bottom statusbar when selecting.
However it is misleading when replacing text or properties. Match seems like a reasonable term to me.
Changed in inkscape: | |
milestone: | none → 0.49 |
Kris (kris-degussem) wrote : | #44 |
Made the update in user messages in revision 11363.
I noticed however another tiny issue for user experience: it is still possible that de "replace all" button is active even when no object matches the selection criteria. Actually now, virtually always the replace button is set to sensitive when the find button is. Probably sensitive should set to false at the bottom of onToggleCheck for the replace button, whereas the status should be set to true only in the specific valid cases in onAction. Not sure about the implementation now, need to study this further ...
Kris (kris-degussem) wrote : | #45 |
Fixed previous mentioned item and undo message in trunk revision 11456.
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
JFTR: the replace text and fonts dialogs are external python-script based extensions, 'Edit > Find…' for selecting objects is based on internal code.
I'm not convinced that those should be merged as shown in the screenshot - 'Edit > Find…' is more about creating selections than replacing the content of attributes or style properties AFAIU, and I don't see that feature supported in the unified dialog.
There have been several feature request filed, about improved selection as well as a feature to replace certain attribute/ properties or text content. I'll provide links as time permits.