Allow the path to be NULL, so that people can ask for information about a

2004-03-14  Federico Mena Quintero  <federico@ximian.com>

	* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
	to be NULL, so that people can ask for information about a
	parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).

	* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
	the condition describe above.

	* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
	information of root paths.

	* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
This commit is contained in:
Federico Mena Quintero 2004-03-15 05:42:51 +00:00 committed by Federico Mena Quintero
parent 6bc9b7f5b4
commit 084bb2fe39
9 changed files with 112 additions and 18 deletions

View File

@ -1,3 +1,17 @@
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.
* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.
* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
Sun Mar 14 22:32:36 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention

View File

@ -1,3 +1,17 @@
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.
* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.
* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
Sun Mar 14 22:32:36 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention

View File

@ -1,3 +1,17 @@
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.
* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.
* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
Sun Mar 14 22:32:36 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention

View File

@ -1,3 +1,17 @@
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.
* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.
* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
Sun Mar 14 22:32:36 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention

View File

@ -1,3 +1,17 @@
2004-03-14 Federico Mena Quintero <federico@ximian.com>
* gtk/gtkfilesystem.c (gtk_file_folder_get_info): Allow the path
to be NULL, so that people can ask for information about a
parent-less file system root (e.g. get_info (get_folder ("/"), NULL)).
* gtk/gtkfilesystemunix.c (gtk_file_folder_unix_get_info): Allow
the condition describe above.
* gtk/gtkfilechooserdefault.c (get_file_info): Allow getting
information of root paths.
* gtk/gtkpathbar.c (_gtk_path_bar_set_path): Handle root paths correctly.
Sun Mar 14 22:32:36 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_set_search_equal_func): Mention

View File

@ -923,19 +923,17 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
GTK_FILE_INFO_DISPLAY_NAME
#if 0
| GTK_FILE_INFO_ICON
#endif
| (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
error);
gtk_file_path_free (parent_path);
if (!parent_folder)
return NULL;
goto out;
info = gtk_file_folder_get_info (parent_folder, path, error);
info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, error);
g_object_unref (parent_folder);
out:
gtk_file_path_free (parent_path);
return info;
}

View File

@ -844,7 +844,6 @@ gtk_file_folder_get_info (GtkFileFolder *folder,
GError **error)
{
g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
return GTK_FILE_FOLDER_GET_IFACE (folder)->get_info (folder, path, error);

View File

@ -465,7 +465,7 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
const char *filename;
gboolean result;
char *parent, *tmp;
system_unix = GTK_FILE_SYSTEM_UNIX (file_system);
filename = gtk_file_path_get_string (path);
@ -475,7 +475,7 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
tmp = remove_trailing_slash (filename);
result = mkdir (tmp, 0777) == 0;
g_free (tmp);
if (!result)
{
int save_errno = errno;
@ -689,12 +689,12 @@ get_parent_dir (const char *filename)
int len;
len = strlen (filename);
/* Ignore trailing slashes */
if (len > 1 && filename[len - 1] == '/')
{
char *tmp, *parent;
tmp = g_strndup (filename, len - 1);
parent = g_path_get_dirname (tmp);
@ -713,7 +713,7 @@ gtk_file_system_unix_get_parent (GtkFileSystem *file_system,
GError **error)
{
const char *filename;
filename = gtk_file_path_get_string (path);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (g_path_is_absolute (filename), FALSE);
@ -1485,6 +1485,26 @@ gtk_file_folder_unix_get_info (GtkFileFolder *folder,
gboolean file_must_exist;
GtkFileInfoType types;
if (!path)
{
struct stat buf;
g_return_val_if_fail (filename_is_root (folder_unix->filename), NULL);
if (stat (folder_unix->filename, &buf) != 0)
return NULL;
info = gtk_file_info_new ();
gtk_file_info_set_display_name (info, "/");
gtk_file_info_set_is_folder (info, TRUE);
gtk_file_info_set_is_hidden (info, FALSE);
gtk_file_info_set_mime_type (info, "x-directory/normal");
gtk_file_info_set_modification_time (info, buf.st_mtime);
gtk_file_info_set_size (info, buf.st_size);
return info;
}
filename = gtk_file_path_get_string (path);
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
@ -1523,12 +1543,12 @@ gtk_file_folder_unix_get_info (GtkFileFolder *folder,
gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
if (!display_name)
display_name = g_strescape (basename, NULL);
gtk_file_info_set_display_name (info, display_name);
g_free (display_name);
}
if (types & GTK_FILE_INFO_IS_HIDDEN)
gtk_file_info_set_is_hidden (info, basename[0] == '.');

View File

@ -989,13 +989,20 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
parent_path ? parent_path : path,
GTK_FILE_INFO_DISPLAY_NAME,
NULL);
file_info = gtk_file_folder_get_info (file_folder, path, error);
if (!file_folder)
{
result = FALSE;
gtk_file_path_free (parent_path);
gtk_file_path_free (path);
break;
}
file_info = gtk_file_folder_get_info (file_folder, parent_path ? path : NULL, error);
g_object_unref (file_folder);
if (!file_info)
{
result = FALSE;
gtk_file_path_free (parent_path);
gtk_file_path_free (path);
break;