[easytag] Only add dummy browser row if the path is readable
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Only add dummy browser row if the path is readable
- Date: Thu, 13 Feb 2014 15:32:57 +0000 (UTC)
commit 81a1e7cf4bcb7897abd7c7ac4f6bfe0f0a038395
Author: Abhinav <abhijangda hotmail com>
Date: Thu Feb 13 19:27:48 2014 +0530
Only add dummy browser row if the path is readable
Prevent empty rows from appearing in the browser when parent directories
are deleted externally. Additionally, delete the parent directory from
the tree if it is not found.
https://bugzilla.gnome.org/show_bug.cgi?id=722380
src/browser.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index c88eba1..eb88d12 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -3004,6 +3004,7 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
GIcon *icon;
GFile *file;
GFileInfo *fileinfo;
+ GError *error = NULL;
g_return_if_fail (directoryTreeModel != NULL);
@@ -3014,7 +3015,7 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
file = g_file_new_for_path (path);
g_free (path);
fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_READ,
- G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ G_FILE_QUERY_INFO_NONE, NULL, &error);
g_object_unref (file);
if (fileinfo)
@@ -3057,8 +3058,21 @@ static void collapse_cb (GtkWidget *tree, GtkTreeIter *iter, GtkTreePath *treePa
TREE_COLUMN_ICON, icon, -1);
#endif /* !G_OS_WIN32 */
- /* Insert dummy node. */
- gtk_tree_store_append (directoryTreeModel, &subNodeIter, iter);
+ /* Insert dummy node only if directory exists. */
+ if (error)
+ {
+ /* Remove the parent (missing) directory from the tree. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ gtk_tree_store_remove (directoryTreeModel, iter);
+ }
+
+ g_error_free (error);
+ }
+ else
+ {
+ gtk_tree_store_append (directoryTreeModel, &subNodeIter, iter);
+ }
g_object_unref (icon);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]