static void set_metadata_get_info_callback (GObject *source_object, GAsyncResult *res, gpointer callback_data) { NautilusFile *file; GFileInfo *new_info; GError *error; file = callback_data; error = NULL; new_info = g_file_query_info_finish (G_FILE (source_object), res, &error); if (new_info != NULL) { if (nautilus_file_update_info (file, new_info)) { nautilus_file_changed (file); } g_object_unref (new_info); } nautilus_file_unref (file); if (error) { g_error_free (error); } }
static void real_file_changed_callback (NautilusFile *real_file, gpointer callback_data) { NautilusDesktopDirectoryFile *desktop_file; desktop_file = NAUTILUS_DESKTOP_DIRECTORY_FILE (callback_data); nautilus_file_changed (NAUTILUS_FILE (desktop_file)); }
void nautilus_keyfile_metadata_set_stringv (NautilusFile *file, const char *keyfile_filename, const char *name, const char *key, const char * const *stringv) { GKeyFile *keyfile; guint length; gchar **actual_stringv = NULL; gboolean free_strv = FALSE; keyfile = get_keyfile (keyfile_filename); /* if we would be setting a single-length strv, append a fake * terminator to the array, to be able to differentiate it later from * the single string case */ length = g_strv_length ((gchar **) stringv); if (length == 1) { actual_stringv = g_malloc0 (3 * sizeof (gchar *)); actual_stringv[0] = (gchar *) stringv[0]; actual_stringv[1] = STRV_TERMINATOR; actual_stringv[2] = NULL; length = 2; free_strv = TRUE; } else { actual_stringv = (gchar **) stringv; } g_key_file_set_string_list (keyfile, name, key, (const gchar **) actual_stringv, length); save_in_idle (keyfile_filename); if (nautilus_keyfile_metadata_update_from_keyfile (file, keyfile_filename, name)) { nautilus_file_changed (file); } if (free_strv) { g_free (actual_stringv); } }
void nautilus_keyfile_metadata_set_string (NautilusFile *file, const char *keyfile_filename, const gchar *name, const gchar *key, const gchar *string) { GKeyFile *keyfile; keyfile = get_keyfile (keyfile_filename); g_key_file_set_string (keyfile, name, key, string); save_in_idle (keyfile_filename); if (nautilus_keyfile_metadata_update_from_keyfile (file, keyfile_filename, name)) { nautilus_file_changed (file); } }
void nautilus_directory_notify_files_added (GList *files) { GHashTable *added_lists; GList *p; NautilusDirectory *directory; GHashTable *parent_directories; NautilusFile *file; GFile *location, *parent; /* Make a list of added files in each directory. */ added_lists = g_hash_table_new (NULL, NULL); /* Make a list of parent directories that will need their counts updated. */ parent_directories = g_hash_table_new (NULL, NULL); for (p = files; p != NULL; p = p->next) { location = p->data; /* See if the directory is already known. */ directory = get_parent_directory_if_exists (location); if (directory == NULL) { /* In case the directory is not being * monitored, but the corresponding file is, * we must invalidate it's item count. */ file = NULL; parent = g_file_get_parent (location); if (parent) { file = nautilus_file_get_existing (parent); g_object_unref (parent); } if (file != NULL) { nautilus_file_invalidate_count_and_mime_list (file); nautilus_file_unref (file); } continue; } collect_parent_directories (parent_directories, directory); /* If no one is monitoring files in the directory, nothing to do. */ if (!nautilus_directory_is_file_list_monitored (directory)) { nautilus_directory_unref (directory); continue; } file = nautilus_file_get_existing (location); /* We check is_added here, because the file could have been added * to the directory by a nautilus_file_get() but not gotten * files_added emitted */ if (file && file->details->is_added) { /* A file already exists, it was probably renamed. * If it was renamed this could be ignored, but * queue a change just in case */ nautilus_file_changed (file); nautilus_file_unref (file); } else { hash_table_list_prepend (added_lists, directory, g_object_ref (location)); } nautilus_directory_unref (directory); } /* Now get file info for the new files. This creates NautilusFile * objects for the new files, and sends out a files_added signal. */ g_hash_table_foreach (added_lists, call_get_file_info_free_list, NULL); g_hash_table_destroy (added_lists); /* Invalidate count for each parent directory. */ g_hash_table_foreach (parent_directories, invalidate_count_and_unref, NULL); g_hash_table_destroy (parent_directories); }