diff options
Diffstat (limited to 'libnautilus-extensions')
-rw-r--r-- | libnautilus-extensions/nautilus-directory-background.c | 303 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory-background.h | 16 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory-metafile.c | 168 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory-metafile.h | 20 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory.c | 53 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory.h | 37 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file.c | 81 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file.h | 17 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-metadata.h | 12 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-mime-actions.c | 140 |
10 files changed, 410 insertions, 437 deletions
diff --git a/libnautilus-extensions/nautilus-directory-background.c b/libnautilus-extensions/nautilus-directory-background.c index 8c87c8d19..175b9d711 100644 --- a/libnautilus-extensions/nautilus-directory-background.c +++ b/libnautilus-extensions/nautilus-directory-background.c @@ -2,7 +2,7 @@ /* nautilus-directory-background.c: Helper for the background of a widget - that is viewing a particular directory. + that is viewing a particular location. Copyright (C) 2000 Eazel, Inc. @@ -42,32 +42,35 @@ #include <libgnome/gnome-util.h> #include <libgnomevfs/gnome-vfs-utils.h> -static void background_changed_callback (NautilusBackground *background, NautilusDirectory *directory); -static void background_reset_callback (NautilusBackground *background, NautilusDirectory *directory); +static void background_changed_callback (NautilusBackground *background, + NautilusFile *file); +static void background_reset_callback (NautilusBackground *background, + NautilusFile *file); -static void saved_settings_changed_callback (NautilusDirectory *directory, NautilusBackground *background); +static void saved_settings_changed_callback (NautilusFile *file, + NautilusBackground *background); -static void nautilus_directory_background_receive_root_window_changes (NautilusBackground *background); +static void nautilus_file_background_receive_root_window_changes (NautilusBackground *background); -static const char *default_theme_source = "directory"; +static const char *default_theme_source = "file"; static const char *desktop_theme_source = "desktop"; void -static nautilus_directory_background_set_desktop (NautilusBackground *background) +static nautilus_file_background_set_desktop (NautilusBackground *background) { gtk_object_set_data (GTK_OBJECT (background), "theme_source", (gpointer) desktop_theme_source); - nautilus_directory_background_receive_root_window_changes (background); + nautilus_file_background_receive_root_window_changes (background); } static gboolean -nautilus_directory_background_is_desktop (NautilusBackground *background) +nautilus_file_background_is_desktop (NautilusBackground *background) { /* == works because we're carful to always use the same string. */ return gtk_object_get_data (GTK_OBJECT (background), "theme_source") == desktop_theme_source; } -static const char *nautilus_directory_background_peek_theme_source (NautilusBackground *background) +static const char *nautilus_file_background_peek_theme_source (NautilusBackground *background) { char *theme_source; @@ -110,20 +113,20 @@ theme_image_path_to_uri (char *image_file) */ static void -nautilus_directory_background_get_default_settings (const char* theme_source, - char **color, - char **image, - NautilusBackgroundImagePlacement *placement, - gboolean *combine) +nautilus_file_background_get_default_settings (const char* theme_source, + char **color, + char **image, + NautilusBackgroundImagePlacement *placement, + gboolean *combine) { char *combine_str; char *image_local_path; *placement = NAUTILUS_BACKGROUND_TILED; - *color = nautilus_theme_get_theme_data (theme_source, NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR); + *color = nautilus_theme_get_theme_data (theme_source, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR); - image_local_path = nautilus_theme_get_theme_data (theme_source, NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE); + image_local_path = nautilus_theme_get_theme_data (theme_source, NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE); *image = theme_image_path_to_uri (image_local_path); g_free (image_local_path); @@ -153,10 +156,10 @@ enum { }; static void -nautilus_directory_background_read_desktop_settings (char **color, - char **image, - NautilusBackgroundImagePlacement *placement, - gboolean *combine) +nautilus_file_background_read_desktop_settings (char **color, + char **image, + NautilusBackgroundImagePlacement *placement, + gboolean *combine) { int image_alignment; char* image_local_path; @@ -172,7 +175,7 @@ nautilus_directory_background_read_desktop_settings (char **color, gboolean no_start_color; gboolean no_end_color; - nautilus_directory_background_get_default_settings (desktop_theme_source, &default_color, &default_image_file, &default_placement, combine); + nautilus_file_background_get_default_settings (desktop_theme_source, &default_color, &default_image_file, &default_placement, combine); /* note - value of combine comes from the theme, not currently setable in gnome_config */ image_local_path = gnome_config_get_string ("/Background/Default/wallpaper=none"); @@ -233,7 +236,7 @@ nautilus_directory_background_read_desktop_settings (char **color, } static void -nautilus_directory_background_write_desktop_settings (char *color, char *image, NautilusBackgroundImagePlacement placement, gboolean combine) +nautilus_file_background_write_desktop_settings (char *color, char *image, NautilusBackgroundImagePlacement placement, gboolean combine) { char *end_color; char *start_color; @@ -315,29 +318,29 @@ nautilus_directory_background_write_desktop_settings (char *color, char *image, } static void -nautilus_directory_background_write_desktop_default_settings () +nautilus_file_background_write_desktop_default_settings () { char *color; char *image; gboolean combine; NautilusBackgroundImagePlacement placement; - nautilus_directory_background_get_default_settings (desktop_theme_source, &color, &image, &placement, &combine); - nautilus_directory_background_write_desktop_settings (color, image, placement, combine); + nautilus_file_background_get_default_settings (desktop_theme_source, &color, &image, &placement, &combine); + nautilus_file_background_write_desktop_settings (color, image, placement, combine); } static int call_settings_changed (NautilusBackground *background) { - NautilusDirectory *directory; - directory = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_directory"); - if (directory) { - saved_settings_changed_callback (directory, background); + NautilusFile *file; + file = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_file"); + if (file) { + saved_settings_changed_callback (file, background); } return FALSE; } static GdkFilterReturn -nautilus_directory_background_event_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) +nautilus_file_background_event_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { XEvent *xevent; NautilusBackground *background; @@ -366,16 +369,16 @@ nautilus_directory_background_event_filter (GdkXEvent *gdk_xevent, GdkEvent *eve static void desktop_background_destroyed_callback (NautilusBackground *background, void *georgeWBush) { - gdk_window_remove_filter (GDK_ROOT_PARENT(), nautilus_directory_background_event_filter, background); + gdk_window_remove_filter (GDK_ROOT_PARENT(), nautilus_file_background_event_filter, background); } static void -nautilus_directory_background_receive_root_window_changes (NautilusBackground *background) +nautilus_file_background_receive_root_window_changes (NautilusBackground *background) { XWindowAttributes attribs = { 0 }; /* set up a filter on the root window to get notified about property changes */ - gdk_window_add_filter (GDK_ROOT_PARENT(), nautilus_directory_background_event_filter, background); + gdk_window_add_filter (GDK_ROOT_PARENT(), nautilus_file_background_event_filter, background); gdk_error_trap_push (); @@ -514,7 +517,7 @@ image_loading_done_callback (NautilusBackground *background, gboolean successful } static void -nautilus_directory_update_root_window (NautilusBackground *background) +nautilus_file_update_root_window (NautilusBackground *background) { if (nautilus_background_is_loaded (background)) { image_loading_done_callback (background, TRUE, GINT_TO_POINTER (FALSE)); @@ -528,7 +531,7 @@ nautilus_directory_update_root_window (NautilusBackground *background) /* return true if the background is not in the default state */ gboolean -nautilus_directory_background_is_set (NautilusBackground *background) +nautilus_file_background_is_set (NautilusBackground *background) { char *color; char *image; @@ -547,8 +550,8 @@ nautilus_directory_background_is_set (NautilusBackground *background) combine = nautilus_background_get_combine_mode (background); placement = nautilus_background_get_image_placement (background); - nautilus_directory_background_get_default_settings ( - nautilus_directory_background_peek_theme_source (background), + nautilus_file_background_get_default_settings ( + nautilus_file_background_peek_theme_source (background), &default_color, &default_image, &default_placement, &default_combine); is_set = (default_color != NULL && nautilus_strcmp (color, default_color) != 0) || @@ -567,41 +570,41 @@ nautilus_directory_background_is_set (NautilusBackground *background) /* handle the background changed signal */ static void background_changed_callback (NautilusBackground *background, - NautilusDirectory *directory) + NautilusFile *file) { char *color, *image; g_assert (NAUTILUS_IS_BACKGROUND (background)); - g_assert (NAUTILUS_IS_DIRECTORY (directory)); - g_assert (gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_directory") - == directory); + g_assert (NAUTILUS_IS_FILE (file)); + g_assert (gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_file") + == file); color = nautilus_background_get_color (background); image = nautilus_background_get_image_uri (background); - if (nautilus_directory_background_is_desktop (background)) { - nautilus_directory_background_write_desktop_settings (color, image, nautilus_background_get_image_placement (background), nautilus_background_get_combine_mode (background)); + if (nautilus_file_background_is_desktop (background)) { + nautilus_file_background_write_desktop_settings (color, image, nautilus_background_get_image_placement (background), nautilus_background_get_combine_mode (background)); } else { /* Block the other handler while we are writing metadata so it doesn't * try to change the background. */ - gtk_signal_handler_block_by_func (GTK_OBJECT (directory), + gtk_signal_handler_block_by_func (GTK_OBJECT (file), saved_settings_changed_callback, background); - nautilus_directory_set_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR, - NULL, - color); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, + NULL, + color); - nautilus_directory_set_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE, - NULL, - image); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, + NULL, + image); /* Unblock the handler. */ - gtk_signal_handler_unblock_by_func (GTK_OBJECT (directory), + gtk_signal_handler_unblock_by_func (GTK_OBJECT (file), saved_settings_changed_callback, background); } @@ -609,43 +612,43 @@ background_changed_callback (NautilusBackground *background, g_free (color); g_free (image); - if (nautilus_directory_background_is_desktop (background)) { - nautilus_directory_update_root_window (background); + if (nautilus_file_background_is_desktop (background)) { + nautilus_file_update_root_window (background); } } -/* handle the directory changed signal */ +/* handle the file changed signal */ static void -saved_settings_changed_callback (NautilusDirectory *directory, - NautilusBackground *background) +saved_settings_changed_callback (NautilusFile *file, + NautilusBackground *background) { char *color; char *image; gboolean combine; NautilusBackgroundImagePlacement placement; - g_assert (NAUTILUS_IS_DIRECTORY (directory)); + g_assert (NAUTILUS_IS_FILE (file)); g_assert (NAUTILUS_IS_BACKGROUND (background)); - g_assert (gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_directory") - == directory); + g_assert (gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_file") + == file); - if (nautilus_directory_background_is_desktop (background)) { - nautilus_directory_background_read_desktop_settings (&color, &image, &placement, &combine); + if (nautilus_file_background_is_desktop (background)) { + nautilus_file_background_read_desktop_settings (&color, &image, &placement, &combine); } else { - color = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR, - NULL); - image = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE, - NULL); + color = nautilus_file_get_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, + NULL); + image = nautilus_file_get_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, + NULL); placement = NAUTILUS_BACKGROUND_TILED; /* non-tiled only avail for desktop, at least for now */ combine = FALSE; /* only from theme, at least for now */ /* if there's none, read the default from the theme */ if (color == NULL && image == NULL) { - nautilus_directory_background_get_default_settings ( - nautilus_directory_background_peek_theme_source (background), - &color, &image, &placement, &combine); + nautilus_file_background_get_default_settings + (nautilus_file_background_peek_theme_source (background), + &color, &image, &placement, &combine); } } @@ -654,7 +657,7 @@ saved_settings_changed_callback (NautilusDirectory *directory, */ gtk_signal_handler_block_by_func (GTK_OBJECT (background), background_changed_callback, - directory); + file); nautilus_background_set_color (background, color); nautilus_background_set_image_uri (background, image); @@ -663,8 +666,8 @@ saved_settings_changed_callback (NautilusDirectory *directory, /* Unblock the handler. */ gtk_signal_handler_unblock_by_func (GTK_OBJECT (background), - background_changed_callback, - directory); + background_changed_callback, + file); g_free (color); g_free (image); @@ -672,190 +675,180 @@ saved_settings_changed_callback (NautilusDirectory *directory, /* handle the theme changing */ static void -nautilus_directory_background_theme_changed (gpointer user_data) +nautilus_file_background_theme_changed (gpointer user_data) { - NautilusDirectory *directory; + NautilusFile *file; NautilusBackground *background; background = NAUTILUS_BACKGROUND (user_data); - directory = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_directory"); - if (directory) { - saved_settings_changed_callback (directory, background); + file = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_file"); + if (file) { + saved_settings_changed_callback (file, background); } } /* handle the background reset signal by setting values from the current theme */ static void background_reset_callback (NautilusBackground *background, - NautilusDirectory *directory) + NautilusFile *file) { - if (nautilus_directory_background_is_desktop (background)) { - nautilus_directory_background_write_desktop_default_settings (); + if (nautilus_file_background_is_desktop (background)) { + nautilus_file_background_write_desktop_default_settings (); } else { /* Block the other handler while we are writing metadata so it doesn't * try to change the background. */ - gtk_signal_handler_block_by_func (GTK_OBJECT (directory), + gtk_signal_handler_block_by_func (GTK_OBJECT (file), saved_settings_changed_callback, background); /* reset the metadata */ - nautilus_directory_set_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR, - NULL, - NULL); - - nautilus_directory_set_metadata (directory, - NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE, - NULL, - NULL); + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR, + NULL, + NULL); + + nautilus_file_set_metadata (file, + NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE, + NULL, + NULL); /* Unblock the handler. */ - gtk_signal_handler_unblock_by_func (GTK_OBJECT (directory), + gtk_signal_handler_unblock_by_func (GTK_OBJECT (file), saved_settings_changed_callback, background); } - saved_settings_changed_callback (directory, background); + saved_settings_changed_callback (file, background); /* We don't want the default reset handler running. * It will set color and image_uri to NULL. */ gtk_signal_emit_stop_by_name (GTK_OBJECT (background), "reset"); - if (nautilus_directory_background_is_desktop (background)) { - nautilus_directory_update_root_window (background); + if (nautilus_file_background_is_desktop (background)) { + nautilus_file_update_root_window (background); } } /* handle the background destroyed signal */ static void background_destroyed_callback (NautilusBackground *background, - NautilusDirectory *directory) + NautilusFile *file) { - gtk_signal_disconnect_by_func (GTK_OBJECT (directory), + gtk_signal_disconnect_by_func (GTK_OBJECT (file), GTK_SIGNAL_FUNC (saved_settings_changed_callback), background); - nautilus_directory_file_monitor_remove (directory, background); + nautilus_file_monitor_remove (file, background); nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME, - nautilus_directory_background_theme_changed, + nautilus_file_background_theme_changed, background); } -/* key routine that hooks up a background and directory */ +/* key routine that hooks up a background and location */ void -nautilus_connect_background_to_directory_metadata (GtkWidget *widget, - NautilusDirectory *directory) +nautilus_connect_background_to_file_metadata (GtkWidget *widget, + NautilusFile *file) { NautilusBackground *background; - gpointer old_directory; + gpointer old_file; GList *attributes; /* Get at the background object we'll be connecting. */ background = nautilus_get_widget_background (widget); - /* Check if it is already connected. */ - old_directory = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_directory"); - if (old_directory == directory) { + old_file = gtk_object_get_data (GTK_OBJECT (background), "nautilus_background_file"); + if (old_file == file) { return; } /* Disconnect old signal handlers. */ - if (old_directory != NULL) { - g_assert (NAUTILUS_IS_DIRECTORY (old_directory)); + if (old_file != NULL) { + g_assert (NAUTILUS_IS_FILE (old_file)); gtk_signal_disconnect_by_func (GTK_OBJECT (background), GTK_SIGNAL_FUNC (background_changed_callback), - old_directory); + old_file); gtk_signal_disconnect_by_func (GTK_OBJECT (background), GTK_SIGNAL_FUNC (background_destroyed_callback), - old_directory); + old_file); gtk_signal_disconnect_by_func (GTK_OBJECT (background), GTK_SIGNAL_FUNC (background_reset_callback), - old_directory); - gtk_signal_disconnect_by_func (GTK_OBJECT (old_directory), + old_file); + gtk_signal_disconnect_by_func (GTK_OBJECT (old_file), GTK_SIGNAL_FUNC (saved_settings_changed_callback), background); - nautilus_directory_file_monitor_remove (old_directory, background); + nautilus_file_monitor_remove (old_file, background); nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME, - nautilus_directory_background_theme_changed, - background); + nautilus_file_background_theme_changed, + background); } /* Attach the new directory. */ - nautilus_directory_ref (directory); + nautilus_file_ref (file); gtk_object_set_data_full (GTK_OBJECT (background), - "nautilus_background_directory", - directory, - (GtkDestroyNotify) nautilus_directory_unref); + "nautilus_background_file", + file, + (GtkDestroyNotify) nautilus_file_unref); /* Connect new signal handlers. */ - if (directory != NULL) { + if (file != NULL) { gtk_signal_connect (GTK_OBJECT (background), "settings_changed", GTK_SIGNAL_FUNC (background_changed_callback), - directory); + file); gtk_signal_connect (GTK_OBJECT (background), "destroy", GTK_SIGNAL_FUNC (background_destroyed_callback), - directory); + file); gtk_signal_connect (GTK_OBJECT (background), "reset", GTK_SIGNAL_FUNC (background_reset_callback), - directory); - gtk_signal_connect (GTK_OBJECT (directory), - "metadata_changed", + file); + gtk_signal_connect (GTK_OBJECT (file), + "changed", GTK_SIGNAL_FUNC (saved_settings_changed_callback), background); - /* arrange to receive directory metadata */ - /* FIXME bugzilla.eazel.com 2551: - * This says we want to monitor the file - * metadata, and it has the side effect of monitoring - * the file list. We want to monitor the directory - * metadata, which would not mean monitoring the file - * list. This may require a change to the - * NautilusDirectory API. - */ - + /* arrange to receive file metadata */ attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); - nautilus_directory_file_monitor_add (directory, - background, - attributes, FALSE); + nautilus_file_monitor_add (file, + background, + attributes); g_list_free (attributes); /* arrange for notification when the theme changes */ nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_THEME, - nautilus_directory_background_theme_changed, background); + nautilus_file_background_theme_changed, background); } - /* Update the background based on the directory metadata. */ - saved_settings_changed_callback (directory, background); + /* Update the background based on the file metadata. */ + saved_settings_changed_callback (file, background); } void -nautilus_connect_desktop_background_to_directory_metadata (GtkWidget *widget, - NautilusDirectory *directory) +nautilus_connect_desktop_background_to_file_metadata (GtkWidget *widget, + NautilusFile *file) { - nautilus_directory_background_set_desktop (nautilus_get_widget_background (widget)); + nautilus_file_background_set_desktop (nautilus_get_widget_background (widget)); /* Strictly speaking, we don't need to know about metadata changes, since * the desktop setting aren't stored there. But, hooking up to metadata * changes is actually a small part of what this fn does, and we do need * the other stuff (hooked up to background & theme changes). Being notified - * of metadata changes on the directory is a waste, but won't hurt, so I don't + * of metadata changes on the file is a waste, but won't hurt, so I don't * think it's worth refactoring the fn at this point. */ - nautilus_connect_background_to_directory_metadata (widget, directory); + nautilus_connect_background_to_file_metadata (widget, file); } void -nautilus_connect_background_to_directory_metadata_by_uri (GtkWidget *widget, - const char *uri) +nautilus_connect_background_to_file_metadata_by_uri (GtkWidget *widget, + const char *uri) { - NautilusDirectory *directory; - directory = nautilus_directory_get (uri); - nautilus_connect_background_to_directory_metadata (widget, directory); - nautilus_directory_unref (directory); + NautilusFile *file; + file = nautilus_file_get (uri); + nautilus_connect_background_to_file_metadata (widget, file); + nautilus_file_unref (file); } diff --git a/libnautilus-extensions/nautilus-directory-background.h b/libnautilus-extensions/nautilus-directory-background.h index 46d2032d6..9adf6ea4d 100644 --- a/libnautilus-extensions/nautilus-directory-background.h +++ b/libnautilus-extensions/nautilus-directory-background.h @@ -25,14 +25,14 @@ */ #include <gtk/gtkwidget.h> -#include "nautilus-directory.h" +#include "nautilus-file.h" #include "nautilus-background.h" -void nautilus_connect_background_to_directory_metadata (GtkWidget *widget, - NautilusDirectory *directory); -void nautilus_connect_desktop_background_to_directory_metadata (GtkWidget *widget, - NautilusDirectory *directory); -void nautilus_connect_background_to_directory_metadata_by_uri (GtkWidget *widget, - const char *uri); -gboolean nautilus_directory_background_is_set (NautilusBackground *background); +void nautilus_connect_background_to_file_metadata (GtkWidget *widget, + NautilusFile *file); +void nautilus_connect_desktop_background_to_file_metadata (GtkWidget *widget, + NautilusFile *file); +void nautilus_connect_background_to_file_metadata_by_uri (GtkWidget *widget, + const char *uri); +gboolean nautilus_file_background_is_set (NautilusBackground *background); diff --git a/libnautilus-extensions/nautilus-directory-metafile.c b/libnautilus-extensions/nautilus-directory-metafile.c index 1e205e6cd..83d164961 100644 --- a/libnautilus-extensions/nautilus-directory-metafile.c +++ b/libnautilus-extensions/nautilus-directory-metafile.c @@ -172,13 +172,9 @@ set_metadata_string_in_metafile (NautilusDirectory *directory, xmlAttr *property_node; /* If the data in the metafile is already correct, do nothing. */ - if (file_name == NULL) { - old_metadata = nautilus_directory_get_metadata - (directory, key, default_metadata); - } else { - old_metadata = nautilus_directory_get_file_metadata - (directory, file_name, key, default_metadata); - } + old_metadata = nautilus_directory_get_file_metadata + (directory, file_name, key, default_metadata); + old_metadata_matches = nautilus_strcmp (old_metadata, metadata) == 0; g_free (old_metadata); if (old_metadata_matches) { @@ -536,29 +532,6 @@ nautilus_directory_metafile_destroy (NautilusDirectory *directory) destroy_metadata_changes_hash_table (directory->details->metadata_changes); } -char * -nautilus_directory_get_metadata (NautilusDirectory *directory, - const char *key, - const char *default_metadata) -{ - g_return_val_if_fail (key != NULL, g_strdup (default_metadata)); - g_return_val_if_fail (key[0] != '\0', g_strdup (default_metadata)); - - /* It's legal to call this on a NULL directory. */ - if (directory == NULL) { - return g_strdup (default_metadata); - } - - g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), g_strdup (default_metadata)); - - if (directory->details->metafile_read) { - return get_metadata_string_from_metafile - (directory, NULL, key, default_metadata); - } else { - return get_metadata_string_from_table - (directory, NULL, key, default_metadata); - } -} char * nautilus_directory_get_file_metadata (NautilusDirectory *directory, @@ -582,31 +555,6 @@ nautilus_directory_get_file_metadata (NautilusDirectory *directory, } -GList * -nautilus_directory_get_metadata_list (NautilusDirectory *directory, - const char *list_key, - const char *list_subkey) -{ - g_return_val_if_fail (list_key != NULL, NULL); - g_return_val_if_fail (list_key[0] != '\0', NULL); - g_return_val_if_fail (list_subkey != NULL, NULL); - g_return_val_if_fail (list_subkey[0] != '\0', NULL); - - /* It's legal to call this on a NULL directory. */ - if (directory == NULL) { - return NULL; - } - - g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL); - - if (directory->details->metafile_read) { - return get_metadata_list_from_metafile - (directory, NULL, list_key, list_subkey); - } else { - return get_metadata_list_from_table - (directory, NULL, list_key, list_subkey); - } -} GList * nautilus_directory_get_file_metadata_list (NautilusDirectory *directory, @@ -631,58 +579,6 @@ nautilus_directory_get_file_metadata_list (NautilusDirectory *directory, } } -void -nautilus_directory_set_metadata (NautilusDirectory *directory, - const char *key, - const char *default_metadata, - const char *metadata) -{ - MetadataValue *value; - - g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory)); - g_return_if_fail (key != NULL); - g_return_if_fail (key[0] != '\0'); - - if (directory->details->metafile_read) { - if (set_metadata_string_in_metafile (directory, NULL, key, - default_metadata, metadata)) { - nautilus_directory_emit_metadata_changed (directory); - } - } else { - value = metadata_value_new (default_metadata, metadata); - if (set_metadata_eat_value (directory, NULL, key, NULL, value)) { - nautilus_directory_emit_metadata_changed (directory); - } - } -} - -void -nautilus_directory_set_metadata_list (NautilusDirectory *directory, - const char *list_key, - const char *list_subkey, - GList *list) -{ - MetadataValue *value; - - g_return_if_fail (NAUTILUS_IS_DIRECTORY (directory)); - g_return_if_fail (list_key != NULL); - g_return_if_fail (list_key[0] != '\0'); - g_return_if_fail (list_subkey != NULL); - g_return_if_fail (list_subkey[0] != '\0'); - - if (directory->details->metafile_read) { - if (set_metadata_list_in_metafile (directory, NULL, - list_key, list_subkey, list)) { - nautilus_directory_emit_metadata_changed (directory); - } - } else { - value = metadata_value_new_list (list); - if (set_metadata_eat_value (directory, NULL, - list_key, list_subkey, value)) { - nautilus_directory_emit_metadata_changed (directory); - } - } -} gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory, @@ -831,16 +727,19 @@ nautilus_directory_metafile_apply_pending_changes (NautilusDirectory *directory) directory->details->metadata_changes = NULL; } + + gboolean -nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, - const char *key, - gboolean default_metadata) +nautilus_directory_get_boolean_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + gboolean default_metadata) { char *result_as_string; gboolean result; - result_as_string = nautilus_directory_get_metadata - (directory, key, + result_as_string = nautilus_directory_get_file_metadata + (directory, file_name, key, default_metadata ? "true" : "false"); g_strdown (result_as_string); @@ -859,30 +758,32 @@ nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, return result; } -void -nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, - const char *key, - gboolean default_metadata, - gboolean metadata) -{ - nautilus_directory_set_metadata - (directory, key, +gboolean +nautilus_directory_set_boolean_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + gboolean default_metadata, + gboolean metadata) +{ + return nautilus_directory_set_file_metadata + (directory, file_name, key, default_metadata ? "true" : "false", metadata ? "true" : "false"); } int -nautilus_directory_get_integer_metadata (NautilusDirectory *directory, - const char *key, - int default_metadata) +nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + int default_metadata) { char *result_as_string; char *default_as_string; int result; default_as_string = g_strdup_printf ("%d", default_metadata); - result_as_string = nautilus_directory_get_metadata - (directory, key, default_as_string); + result_as_string = nautilus_directory_get_file_metadata + (directory, file_name, key, default_as_string); /* Handle oddball case of non-existent directory */ if (result_as_string == NULL) { @@ -897,11 +798,12 @@ nautilus_directory_get_integer_metadata (NautilusDirectory *directory, } -void -nautilus_directory_set_integer_metadata (NautilusDirectory *directory, - const char *key, - int default_metadata, - int metadata) +gboolean +nautilus_directory_set_integer_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + int default_metadata, + int metadata) { char *value_as_string; char *default_as_string; @@ -909,14 +811,16 @@ nautilus_directory_set_integer_metadata (NautilusDirectory *directory, value_as_string = g_strdup_printf ("%d", metadata); default_as_string = g_strdup_printf ("%d", default_metadata); - nautilus_directory_set_metadata - (directory, key, + return nautilus_directory_set_file_metadata + (directory, file_name, key, default_as_string, value_as_string); g_free (value_as_string); g_free (default_as_string); } + + static void copy_file_metadata_for_key (NautilusDirectory *source_directory, const char *source_file_name, diff --git a/libnautilus-extensions/nautilus-directory-metafile.h b/libnautilus-extensions/nautilus-directory-metafile.h index 330ac9aa1..3aa6f254c 100644 --- a/libnautilus-extensions/nautilus-directory-metafile.h +++ b/libnautilus-extensions/nautilus-directory-metafile.h @@ -34,6 +34,15 @@ GList * nautilus_directory_get_file_metadata_list (NautilusDirectory *d const char *file_name, const char *list_key, const char *list_subkey); +gboolean nautilus_directory_get_boolean_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + gboolean default_metadata); +int nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + int default_metadata); + gboolean nautilus_directory_set_file_metadata (NautilusDirectory *directory, const char *file_name, const char *key, @@ -44,6 +53,17 @@ gboolean nautilus_directory_set_file_metadata_list (NautilusDirectory *d const char *list_key, const char *list_subkey, GList *list); +gboolean nautilus_directory_set_boolean_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + gboolean default_metadata, + gboolean metadata); +gboolean nautilus_directory_set_integer_file_metadata (NautilusDirectory *directory, + const char *file_name, + const char *key, + int default_metadata, + int metadata); + void nautilus_directory_copy_file_metadata (NautilusDirectory *source_directory, const char *source_file_name, NautilusDirectory *destination_directory, diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c index 7ecbcf8af..5ab99d517 100644 --- a/libnautilus-extensions/nautilus-directory.c +++ b/libnautilus-extensions/nautilus-directory.c @@ -46,7 +46,6 @@ enum { FILES_ADDED, FILES_CHANGED, - METADATA_CHANGED, DONE_LOADING, LAST_SIGNAL }; @@ -99,13 +98,6 @@ nautilus_directory_initialize_class (NautilusDirectoryClass *klass) GTK_SIGNAL_OFFSET (NautilusDirectoryClass, files_changed), gtk_marshal_NONE__POINTER, GTK_TYPE_NONE, 1, GTK_TYPE_POINTER); - signals[METADATA_CHANGED] = - gtk_signal_new ("metadata_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusDirectoryClass, metadata_changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); signals[DONE_LOADING] = gtk_signal_new ("done_loading", GTK_RUN_LAST, @@ -659,10 +651,6 @@ nautilus_directory_emit_change_signals_deep (NautilusDirectory *directory, void nautilus_directory_emit_metadata_changed (NautilusDirectory *directory) { - /* Tell that the directory metadata has changed. */ - gtk_signal_emit (GTK_OBJECT (directory), - signals[METADATA_CHANGED]); - /* Say that all the files have changed. * We could optimize this to only mention files that * have metadata, but this is a fine rough cut for now. @@ -1284,7 +1272,6 @@ static void got_metadata_callback (NautilusDirectory *directory, GList *files, gpointer callback_data) { g_assert (NAUTILUS_IS_DIRECTORY (directory)); - g_assert (files == NULL); g_assert (callback_data == &data_dummy); got_metadata_flag = TRUE; @@ -1311,9 +1298,11 @@ void nautilus_self_check_directory (void) { NautilusDirectory *directory; + NautilusFile *file; GList *attributes; directory = nautilus_directory_get ("file:///etc"); + file = nautilus_file_get ("file:///etc/passwd"); NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); @@ -1332,23 +1321,23 @@ nautilus_self_check_directory (void) gtk_main_iteration (); } - nautilus_directory_set_metadata (directory, "TEST", "default", "value"); - NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value"); + nautilus_file_set_metadata (file, "TEST", "default", "value"); + NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_metadata (file, "TEST", "default"), "value"); - nautilus_directory_set_boolean_metadata (directory, "TEST_BOOLEAN", TRUE, TRUE); - NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get_boolean_metadata (directory, "TEST_BOOLEAN", TRUE), TRUE); - nautilus_directory_set_boolean_metadata (directory, "TEST_BOOLEAN", TRUE, FALSE); - NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get_boolean_metadata (directory, "TEST_BOOLEAN", TRUE), FALSE); - NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get_boolean_metadata (NULL, "TEST_BOOLEAN", TRUE), TRUE); + nautilus_file_set_boolean_metadata (file, "TEST_BOOLEAN", TRUE, TRUE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (file, "TEST_BOOLEAN", TRUE), TRUE); + nautilus_file_set_boolean_metadata (file, "TEST_BOOLEAN", TRUE, FALSE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (file, "TEST_BOOLEAN", TRUE), FALSE); + NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_file_get_boolean_metadata (NULL, "TEST_BOOLEAN", TRUE), TRUE); - nautilus_directory_set_integer_metadata (directory, "TEST_INTEGER", 0, 17); - NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_get_integer_metadata (directory, "TEST_INTEGER", 0), 17); - nautilus_directory_set_integer_metadata (directory, "TEST_INTEGER", 0, -1); - NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_get_integer_metadata (directory, "TEST_INTEGER", 0), -1); - nautilus_directory_set_integer_metadata (directory, "TEST_INTEGER", 42, 42); - NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_get_integer_metadata (directory, "TEST_INTEGER", 42), 42); - NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_get_integer_metadata (NULL, "TEST_INTEGER", 42), 42); - NAUTILUS_CHECK_INTEGER_RESULT (nautilus_directory_get_integer_metadata (directory, "NONEXISTENT_KEY", 42), 42); + nautilus_file_set_integer_metadata (file, "TEST_INTEGER", 0, 17); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "TEST_INTEGER", 0), 17); + nautilus_file_set_integer_metadata (file, "TEST_INTEGER", 0, -1); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "TEST_INTEGER", 0), -1); + nautilus_file_set_integer_metadata (file, "TEST_INTEGER", 42, 42); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "TEST_INTEGER", 42), 42); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (NULL, "TEST_INTEGER", 42), 42); + NAUTILUS_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "NONEXISTENT_KEY", 42), 42); NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc") == directory, TRUE); nautilus_directory_unref (directory); @@ -1359,6 +1348,8 @@ nautilus_self_check_directory (void) NAUTILUS_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc////") == directory, TRUE); nautilus_directory_unref (directory); + nautilus_file_unref (file); + nautilus_directory_file_monitor_remove (directory, &data_dummy); nautilus_directory_unref (directory); @@ -1399,7 +1390,11 @@ nautilus_self_check_directory (void) NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1); - NAUTILUS_CHECK_STRING_RESULT (nautilus_directory_get_metadata (directory, "TEST", "default"), "value"); + file = nautilus_file_get ("file:///etc/passwd"); + + NAUTILUS_CHECK_STRING_RESULT (nautilus_file_get_metadata (file, "TEST", "default"), "value"); + + nautilus_file_unref (file); nautilus_directory_unref (directory); diff --git a/libnautilus-extensions/nautilus-directory.h b/libnautilus-extensions/nautilus-directory.h index 671b3a686..8d895d59d 100644 --- a/libnautilus-extensions/nautilus-directory.h +++ b/libnautilus-extensions/nautilus-directory.h @@ -93,12 +93,6 @@ typedef struct void (* files_changed) (NautilusDirectory *directory, GList *changed_files); - /* The metadata_changed signal is emitted when changes to the metadata - * for the directory itself are made. Changes to file metadata just - * result in calls to files_changed. - */ - void (* metadata_changed) (NautilusDirectory *directory); - /* The done_loading signal is emitted when a directory load * request completes. This is needed because, at least in the * case where the directory is empty, the caller will receive @@ -169,37 +163,6 @@ void nautilus_directory_cancel_callback (NautilusDirectory NautilusDirectoryCallback callback, gpointer callback_data); -/* Getting and setting metadata. */ -char * nautilus_directory_get_metadata (NautilusDirectory *directory, - const char *key, - const char *default_metadata); -GList *nautilus_directory_get_metadata_list (NautilusDirectory *directory, - const char *list_key, - const char *list_subkey); -void nautilus_directory_set_metadata (NautilusDirectory *directory, - const char *key, - const char *default_metadata, - const char *metadata); -void nautilus_directory_set_metadata_list (NautilusDirectory *directory, - const char *list_key, - const char *list_subkey, - GList *list); - -/* Covers for common data types. */ -gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, - const char *key, - gboolean default_metadata); -void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, - const char *key, - gboolean default_metadata, - gboolean metadata); -int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, - const char *key, - int default_metadata); -void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, - const char *key, - int default_metadata, - int metadata); /* Monitor the files in a directory. */ void nautilus_directory_file_monitor_add (NautilusDirectory *directory, diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c index 8aa3b889e..f01b075e4 100644 --- a/libnautilus-extensions/nautilus-file.c +++ b/libnautilus-extensions/nautilus-file.c @@ -1661,6 +1661,87 @@ nautilus_file_set_metadata_list (NautilusFile *file, } } + +gboolean +nautilus_file_get_boolean_metadata (NautilusFile *file, + const char *key, + gboolean default_metadata) +{ + g_return_val_if_fail (key != NULL, default_metadata); + g_return_val_if_fail (key[0] != '\0', default_metadata); + if (file == NULL) { + return default_metadata; + } + g_return_val_if_fail (NAUTILUS_IS_FILE (file), default_metadata); + + return nautilus_directory_get_boolean_file_metadata + (file->details->directory, + file->details->name, + key, + default_metadata); +} + +int +nautilus_file_get_integer_metadata (NautilusFile *file, + const char *key, + int default_metadata) +{ + g_return_val_if_fail (key != NULL, default_metadata); + g_return_val_if_fail (key[0] != '\0', default_metadata); + if (file == NULL) { + return default_metadata; + } + g_return_val_if_fail (NAUTILUS_IS_FILE (file), default_metadata); + + return nautilus_directory_get_integer_file_metadata + (file->details->directory, + file->details->name, + key, + default_metadata); +} + + +void +nautilus_file_set_boolean_metadata (NautilusFile *file, + const char *key, + gboolean default_metadata, + gboolean metadata) +{ + g_return_if_fail (NAUTILUS_IS_FILE (file)); + g_return_if_fail (key != NULL); + g_return_if_fail (key[0] != '\0'); + + if (nautilus_directory_set_boolean_file_metadata (file->details->directory, + file->details->name, + key, + default_metadata, + metadata)) { + nautilus_file_changed (file); + } +} + +void +nautilus_file_set_integer_metadata (NautilusFile *file, + const char *key, + int default_metadata, + int metadata) +{ + g_return_if_fail (NAUTILUS_IS_FILE (file)); + g_return_if_fail (key != NULL); + g_return_if_fail (key[0] != '\0'); + + if (nautilus_directory_set_integer_file_metadata (file->details->directory, + file->details->name, + key, + default_metadata, + metadata)) { + nautilus_file_changed (file); + } +} + + + + char * nautilus_file_get_name (NautilusFile *file) { diff --git a/libnautilus-extensions/nautilus-file.h b/libnautilus-extensions/nautilus-file.h index 70882c926..b8bf1c191 100644 --- a/libnautilus-extensions/nautilus-file.h +++ b/libnautilus-extensions/nautilus-file.h @@ -213,6 +213,23 @@ void nautilus_file_set_metadata_list (NautilusFile const char *list_subkey, GList *list); +/* Covers for common data types. */ +gboolean nautilus_file_get_boolean_metadata (NautilusFile *file, + const char *key, + gboolean default_metadata); +void nautilus_file_set_boolean_metadata (NautilusFile *file, + const char *key, + gboolean default_metadata, + gboolean metadata); +int nautilus_file_get_integer_metadata (NautilusFile *file, + const char *key, + int default_metadata); +void nautilus_file_set_integer_metadata (NautilusFile *file, + const char *key, + int default_metadata, + int metadata); + + /* Attributes for file objects as user-displayable strings. */ char * nautilus_file_get_string_attribute (NautilusFile *file, const char *attribute_name); diff --git a/libnautilus-extensions/nautilus-metadata.h b/libnautilus-extensions/nautilus-metadata.h index c4c1c4500..3de64b564 100644 --- a/libnautilus-extensions/nautilus-metadata.h +++ b/libnautilus-extensions/nautilus-metadata.h @@ -29,7 +29,7 @@ * should define its key here, so we can keep track of the whole set easily. */ -/* Per-directory */ +/* Per-file */ #define NAUTILUS_METADATA_KEY_CONTENT_VIEWS "CONTENT_VIEWS" @@ -45,10 +45,8 @@ #define NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT "EXPLICIT_CONTENT_VIEW" #define NAUTILUS_METADATA_SUBKEY_COMPONENT_IID "IID" -#define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY "WINDOW_GEOMETRY" - -#define NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR "BACKGROUND_COLOR" -#define NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE "BACKGROUND_TILE_IMAGE" +#define NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_COLOR "BACKGROUND_COLOR" +#define NAUTILUS_METADATA_KEY_LOCATION_BACKGROUND_IMAGE "BACKGROUND_TILE_IMAGE" #define NAUTILUS_METADATA_KEY_ICON_VIEW_ZOOM_LEVEL "ICONS_ZOOM_LEVEL" #define NAUTILUS_METADATA_KEY_ICON_VIEW_AUTO_LAYOUT "ICONS_AUTO_LAYOUT" @@ -60,14 +58,14 @@ #define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_COLUMN "LIST_SORT_COLUMN" #define NAUTILUS_METADATA_KEY_LIST_VIEW_SORT_REVERSED "LIST_SORT_REVERSED" +#define NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY "WINDOW_GEOMETRY" + #define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR "SIDEBAR_BACKGROUND_COLOR" #define NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE "SIDEBAR_BACKGROUND_TILE_IMAGE" #define NAUTILUS_METADATA_KEY_SIDEBAR_BUTTONS "SIDEBAR_BUTTONS" #define NAUTILUS_METADATA_KEY_SIDEBAR_TAB_COLOR "SIDEBAR_TAB_COLOR" #define NAUTILUS_METADATA_KEY_SIDEBAR_TITLE_TAB_COLOR "SIDEBAR_TITLE_TAB_COLOR" -/* Per-file */ - #define NAUTILUS_METADATA_KEY_NOTES "NOTES" #define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_ICON_POSITION "ICON_POSITION" diff --git a/libnautilus-extensions/nautilus-mime-actions.c b/libnautilus-extensions/nautilus-mime-actions.c index 60fe4b3f3..2533a9ac1 100644 --- a/libnautilus-extensions/nautilus-mime-actions.c +++ b/libnautilus-extensions/nautilus-mime-actions.c @@ -53,7 +53,7 @@ static char *extract_prefix_add_suffix (const char const char *suffix); static char *mime_type_get_supertype (const char *mime_type); static char *uri_string_get_scheme (const char *uri_string); -static GList *get_explicit_content_view_iids_from_metafile (NautilusDirectory *directory); +static GList *get_explicit_content_view_iids_from_metafile (NautilusFile *file); static char *make_oaf_query_for_explicit_content_view_iids (GList *view_iids); static char *make_oaf_query_with_known_mime_type (const char *mime_type, const char *uri_scheme, @@ -99,9 +99,8 @@ is_known_mime_type (const char *mime_type) } static void -nautilus_directory_wait_for_metadata (NautilusDirectory *directory) +nautilus_file_wait_for_metadata (NautilusFile *file) { - GList *file_list; GList *attributes; /* When nautilus_directory_wait_until_ready is called this way, it @@ -111,9 +110,8 @@ nautilus_directory_wait_for_metadata (NautilusDirectory *directory) */ attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); - file_list = nautilus_directory_wait_until_ready (directory, attributes); + nautilus_file_wait_until_ready (file, attributes); g_list_free (attributes); - nautilus_file_list_free (file_list); } GnomeVFSMimeActionType @@ -124,9 +122,10 @@ nautilus_mime_get_default_action_type_for_uri (NautilusDirectory *directory, char *action_type_string; GnomeVFSMimeActionType action_type; - nautilus_directory_wait_for_metadata (directory); - action_type_string = nautilus_directory_get_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL); + nautilus_file_wait_for_metadata (file); + + action_type_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL); if (action_type_string == NULL) { mime_type = get_mime_type_from_file (file); @@ -194,9 +193,9 @@ nautilus_mime_get_default_application_for_uri_internal (NautilusDirectory *direc used_user_chosen_info = TRUE; - nautilus_directory_wait_for_metadata (directory); - default_application_string = nautilus_directory_get_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); + nautilus_file_wait_for_metadata (file); + default_application_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL); if (default_application_string == NULL) { mime_type = get_mime_type_from_file (file); @@ -278,17 +277,18 @@ nautilus_mime_get_default_component_for_uri_internal (NautilusDirectory *directo g_free (uri); + nautilus_file_wait_for_metadata (file); + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + /* Arrange for all the file attributes we will need. */ attributes = NULL; attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); - files = nautilus_directory_wait_until_ready (directory, attributes); - default_component_string = nautilus_directory_get_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); - explicit_iids = get_explicit_content_view_iids_from_metafile (directory); g_list_free (attributes); + default_component_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); + if (default_component_string == NULL && is_known_mime_type (mime_type)) { mime_default = gnome_vfs_mime_get_default_component (mime_type); if (mime_default != NULL) { @@ -438,13 +438,13 @@ nautilus_mime_get_short_list_applications_for_uri (NautilusDirectory *directory, CORBA_exception_init (&ev); - nautilus_directory_wait_for_metadata (directory); - metadata_application_add_ids = nautilus_directory_get_metadata_list - (directory, + nautilus_file_wait_for_metadata (file); + metadata_application_add_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - metadata_application_remove_ids = nautilus_directory_get_metadata_list - (directory, + metadata_application_remove_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); @@ -507,21 +507,22 @@ nautilus_mime_get_short_list_components_for_uri (NautilusDirectory *directory, g_free (uri); + nautilus_file_wait_for_metadata (file); + explicit_iids = get_explicit_content_view_iids_from_metafile (file); + /* Arrange for all the file attributes we will need. */ attributes = NULL; attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); - files = nautilus_directory_wait_until_ready (directory, attributes); - explicit_iids = get_explicit_content_view_iids_from_metafile (directory); g_list_free (attributes); - metadata_component_add_ids = nautilus_directory_get_metadata_list - (directory, + + metadata_component_add_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); - metadata_component_remove_ids = nautilus_directory_get_metadata_list - (directory, + metadata_component_remove_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); @@ -608,9 +609,9 @@ nautilus_mime_get_all_applications_for_uri (NautilusDirectory *directory, GList *p; GnomeVFSMimeApplication *application; - nautilus_directory_wait_for_metadata (directory); - metadata_application_ids = nautilus_directory_get_metadata_list - (directory, + nautilus_file_wait_for_metadata (file); + metadata_application_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); @@ -668,14 +669,15 @@ nautilus_mime_get_all_components_for_uri (NautilusDirectory *directory, uri = nautilus_file_get_uri (file); uri_scheme = uri_string_get_scheme (uri); g_free (uri); + + nautilus_file_wait_for_metadata (file); + explicit_iids = get_explicit_content_view_iids_from_metafile (file); /* Arrange for all the file attributes we will need. */ attributes = NULL; attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE); - attributes = g_list_append (NULL, NAUTILUS_FILE_ATTRIBUTE_METADATA); files = nautilus_directory_wait_until_ready (directory, attributes); - explicit_iids = get_explicit_content_view_iids_from_metafile (directory); g_list_free (attributes); info_list = nautilus_do_component_query (mime_type, uri_scheme, files, explicit_iids, NULL, NULL, &ev); @@ -721,9 +723,9 @@ nautilus_mime_set_default_action_type_for_uri (NautilusDirectory *directory action_string = "none"; } - nautilus_directory_wait_for_metadata (directory); - nautilus_directory_set_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL, action_string); + nautilus_file_wait_for_metadata (file); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_ACTION_TYPE, NULL, action_string); return GNOME_VFS_OK; } @@ -733,9 +735,9 @@ nautilus_mime_set_default_application_for_uri (NautilusDirectory *directory, NautilusFile *file, const char *application_id) { - nautilus_directory_wait_for_metadata (directory); - nautilus_directory_set_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL, application_id); + nautilus_file_wait_for_metadata (file); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_APPLICATION, NULL, application_id); /* If there's no default action type, set it to match this. */ if (application_id != NULL && @@ -751,9 +753,9 @@ nautilus_mime_set_default_component_for_uri (NautilusDirectory *directory, NautilusFile *file, const char *component_iid) { - nautilus_directory_wait_for_metadata (directory); - nautilus_directory_set_metadata - (directory, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL, component_iid); + nautilus_file_wait_for_metadata (file); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL, component_iid); /* If there's no default action type, set it to match this. */ if (component_iid != NULL && @@ -792,14 +794,14 @@ nautilus_mime_set_short_list_applications_for_uri (NautilusDirectory *directory, add_list = str_list_difference (applications, normal_short_list_ids); remove_list = str_list_difference (normal_short_list_ids, applications); - nautilus_directory_wait_for_metadata (directory); - nautilus_directory_set_metadata_list - (directory, + nautilus_file_wait_for_metadata (file); + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_ADD, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, add_list); - nautilus_directory_set_metadata_list - (directory, + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_APPLICATION_REMOVE, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, remove_list); @@ -839,14 +841,14 @@ nautilus_mime_set_short_list_components_for_uri (NautilusDirectory *directory, add_list = str_list_difference (components, normal_short_list_ids); remove_list = str_list_difference (normal_short_list_ids, components); - nautilus_directory_wait_for_metadata (directory); - nautilus_directory_set_metadata_list - (directory, + nautilus_file_wait_for_metadata (file); + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_ADD, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, add_list); - nautilus_directory_set_metadata_list - (directory, + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_SHORT_LIST_COMPONENT_REMOVE, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID, remove_list); @@ -967,10 +969,10 @@ nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, GList *extras; GList *final_applications; - nautilus_directory_wait_for_metadata (directory); + nautilus_file_wait_for_metadata (file); - metadata_application_ids = nautilus_directory_get_metadata_list - (directory, + metadata_application_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); @@ -978,8 +980,8 @@ nautilus_mime_extend_all_applications_for_uri (NautilusDirectory *directory, final_applications = g_list_concat (g_list_copy (metadata_application_ids), extras); - nautilus_directory_set_metadata_list - (directory, + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, final_applications); @@ -995,21 +997,21 @@ nautilus_mime_remove_from_all_applications_for_uri (NautilusDirectory *directory GList *metadata_application_ids; GList *final_applications; - nautilus_directory_wait_for_metadata (directory); + nautilus_file_wait_for_metadata (file); - metadata_application_ids = nautilus_directory_get_metadata_list - (directory, + metadata_application_ids = nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID); - + final_applications = str_list_difference (metadata_application_ids, applications); - - nautilus_directory_set_metadata_list - (directory, + + nautilus_file_set_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_APPLICATION, NAUTILUS_METADATA_SUBKEY_APPLICATION_ID, final_applications); - + return GNOME_VFS_OK; } @@ -1091,11 +1093,11 @@ uri_string_get_scheme (const char *uri_string) */ static GList * -get_explicit_content_view_iids_from_metafile (NautilusDirectory *directory) +get_explicit_content_view_iids_from_metafile (NautilusFile *file) { - if (directory != NULL) { - return nautilus_directory_get_metadata_list - (directory, + if (file != NULL) { + return nautilus_file_get_metadata_list + (file, NAUTILUS_METADATA_KEY_EXPLICIT_COMPONENT, NAUTILUS_METADATA_SUBKEY_COMPONENT_IID); } else { |