/** * nautilus_directory_get_by_uri: * @uri: URI of directory to get. * * Get a directory given a uri. * Creates the appropriate subclass given the uri mappings. * Returns a referenced object, not a floating one. Unref when finished. * If two windows are viewing the same uri, the directory object is shared. */ NautilusDirectory * nautilus_directory_get_internal (GFile *location, gboolean create) { NautilusDirectory *directory; /* Create the hash table first time through. */ if (directories == NULL) { directories = eel_g_hash_table_new_free_at_exit (g_file_hash, (GCompareFunc)g_file_equal, "nautilus-directory.c: directories"); add_preferences_callbacks (); } /* If the object is already in the hash table, look it up. */ directory = g_hash_table_lookup (directories, location); if (directory != NULL) { nautilus_directory_ref (directory); } else if (create) { /* Create a new directory object instead. */ directory = nautilus_directory_new (location); if (directory == NULL) { return NULL; } /* Put it in the hash table. */ g_hash_table_insert (directories, directory->details->location, directory); } return directory; }
static void collect_parent_directories (GHashTable *hash_table, NautilusDirectory *directory) { g_assert (hash_table != NULL); g_assert (NAUTILUS_IS_DIRECTORY (directory)); if (g_hash_table_lookup (hash_table, directory) == NULL) { nautilus_directory_ref (directory); g_hash_table_insert (hash_table, directory, directory); } }
static void collect_all_directories (gpointer key, gpointer value, gpointer callback_data) { NautilusDirectory *directory; GList **dirs; directory = NAUTILUS_DIRECTORY (value); dirs = callback_data; *dirs = g_list_prepend (*dirs, nautilus_directory_ref (directory)); }
static void collect_directories_by_container (gpointer key, gpointer value, gpointer callback_data) { NautilusDirectory *directory; CollectData *collect_data; GFile *location; location = (GFile *) key; directory = NAUTILUS_DIRECTORY (value); collect_data = (CollectData *) callback_data; if (g_file_has_prefix (location, collect_data->container) || g_file_equal (collect_data->container, location)) { nautilus_directory_ref (directory); collect_data->directories = g_list_prepend (collect_data->directories, directory); } }
NautilusDirectory * nautilus_desktop_directory_get_real_directory (NautilusDesktopDirectory *desktop) { nautilus_directory_ref (desktop->details->real_directory); return desktop->details->real_directory; }