After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 437626 - Searching for hidden folders
Searching for hidden folders
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: File Search Interface
3.5.x
Other All
: Normal minor
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
: 681602 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-05-11 06:06 UTC by torgeriedel
Modified: 2012-09-19 16:58 UTC
See Also:
GNOME target: ---
GNOME version: 3.5/3.6


Attachments
Allow built-in search in Nautilus to see hidden files (1.05 KB, patch)
2010-05-17 21:49 UTC, Jim Danner
none Details | Review
proposed patch (3.26 KB, patch)
2012-08-23 11:58 UTC, Javier Hernández
needs-work Details | Review
Proposed patch with Cosimo's suggestions (5.06 KB, patch)
2012-08-24 16:56 UTC, Javier Hernández
needs-work Details | Review
Proposed patch with Cosimo's suggestions #2 (10.70 KB, patch)
2012-08-31 00:09 UTC, Javier Hernández
needs-work Details | Review
search-engine-simple: always include hidden files (1.19 KB, patch)
2012-09-19 03:20 UTC, Cosimo Cecchi
committed Details | Review

Description torgeriedel 2007-05-11 06:06:17 UTC
I tried to search for hidden folders (folders beginning with a ".") using nautilus. Although I've selected to display hidden files and folders, nautilus is not able to search for and display them. I want to use this to delete the ".svn" folders created by Subclipse.

Other information:
Comment 1 Nelson Benitez 2007-05-11 11:16:30 UTC
The affected code is in libnautilus-private/nautilus-search-engine-simple.c:search_visit_func() ,but don't know if it's better automatically search hidden locations if the folder has the "display hidden files" option activated or just add a checkbox to the simple search dialog especifying this.
Comment 2 Przemyslaw Kochanski 2010-05-15 12:03:54 UTC
Please, add a checkbox to the search dialog!

It's been 3 years, look at launchpad comments: https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/334125
Comment 3 Jim Danner 2010-05-17 21:49:56 UTC
Created attachment 161283 [details] [review]
Allow built-in search in Nautilus to see hidden files

Attached is a simple patch that would allow the built-in search function to see hidden files and files within hidden folders, IF "Show hidden and backup files" has been selected in the Preferences. Ordinary users who keep hidden files invisible will not see anything different than normal; it's only the people who prefer to see those files who can also get them in their search results.

It would be nice if we could "have" this patch. I know it's not perfect (because it doesn't use the current window's specific visibility settings), but for those who want to search hidden files this is a whole lot better than the current situation...
Comment 4 André Klapper 2012-08-21 11:35:37 UTC
Needs retesting in 3.5 after Search interface was completely rewritten.
Comment 5 Javier Hernández 2012-08-23 11:58:31 UTC
Created attachment 222212 [details] [review]
proposed patch

Hi all!

This patch does not apply. Either the nautilus API has changed or Jim forgot to adding some bits into the patch.

I'm adding a patch which solves the issue for me. I don't know if this is the best way for doing this, so I'll accept suggestions and will make the required changes.

Cheers!
Comment 6 Cosimo Cecchi 2012-08-24 10:22:37 UTC
Review of attachment 222212 [details] [review]:

Thanks for the patch! I have some comments on the approach used:

::: libnautilus-private/nautilus-global-preferences.h
@@ +169,3 @@
 GSettings *gnome_background_preferences;
 
+gboolean show_hidden;

The use of a global variable for this is wrong, but I understand why you did this (as the value of show_hidden doesn't only depend on the gsetting but also on the current "override" value.
I think a better way to implement it would probably be adding a property to NautilusQuery for it, and having the query editor set it when it creates the object according to the current value in the window.
Comment 7 Javier Hernández 2012-08-24 16:56:23 UTC
Created attachment 222352 [details] [review]
Proposed patch with Cosimo's suggestions

Hey Cosimo, thanks for reviewing!

You're right, I was using this global variable (against my beliefs) because of this special case, so thanks for the hint. 

I added the 'show_hidden' property to NautilusQuery, and now, NautilusQueryEditor is setting up this property at each NautilsQuery object creation.

I don't know if it's the best way for getting the NautilusWindowShowHiddenFilesMode state, so a hint about this and/or about other thing will be appreciated.


Cheers!
Comment 8 Cosimo Cecchi 2012-08-24 17:50:51 UTC
Review of attachment 222352 [details] [review]:

Looks a lot better now, I have a couple other minor things I would like to see fixed before this can be committed.

::: libnautilus-private/nautilus-search-engine-simple.c
@@ +237,2 @@
 	while ((info = g_file_enumerator_next_file (enumerator, data->cancellable, NULL)) != NULL) {
+		if (g_file_info_get_is_hidden (info) && data->show_hidden != TRUE) {

Coding style: use !data->show_hidden

::: src/nautilus-query-editor.c
@@ +1147,3 @@
 
+	window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (editor->details->entry)));
+	NautilusWindowShowHiddenFilesMode mode = nautilus_window_get_hidden_files_mode(window);

Since the only other user of this method (NautilusView) basically needs to do exactly the same thing, I think it would be better to have a nautilus_window_get_show_hidden_files() method replacing this and sharing this code, and make it used by both the query editor and the view.

@@ +1152,3 @@
+		show_hidden_setting = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
+	}
+	else {

Coding style: Nautilus uses the following convention

if (condition) {
  /* block */
} else {
  /* other block */
}
Comment 9 William Jon McCann 2012-08-24 21:52:36 UTC
*** Bug 681602 has been marked as a duplicate of this bug. ***
Comment 10 Javier Hernández 2012-08-27 03:04:08 UTC
I've just applied all these changes, but while playing a little with it, I discovered something.

Use Case 1
-----------
Open Nautilus. If you do the Ctrl+h thing and you start searching something like ".lo", you'll get hits like "pgadmin.log" or ".local" (hidden and unhidden elements), as it is expected. Then, if you do the Ctrl+h again, hidden files are not being shown on the hits list. Good.

Use Case 2
----------
Well, let's start again, open Nautilus. If you don't do the Ctrl+h thing, and start searching ".lo" again, you'll not get hidden files. But if you do the Ctrl+h, you don't get the hidden files on the hits list. If you start typing again you'll start to see the hidden files on the list. 


This behaviour on Use Case 2 is caused because the NautilusQuery object isn't updating the show_hidden_files property accordingly when Ctrl+h occurs. 
In the first Use Case, we're getting such behaviour because the NautilusQuery isn't getting updated while you do the Ctrl+h, but NautilusView does it.

As one solution, we can connect NautilusQueryEditor to the NautilusWindow "hidden-files-mode-changed" signal and update the query's show_hidden_files property.

Alternatively, we can drop the show_hidden_files property from the NautilusQuery and let NautilusView to decide whether the hidden_files must be shown or not. On one hand, we're removing the show_hidden option from NautilusQuery, and queries will always return a list which is including all the hidden and unhidden files. On the other hand, I think that we'll save some lines of code and nautilus' show_hidden_files related code will get simplified.

What do you think? 


Cheers!
Comment 11 Javier Hernández 2012-08-31 00:09:48 UTC
Created attachment 222999 [details] [review]
Proposed patch with Cosimo's suggestions #2

Hi again.

I'm attaching the first solution I mentioned on my previous comment.

I found some problems while connecting to the NautilusWindow's hidden_files_mode_changed signal from the NautilusQueryEditor. So I moved this signal to NautilusSignaller and now is working fine from NautilusView and NautilusQueryEditor.
I added a "nautilus_window_get_show_hidden_files()" and I fixed the coding-style issues as Cosimo suggested.

As a related note, I'm experiencing some issues with the search feature. Regardless this patch is applied or not, I'm randomly getting an error dialog with this message: "Sorry, could not display all the contents of “Search for “do””: Unable to complete the requested search" 
At the same time I'm getting a "WARNING **: atk-bridge: get_device_events_reply: unknown signature" on my terminal. I don't know if it's related but should be investigated. (I'll try to get some useful info and file this into a separate bug report)


Cheers!
Comment 12 Cosimo Cecchi 2012-08-31 17:09:12 UTC
Review of attachment 222999 [details] [review]:

Thanks for the updated patch; I think it's almost ready, but I don't like the fact that you're moving the hidden-files-changed signal to NautilusSignaller; hidden_files is not a global setting, and we don't want a Ctrl+H in a window to generally influence queries in other windows.
What issues specifically are you having with connecting to the window signal directly from NautilusQueryEditor? I think to make this easier, it would be nice to have the window be a construct property of NautilusQueryEditor. In order to make this possible, I now changed NautilusWindowSlot in the same way in git master [1], so you'll be able to just pass the window to the query editor constructor from the slot (after adding similar boilerplate code to NautilusQueryEditor).

[1] http://git.gnome.org/browse/nautilus/commit/?id=5dd2e1f974b969be9e270e8b219ce243b775da52

::: src/nautilus-view.c
@@ +7225,3 @@
 	}
 
+	view->details->show_hidden_files = nautilus_window_get_show_hidden_files (view->details->window);

I think it'd be nice to keep the show_hidden_changed logic here.
Comment 13 Cosimo Cecchi 2012-09-19 03:19:45 UTC
This already works in most cases in git master, because the NautilusDirectory model we now prefer to the simple search engine uses a file monitor that includes hidden files, and NautilusSearchDirectory filters them out for the view automatically; so it turns out the only thing left to do is to patch the simple engine to do the same.
I am attaching a patch that does that.
Comment 14 Cosimo Cecchi 2012-09-19 03:20:08 UTC
Created attachment 224689 [details] [review]
search-engine-simple: always include hidden files

Since the NautilusDirectory controlling the view model will filter them
out anyway according to the preference; this way we can make Ctrl+H work
correctly also in case the simple engine, and not the
NautilusDirectory one, is used.
Comment 15 Javier Hernández 2012-09-19 15:21:23 UTC
Hey Cosimo, this easy patch solves the issue for sure. :]

I didn't have time enough for diggin into this after the NautilusWindow's signals were dropped, but I think this solution will always do the magic (as I proposed on comment #10).

BTW, thanks for the attention provided.


Cheers!
Comment 16 Cosimo Cecchi 2012-09-19 15:25:19 UTC
Comment on attachment 224689 [details] [review]
search-engine-simple: always include hidden files

Marking as accepted after freeze to remove from the patch queue.
Comment 17 Cosimo Cecchi 2012-09-19 16:58:53 UTC
Attachment 224689 [details] pushed as a0c2509 - search-engine-simple: always include hidden files

Pushed after r-t approval