GNOME Bugzilla – Bug 584931
Old directory name doesn't disappear from dir list if renaming
Last modified: 2009-06-15 23:16:28 UTC
If you rename a directory in the folders pane, after renaming it you still see the old directory name in the directories list. The new name is presented at the beginning of the list, and not where it should be presented.
Created attachment 136236 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming Add gfile_get_basename_for_uri to gfile-utils Update gth-monitor to use full URIs Update gth-browser-action-callbacks to send full URIs to the directory callbacks Update gth-browser to use URIs for directory callbacks Update gth-dir-list to use the new gfile_get_basename_for_uri Remove and readd .. item in gth_dir_list_add_directory to keep dir_list->list ordering correct Fix using new_path after g_free in folder_rename
Created attachment 136251 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming
Could you check the formatting of your patches? It looks like some of your tabs are only 4 spaces, not 8. Click on the attachment link above and you can see how the indentation is messed up everywhere. It needs to be fixed. - Mike
Created attachment 136288 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming Odd, not sure why my settings changed.
The patch seems to have problems. If I create a new folder (Ctrl+Shift+N), it is not inserted in the correct location. I have to press Ctrl+R to refresh the list properly. Also, don't do this: - char *uri = g_file_get_parse_name (gfile); + char *uri; + uri = g_file_get_uri (gfile); add_monitor_event (monitor, event_type, uri, priv->monitor_events); At the moment, all file lists use the parse name (also called the utf8_path in FileData), and NOT the URI. Don't mix them! They are different. I will be changing the monitor code to accept gfile arguments, instead of parse names or URIs, soon, which will eliminate this confusion. - Mike
Yes, all the problems left with this bug are related to URIs vs parse names I think. I'm going to change gth-dir-list to store GFiles for the directory list so it will be easy to access both formats. GFiles will help later for Bug 328509 – folders tree view too.
Ideally, ALL path_lists and file_lists should be replaced with gfile_lists, and we should be using functions like g_file_equal (instead of same_uri) and gfile_list_free (instead of path_list_free). In cases where we really need a list of FileDatas, we can be a gfile_list and use file_data_new_from_gfile. fd->utf8_path should only be used for display applications, and nothing else. However, it can also be replaced with g_file_get_parse_name (gfile). URIs should never be handled directly, except in some thumbnail-related code. - Mike
Created attachment 136345 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming Update gth-dir-list to use GFile for the directory list Remove .. items from the gth-dir-list dir_list->list and only have it in the gtk_list_store Add gth_sort_by_gfile to gth-sort-utils Add gfile_get_basename_for_uri to gfile-utils Update gth-browser and gth-browser-actions-callbacks to pass GFiles to gth-dir-list add_dir and remove_dir functions Fix using new_path after g_free in folder_rename (gth-browser-actions-callbacks)
+int gth_sort_by_gfile (GFile *file1, + GFile *file2) +{ + char *path1, *path2; + int result; + path1 = g_file_get_parse_name(file1); + path2 = g_file_get_parse_name(file2); + result = gth_sort_by_filename(path1, path2, FALSE); + if(path1 && path2) { + g_free(path1); + g_free(path2); + } + return result; +} What's the "if" statement for? - Mike
Absolutely nothing. Feel free to remove it or wait until I'm on my development machine and I'll remove it and resubmit the patch.
Created attachment 136495 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming Update gth-dir-list to use GFile for the directory list Remove .. items from the gth-dir-list dir_list->list and only have it in the gtk_list_store Add gth_sort_by_gfile to gth-sort-utils Add gfile_get_basename_for_uri to gfile-utils Update gth-browser and gth-browser-actions-callbacks to pass GFiles to gth-dir-list add_dir and remove_dir functions Fix using new_path after g_free in folder_rename (gth-browser-actions-callbacks)
[mjc@xena gthumb]$ make > eraseme gth-browser-actions-callbacks.c: In function ‘edit_current_folder_tags__done’: gth-browser-actions-callbacks.c:1406: warning: passing argument 2 of ‘gth_dir_list_remove_directory’ from incompatible pointer type gth-dir-list.h:82: note: expected ‘struct GFile *’ but argument is of type ‘const char *’ gth-browser-actions-callbacks.c:1407: warning: passing argument 2 of ‘gth_dir_list_add_directory’ from incompatible pointer type gth-dir-list.h:80: note: expected ‘struct GFile *’ but argument is of type ‘const char *’
Created attachment 136645 [details] [review] GIO Fix Bug: 584931 Old directory name doesn't disappear from dir list if renaming Update gth-dir-list to use GFile for the directory list Remove .. items from the gth-dir-list dir_list->list and only have it in the gtk_list_store Add gfile_get_basename_for_uri to gfile-utils Update gth-browser and gth-browser-actions-callbacks to pass GFiles to gth-dir-list add_dir and remove_dir functions Fix using new_path after g_free in folder_rename (gth-browser-actions-callbacks) Update current_folder_tag functions in gth-browser-actions-callbacks for GFiles
Committed, with some edits. Thanks! - Mike