diff options
31 files changed, 850 insertions, 504 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index 9adabf6ea..2c66a4d2f 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,16 +1,53 @@ -2000-04-10 Andy Hertzfeld <andy@eazel.com> +2000-04-10 Darin Adler <darin@eazel.com> + + Finished changing all callers that use metadata to use it in a way + that is compatible with async. metadata reading. + + * components/notes/ntl-notes.c: + (notes_load_metainfo): Changed to use nautilus_file_call_when_ready + to wait for the metadata. Also fixed a bug that was causing an assert + inside the call to gtk_editable_insert_text. + (main): Made warnings and criticals stop in the debugger. + + * libnautilus/nautilus-directory.c: + * libnautilus/nautilus-directory.h: + (nautilus_directory_call_when_ready): Renamed the call to indicate + it can wait for more than just metadata. For now it does only wait + for metadata, though. + (nautilus_directory_cancel_callback): Renamed this too. + + * libnautilus/nautilus-file.c: + (nautilus_file_call_when_ready), (nautilus_file_cancel_callback): + Made a corresponding call for the metadata of a single file. + + * libnautilus/nautilus-gdk-extensions.c: + * src/nautilus-index-title.c: + Formatting changes. + + * libnautilus/nautilus-metadata.h: + Clarified that ANNOTATION is a per-file piece of metadata. + + * src/ntl-uri-map.c: + * src/file-manager/fm-directory-view.c: + Use new names of calls. + + * src/file-manager/fm-icon-view.c: + * src/file-manager/fm-list-view.c: + Added comment. + +2000-04-10 Andy Hertzfeld <andy@eazel.com> * src/nautilus-index-title.c: fixed bug where multi-line titles in index panel would have a big vertical gap. Fixed by breaking out of the loop after it finds a split point. Also, removed an unneccesary justification call. -2000-04-10 Andy Hertzfeld <andy@eazel.com> +2000-04-10 Andy Hertzfeld <andy@eazel.com> * components/services/startup/eazel-register.c: added io ports to hardware configuration synopsis - -2000-04-10 John Sullivan <sullivan@eazel.com> + +2000-04-10 John Sullivan <sullivan@eazel.com> Fixed bug 377 (clipping emblems in list view looks bad and loses information) @@ -19,7 +56,7 @@ (draw_row): Made it draw the ellipsis character if there's not enough room to show all emblems. -2000-04-10 John Sullivan <sullivan@eazel.com> +2000-04-10 John Sullivan <sullivan@eazel.com> * libnautilus/nautilus-list.c: (nautilus_list_initialize_class), (nautilus_list_initialize), @@ -35,17 +72,18 @@ such operations as Select All, switch-from-icon-view-with-lots- selected, and arrow-key-to-end-of-list significantly faster. -2000-04-09 Andy Hertzfeld <andy@eazel.com> +2000-04-09 Andy Hertzfeld <andy@eazel.com> * components/services/startup/nautilus-service-startup-view.c: - now it saves the account toke assigned by the service, and passes it back in the - header of subsequent requests + now it saves the account token assigned by the service, and passes + it back in the header of subsequent requests * libnautilus/nautilus-icon-factory.c: - fixed bug #293, thumbnails of thumbnails endlessly, by explicitly testing for thumbnails - of thumbnails as part of the criteria for making them - also, make a "snapshot" frame for thumbnails (task 295) + fixed bug #293, thumbnails of thumbnails endlessly, by explicitly + testing for thumbnails of thumbnails as part of the criteria for + making them also, make a "snapshot" frame for thumbnails (task + 295) -2000-04-09 John Sullivan <sullivan@eazel.com> +2000-04-09 John Sullivan <sullivan@eazel.com> Finished task 307 (keyboard navigation in list view should use same keys/behavior as in icon view). There are a few @@ -78,13 +116,13 @@ functions that were used by the GtkCList key bindings in favor of nautilus_list_key_press and friends. -2000-04-07 Andy Hertzfeld <andy@eazel.com> +2000-04-07 Andy Hertzfeld <andy@eazel.com> * libnautilus/nautilus-icon-canvas-item.c: inspired by John's list view underlining, the text beneath icons is now underlined when the icon is pre-lit -2000-04-07 John Sullivan <sullivan@eazel.com> +2000-04-07 John Sullivan <sullivan@eazel.com> Fixed bug Andy pointed out where list view "links" could be activated by clicking in white space past the name. @@ -128,26 +166,28 @@ (draw_row) Use get_cell_horizontal_start_position that was extracted from this function. -2000-04-07 Andy Hertzfeld <andy@eazel.com> +2000-04-07 Andy Hertzfeld <andy@eazel.com> * components/services/startup/nautilus-service-startup-view.c: switched over to using Jonathan's prototype service, which is only accessible from eazel's intranet for now. Registration now works with the service. + * libnautilus/nautilus-icon-canvas-item.c: first, simple version of drag/swallow highliting - it just darkens the icon and emboldens the text, exactly like selection highlighting. Pavel's going to set the flag during dragging soon, so this will help him see what he's doing. Soon, we'll have a more elaborate approach. -2000-04-06 Andy Hertzfeld <andy@eazel.com> +2000-04-06 Andy Hertzfeld <andy@eazel.com> * components/services/startup/nautilus-service-startup-view.c: made configuration upload make the HTTP request and handle errors, but still not quite finished, since it's not passing the cookie back yet. Also, created a stub summary page plus minor clean-ups -2000-04-06 Pavel Cisler <pavel@eazel.com> +2000-04-06 Pavel Cisler <pavel@eazel.com> + * src/file-manager/dfos-xfer-progress-dialog.c: * src/file-manager/dfos-xfer-progress-dialog.h: (dfos_xfer_progress_dialog_new_file): @@ -176,7 +216,7 @@ (fs_xfer): New copy engine main entry. -2000-04-06 Andy Hertzfeld <andy@eazel.com> +2000-04-06 Andy Hertzfeld <andy@eazel.com> * components/services/startup/nautilus-service-startup-view.c: more work to polish registration and implement configuration upload, diff --git a/components/notes/nautilus-notes.c b/components/notes/nautilus-notes.c index 23bfb911f..878522f37 100644 --- a/components/notes/nautilus-notes.c +++ b/components/notes/nautilus-notes.c @@ -36,77 +36,103 @@ #include <ctype.h> #include <libnautilus/nautilus-background.h> #include <libnautilus/nautilus-file.h> +#include <libnautilus/nautilus-debug.h> #define NOTES_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/BBBB" typedef struct { NautilusViewFrame *view; GtkWidget *note_text_field; - char* uri; -} NotesView; + char *uri; + NautilusFile *file; +} Notes; static int notes_object_count = 0; static void -notes_load_metainfo (NotesView *hview) +finish_loading_note (NautilusFile *file, + gpointer callback_data) { - NautilusFile *file; + Notes *notes; int position; char *notes_text; - - gtk_editable_delete_text (GTK_EDITABLE (hview->note_text_field), 0, -1); - - file = nautilus_file_get (hview->uri); - if (file == NULL) { - return; - } - + + g_assert (NAUTILUS_IS_FILE (file)); + + notes = callback_data; + g_assert (notes->file == file); + notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, ""); - gtk_editable_insert_text (GTK_EDITABLE (hview->note_text_field), + position = 0; + gtk_editable_insert_text (GTK_EDITABLE (notes->note_text_field), notes_text, strlen (notes_text), &position); g_free (notes_text); - - nautilus_file_unref (file); } -/* save the metainfo corresponding to the current uri, if any, into the text field */ +static void +done_with_file (Notes *notes) +{ + nautilus_file_cancel_callback (notes->file, finish_loading_note, notes); + nautilus_file_unref (notes->file); +} static void -notes_save_metainfo(NotesView *hview) +notes_load_metainfo (Notes *notes) { NautilusFile *file; - char *notes_text; + GList *keys; + + gtk_editable_delete_text (GTK_EDITABLE (notes->note_text_field), 0, -1); - file = nautilus_file_get (hview->uri); + done_with_file (notes); + notes->file = nautilus_file_get (notes->uri); if (file == NULL) { return; } - notes_text = gtk_editable_get_chars (GTK_EDITABLE (hview->note_text_field), 0 , -1); - nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text); + keys = g_list_prepend (NULL, NAUTILUS_METADATA_KEY_ANNOTATION); + nautilus_file_call_when_ready (file, keys, finish_loading_note, notes); + g_list_free (keys); +} + +/* save the metainfo corresponding to the current uri, if any, into the text field */ + +static void +notes_save_metainfo (Notes *notes) +{ + char *notes_text; + + if (notes->file == NULL) { + return; + } + + notes_text = gtk_editable_get_chars (GTK_EDITABLE (notes->note_text_field), 0 , -1); + nautilus_file_set_metadata (notes->file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text); g_free (notes_text); - - nautilus_file_unref (file); } static void notes_notify_location_change (NautilusViewFrame *view, Nautilus_NavigationInfo *loci, - NotesView *hview) -{ - if (strcmp (hview->uri, loci->requested_uri) != 0) { - notes_save_metainfo (hview); - g_free (hview->uri); - hview->uri = g_strdup (loci->requested_uri); - notes_load_metainfo (hview); + Notes *notes) +{ + if (strcmp (notes->uri, loci->requested_uri) != 0) { + notes_save_metainfo (notes); + g_free (notes->uri); + notes->uri = g_strdup (loci->requested_uri); + notes_load_metainfo (notes); } } static void -do_destroy (GtkObject *obj, NotesView *hview) +do_destroy (GtkObject *obj, Notes *notes) { + done_with_file (notes); + g_free (notes->uri); + g_free (notes); + notes_object_count--; if (notes_object_count <= 0) { gtk_main_quit(); @@ -117,13 +143,13 @@ static BonoboObject * make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer closure) { GtkWidget *vbox; - NotesView *hview; + Notes *notes; NautilusBackground *background; g_return_val_if_fail (strcmp (goad_id, "ntl_notes_view") == 0, NULL); - hview = g_new0 (NotesView, 1); - hview->uri = g_strdup (""); + notes = g_new0 (Notes, 1); + notes->uri = g_strdup (""); /* allocate a vbox to hold all of the UI elements */ @@ -131,28 +157,28 @@ make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer cl /* create the text container */ - hview->note_text_field = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (hview->note_text_field), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), hview->note_text_field, TRUE, TRUE, 0); - background = nautilus_get_widget_background (GTK_WIDGET (hview->note_text_field)); + notes->note_text_field = gtk_text_new (NULL, NULL); + gtk_text_set_editable (GTK_TEXT (notes->note_text_field), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), notes->note_text_field, TRUE, TRUE, 0); + background = nautilus_get_widget_background (GTK_WIDGET (notes->note_text_field)); nautilus_background_set_color (background, NOTES_DEFAULT_BACKGROUND_COLOR); gtk_widget_show_all (vbox); /* Create CORBA object. */ - hview->view = NAUTILUS_VIEW_FRAME (nautilus_meta_view_frame_new (vbox)); - gtk_signal_connect (GTK_OBJECT (hview->view), "destroy", do_destroy, hview); + notes->view = NAUTILUS_VIEW_FRAME (nautilus_meta_view_frame_new (vbox)); + gtk_signal_connect (GTK_OBJECT (notes->view), "destroy", do_destroy, notes); notes_object_count++; /* handle events */ - gtk_signal_connect (GTK_OBJECT (hview->view), "notify_location_change", - notes_notify_location_change, hview); + gtk_signal_connect (GTK_OBJECT (notes->view), "notify_location_change", + notes_notify_location_change, notes); /* set description */ - nautilus_meta_view_frame_set_label (NAUTILUS_META_VIEW_FRAME (hview->view), + nautilus_meta_view_frame_set_label (NAUTILUS_META_VIEW_FRAME (notes->view), _("Notes")); - return BONOBO_OBJECT (hview->view); + return BONOBO_OBJECT (notes->view); } int @@ -162,6 +188,14 @@ main(int argc, char *argv[]) CORBA_ORB orb; CORBA_Environment ev; + /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. + * Unfortunately, this has to be done explicitly for each domain. + */ + if (getenv("NAUTILUS_DEBUG") != NULL) { + nautilus_make_warnings_and_criticals_stop_in_debugger + (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); + } + /* initialize CORBA and Bonobo */ CORBA_exception_init (&ev); orb = gnome_CORBA_init_with_popt_table ("ntl-notes", VERSION, &argc, argv, diff --git a/components/notes/ntl-notes.c b/components/notes/ntl-notes.c index 23bfb911f..878522f37 100644 --- a/components/notes/ntl-notes.c +++ b/components/notes/ntl-notes.c @@ -36,77 +36,103 @@ #include <ctype.h> #include <libnautilus/nautilus-background.h> #include <libnautilus/nautilus-file.h> +#include <libnautilus/nautilus-debug.h> #define NOTES_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/BBBB" typedef struct { NautilusViewFrame *view; GtkWidget *note_text_field; - char* uri; -} NotesView; + char *uri; + NautilusFile *file; +} Notes; static int notes_object_count = 0; static void -notes_load_metainfo (NotesView *hview) +finish_loading_note (NautilusFile *file, + gpointer callback_data) { - NautilusFile *file; + Notes *notes; int position; char *notes_text; - - gtk_editable_delete_text (GTK_EDITABLE (hview->note_text_field), 0, -1); - - file = nautilus_file_get (hview->uri); - if (file == NULL) { - return; - } - + + g_assert (NAUTILUS_IS_FILE (file)); + + notes = callback_data; + g_assert (notes->file == file); + notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, ""); - gtk_editable_insert_text (GTK_EDITABLE (hview->note_text_field), + position = 0; + gtk_editable_insert_text (GTK_EDITABLE (notes->note_text_field), notes_text, strlen (notes_text), &position); g_free (notes_text); - - nautilus_file_unref (file); } -/* save the metainfo corresponding to the current uri, if any, into the text field */ +static void +done_with_file (Notes *notes) +{ + nautilus_file_cancel_callback (notes->file, finish_loading_note, notes); + nautilus_file_unref (notes->file); +} static void -notes_save_metainfo(NotesView *hview) +notes_load_metainfo (Notes *notes) { NautilusFile *file; - char *notes_text; + GList *keys; + + gtk_editable_delete_text (GTK_EDITABLE (notes->note_text_field), 0, -1); - file = nautilus_file_get (hview->uri); + done_with_file (notes); + notes->file = nautilus_file_get (notes->uri); if (file == NULL) { return; } - notes_text = gtk_editable_get_chars (GTK_EDITABLE (hview->note_text_field), 0 , -1); - nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text); + keys = g_list_prepend (NULL, NAUTILUS_METADATA_KEY_ANNOTATION); + nautilus_file_call_when_ready (file, keys, finish_loading_note, notes); + g_list_free (keys); +} + +/* save the metainfo corresponding to the current uri, if any, into the text field */ + +static void +notes_save_metainfo (Notes *notes) +{ + char *notes_text; + + if (notes->file == NULL) { + return; + } + + notes_text = gtk_editable_get_chars (GTK_EDITABLE (notes->note_text_field), 0 , -1); + nautilus_file_set_metadata (notes->file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text); g_free (notes_text); - - nautilus_file_unref (file); } static void notes_notify_location_change (NautilusViewFrame *view, Nautilus_NavigationInfo *loci, - NotesView *hview) -{ - if (strcmp (hview->uri, loci->requested_uri) != 0) { - notes_save_metainfo (hview); - g_free (hview->uri); - hview->uri = g_strdup (loci->requested_uri); - notes_load_metainfo (hview); + Notes *notes) +{ + if (strcmp (notes->uri, loci->requested_uri) != 0) { + notes_save_metainfo (notes); + g_free (notes->uri); + notes->uri = g_strdup (loci->requested_uri); + notes_load_metainfo (notes); } } static void -do_destroy (GtkObject *obj, NotesView *hview) +do_destroy (GtkObject *obj, Notes *notes) { + done_with_file (notes); + g_free (notes->uri); + g_free (notes); + notes_object_count--; if (notes_object_count <= 0) { gtk_main_quit(); @@ -117,13 +143,13 @@ static BonoboObject * make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer closure) { GtkWidget *vbox; - NotesView *hview; + Notes *notes; NautilusBackground *background; g_return_val_if_fail (strcmp (goad_id, "ntl_notes_view") == 0, NULL); - hview = g_new0 (NotesView, 1); - hview->uri = g_strdup (""); + notes = g_new0 (Notes, 1); + notes->uri = g_strdup (""); /* allocate a vbox to hold all of the UI elements */ @@ -131,28 +157,28 @@ make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer cl /* create the text container */ - hview->note_text_field = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (hview->note_text_field), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), hview->note_text_field, TRUE, TRUE, 0); - background = nautilus_get_widget_background (GTK_WIDGET (hview->note_text_field)); + notes->note_text_field = gtk_text_new (NULL, NULL); + gtk_text_set_editable (GTK_TEXT (notes->note_text_field), TRUE); + gtk_box_pack_start (GTK_BOX (vbox), notes->note_text_field, TRUE, TRUE, 0); + background = nautilus_get_widget_background (GTK_WIDGET (notes->note_text_field)); nautilus_background_set_color (background, NOTES_DEFAULT_BACKGROUND_COLOR); gtk_widget_show_all (vbox); /* Create CORBA object. */ - hview->view = NAUTILUS_VIEW_FRAME (nautilus_meta_view_frame_new (vbox)); - gtk_signal_connect (GTK_OBJECT (hview->view), "destroy", do_destroy, hview); + notes->view = NAUTILUS_VIEW_FRAME (nautilus_meta_view_frame_new (vbox)); + gtk_signal_connect (GTK_OBJECT (notes->view), "destroy", do_destroy, notes); notes_object_count++; /* handle events */ - gtk_signal_connect (GTK_OBJECT (hview->view), "notify_location_change", - notes_notify_location_change, hview); + gtk_signal_connect (GTK_OBJECT (notes->view), "notify_location_change", + notes_notify_location_change, notes); /* set description */ - nautilus_meta_view_frame_set_label (NAUTILUS_META_VIEW_FRAME (hview->view), + nautilus_meta_view_frame_set_label (NAUTILUS_META_VIEW_FRAME (notes->view), _("Notes")); - return BONOBO_OBJECT (hview->view); + return BONOBO_OBJECT (notes->view); } int @@ -162,6 +188,14 @@ main(int argc, char *argv[]) CORBA_ORB orb; CORBA_Environment ev; + /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. + * Unfortunately, this has to be done explicitly for each domain. + */ + if (getenv("NAUTILUS_DEBUG") != NULL) { + nautilus_make_warnings_and_criticals_stop_in_debugger + (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); + } + /* initialize CORBA and Bonobo */ CORBA_exception_init (&ev); orb = gnome_CORBA_init_with_popt_table ("ntl-notes", VERSION, &argc, argv, diff --git a/libnautilus-extensions/nautilus-directory.c b/libnautilus-extensions/nautilus-directory.c index be2fe0079..a4b329494 100644 --- a/libnautilus-extensions/nautilus-directory.c +++ b/libnautilus-extensions/nautilus-directory.c @@ -1083,19 +1083,20 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory, } void -nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data) { /* For now, it's synchronous for testing. */ (* callback) (directory, callback_data); } void -nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data) { } diff --git a/libnautilus-extensions/nautilus-directory.h b/libnautilus-extensions/nautilus-directory.h index 3083e4084..fcaf27d19 100644 --- a/libnautilus-extensions/nautilus-directory.h +++ b/libnautilus-extensions/nautilus-directory.h @@ -56,77 +56,82 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass; #define NAUTILUS_IS_DIRECTORY_CLASS(klass) \ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY)) -typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory, - gpointer callback_data); -typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, - GList *files, - gpointer callback_data); +typedef void (*NautilusDirectoryCallback) (NautilusDirectory *directory, + gpointer callback_data); +typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, + GList *files, + gpointer callback_data); /* Basic GtkObject requirements. */ -GtkType nautilus_directory_get_type (void); +GtkType nautilus_directory_get_type (void); /* 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 (const char *uri); +NautilusDirectory *nautilus_directory_get (const char *uri); /* Convenience functions, since we do a lot of ref'ing and unref'ing. */ -void nautilus_directory_ref (NautilusDirectory *directory); -void nautilus_directory_unref (NautilusDirectory *directory); +void nautilus_directory_ref (NautilusDirectory *directory); +void nautilus_directory_unref (NautilusDirectory *directory); /* Access to a URI. */ -char * nautilus_directory_get_uri (NautilusDirectory *directory); +char * nautilus_directory_get_uri (NautilusDirectory *directory); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data); +void nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data); /* Getting and setting metadata. */ -char * nautilus_directory_get_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata); -void nautilus_directory_set_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata, - const char *metadata); -void nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data); -void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data); +char * nautilus_directory_get_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata); +void nautilus_directory_set_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata, + const char *metadata); /* Covers for common data types. */ -gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata); -void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata, - gboolean metadata); -int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata); -void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata, - int metadata); +gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata); +void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata, + gboolean metadata); +int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata); +void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata, + int metadata); /* Monitor the files in a directory. */ -void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, - NautilusFileListCallback initial_files_callback, - gpointer callback_data); -void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); +void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, + NautilusFileListCallback initial_files_callback, + gpointer callback_data); +void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); /* Return true if the directory has information about all the files. * This will be false until the directory has been read at least once. */ -gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); +gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); /* Return true if the directory metadata has been loaded. * Until this is true, get_metadata calls will return defaults. * (We could have another way to indicate "don't know".) */ -gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); +gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); typedef struct NautilusDirectoryDetails NautilusDirectoryDetails; @@ -143,25 +148,24 @@ struct NautilusDirectoryClass /*** Notification signals for clients to connect to. ***/ /* The files_added signal is emitted as the directory model - discovers new files. - */ + * discovers new files. + */ void (* files_added) (NautilusDirectory *directory, GList *added_files); /* The files_changed signal is emitted as changes occur to - existing files that are noticed by the synchronization framework, - including when an old file has been deleted. When an old file - has been deleted, this is the last chance to forget about these - file objects, which are about to be unref'd. Use nautilus_file_is_gone () - to test for this case. - The client must register which file attributes it is interested - in. Changes to other attributes are not reported via the signal. - */ + * existing files that are noticed by the synchronization framework, + * including when an old file has been deleted. When an old file + * has been deleted, this is the last chance to forget about these + * file objects, which are about to be unref'd. Use a call to + * nautilus_file_is_gone () to test for this case. + */ 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. + * for the directory itself are made. Changes to file metadata just + * result in calls to files_changed. */ void (* metadata_changed) (NautilusDirectory *directory); }; diff --git a/libnautilus-extensions/nautilus-file.c b/libnautilus-extensions/nautilus-file.c index 62f9795d3..0ed7bf771 100644 --- a/libnautilus-extensions/nautilus-file.c +++ b/libnautilus-extensions/nautilus-file.c @@ -1407,6 +1407,23 @@ nautilus_file_is_gone (NautilusFile *file) return file->details->is_gone; } +void +nautilus_file_call_when_ready (NautilusFile *file, + GList *file_metadata_tags, + NautilusFileCallback callback, + gpointer callback_data) +{ + /* For now, it's synchronous for testing. */ + (* callback) (file, callback_data); +} + +void +nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data) +{ +} + /** * nautilus_file_list_ref * diff --git a/libnautilus-extensions/nautilus-file.h b/libnautilus-extensions/nautilus-file.h index 1cb8b3b4c..6cc0c79be 100644 --- a/libnautilus-extensions/nautilus-file.h +++ b/libnautilus-extensions/nautilus-file.h @@ -56,6 +56,9 @@ typedef enum { NAUTILUS_FILE_SORT_BY_EMBLEMS } NautilusFileSortType; +typedef void (*NautilusFileCallback) (NautilusFile *file, + gpointer callback_data); + /* GtkObject requirements. */ GtkType nautilus_file_get_type (void); @@ -67,8 +70,17 @@ void nautilus_file_ref (NautilusFile * void nautilus_file_unref (NautilusFile *file); void nautilus_file_delete (NautilusFile *file); -/* Change notification. */ -void nautilus_file_changed (NautilusFile *file); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_file_call_when_ready (NautilusFile *file, + GList *metadata_tags, + NautilusFileCallback callback, + gpointer callback_data); +void nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data); /* Basic attributes for file objects. */ char * nautilus_file_get_name (NautilusFile *file); @@ -84,11 +96,12 @@ guint nautilus_file_get_directory_item_count (NautilusFile * GList * nautilus_file_get_keywords (NautilusFile *file); void nautilus_file_set_keywords (NautilusFile *file, GList *keywords); -GList * nautilus_file_get_emblem_names (NautilusFile *file); -gboolean nautilus_file_can_rename (NautilusFile *file); -GnomeVFSResult nautilus_file_rename (NautilusFile *file, - const char *new_name); +GList * nautilus_file_get_emblem_names (NautilusFile *file); +/* Basic operations for file objects. */ +gboolean nautilus_file_can_rename (NautilusFile *file); +GnomeVFSResult nautilus_file_rename (NautilusFile *file, + const char *new_name); /* Return true if this file has already been deleted. This object will be unref'd after sending the files_removed signal, @@ -117,6 +130,13 @@ int nautilus_file_compare_for_sort_reversed (NautilusFile * NautilusFile *file_2, NautilusFileSortType sort_type); +/* Change notification hack. + * This is called when code modifies the file and it needs to trigger + * a notification. Eventually this should become private, but for now + * it needs to be used for code like the thumbnail generation. + */ +void nautilus_file_changed (NautilusFile *file); + /* Convenience functions for dealing with a list of NautilusFile objects that each have a ref. */ void nautilus_file_list_ref (GList *file_list); void nautilus_file_list_unref (GList *file_list); diff --git a/libnautilus-extensions/nautilus-gdk-extensions.c b/libnautilus-extensions/nautilus-gdk-extensions.c index 59779638a..527ed7411 100644 --- a/libnautilus-extensions/nautilus-gdk-extensions.c +++ b/libnautilus-extensions/nautilus-gdk-extensions.c @@ -46,7 +46,8 @@ nautilus_fill_rectangle (GdkDrawable *drawable, const GdkRectangle *rectangle) { gdk_draw_rectangle (drawable, gc, TRUE, - rectangle->x, rectangle->y, rectangle->width, rectangle->height); + rectangle->x, rectangle->y, + rectangle->width, rectangle->height); } /** @@ -67,7 +68,7 @@ nautilus_fill_rectangle_with_color (GdkDrawable *drawable, { GdkGCValues saved_values; - gdk_gc_get_values(gc, &saved_values); + gdk_gc_get_values (gc, &saved_values); gdk_rgb_gc_set_foreground (gc, rgb); nautilus_fill_rectangle (drawable, gc, rectangle); gdk_gc_set_foreground (gc, &saved_values.foreground); @@ -131,8 +132,9 @@ nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable, /* Last band may need to be a bit smaller to avoid writing outside the box. * This is more efficient than changing and restoring the clip. */ - if (band == num_bands - 1) + if (band == num_bands - 1) { *size = last_band_size; + } nautilus_fill_rectangle_with_color (drawable, gc, &band_box, band_rgb); *position += *size; @@ -227,12 +229,14 @@ nautilus_gradient_new (const char *start_color, /* Handle the special case where the start and end colors are identical. Handle the special case where the end color is an empty string. */ - if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') + if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') { return g_strdup (start_color); + } /* Handle the special case where the start color is an empty string. */ - if (start_color == NULL || start_color[0] == '\0') + if (start_color == NULL || start_color[0] == '\0') { return g_strdup (end_color); + } /* Handle the general case. */ return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL); @@ -272,8 +276,9 @@ nautilus_gradient_strip_trailing_direction_if_any (const char *gradient_spec) length = nautilus_strlen (gradient_spec); if (length >= 2 && gradient_spec[length - 2] == ':' - && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) + && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) { length -= 2; + } return g_strndup (gradient_spec, length); } @@ -291,8 +296,9 @@ nautilus_gradient_get_start_color_spec (const char *gradient_spec) const char *separator; separator = nautilus_strchr (gradient_spec, '-'); - if (separator == NULL) + if (separator == NULL) { return nautilus_gradient_strip_trailing_direction_if_any (gradient_spec); + } return g_strndup (gradient_spec, separator - gradient_spec); } @@ -458,10 +464,12 @@ gboolean nautilus_gdk_font_equal (GdkFont *font_a_null_allowed, GdkFont *font_b_null_allowed) { - if (font_a_null_allowed == NULL) + if (font_a_null_allowed == NULL) { return font_b_null_allowed == NULL; - if (font_b_null_allowed == NULL) + } + if (font_b_null_allowed == NULL) { return FALSE; + } return gdk_font_equal (font_a_null_allowed, font_b_null_allowed); } diff --git a/libnautilus-extensions/nautilus-metadata.h b/libnautilus-extensions/nautilus-metadata.h index 11ab66da0..87602f24b 100644 --- a/libnautilus-extensions/nautilus-metadata.h +++ b/libnautilus-extensions/nautilus-metadata.h @@ -31,7 +31,6 @@ /* Per-directory */ -#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_INITIAL_VIEW "INITIAL_VIEW" #define NAUTILUS_METADATA_KEY_CONTENT_VIEWS "CONTENT_VIEWS" @@ -49,6 +48,7 @@ /* Per-file */ #define NAUTILUS_METADATA_KEY_NOTES "NOTES" +#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_ICON_POSITION "ICON_POSITION" #define NAUTILUS_METADATA_KEY_ICON_SCALE "ICON_SCALE" #define NAUTILUS_METADATA_KEY_CUSTOM_ICON "CUSTOM_ICON" diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c index be2fe0079..a4b329494 100644 --- a/libnautilus-private/nautilus-directory.c +++ b/libnautilus-private/nautilus-directory.c @@ -1083,19 +1083,20 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory, } void -nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data) { /* For now, it's synchronous for testing. */ (* callback) (directory, callback_data); } void -nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data) { } diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h index 3083e4084..fcaf27d19 100644 --- a/libnautilus-private/nautilus-directory.h +++ b/libnautilus-private/nautilus-directory.h @@ -56,77 +56,82 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass; #define NAUTILUS_IS_DIRECTORY_CLASS(klass) \ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY)) -typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory, - gpointer callback_data); -typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, - GList *files, - gpointer callback_data); +typedef void (*NautilusDirectoryCallback) (NautilusDirectory *directory, + gpointer callback_data); +typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, + GList *files, + gpointer callback_data); /* Basic GtkObject requirements. */ -GtkType nautilus_directory_get_type (void); +GtkType nautilus_directory_get_type (void); /* 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 (const char *uri); +NautilusDirectory *nautilus_directory_get (const char *uri); /* Convenience functions, since we do a lot of ref'ing and unref'ing. */ -void nautilus_directory_ref (NautilusDirectory *directory); -void nautilus_directory_unref (NautilusDirectory *directory); +void nautilus_directory_ref (NautilusDirectory *directory); +void nautilus_directory_unref (NautilusDirectory *directory); /* Access to a URI. */ -char * nautilus_directory_get_uri (NautilusDirectory *directory); +char * nautilus_directory_get_uri (NautilusDirectory *directory); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data); +void nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data); /* Getting and setting metadata. */ -char * nautilus_directory_get_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata); -void nautilus_directory_set_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata, - const char *metadata); -void nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data); -void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data); +char * nautilus_directory_get_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata); +void nautilus_directory_set_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata, + const char *metadata); /* Covers for common data types. */ -gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata); -void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata, - gboolean metadata); -int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata); -void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata, - int metadata); +gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata); +void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata, + gboolean metadata); +int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata); +void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata, + int metadata); /* Monitor the files in a directory. */ -void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, - NautilusFileListCallback initial_files_callback, - gpointer callback_data); -void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); +void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, + NautilusFileListCallback initial_files_callback, + gpointer callback_data); +void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); /* Return true if the directory has information about all the files. * This will be false until the directory has been read at least once. */ -gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); +gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); /* Return true if the directory metadata has been loaded. * Until this is true, get_metadata calls will return defaults. * (We could have another way to indicate "don't know".) */ -gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); +gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); typedef struct NautilusDirectoryDetails NautilusDirectoryDetails; @@ -143,25 +148,24 @@ struct NautilusDirectoryClass /*** Notification signals for clients to connect to. ***/ /* The files_added signal is emitted as the directory model - discovers new files. - */ + * discovers new files. + */ void (* files_added) (NautilusDirectory *directory, GList *added_files); /* The files_changed signal is emitted as changes occur to - existing files that are noticed by the synchronization framework, - including when an old file has been deleted. When an old file - has been deleted, this is the last chance to forget about these - file objects, which are about to be unref'd. Use nautilus_file_is_gone () - to test for this case. - The client must register which file attributes it is interested - in. Changes to other attributes are not reported via the signal. - */ + * existing files that are noticed by the synchronization framework, + * including when an old file has been deleted. When an old file + * has been deleted, this is the last chance to forget about these + * file objects, which are about to be unref'd. Use a call to + * nautilus_file_is_gone () to test for this case. + */ 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. + * for the directory itself are made. Changes to file metadata just + * result in calls to files_changed. */ void (* metadata_changed) (NautilusDirectory *directory); }; diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index 62f9795d3..0ed7bf771 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -1407,6 +1407,23 @@ nautilus_file_is_gone (NautilusFile *file) return file->details->is_gone; } +void +nautilus_file_call_when_ready (NautilusFile *file, + GList *file_metadata_tags, + NautilusFileCallback callback, + gpointer callback_data) +{ + /* For now, it's synchronous for testing. */ + (* callback) (file, callback_data); +} + +void +nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data) +{ +} + /** * nautilus_file_list_ref * diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index 1cb8b3b4c..6cc0c79be 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -56,6 +56,9 @@ typedef enum { NAUTILUS_FILE_SORT_BY_EMBLEMS } NautilusFileSortType; +typedef void (*NautilusFileCallback) (NautilusFile *file, + gpointer callback_data); + /* GtkObject requirements. */ GtkType nautilus_file_get_type (void); @@ -67,8 +70,17 @@ void nautilus_file_ref (NautilusFile * void nautilus_file_unref (NautilusFile *file); void nautilus_file_delete (NautilusFile *file); -/* Change notification. */ -void nautilus_file_changed (NautilusFile *file); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_file_call_when_ready (NautilusFile *file, + GList *metadata_tags, + NautilusFileCallback callback, + gpointer callback_data); +void nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data); /* Basic attributes for file objects. */ char * nautilus_file_get_name (NautilusFile *file); @@ -84,11 +96,12 @@ guint nautilus_file_get_directory_item_count (NautilusFile * GList * nautilus_file_get_keywords (NautilusFile *file); void nautilus_file_set_keywords (NautilusFile *file, GList *keywords); -GList * nautilus_file_get_emblem_names (NautilusFile *file); -gboolean nautilus_file_can_rename (NautilusFile *file); -GnomeVFSResult nautilus_file_rename (NautilusFile *file, - const char *new_name); +GList * nautilus_file_get_emblem_names (NautilusFile *file); +/* Basic operations for file objects. */ +gboolean nautilus_file_can_rename (NautilusFile *file); +GnomeVFSResult nautilus_file_rename (NautilusFile *file, + const char *new_name); /* Return true if this file has already been deleted. This object will be unref'd after sending the files_removed signal, @@ -117,6 +130,13 @@ int nautilus_file_compare_for_sort_reversed (NautilusFile * NautilusFile *file_2, NautilusFileSortType sort_type); +/* Change notification hack. + * This is called when code modifies the file and it needs to trigger + * a notification. Eventually this should become private, but for now + * it needs to be used for code like the thumbnail generation. + */ +void nautilus_file_changed (NautilusFile *file); + /* Convenience functions for dealing with a list of NautilusFile objects that each have a ref. */ void nautilus_file_list_ref (GList *file_list); void nautilus_file_list_unref (GList *file_list); diff --git a/libnautilus-private/nautilus-gdk-extensions.c b/libnautilus-private/nautilus-gdk-extensions.c index 59779638a..527ed7411 100644 --- a/libnautilus-private/nautilus-gdk-extensions.c +++ b/libnautilus-private/nautilus-gdk-extensions.c @@ -46,7 +46,8 @@ nautilus_fill_rectangle (GdkDrawable *drawable, const GdkRectangle *rectangle) { gdk_draw_rectangle (drawable, gc, TRUE, - rectangle->x, rectangle->y, rectangle->width, rectangle->height); + rectangle->x, rectangle->y, + rectangle->width, rectangle->height); } /** @@ -67,7 +68,7 @@ nautilus_fill_rectangle_with_color (GdkDrawable *drawable, { GdkGCValues saved_values; - gdk_gc_get_values(gc, &saved_values); + gdk_gc_get_values (gc, &saved_values); gdk_rgb_gc_set_foreground (gc, rgb); nautilus_fill_rectangle (drawable, gc, rectangle); gdk_gc_set_foreground (gc, &saved_values.foreground); @@ -131,8 +132,9 @@ nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable, /* Last band may need to be a bit smaller to avoid writing outside the box. * This is more efficient than changing and restoring the clip. */ - if (band == num_bands - 1) + if (band == num_bands - 1) { *size = last_band_size; + } nautilus_fill_rectangle_with_color (drawable, gc, &band_box, band_rgb); *position += *size; @@ -227,12 +229,14 @@ nautilus_gradient_new (const char *start_color, /* Handle the special case where the start and end colors are identical. Handle the special case where the end color is an empty string. */ - if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') + if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') { return g_strdup (start_color); + } /* Handle the special case where the start color is an empty string. */ - if (start_color == NULL || start_color[0] == '\0') + if (start_color == NULL || start_color[0] == '\0') { return g_strdup (end_color); + } /* Handle the general case. */ return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL); @@ -272,8 +276,9 @@ nautilus_gradient_strip_trailing_direction_if_any (const char *gradient_spec) length = nautilus_strlen (gradient_spec); if (length >= 2 && gradient_spec[length - 2] == ':' - && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) + && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) { length -= 2; + } return g_strndup (gradient_spec, length); } @@ -291,8 +296,9 @@ nautilus_gradient_get_start_color_spec (const char *gradient_spec) const char *separator; separator = nautilus_strchr (gradient_spec, '-'); - if (separator == NULL) + if (separator == NULL) { return nautilus_gradient_strip_trailing_direction_if_any (gradient_spec); + } return g_strndup (gradient_spec, separator - gradient_spec); } @@ -458,10 +464,12 @@ gboolean nautilus_gdk_font_equal (GdkFont *font_a_null_allowed, GdkFont *font_b_null_allowed) { - if (font_a_null_allowed == NULL) + if (font_a_null_allowed == NULL) { return font_b_null_allowed == NULL; - if (font_b_null_allowed == NULL) + } + if (font_b_null_allowed == NULL) { return FALSE; + } return gdk_font_equal (font_a_null_allowed, font_b_null_allowed); } diff --git a/libnautilus-private/nautilus-metadata.h b/libnautilus-private/nautilus-metadata.h index 11ab66da0..87602f24b 100644 --- a/libnautilus-private/nautilus-metadata.h +++ b/libnautilus-private/nautilus-metadata.h @@ -31,7 +31,6 @@ /* Per-directory */ -#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_INITIAL_VIEW "INITIAL_VIEW" #define NAUTILUS_METADATA_KEY_CONTENT_VIEWS "CONTENT_VIEWS" @@ -49,6 +48,7 @@ /* Per-file */ #define NAUTILUS_METADATA_KEY_NOTES "NOTES" +#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_ICON_POSITION "ICON_POSITION" #define NAUTILUS_METADATA_KEY_ICON_SCALE "ICON_SCALE" #define NAUTILUS_METADATA_KEY_CUSTOM_ICON "CUSTOM_ICON" diff --git a/libnautilus/nautilus-directory.c b/libnautilus/nautilus-directory.c index be2fe0079..a4b329494 100644 --- a/libnautilus/nautilus-directory.c +++ b/libnautilus/nautilus-directory.c @@ -1083,19 +1083,20 @@ nautilus_directory_get_file_metadata_node (NautilusDirectory *directory, } void -nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data) { /* For now, it's synchronous for testing. */ (* callback) (directory, callback_data); } void -nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data) +nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data) { } diff --git a/libnautilus/nautilus-directory.h b/libnautilus/nautilus-directory.h index 3083e4084..fcaf27d19 100644 --- a/libnautilus/nautilus-directory.h +++ b/libnautilus/nautilus-directory.h @@ -56,77 +56,82 @@ typedef struct NautilusDirectoryClass NautilusDirectoryClass; #define NAUTILUS_IS_DIRECTORY_CLASS(klass) \ (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_DIRECTORY)) -typedef void (*NautilusMetadataCallback) (NautilusDirectory *directory, - gpointer callback_data); -typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, - GList *files, - gpointer callback_data); +typedef void (*NautilusDirectoryCallback) (NautilusDirectory *directory, + gpointer callback_data); +typedef void (*NautilusFileListCallback) (NautilusDirectory *directory, + GList *files, + gpointer callback_data); /* Basic GtkObject requirements. */ -GtkType nautilus_directory_get_type (void); +GtkType nautilus_directory_get_type (void); /* 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 (const char *uri); +NautilusDirectory *nautilus_directory_get (const char *uri); /* Convenience functions, since we do a lot of ref'ing and unref'ing. */ -void nautilus_directory_ref (NautilusDirectory *directory); -void nautilus_directory_unref (NautilusDirectory *directory); +void nautilus_directory_ref (NautilusDirectory *directory); +void nautilus_directory_unref (NautilusDirectory *directory); /* Access to a URI. */ -char * nautilus_directory_get_uri (NautilusDirectory *directory); +char * nautilus_directory_get_uri (NautilusDirectory *directory); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_directory_call_when_ready (NautilusDirectory *directory, + GList *directory_metadata_tags, + GList *file_metadata_tags, + NautilusDirectoryCallback callback, + gpointer callback_data); +void nautilus_directory_cancel_callback (NautilusDirectory *directory, + NautilusDirectoryCallback callback, + gpointer callback_data); /* Getting and setting metadata. */ -char * nautilus_directory_get_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata); -void nautilus_directory_set_metadata (NautilusDirectory *directory, - const char *tag, - const char *default_metadata, - const char *metadata); -void nautilus_directory_metadata_call_when_ready (NautilusDirectory *directory, - GList *tags, - NautilusMetadataCallback callback, - gpointer callback_data); -void nautilus_directory_metadata_callback_cancel (NautilusDirectory *directory, - NautilusMetadataCallback callback, - gpointer callback_data); +char * nautilus_directory_get_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata); +void nautilus_directory_set_metadata (NautilusDirectory *directory, + const char *tag, + const char *default_metadata, + const char *metadata); /* Covers for common data types. */ -gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata); -void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, - const char *tag, - gboolean default_metadata, - gboolean metadata); -int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata); -void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, - const char *tag, - int default_metadata, - int metadata); +gboolean nautilus_directory_get_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata); +void nautilus_directory_set_boolean_metadata (NautilusDirectory *directory, + const char *tag, + gboolean default_metadata, + gboolean metadata); +int nautilus_directory_get_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata); +void nautilus_directory_set_integer_metadata (NautilusDirectory *directory, + const char *tag, + int default_metadata, + int metadata); /* Monitor the files in a directory. */ -void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, - NautilusFileListCallback initial_files_callback, - gpointer callback_data); -void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); +void nautilus_directory_monitor_files_ref (NautilusDirectory *directory, + NautilusFileListCallback initial_files_callback, + gpointer callback_data); +void nautilus_directory_monitor_files_unref (NautilusDirectory *directory); /* Return true if the directory has information about all the files. * This will be false until the directory has been read at least once. */ -gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); +gboolean nautilus_directory_are_all_files_seen (NautilusDirectory *directory); /* Return true if the directory metadata has been loaded. * Until this is true, get_metadata calls will return defaults. * (We could have another way to indicate "don't know".) */ -gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); +gboolean nautilus_directory_metadata_loaded (NautilusDirectory *directory); typedef struct NautilusDirectoryDetails NautilusDirectoryDetails; @@ -143,25 +148,24 @@ struct NautilusDirectoryClass /*** Notification signals for clients to connect to. ***/ /* The files_added signal is emitted as the directory model - discovers new files. - */ + * discovers new files. + */ void (* files_added) (NautilusDirectory *directory, GList *added_files); /* The files_changed signal is emitted as changes occur to - existing files that are noticed by the synchronization framework, - including when an old file has been deleted. When an old file - has been deleted, this is the last chance to forget about these - file objects, which are about to be unref'd. Use nautilus_file_is_gone () - to test for this case. - The client must register which file attributes it is interested - in. Changes to other attributes are not reported via the signal. - */ + * existing files that are noticed by the synchronization framework, + * including when an old file has been deleted. When an old file + * has been deleted, this is the last chance to forget about these + * file objects, which are about to be unref'd. Use a call to + * nautilus_file_is_gone () to test for this case. + */ 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. + * for the directory itself are made. Changes to file metadata just + * result in calls to files_changed. */ void (* metadata_changed) (NautilusDirectory *directory); }; diff --git a/libnautilus/nautilus-file.c b/libnautilus/nautilus-file.c index 62f9795d3..0ed7bf771 100644 --- a/libnautilus/nautilus-file.c +++ b/libnautilus/nautilus-file.c @@ -1407,6 +1407,23 @@ nautilus_file_is_gone (NautilusFile *file) return file->details->is_gone; } +void +nautilus_file_call_when_ready (NautilusFile *file, + GList *file_metadata_tags, + NautilusFileCallback callback, + gpointer callback_data) +{ + /* For now, it's synchronous for testing. */ + (* callback) (file, callback_data); +} + +void +nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data) +{ +} + /** * nautilus_file_list_ref * diff --git a/libnautilus/nautilus-file.h b/libnautilus/nautilus-file.h index 1cb8b3b4c..6cc0c79be 100644 --- a/libnautilus/nautilus-file.h +++ b/libnautilus/nautilus-file.h @@ -56,6 +56,9 @@ typedef enum { NAUTILUS_FILE_SORT_BY_EMBLEMS } NautilusFileSortType; +typedef void (*NautilusFileCallback) (NautilusFile *file, + gpointer callback_data); + /* GtkObject requirements. */ GtkType nautilus_file_get_type (void); @@ -67,8 +70,17 @@ void nautilus_file_ref (NautilusFile * void nautilus_file_unref (NautilusFile *file); void nautilus_file_delete (NautilusFile *file); -/* Change notification. */ -void nautilus_file_changed (NautilusFile *file); +/* Waiting for data that's read asynchronously. + * This interface currently works only for metadata, but could be expanded + * to other attributes as well. + */ +void nautilus_file_call_when_ready (NautilusFile *file, + GList *metadata_tags, + NautilusFileCallback callback, + gpointer callback_data); +void nautilus_file_cancel_callback (NautilusFile *file, + NautilusFileCallback callback, + gpointer callback_data); /* Basic attributes for file objects. */ char * nautilus_file_get_name (NautilusFile *file); @@ -84,11 +96,12 @@ guint nautilus_file_get_directory_item_count (NautilusFile * GList * nautilus_file_get_keywords (NautilusFile *file); void nautilus_file_set_keywords (NautilusFile *file, GList *keywords); -GList * nautilus_file_get_emblem_names (NautilusFile *file); -gboolean nautilus_file_can_rename (NautilusFile *file); -GnomeVFSResult nautilus_file_rename (NautilusFile *file, - const char *new_name); +GList * nautilus_file_get_emblem_names (NautilusFile *file); +/* Basic operations for file objects. */ +gboolean nautilus_file_can_rename (NautilusFile *file); +GnomeVFSResult nautilus_file_rename (NautilusFile *file, + const char *new_name); /* Return true if this file has already been deleted. This object will be unref'd after sending the files_removed signal, @@ -117,6 +130,13 @@ int nautilus_file_compare_for_sort_reversed (NautilusFile * NautilusFile *file_2, NautilusFileSortType sort_type); +/* Change notification hack. + * This is called when code modifies the file and it needs to trigger + * a notification. Eventually this should become private, but for now + * it needs to be used for code like the thumbnail generation. + */ +void nautilus_file_changed (NautilusFile *file); + /* Convenience functions for dealing with a list of NautilusFile objects that each have a ref. */ void nautilus_file_list_ref (GList *file_list); void nautilus_file_list_unref (GList *file_list); diff --git a/libnautilus/nautilus-gdk-extensions.c b/libnautilus/nautilus-gdk-extensions.c index 59779638a..527ed7411 100644 --- a/libnautilus/nautilus-gdk-extensions.c +++ b/libnautilus/nautilus-gdk-extensions.c @@ -46,7 +46,8 @@ nautilus_fill_rectangle (GdkDrawable *drawable, const GdkRectangle *rectangle) { gdk_draw_rectangle (drawable, gc, TRUE, - rectangle->x, rectangle->y, rectangle->width, rectangle->height); + rectangle->x, rectangle->y, + rectangle->width, rectangle->height); } /** @@ -67,7 +68,7 @@ nautilus_fill_rectangle_with_color (GdkDrawable *drawable, { GdkGCValues saved_values; - gdk_gc_get_values(gc, &saved_values); + gdk_gc_get_values (gc, &saved_values); gdk_rgb_gc_set_foreground (gc, rgb); nautilus_fill_rectangle (drawable, gc, rectangle); gdk_gc_set_foreground (gc, &saved_values.foreground); @@ -131,8 +132,9 @@ nautilus_fill_rectangle_with_gradient (GdkDrawable *drawable, /* Last band may need to be a bit smaller to avoid writing outside the box. * This is more efficient than changing and restoring the clip. */ - if (band == num_bands - 1) + if (band == num_bands - 1) { *size = last_band_size; + } nautilus_fill_rectangle_with_color (drawable, gc, &band_box, band_rgb); *position += *size; @@ -227,12 +229,14 @@ nautilus_gradient_new (const char *start_color, /* Handle the special case where the start and end colors are identical. Handle the special case where the end color is an empty string. */ - if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') + if (nautilus_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0') { return g_strdup (start_color); + } /* Handle the special case where the start color is an empty string. */ - if (start_color == NULL || start_color[0] == '\0') + if (start_color == NULL || start_color[0] == '\0') { return g_strdup (end_color); + } /* Handle the general case. */ return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL); @@ -272,8 +276,9 @@ nautilus_gradient_strip_trailing_direction_if_any (const char *gradient_spec) length = nautilus_strlen (gradient_spec); if (length >= 2 && gradient_spec[length - 2] == ':' - && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) + && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h')) { length -= 2; + } return g_strndup (gradient_spec, length); } @@ -291,8 +296,9 @@ nautilus_gradient_get_start_color_spec (const char *gradient_spec) const char *separator; separator = nautilus_strchr (gradient_spec, '-'); - if (separator == NULL) + if (separator == NULL) { return nautilus_gradient_strip_trailing_direction_if_any (gradient_spec); + } return g_strndup (gradient_spec, separator - gradient_spec); } @@ -458,10 +464,12 @@ gboolean nautilus_gdk_font_equal (GdkFont *font_a_null_allowed, GdkFont *font_b_null_allowed) { - if (font_a_null_allowed == NULL) + if (font_a_null_allowed == NULL) { return font_b_null_allowed == NULL; - if (font_b_null_allowed == NULL) + } + if (font_b_null_allowed == NULL) { return FALSE; + } return gdk_font_equal (font_a_null_allowed, font_b_null_allowed); } diff --git a/libnautilus/nautilus-metadata.h b/libnautilus/nautilus-metadata.h index 11ab66da0..87602f24b 100644 --- a/libnautilus/nautilus-metadata.h +++ b/libnautilus/nautilus-metadata.h @@ -31,7 +31,6 @@ /* Per-directory */ -#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_INITIAL_VIEW "INITIAL_VIEW" #define NAUTILUS_METADATA_KEY_CONTENT_VIEWS "CONTENT_VIEWS" @@ -49,6 +48,7 @@ /* Per-file */ #define NAUTILUS_METADATA_KEY_NOTES "NOTES" +#define NAUTILUS_METADATA_KEY_ANNOTATION "ANNOTATION" #define NAUTILUS_METADATA_KEY_ICON_POSITION "ICON_POSITION" #define NAUTILUS_METADATA_KEY_ICON_SCALE "ICON_SCALE" #define NAUTILUS_METADATA_KEY_CUSTOM_ICON "CUSTOM_ICON" diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 4a15fd19c..5ec74760e 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -46,6 +46,7 @@ #include <libnautilus/nautilus-gtk-extensions.h> #include <libnautilus/nautilus-gtk-macros.h> #include <libnautilus/nautilus-icon-factory.h> +#include <libnautilus/nautilus-metadata.h> #include <libnautilus/nautilus-string.h> #include <libnautilus/nautilus-zoomable.h> @@ -79,7 +80,7 @@ enum static guint signals[LAST_SIGNAL]; -struct _FMDirectoryViewDetails +struct FMDirectoryViewDetails { NautilusContentViewFrame *view_frame; NautilusZoomable *zoomable; @@ -108,81 +109,84 @@ struct _FMDirectoryViewDetails }; /* forward declarations */ -static void delete_cb (GtkMenuItem *item, - GList *files); -static int display_selection_info_idle_cb (gpointer data); -static void display_selection_info (FMDirectoryView *view); -static void fm_directory_view_initialize_class (FMDirectoryViewClass *klass); -static void fm_directory_view_initialize (FMDirectoryView *view); -static void fm_directory_view_delete_with_confirm (FMDirectoryView *view, - GList *files); -static void fm_directory_view_destroy (GtkObject *object); -static void fm_directory_view_activate_file_internal (FMDirectoryView *view, - NautilusFile *file, - gboolean use_new_window); -static void fm_directory_view_append_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu); -static void fm_directory_view_merge_menus (FMDirectoryView *view); -static void fm_directory_view_real_append_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu); -static void fm_directory_view_real_append_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *files); -static void fm_directory_view_real_merge_menus (FMDirectoryView *view); -static void fm_directory_view_real_update_menus (FMDirectoryView *view); -static GtkMenu * create_selection_context_menu (FMDirectoryView *view); -static GtkMenu * create_background_context_menu (FMDirectoryView *view); -static BonoboControl *get_bonobo_control (FMDirectoryView *view); -static void stop_location_change_cb (NautilusViewFrame *view_frame, - FMDirectoryView *directory_view); -static void notify_location_change_cb (NautilusViewFrame *view_frame, - Nautilus_NavigationInfo *nav_context, - FMDirectoryView *directory_view); -static void notify_selection_change_cb (NautilusViewFrame *view_frame, - Nautilus_SelectionInfo *sel_context, - FMDirectoryView *directory_view); -static void open_cb (GtkMenuItem *item, - GList *files); -static void open_in_new_window_cb (GtkMenuItem *item, - GList *files); -static void open_one_in_new_window (gpointer data, - gpointer user_data); -static void open_one_properties_window (gpointer data, - gpointer user_data); -static void select_all_cb (GtkMenuItem *item, - FMDirectoryView *directory_view); -static void zoom_in_cb (GtkMenuItem *item, - FMDirectoryView *directory_view); -static void zoom_out_cb (GtkMenuItem *item, - FMDirectoryView *directory_view); -static void zoomable_zoom_in_cb (NautilusZoomable *zoomable, - FMDirectoryView *directory_view); -static void zoomable_zoom_out_cb (NautilusZoomable *zoomable, - FMDirectoryView *directory_view); -static void schedule_idle_display_of_pending_files (FMDirectoryView *view); -static void unschedule_idle_display_of_pending_files (FMDirectoryView *view); -static void schedule_timeout_display_of_pending_files (FMDirectoryView *view); -static void unschedule_timeout_display_of_pending_files (FMDirectoryView *view); -static void unschedule_display_of_pending_files (FMDirectoryView *view); -static void disconnect_model_handlers (FMDirectoryView *view); -static void user_level_changed_callback (NautilusPreferences *preferences, - const char *name, - gconstpointer value, - gpointer user_data); -static void use_new_window_changed_callback (NautilusPreferences *preferences, - const char *name, - gconstpointer value, - gpointer user_data); -static void add_nautilus_file_to_uri_map (FMDirectoryView *preferences, - NautilusFile *file); -static void remove_nautilus_file_from_uri_map (FMDirectoryView *preferences, - NautilusFile *file); -static void free_file_by_uri_map_entry (gpointer key, - gpointer value, - gpointer data); -static void free_file_by_uri_map (FMDirectoryView *view); - - +static void delete_cb (GtkMenuItem *item, + GList *files); +static int display_selection_info_idle_cb (gpointer data); +static void display_selection_info (FMDirectoryView *view); +static void fm_directory_view_initialize_class (FMDirectoryViewClass *klass); +static void fm_directory_view_initialize (FMDirectoryView *view); +static void fm_directory_view_delete_with_confirm (FMDirectoryView *view, + GList *files); +static void fm_directory_view_destroy (GtkObject *object); +static void fm_directory_view_activate_file_internal (FMDirectoryView *view, + NautilusFile *file, + gboolean use_new_window); +static void fm_directory_view_append_background_context_menu_items (FMDirectoryView *view, + GtkMenu *menu); +static void fm_directory_view_merge_menus (FMDirectoryView *view); +static void fm_directory_view_real_append_background_context_menu_items (FMDirectoryView *view, + GtkMenu *menu); +static void fm_directory_view_real_append_selection_context_menu_items (FMDirectoryView *view, + GtkMenu *menu, + GList *files); +static void fm_directory_view_real_merge_menus (FMDirectoryView *view); +static void fm_directory_view_real_update_menus (FMDirectoryView *view); +static GtkMenu * create_selection_context_menu (FMDirectoryView *view); +static GtkMenu * create_background_context_menu (FMDirectoryView *view); +static BonoboControl *get_bonobo_control (FMDirectoryView *view); +static void stop_location_change_cb (NautilusViewFrame *view_frame, + FMDirectoryView *directory_view); +static void notify_location_change_cb (NautilusViewFrame *view_frame, + Nautilus_NavigationInfo *nav_context, + FMDirectoryView *directory_view); +static void notify_selection_change_cb (NautilusViewFrame *view_frame, + Nautilus_SelectionInfo *sel_context, + FMDirectoryView *directory_view); +static void open_cb (GtkMenuItem *item, + GList *files); +static void open_in_new_window_cb (GtkMenuItem *item, + GList *files); +static void open_one_in_new_window (gpointer data, + gpointer user_data); +static void open_one_properties_window (gpointer data, + gpointer user_data); +static void select_all_cb (GtkMenuItem *item, + FMDirectoryView *directory_view); +static void zoom_in_cb (GtkMenuItem *item, + FMDirectoryView *directory_view); +static void zoom_out_cb (GtkMenuItem *item, + FMDirectoryView *directory_view); +static void zoomable_zoom_in_cb (NautilusZoomable *zoomable, + FMDirectoryView *directory_view); +static void zoomable_zoom_out_cb (NautilusZoomable *zoomable, + FMDirectoryView *directory_view); +static void schedule_idle_display_of_pending_files (FMDirectoryView *view); +static void unschedule_idle_display_of_pending_files (FMDirectoryView *view); +static void schedule_timeout_display_of_pending_files (FMDirectoryView *view); +static void unschedule_timeout_display_of_pending_files (FMDirectoryView *view); +static void unschedule_display_of_pending_files (FMDirectoryView *view); +static void disconnect_model_handlers (FMDirectoryView *view); +static void user_level_changed_callback (NautilusPreferences *preferences, + const char *name, + gconstpointer value, + gpointer user_data); +static void use_new_window_changed_callback (NautilusPreferences *preferences, + const char *name, + gconstpointer value, + gpointer user_data); +static void add_nautilus_file_to_uri_map (FMDirectoryView *preferences, + NautilusFile *file); +static void remove_nautilus_file_from_uri_map (FMDirectoryView *preferences, + NautilusFile *file); +static void free_file_by_uri_map_entry (gpointer key, + gpointer value, + gpointer data); +static void free_file_by_uri_map (FMDirectoryView *view); +static void get_required_metadata_keys (FMDirectoryView *view, + GList **directory_keys_result, + GList **file_keys_result); +static void metadata_ready_callback (NautilusDirectory *directory, + gpointer callback_data); NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryView, fm_directory_view, GTK_TYPE_SCROLLED_WINDOW) NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, add_file) @@ -265,6 +269,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass) klass->append_background_context_menu_items = fm_directory_view_real_append_background_context_menu_items; klass->merge_menus = fm_directory_view_real_merge_menus; klass->update_menus = fm_directory_view_real_update_menus; + klass->get_required_metadata_keys = get_required_metadata_keys; /* Function pointers that subclasses must override */ @@ -830,6 +835,9 @@ display_pending_files (FMDirectoryView *view) add_nautilus_file_to_uri_map (view, NAUTILUS_FILE (file)); + /* FIXME: We really want to ask if it is gone from this directory, + * not if it has been deleted. + */ if (!nautilus_file_is_gone (file)) { gtk_signal_emit (GTK_OBJECT (view), signals[ADD_FILE], @@ -841,8 +849,16 @@ display_pending_files (FMDirectoryView *view) file = p->data; /* FIXME: what does files_changed mean, do I need to - modify the files_by_uri hash table here? */ + * modify the files_by_uri hash table here? -mjs + * Yes, the file's name could have been changed. + * But perhaps we can remove the hash table instead + * and leverage the fact that nautilus_file_get + * always returns the same existing file object. -Darin + */ + /* FIXME: We really want to ask if it is gone from this directory, + * not if it has been deleted. + */ if (nautilus_file_is_gone (file)) { remove_nautilus_file_from_uri_map (view, NAUTILUS_FILE (file)); } @@ -854,7 +870,8 @@ display_pending_files (FMDirectoryView *view) gtk_signal_emit (GTK_OBJECT (view), signals[DONE_ADDING_FILES]); - if (nautilus_directory_are_all_files_seen (view->details->model) && view->details->have_pending_uris_selected) { + if (nautilus_directory_are_all_files_seen (view->details->model) + && view->details->have_pending_uris_selected) { GList *selection; char *uri; @@ -1048,7 +1065,7 @@ queue_pending_files (FMDirectoryView *view, } /* Put the files on the pending list if there are any. */ - if (files) { + if (files != NULL) { nautilus_file_list_ref (files); *pending_list = g_list_concat (*pending_list, g_list_copy (files)); @@ -1825,8 +1842,8 @@ void fm_directory_view_load_uri (FMDirectoryView *view, const char *uri) { - Nautilus_ProgressRequestInfo progress; NautilusDirectory *old_model; + GList *directory_tags, *file_tags; g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); g_return_if_fail (uri != NULL); @@ -1840,6 +1857,24 @@ fm_directory_view_load_uri (FMDirectoryView *view, view->details->model = nautilus_directory_get (uri); nautilus_directory_unref (old_model); + (* FM_DIRECTORY_VIEW_CLASS (GTK_OBJECT (view)->klass)->get_required_metadata_keys) + (view, &directory_tags, &file_tags); + + nautilus_directory_call_when_ready (view->details->model, + directory_tags, + file_tags, + metadata_ready_callback, + view); + + g_list_free (directory_tags); + g_list_free (file_tags); +} + +static void +finish_loading_uri (FMDirectoryView *view) +{ + Nautilus_ProgressRequestInfo progress; + memset (&progress, 0, sizeof (progress)); progress.type = Nautilus_PROGRESS_UNDERWAY; nautilus_view_frame_request_progress_change @@ -1873,6 +1908,46 @@ fm_directory_view_load_uri (FMDirectoryView *view, view); } +static void +metadata_ready_callback (NautilusDirectory *directory, + gpointer callback_data) +{ + FMDirectoryView *view; + + view = callback_data; + + g_assert (FM_IS_DIRECTORY_VIEW (view)); + g_assert (view->details->model == directory); + + finish_loading_uri (view); +} + +static void +get_required_metadata_keys (FMDirectoryView *view, + GList **directory_keys_result, + GList **file_keys_result) +{ + GList *directory_keys; + + g_assert (FM_IS_DIRECTORY_VIEW (view)); + g_assert (directory_keys_result != NULL); + g_assert (file_keys_result != NULL); + + directory_keys = NULL; + + /* This needs to be a list of all the metadata needed. + * For now, it's kinda hard-coded. Later we might want + * to gather this info from various sources. + */ + directory_keys = g_list_prepend (directory_keys, + NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_COLOR); + directory_keys = g_list_prepend (directory_keys, + NAUTILUS_METADATA_KEY_DIRECTORY_BACKGROUND_IMAGE); + + *directory_keys_result = directory_keys; + *file_keys_result = NULL; +} + /** * fm_directory_view_merge_menus: * @@ -1907,6 +1982,10 @@ disconnect_model_handlers (FMDirectoryView *view) nautilus_directory_monitor_files_unref (view->details->model); view->details->loading = FALSE; } + + nautilus_directory_cancel_callback (view->details->model, + metadata_ready_callback, + view); } /** @@ -2085,15 +2164,9 @@ free_file_by_uri_map_entry (gpointer key, static void free_file_by_uri_map (FMDirectoryView *view) { - g_hash_table_foreach (view->details->files_by_uri, - free_file_by_uri_map_entry, - NULL); + g_hash_table_foreach (view->details->files_by_uri, + free_file_by_uri_map_entry, + NULL); g_hash_table_destroy (view->details->files_by_uri); } - - - - - - diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index 50854f220..b15140418 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -32,9 +32,9 @@ #include <libnautilus/nautilus-directory.h> #include <libnautilus/nautilus-file.h> #include <libnautilus/nautilus-icon-container.h> - -typedef struct _FMDirectoryView FMDirectoryView; -typedef struct _FMDirectoryViewClass FMDirectoryViewClass; + +typedef struct FMDirectoryView FMDirectoryView; +typedef struct FMDirectoryViewClass FMDirectoryViewClass; #define FM_TYPE_DIRECTORY_VIEW (fm_directory_view_get_type ()) #define FM_DIRECTORY_VIEW(obj) (GTK_CHECK_CAST ((obj), FM_TYPE_DIRECTORY_VIEW, FMDirectoryView)) @@ -42,14 +42,14 @@ typedef struct _FMDirectoryViewClass FMDirectoryViewClass; #define FM_IS_DIRECTORY_VIEW(obj) (GTK_CHECK_TYPE ((obj), FM_TYPE_DIRECTORY_VIEW)) #define FM_IS_DIRECTORY_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), FM_TYPE_DIRECTORY_VIEW)) -typedef struct _FMDirectoryViewDetails FMDirectoryViewDetails; +typedef struct FMDirectoryViewDetails FMDirectoryViewDetails; -struct _FMDirectoryView { +struct FMDirectoryView { GtkScrolledWindow parent; FMDirectoryViewDetails *details; }; -struct _FMDirectoryViewClass { +struct FMDirectoryViewClass { GtkScrolledWindowClass parent_class; /* The 'clear' signal is emitted to empty the view of its contents. @@ -156,59 +156,68 @@ struct _FMDirectoryViewClass { * subclasses must call parent class's function. */ void (* update_menus) (FMDirectoryView *view); -}; - + /* get_required_metadata_keys is a function pointer that subclasses + * may override to request additional metadata to be read before showing + * the directory view. If overridden, subclasses must call parent class's + * function. + */ + void (* get_required_metadata_keys) + (FMDirectoryView *view, + GList **directory_metadata_keys, + GList **file_metadata_keys); +}; /* GtkObject support */ -GtkType fm_directory_view_get_type (void); +GtkType fm_directory_view_get_type (void); /* Component embedding support */ -NautilusContentViewFrame *fm_directory_view_get_view_frame (FMDirectoryView *view); +NautilusContentViewFrame *fm_directory_view_get_view_frame (FMDirectoryView *view); /* URI handling */ -void fm_directory_view_load_uri (FMDirectoryView *view, - const char *uri); +void fm_directory_view_load_uri (FMDirectoryView *view, + const char *uri); /* Functions callable from the user interface and elsewhere. */ -char * fm_directory_view_get_container_uri (NautilusIconContainer *container, - FMDirectoryView *view); -GList * fm_directory_view_get_selection (FMDirectoryView *view); -void fm_directory_view_stop (FMDirectoryView *view); -gboolean fm_directory_view_can_zoom_in (FMDirectoryView *view); -gboolean fm_directory_view_can_zoom_out (FMDirectoryView *view); -void fm_directory_view_bump_zoom_level (FMDirectoryView *view, - int zoom_increment); -void fm_directory_view_select_all (FMDirectoryView *view); -void fm_directory_view_set_selection (FMDirectoryView *view, GList *selection); -void fm_directory_view_move_copy_items (NautilusIconContainer *container, - const GList *item_uris, - const GdkPoint *relative_item_points, - const char *target_uri, - int copy_action, - int x, - int y, - FMDirectoryView *view); +char * fm_directory_view_get_container_uri (NautilusIconContainer *container, + FMDirectoryView *view); +GList * fm_directory_view_get_selection (FMDirectoryView *view); +void fm_directory_view_stop (FMDirectoryView *view); +gboolean fm_directory_view_can_zoom_in (FMDirectoryView *view); +gboolean fm_directory_view_can_zoom_out (FMDirectoryView *view); +void fm_directory_view_bump_zoom_level (FMDirectoryView *view, + int zoom_increment); +void fm_directory_view_select_all (FMDirectoryView *view); +void fm_directory_view_set_selection (FMDirectoryView *view, + GList *selection); +void fm_directory_view_move_copy_items (NautilusIconContainer *container, + const GList *item_uris, + const GdkPoint *relative_item_points, + const char *target_uri, + int copy_action, + int x, + int y, + FMDirectoryView *view); /* Wrappers for signal emitters. These are normally called * only by FMDirectoryView itself. They have corresponding signals * that observers might want to connect with. */ -void fm_directory_view_clear (FMDirectoryView *view); -void fm_directory_view_begin_loading (FMDirectoryView *view); +void fm_directory_view_clear (FMDirectoryView *view); +void fm_directory_view_begin_loading (FMDirectoryView *view); /* Hooks for subclasses to call. These are normally called only by * FMDirectoryView and its subclasses */ -void fm_directory_view_activate_file (FMDirectoryView *view, - NautilusFile *file, - gboolean request_new_window); -void fm_directory_view_notify_selection_changed (FMDirectoryView *view); -BonoboUIHandler * fm_directory_view_get_bonobo_ui_handler (FMDirectoryView *view); -NautilusDirectory * fm_directory_view_get_model (FMDirectoryView *view); -void fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view); -void fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view); -void fm_directory_view_update_menus (FMDirectoryView *view); +void fm_directory_view_activate_file (FMDirectoryView *view, + NautilusFile *file, + gboolean request_new_window); +void fm_directory_view_notify_selection_changed (FMDirectoryView *view); +BonoboUIHandler * fm_directory_view_get_bonobo_ui_handler (FMDirectoryView *view); +NautilusDirectory * fm_directory_view_get_model (FMDirectoryView *view); +void fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view); +void fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view); +void fm_directory_view_update_menus (FMDirectoryView *view); #endif /* FM_DIRECTORY_VIEW_H */ diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index ad34fed0b..07e69ec41 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -550,6 +550,9 @@ static void fm_icon_view_file_changed (FMDirectoryView *view, NautilusFile *file) { /* This handles both changes to an existing file and the existing file going away. */ + /* FIXME: We really want to ask if it is gone from this directory, + * not if it has been deleted. + */ if (nautilus_file_is_gone (file)) { if (nautilus_icon_container_remove (get_icon_container (FM_ICON_VIEW (view)), NAUTILUS_ICON_CONTAINER_ICON_DATA (file))) { diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 782b6e7fa..bdc0ebb48 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -637,6 +637,9 @@ fm_list_view_file_changed (FMDirectoryView *view, NautilusFile *file) was_selected = remove_from_list (list_view, file); + /* FIXME: We really want to ask if it is gone from this directory, + * not if it has been deleted. + */ if (!nautilus_file_is_gone (file)) { new_row = add_to_list (list_view, file); diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index a430eaba7..eba9114e9 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -455,7 +455,7 @@ nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *nri, const char *referring_iid) { NautilusNavigationInfo *navinfo; - GList *metadata_keys; + GList *keys; navinfo = g_new0 (NautilusNavigationInfo, 1); @@ -474,15 +474,15 @@ nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *nri, navinfo->directory = nautilus_directory_get (nri->requested_uri); /* Arrange for all the metadata we will need. */ - metadata_keys = NULL; - metadata_keys = g_list_prepend (metadata_keys, NAUTILUS_METADATA_KEY_CONTENT_VIEWS); - metadata_keys = g_list_prepend (metadata_keys, NAUTILUS_METADATA_KEY_INITIAL_VIEW); - nautilus_directory_metadata_call_when_ready - (navinfo->directory, - metadata_keys, - got_metadata_callback, - navinfo); - g_list_free (metadata_keys); + keys = NULL; + keys = g_list_prepend (keys, NAUTILUS_METADATA_KEY_CONTENT_VIEWS); + keys = g_list_prepend (keys, NAUTILUS_METADATA_KEY_INITIAL_VIEW); + nautilus_directory_call_when_ready (navinfo->directory, + keys, + NULL, + got_metadata_callback, + navinfo); + g_list_free (keys); return navinfo; } @@ -497,7 +497,7 @@ nautilus_navigation_info_cancel (NautilusNavigationInfo *info) info->ah = NULL; } - nautilus_directory_metadata_callback_cancel + nautilus_directory_cancel_callback (info->directory, got_metadata_callback, info); } diff --git a/src/nautilus-index-title.c b/src/nautilus-index-title.c index 7b4069a24..cd30f884d 100644 --- a/src/nautilus-index-title.c +++ b/src/nautilus-index-title.c @@ -380,7 +380,7 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) /* see if there are any notes for this file. If so, display them */ notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_NOTES, NULL); - if (notes_text) { + if (notes_text != NULL) { if (index_title->details->notes != NULL) gtk_label_set_text(GTK_LABEL(index_title->details->notes), notes_text); else { diff --git a/src/nautilus-main.c b/src/nautilus-main.c index 99e24b07d..99e6db5bc 100644 --- a/src/nautilus-main.c +++ b/src/nautilus-main.c @@ -46,6 +46,7 @@ main(int argc, char *argv[]) gboolean check = FALSE; #endif const char **args; + NautilusApp *app; struct poptOption options[] = { #if !defined (NAUTILUS_OMIT_SELF_CHECK) @@ -58,9 +59,10 @@ main(int argc, char *argv[]) /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. * Unfortunately, this has to be done explicitly for each domain. */ - if (getenv("NAUTILUS_DEBUG") != NULL) + if (getenv("NAUTILUS_DEBUG") != NULL) { nautilus_make_warnings_and_criticals_stop_in_debugger (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); + } /* Initialize the services that we use. */ CORBA_exception_init(&ev); @@ -80,14 +82,12 @@ main(int argc, char *argv[]) nautilus_exit_if_self_checks_failed (); } else { #endif - NautilusApp *app; - - app = NAUTILUS_APP(nautilus_app_new()); /* Run the nautilus application. */ + app = NAUTILUS_APP (nautilus_app_new ()); nautilus_app_startup (app, args ? args[0] : NULL); bonobo_main(); - bonobo_object_unref(BONOBO_OBJECT(app)); + bonobo_object_unref (BONOBO_OBJECT (app)); #if !defined (NAUTILUS_OMIT_SELF_CHECK) } diff --git a/src/nautilus-sidebar-title.c b/src/nautilus-sidebar-title.c index 7b4069a24..cd30f884d 100644 --- a/src/nautilus-sidebar-title.c +++ b/src/nautilus-sidebar-title.c @@ -380,7 +380,7 @@ nautilus_index_title_update_info (NautilusIndexTitle *index_title) /* see if there are any notes for this file. If so, display them */ notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_NOTES, NULL); - if (notes_text) { + if (notes_text != NULL) { if (index_title->details->notes != NULL) gtk_label_set_text(GTK_LABEL(index_title->details->notes), notes_text); else { diff --git a/src/ntl-main.c b/src/ntl-main.c index 99e24b07d..99e6db5bc 100644 --- a/src/ntl-main.c +++ b/src/ntl-main.c @@ -46,6 +46,7 @@ main(int argc, char *argv[]) gboolean check = FALSE; #endif const char **args; + NautilusApp *app; struct poptOption options[] = { #if !defined (NAUTILUS_OMIT_SELF_CHECK) @@ -58,9 +59,10 @@ main(int argc, char *argv[]) /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. * Unfortunately, this has to be done explicitly for each domain. */ - if (getenv("NAUTILUS_DEBUG") != NULL) + if (getenv("NAUTILUS_DEBUG") != NULL) { nautilus_make_warnings_and_criticals_stop_in_debugger (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); + } /* Initialize the services that we use. */ CORBA_exception_init(&ev); @@ -80,14 +82,12 @@ main(int argc, char *argv[]) nautilus_exit_if_self_checks_failed (); } else { #endif - NautilusApp *app; - - app = NAUTILUS_APP(nautilus_app_new()); /* Run the nautilus application. */ + app = NAUTILUS_APP (nautilus_app_new ()); nautilus_app_startup (app, args ? args[0] : NULL); bonobo_main(); - bonobo_object_unref(BONOBO_OBJECT(app)); + bonobo_object_unref (BONOBO_OBJECT (app)); #if !defined (NAUTILUS_OMIT_SELF_CHECK) } diff --git a/src/ntl-uri-map.c b/src/ntl-uri-map.c index a430eaba7..eba9114e9 100644 --- a/src/ntl-uri-map.c +++ b/src/ntl-uri-map.c @@ -455,7 +455,7 @@ nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *nri, const char *referring_iid) { NautilusNavigationInfo *navinfo; - GList *metadata_keys; + GList *keys; navinfo = g_new0 (NautilusNavigationInfo, 1); @@ -474,15 +474,15 @@ nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *nri, navinfo->directory = nautilus_directory_get (nri->requested_uri); /* Arrange for all the metadata we will need. */ - metadata_keys = NULL; - metadata_keys = g_list_prepend (metadata_keys, NAUTILUS_METADATA_KEY_CONTENT_VIEWS); - metadata_keys = g_list_prepend (metadata_keys, NAUTILUS_METADATA_KEY_INITIAL_VIEW); - nautilus_directory_metadata_call_when_ready - (navinfo->directory, - metadata_keys, - got_metadata_callback, - navinfo); - g_list_free (metadata_keys); + keys = NULL; + keys = g_list_prepend (keys, NAUTILUS_METADATA_KEY_CONTENT_VIEWS); + keys = g_list_prepend (keys, NAUTILUS_METADATA_KEY_INITIAL_VIEW); + nautilus_directory_call_when_ready (navinfo->directory, + keys, + NULL, + got_metadata_callback, + navinfo); + g_list_free (keys); return navinfo; } @@ -497,7 +497,7 @@ nautilus_navigation_info_cancel (NautilusNavigationInfo *info) info->ah = NULL; } - nautilus_directory_metadata_callback_cancel + nautilus_directory_cancel_callback (info->directory, got_metadata_callback, info); } |