[gthumb] Exclude hidden folders from search result when view->hidden files is not active



commit 5f0789bcf4c445d5419b066d05a38b71448fbcc6
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Jul 4 13:36:04 2011 +0200

    Exclude hidden folders from search result when view->hidden files is not active
    
    [bug #502524]

 extensions/search/gth-search-task.c |   17 +++++++++++++++++
 gthumb/gth-browser.c                |   12 ++++++------
 2 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/extensions/search/gth-search-task.c b/extensions/search/gth-search-task.c
index dedc483..f64e9ac 100644
--- a/extensions/search/gth-search-task.c
+++ b/extensions/search/gth-search-task.c
@@ -33,6 +33,7 @@ struct _GthSearchTaskPrivate
 	GthSearch     *search;
 	GthTestChain  *test;
 	GFile         *search_catalog;
+	gboolean       show_hidden_files;
 	gboolean       io_operation;
 	GError        *error;
 	gulong         location_ready_id;
@@ -208,6 +209,18 @@ for_each_file_func (GFile     *file,
 }
 
 
+static gboolean
+file_is_visible (GthSearchTask *task,
+		 GFileInfo     *info)
+{
+	if (task->priv->show_hidden_files)
+		return TRUE;
+	else
+		return ! g_file_info_get_is_hidden (info);
+
+}
+
+
 static DirOp
 start_dir_func (GFile      *directory,
 		GFileInfo  *info,
@@ -218,6 +231,9 @@ start_dir_func (GFile      *directory,
 	char          *uri;
 	char          *text;
 
+	if (! file_is_visible (task, info))
+		return DIR_OP_SKIP;
+
 	uri = g_file_get_parse_name (directory);
 	text = g_strdup_printf ("Searching in %s", uri);
 	gth_embedded_dialog_set_primary_text (GTH_EMBEDDED_DIALOG (task->priv->dialog), text);
@@ -294,6 +310,7 @@ browser_location_ready_cb (GthBrowser    *browser,
 		g_object_unref (general_filter);
 	}
 
+	task->priv->show_hidden_files = eel_gconf_get_boolean (PREF_SHOW_HIDDEN_FILES, FALSE);
 	task->priv->io_operation = TRUE;
 
 	task->priv->file_source = gth_main_get_file_source (gth_search_get_folder (task->priv->search));
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 555a11b..00cccbb 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -1429,7 +1429,7 @@ load_data_load_next_folder (LoadData *load_data)
 
 
 static gboolean
-_gth_browser_folder_is_visible (GthBrowser  *browser,
+_gth_browser_file_is_visible (GthBrowser  *browser,
 				GthFileData *file_data)
 {
 	if (browser->priv->show_hidden_files)
@@ -1440,8 +1440,8 @@ _gth_browser_folder_is_visible (GthBrowser  *browser,
 
 
 static GList *
-_gth_browser_get_visible_folders (GthBrowser *browser,
-				  GList      *list)
+_gth_browser_get_visible_files (GthBrowser *browser,
+			        GList      *list)
 {
 	GList *visible_list = NULL;
 	GList *scan;
@@ -1449,7 +1449,7 @@ _gth_browser_get_visible_folders (GthBrowser *browser,
 	for (scan = list; scan; scan = scan->next) {
 		GthFileData *file_data = scan->data;
 
-		if (_gth_browser_folder_is_visible (browser, file_data))
+		if (_gth_browser_file_is_visible (browser, file_data))
 			visible_list = g_list_prepend (visible_list, g_object_ref (file_data));
 	}
 
@@ -1481,7 +1481,7 @@ load_data_continue (LoadData *load_data,
 	}
 
 	loaded_folder = (GFile *) load_data->current->data;
-	files = _gth_browser_get_visible_folders (browser, loaded_files);
+	files = _gth_browser_get_visible_files (browser, loaded_files);
 	gth_folder_tree_set_children (GTH_FOLDER_TREE (browser->priv->folder_tree), loaded_folder, files);
 
 	path = gth_folder_tree_get_path (GTH_FOLDER_TREE (browser->priv->folder_tree), loaded_folder);
@@ -2858,7 +2858,7 @@ file_attributes_ready_cb (GthFileSource *file_source,
 		return;
 	}
 
-	visible_folders = _gth_browser_get_visible_folders (browser, files);
+	visible_folders = _gth_browser_get_visible_files (browser, files);
 
 	if (monitor_data->event == GTH_MONITOR_EVENT_CREATED) {
 		if (monitor_data->update_folder_tree)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]