diff options
author | Federico Mena Quintero <federico@ximian.com> | 2004-02-06 16:15:01 +0000 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2004-02-06 16:15:01 +0000 |
commit | bf54dcdc5c6df799540a8721c090806736567d80 (patch) | |
tree | 7f3842a959a58f6a28ef0c857df45a8cdcce203f | |
parent | 41055272dd2650ce141c28a8becb8e1bdbdb2353 (diff) | |
download | gtk+-bf54dcdc5c6df799540a8721c090806736567d80.tar.gz |
Fix #132327.
2004-02-06 Federico Mena Quintero <federico@ximian.com>
Fix #132327.
* gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a
folder_hash field to keep a list of live folder objects.
(gtk_file_system_unix_init): Create the folder_hash.
(gtk_file_system_unix_finalize): Destroy the folder_hash.
(gtk_file_system_unix_get_folder): Ref and return an existing
folder if we have it around, otherwise return a new folder object.
(struct _GtkFileFolderUnix): Add a field for the parent file system.
(gtk_file_folder_unix_finalize): Remove the folder from the file
system's hash table.
(gtk_file_system_unix_create_folder): Emit "files-added" on the
newly-created folder's parent. Fixes #132327.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 16 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 16 | ||||
-rw-r--r-- | gtk/gtkfilesystemunix.c | 60 |
6 files changed, 135 insertions, 5 deletions
@@ -1,3 +1,19 @@ +2004-02-06 Federico Mena Quintero <federico@ximian.com> + + Fix #132327. + + * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a + folder_hash field to keep a list of live folder objects. + (gtk_file_system_unix_init): Create the folder_hash. + (gtk_file_system_unix_finalize): Destroy the folder_hash. + (gtk_file_system_unix_get_folder): Ref and return an existing + folder if we have it around, otherwise return a new folder object. + (struct _GtkFileFolderUnix): Add a field for the parent file system. + (gtk_file_folder_unix_finalize): Remove the folder from the file + system's hash table. + (gtk_file_system_unix_create_folder): Emit "files-added" on the + newly-created folder's parent. Fixes #132327. + Fri Feb 6 00:51:57 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkstock.c (builtin_items): Change the labels of the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 92cf832794..883f182906 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,19 @@ +2004-02-06 Federico Mena Quintero <federico@ximian.com> + + Fix #132327. + + * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a + folder_hash field to keep a list of live folder objects. + (gtk_file_system_unix_init): Create the folder_hash. + (gtk_file_system_unix_finalize): Destroy the folder_hash. + (gtk_file_system_unix_get_folder): Ref and return an existing + folder if we have it around, otherwise return a new folder object. + (struct _GtkFileFolderUnix): Add a field for the parent file system. + (gtk_file_folder_unix_finalize): Remove the folder from the file + system's hash table. + (gtk_file_system_unix_create_folder): Emit "files-added" on the + newly-created folder's parent. Fixes #132327. + Fri Feb 6 00:51:57 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkstock.c (builtin_items): Change the labels of the diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 92cf832794..883f182906 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,19 @@ +2004-02-06 Federico Mena Quintero <federico@ximian.com> + + Fix #132327. + + * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a + folder_hash field to keep a list of live folder objects. + (gtk_file_system_unix_init): Create the folder_hash. + (gtk_file_system_unix_finalize): Destroy the folder_hash. + (gtk_file_system_unix_get_folder): Ref and return an existing + folder if we have it around, otherwise return a new folder object. + (struct _GtkFileFolderUnix): Add a field for the parent file system. + (gtk_file_folder_unix_finalize): Remove the folder from the file + system's hash table. + (gtk_file_system_unix_create_folder): Emit "files-added" on the + newly-created folder's parent. Fixes #132327. + Fri Feb 6 00:51:57 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkstock.c (builtin_items): Change the labels of the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 92cf832794..883f182906 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,19 @@ +2004-02-06 Federico Mena Quintero <federico@ximian.com> + + Fix #132327. + + * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a + folder_hash field to keep a list of live folder objects. + (gtk_file_system_unix_init): Create the folder_hash. + (gtk_file_system_unix_finalize): Destroy the folder_hash. + (gtk_file_system_unix_get_folder): Ref and return an existing + folder if we have it around, otherwise return a new folder object. + (struct _GtkFileFolderUnix): Add a field for the parent file system. + (gtk_file_folder_unix_finalize): Remove the folder from the file + system's hash table. + (gtk_file_system_unix_create_folder): Emit "files-added" on the + newly-created folder's parent. Fixes #132327. + Fri Feb 6 00:51:57 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkstock.c (builtin_items): Change the labels of the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 92cf832794..883f182906 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,19 @@ +2004-02-06 Federico Mena Quintero <federico@ximian.com> + + Fix #132327. + + * gtk/gtkfilesystemunix.c (struct _GtkFileSystemUnix): Add a + folder_hash field to keep a list of live folder objects. + (gtk_file_system_unix_init): Create the folder_hash. + (gtk_file_system_unix_finalize): Destroy the folder_hash. + (gtk_file_system_unix_get_folder): Ref and return an existing + folder if we have it around, otherwise return a new folder object. + (struct _GtkFileFolderUnix): Add a field for the parent file system. + (gtk_file_folder_unix_finalize): Remove the folder from the file + system's hash table. + (gtk_file_system_unix_create_folder): Emit "files-added" on the + newly-created folder's parent. Fixes #132327. + Fri Feb 6 00:51:57 2004 Matthias Clasen <maclas@gmx.de> * gtk/gtkstock.c (builtin_items): Change the labels of the diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c index 0a270d5050..9f6db9b310 100644 --- a/gtk/gtkfilesystemunix.c +++ b/gtk/gtkfilesystemunix.c @@ -50,6 +50,8 @@ struct _GtkFileSystemUnixClass struct _GtkFileSystemUnix { GObject parent_instance; + + GHashTable *folder_hash; }; /* Icon type, supplemented by MIME type @@ -86,6 +88,7 @@ struct _GtkFileFolderUnix { GObject parent_instance; + GtkFileSystemUnix *system_unix; GtkFileInfoType types; gchar *filename; }; @@ -280,11 +283,19 @@ gtk_file_system_unix_iface_init (GtkFileSystemIface *iface) static void gtk_file_system_unix_init (GtkFileSystemUnix *system_unix) { + system_unix->folder_hash = g_hash_table_new (g_str_hash, g_str_equal); } static void gtk_file_system_unix_finalize (GObject *object) { + GtkFileSystemUnix *system_unix; + + system_unix = GTK_FILE_SYSTEM_UNIX (object); + + /* FIXME: assert that the hash is empty? */ + g_hash_table_destroy (system_unix->folder_hash); + system_parent_class->finalize (object); } @@ -314,18 +325,31 @@ gtk_file_system_unix_get_folder (GtkFileSystem *file_system, GtkFileInfoType types, GError **error) { + GtkFileSystemUnix *system_unix; GtkFileFolderUnix *folder_unix; const char *filename; + system_unix = GTK_FILE_SYSTEM_UNIX (file_system); + 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); - folder_unix = g_object_new (GTK_TYPE_FILE_FOLDER_UNIX, NULL); - folder_unix->filename = g_strdup (filename); - folder_unix->types = types; + folder_unix = g_hash_table_lookup (system_unix->folder_hash, filename); + + if (folder_unix) + return g_object_ref (folder_unix); + else + { + folder_unix = g_object_new (GTK_TYPE_FILE_FOLDER_UNIX, NULL); + folder_unix->system_unix = system_unix; + folder_unix->filename = g_strdup (filename); + folder_unix->types = types; + + g_hash_table_insert (system_unix->folder_hash, folder_unix->filename, folder_unix); - return GTK_FILE_FOLDER (folder_unix); + return GTK_FILE_FOLDER (folder_unix); + } } static gboolean @@ -333,8 +357,12 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error) { + GtkFileSystemUnix *system_unix; const char *filename; gboolean result; + char *parent; + + system_unix = GTK_FILE_SYSTEM_UNIX (file_system); filename = gtk_file_path_get_string (path); g_return_val_if_fail (filename != NULL, FALSE); @@ -352,9 +380,29 @@ gtk_file_system_unix_create_folder (GtkFileSystem *file_system, filename_utf8 ? filename_utf8 : "???", g_strerror (errno)); g_free (filename_utf8); + return FALSE; } - return result; + if (filename_is_root (filename)) + return TRUE; /* hmmm, but with no notification */ + + parent = g_path_get_dirname (filename); + if (parent) + { + GtkFileFolderUnix *folder_unix; + + folder_unix = g_hash_table_lookup (system_unix->folder_hash, parent); + if (folder_unix) + { + GSList *paths; + + paths = g_slist_append (NULL, (GtkFilePath *) path); + g_signal_emit_by_name (folder_unix, "files-added", paths); + g_slist_free (paths); + } + } + + return TRUE; } static void @@ -1202,6 +1250,8 @@ gtk_file_folder_unix_finalize (GObject *object) { GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (object); + g_hash_table_remove (folder_unix->system_unix->folder_hash, folder_unix->filename); + g_free (folder_unix->filename); folder_parent_class->finalize (object); |