static void merged_add_real_directory (NemoMergedDirectory *merged, NemoDirectory *real_directory) { g_return_if_fail (NEMO_IS_MERGED_DIRECTORY (merged)); g_return_if_fail (NEMO_IS_DIRECTORY (real_directory)); g_return_if_fail (!NEMO_IS_MERGED_DIRECTORY (real_directory)); g_return_if_fail (g_list_find (merged->details->directories, real_directory) == NULL); /* Add to our list of directories. */ nemo_directory_ref (real_directory); merged->details->directories = g_list_prepend (merged->details->directories, real_directory); merged->details->directories_not_done_loading = g_list_prepend (merged->details->directories_not_done_loading, real_directory); g_signal_connect_object (real_directory, "done_loading", G_CALLBACK (done_loading_callback), merged, 0); /* FIXME bugzilla.gnome.org 45084: The done_loading part won't work for the case where * we have no directories in our list. */ /* Add the directory to any extant monitors. */ g_hash_table_foreach (merged->details->monitors, monitor_add_directory, real_directory); /* FIXME bugzilla.gnome.org 42541: Do we need to add the directory to callbacks too? */ g_signal_connect_object (real_directory, "files_added", G_CALLBACK (forward_files_added_cover), merged, 0); g_signal_connect_object (real_directory, "files_changed", G_CALLBACK (forward_files_changed_cover), merged, 0); }
static void add_directory_to_directory_list (NemoActionManager *action_manager, NemoDirectory *directory, GList **directory_list, GCallback changed_callback) { NemoFileAttributes attributes; if (g_list_find (*directory_list, directory) == NULL) { nemo_directory_ref (directory); attributes = NEMO_FILE_ATTRIBUTES_FOR_ICON | NEMO_FILE_ATTRIBUTE_INFO | NEMO_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT; nemo_directory_file_monitor_add (directory, directory_list, FALSE, attributes, (NemoDirectoryCallback)changed_callback, action_manager); g_signal_connect_object (directory, "files_added", G_CALLBACK (changed_callback), action_manager, 0); g_signal_connect_object (directory, "files_changed", G_CALLBACK (changed_callback), action_manager, 0); *directory_list = g_list_append (*directory_list, directory); } }
/** * nemo_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. */ NemoDirectory * nemo_directory_get_internal (GFile *location, gboolean create) { NemoDirectory *directory; /* Create the hash table first time through. */ if (directories == NULL) { directories = g_hash_table_new (g_file_hash, (GCompareFunc) g_file_equal); 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) { nemo_directory_ref (directory); } else if (create) { /* Create a new directory object instead. */ directory = nemo_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, NemoDirectory *directory) { g_assert (hash_table != NULL); g_assert (NEMO_IS_DIRECTORY (directory)); if (g_hash_table_lookup (hash_table, directory) == NULL) { nemo_directory_ref (directory); g_hash_table_insert (hash_table, directory, directory); } }
static void collect_all_directories (gpointer key, gpointer value, gpointer callback_data) { NemoDirectory *directory; GList **dirs; directory = NEMO_DIRECTORY (value); dirs = callback_data; *dirs = g_list_prepend (*dirs, nemo_directory_ref (directory)); }
static void collect_directories_by_container (gpointer key, gpointer value, gpointer callback_data) { NemoDirectory *directory; CollectData *collect_data; GFile *location; location = (GFile *) key; directory = NEMO_DIRECTORY (value); collect_data = (CollectData *) callback_data; if (g_file_has_prefix (location, collect_data->container) || g_file_equal (collect_data->container, location)) { nemo_directory_ref (directory); collect_data->directories = g_list_prepend (collect_data->directories, directory); } }
NemoDirectory * nemo_desktop_directory_get_real_directory (NemoDesktopDirectory *desktop) { nemo_directory_ref (desktop->details->real_directory); return desktop->details->real_directory; }