nautilus/test/test-nautilus-mime-actions.c

142 lines
3.5 KiB
C
Raw Normal View History

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* test-mime.c - Test for the mime handler detection features of the GNOME
Virtual File System Library
Copyright (C) 2000 Eazel
The Gnome Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the Gnome Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Author: Maciej Stachowiak <mjs@eazel.com>
*/
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
#include <config.h>
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
#include <gnome.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <stdio.h>
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
static gboolean ready = FALSE;
static void
append_comma_and_scheme (gpointer scheme,
gpointer user_data)
{
char **string;
string = (char **) user_data;
if (strlen (*string) > 0) {
*string = g_strconcat (*string, ", ", scheme, NULL);
}
else {
*string = g_strdup (scheme);
}
}
static char *
format_supported_uri_schemes_for_display (GList *supported_uri_schemes)
{
char *string;
string = g_strdup ("");
g_list_foreach (supported_uri_schemes,
append_comma_and_scheme,
&string);
return string;
}
static void
print_application (GnomeVFSMimeApplication *application)
{
if (application == NULL) {
puts ("(none)");
} else {
printf ("name: %s\ncommand: %s\ncan_open_multiple_files: %s\nexpects_uris: %s\nsupported_uri_schemes: %s\nrequires_terminal: %s\n",
application->name, application->command,
(application->can_open_multiple_files ? "TRUE" : "FALSE"),
(application->expects_uris ? "TRUE" : "FALSE"),
format_supported_uri_schemes_for_display (application->supported_uri_schemes),
(application->requires_terminal ? "TRUE" : "FALSE"));
}
}
static void
print_application_list (GList *applications)
{
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
GList *p;
if (applications == NULL) {
puts ("(none)");
} else {
for (p = applications; p != NULL; p = p->next) {
print_application (p->data);
puts ("------");
}
}
}
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
static void
ready_callback (NautilusFile *file,
gpointer callback_data)
{
ready = TRUE;
}
int
main (int argc, char **argv)
{
const char *uri;
GnomeVFSMimeApplication *default_application;
GList *all_applications;
Rename NAUTILUS_FILE_ATTRIBUTE_FAST_MIME_TYPE to * libnautilus-extensions/nautilus-file-attributes.h: Rename NAUTILUS_FILE_ATTRIBUTE_FAST_MIME_TYPE to NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE; add NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE, for now just a synonym for NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE. * libnautilus-extensions/nautilus-directory-async.c: (set_up_request_by_file_attributes): Handle the new file attributes. * libnautilus-extensions/nautilus-directory.h: move nautilus_directory_wait_until_ready call to nautilus-wait-until-ready.h * libnautilus-extensions/nautilus-directory.c: (nautilus_self_check_directory): Include nautilus-wait-until-ready.h, use new attributes. * libnautilus-extensions/nautilus-wait-until-ready.h: New header for the deprecated wait_until_ready calls. * libnautilus-extensions/nautilus-file.c: (nautilus_file_wait_until_ready): file equivalent of nautilus_directory_wait_until_ready; temporary to help me refactor. (file_wait_until_ready_callback): helper function. * libnautilus-extensions/Makefile.am: Add nautilus-wait-until-ready.h * libnautilus-extensions/nautilus-icon-factory.c: (nautilus_icon_factory_get_required_file_attributes): Use new attribute for mime type. * libnautilus-extensions/nautilus-mime-actions.h, libnautilus-extensions/nautilus-mime-actions.c: (nautilus_mime_get_default_action_type_for_uri), (nautilus_mime_get_default_action_for_uri), (nautilus_mime_get_default_application_for_uri_internal), (nautilus_mime_get_default_application_for_uri), (nautilus_mime_is_default_application_for_uri_user_chosen), (nautilus_mime_get_default_component_for_uri_internal), (nautilus_mime_get_default_component_for_uri), (nautilus_mime_is_default_component_for_uri_user_chosen), (nautilus_mime_get_short_list_applications_for_uri), (nautilus_mime_get_short_list_components_for_uri), (nautilus_mime_get_short_list_methods_for_uri), (nautilus_mime_get_all_applications_for_uri), (nautilus_mime_has_any_applications_for_uri), (nautilus_mime_get_all_components_for_uri), (nautilus_mime_has_any_components_for_uri), (nautilus_mime_set_default_action_type_for_uri), (nautilus_mime_set_default_application_for_uri), (nautilus_mime_set_default_component_for_uri), (nautilus_mime_set_short_list_applications_for_uri), (nautilus_mime_set_short_list_components_for_uri), (nautilus_mime_add_application_to_short_list_for_uri), (nautilus_mime_remove_application_from_short_list_for_uri), (nautilus_mime_add_component_to_short_list_for_uri), (nautilus_mime_remove_component_from_short_list_for_uri), (nautilus_mime_extend_all_applications_for_uri), (nautilus_mime_remove_from_all_applications_for_uri): All these functions now take a NautilusDirectory and a NautilusFile, rather than a URI. (gnome_vfs_mime_application_has_id), (gnome_vfs_mime_id_matches_application), (gnome_vfs_mime_application_has_id_not_in_list), (string_not_in_list), (extract_prefix_add_suffix), (make_oaf_query_with_known_mime_type), (make_oaf_query_with_uri_scheme_only), (free_key), (server_matches_content_requirements), (nautilus_do_component_query), (str_list_difference), (strv_concat): Reformatted. (get_mime_type_from_file): Changed from get_mime_type_from_uri; uses nautilus_file_wait_until_ready instead of synchronous I/O. * libnautilus-extensions/nautilus-program-chooser.c: (repopulate_program_list), (is_application_default_for_uri), (is_component_default_for_uri), (is_component_in_short_list_for_uri), (is_application_in_short_list_for_uri), (program_file_pair_is_default_for_file), (add_to_short_list_for_file), (remove_from_short_list_for_file), (remove_default_for_item), (set_default_for_item): * libnautilus-extensions/nautilus-program-choosing.c: (any_programs_available_for_file): * libnautilus-extensions/nautilus-wait-until-ready.h: * src/file-manager/fm-directory-view.c: (switch_location_and_view), (create_open_with_gtk_menu), (reset_bonobo_open_with_menu), (activate_callback): * src/nautilus-applicable-views.c: (got_file_info_callback), (nautilus_navigation_info_new), (nautilus_navigation_info_free): * src/nautilus-applicable-views.h: * src/nautilus-sidebar.c: (nautilus_sidebar_update_buttons): * src/nautilus-theme-selector.c: (add_theme_to_icons): * src/nautilus-window.c: (nautilus_window_switch_views), (nautilus_window_load_content_view_menu): * test/test-nautilus-mime-actions-set.c: (main): * test/test-nautilus-mime-actions.c: (main): Deal with above API changes.
2000-09-27 22:00:49 +00:00
NautilusFile *file;
Convert file attributes from list of strings to a bitmask. Patch from 2003-04-02 Alexander Larsson <alexl@redhat.com> * components/notes/nautilus-notes.c: * components/tree/nautilus-tree-model.c: * components/tree/nautilus-tree-view.c: * libnautilus-private/nautilus-directory-async.c: * libnautilus-private/nautilus-directory-background.c: * libnautilus-private/nautilus-directory-private.h: * libnautilus-private/nautilus-directory.c: * libnautilus-private/nautilus-directory.h: * libnautilus-private/nautilus-file-attributes.h: * libnautilus-private/nautilus-file-private.h: * libnautilus-private/nautilus-file.c: (rename_callback), * libnautilus-private/nautilus-file.h: * libnautilus-private/nautilus-icon-factory.c: * libnautilus-private/nautilus-icon-factory.h: * libnautilus-private/nautilus-link.c: * libnautilus-private/nautilus-merged-directory.c: * libnautilus-private/nautilus-mime-actions.c: * libnautilus-private/nautilus-mime-actions.h: * libnautilus-private/nautilus-program-choosing.c: * libnautilus-private/nautilus-trash-file.c: * libnautilus-private/nautilus-trash-monitor.c: * libnautilus-private/nautilus-vfs-directory.c: * libnautilus-private/nautilus-vfs-file.c: * src/file-manager/fm-directory-view.c: * src/file-manager/fm-icon-container.c: * src/file-manager/fm-properties-window.c: * src/nautilus-applicable-views.c: * src/nautilus-information-panel.c: * src/nautilus-sidebar-title.c: * src/nautilus-window-manage-views.c: * src/nautilus-window.c: * test/test-nautilus-mime-actions-set.c: * test/test-nautilus-mime-actions.c: Convert file attributes from list of strings to a bitmask. Patch from andersca@codefactory.se.
2003-04-02 11:51:14 +00:00
NautilusFileAttributes attributes;
gnome_program_init ("test-nautilus-mime-actions", "0.0",
LIBGNOMEUI_MODULE, argc, argv, NULL);
if (argc != 2) {
fprintf (stderr, "Usage: %s uri\n", *argv);
return 1;
}
uri = argv[1];
Rename NAUTILUS_FILE_ATTRIBUTE_FAST_MIME_TYPE to * libnautilus-extensions/nautilus-file-attributes.h: Rename NAUTILUS_FILE_ATTRIBUTE_FAST_MIME_TYPE to NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE; add NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE, for now just a synonym for NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE. * libnautilus-extensions/nautilus-directory-async.c: (set_up_request_by_file_attributes): Handle the new file attributes. * libnautilus-extensions/nautilus-directory.h: move nautilus_directory_wait_until_ready call to nautilus-wait-until-ready.h * libnautilus-extensions/nautilus-directory.c: (nautilus_self_check_directory): Include nautilus-wait-until-ready.h, use new attributes. * libnautilus-extensions/nautilus-wait-until-ready.h: New header for the deprecated wait_until_ready calls. * libnautilus-extensions/nautilus-file.c: (nautilus_file_wait_until_ready): file equivalent of nautilus_directory_wait_until_ready; temporary to help me refactor. (file_wait_until_ready_callback): helper function. * libnautilus-extensions/Makefile.am: Add nautilus-wait-until-ready.h * libnautilus-extensions/nautilus-icon-factory.c: (nautilus_icon_factory_get_required_file_attributes): Use new attribute for mime type. * libnautilus-extensions/nautilus-mime-actions.h, libnautilus-extensions/nautilus-mime-actions.c: (nautilus_mime_get_default_action_type_for_uri), (nautilus_mime_get_default_action_for_uri), (nautilus_mime_get_default_application_for_uri_internal), (nautilus_mime_get_default_application_for_uri), (nautilus_mime_is_default_application_for_uri_user_chosen), (nautilus_mime_get_default_component_for_uri_internal), (nautilus_mime_get_default_component_for_uri), (nautilus_mime_is_default_component_for_uri_user_chosen), (nautilus_mime_get_short_list_applications_for_uri), (nautilus_mime_get_short_list_components_for_uri), (nautilus_mime_get_short_list_methods_for_uri), (nautilus_mime_get_all_applications_for_uri), (nautilus_mime_has_any_applications_for_uri), (nautilus_mime_get_all_components_for_uri), (nautilus_mime_has_any_components_for_uri), (nautilus_mime_set_default_action_type_for_uri), (nautilus_mime_set_default_application_for_uri), (nautilus_mime_set_default_component_for_uri), (nautilus_mime_set_short_list_applications_for_uri), (nautilus_mime_set_short_list_components_for_uri), (nautilus_mime_add_application_to_short_list_for_uri), (nautilus_mime_remove_application_from_short_list_for_uri), (nautilus_mime_add_component_to_short_list_for_uri), (nautilus_mime_remove_component_from_short_list_for_uri), (nautilus_mime_extend_all_applications_for_uri), (nautilus_mime_remove_from_all_applications_for_uri): All these functions now take a NautilusDirectory and a NautilusFile, rather than a URI. (gnome_vfs_mime_application_has_id), (gnome_vfs_mime_id_matches_application), (gnome_vfs_mime_application_has_id_not_in_list), (string_not_in_list), (extract_prefix_add_suffix), (make_oaf_query_with_known_mime_type), (make_oaf_query_with_uri_scheme_only), (free_key), (server_matches_content_requirements), (nautilus_do_component_query), (str_list_difference), (strv_concat): Reformatted. (get_mime_type_from_file): Changed from get_mime_type_from_uri; uses nautilus_file_wait_until_ready instead of synchronous I/O. * libnautilus-extensions/nautilus-program-chooser.c: (repopulate_program_list), (is_application_default_for_uri), (is_component_default_for_uri), (is_component_in_short_list_for_uri), (is_application_in_short_list_for_uri), (program_file_pair_is_default_for_file), (add_to_short_list_for_file), (remove_from_short_list_for_file), (remove_default_for_item), (set_default_for_item): * libnautilus-extensions/nautilus-program-choosing.c: (any_programs_available_for_file): * libnautilus-extensions/nautilus-wait-until-ready.h: * src/file-manager/fm-directory-view.c: (switch_location_and_view), (create_open_with_gtk_menu), (reset_bonobo_open_with_menu), (activate_callback): * src/nautilus-applicable-views.c: (got_file_info_callback), (nautilus_navigation_info_new), (nautilus_navigation_info_free): * src/nautilus-applicable-views.h: * src/nautilus-sidebar.c: (nautilus_sidebar_update_buttons): * src/nautilus-theme-selector.c: (add_theme_to_icons): * src/nautilus-window.c: (nautilus_window_switch_views), (nautilus_window_load_content_view_menu): * test/test-nautilus-mime-actions-set.c: (main): * test/test-nautilus-mime-actions.c: (main): Deal with above API changes.
2000-09-27 22:00:49 +00:00
file = nautilus_file_get (uri);
Fixed bugzilla.eazel.com bugs 2222, 3177, 3468, 3650, 3788 (some vestiges of wait_until_ready remain in the farther reaches of the UI). * libnautilus-extensions/nautilus-mime-actions.h, libnautilus-extensions/nautilus-mime-actions.c (nautilus_mime_actions_check_if_required_attributes_ready, nautilus_mime_actions_get_required_file_attributes, nautilus_mime_actions_wait_for_required_file_attributes): New functions to help with monitoring or waiting for required attributes for the nautilus mime API. (nautilus_mime_get_default_action_type_for_file, nautilus_mime_get_default_action_for_file, nautilus_mime_get_default_application_for_file_internal, nautilus_mime_get_default_application_for_file, nautilus_mime_is_default_application_for_file_user_chosen, nautilus_mime_get_default_component_for_file_internal, nautilus_mime_get_default_component_for_file, nautilus_mime_is_default_component_for_file_user_chosen, nautilus_mime_get_short_list_applications_for_file, nautilus_mime_get_short_list_components_for_file, nautilus_mime_get_short_list_methods_for_file, nautilus_mime_get_all_applications_for_file, nautilus_mime_has_any_applications_for_file, nautilus_mime_get_all_components_for_file, nautilus_mime_has_any_components_for_file, nautilus_mime_set_default_action_type_for_file, nautilus_mime_set_default_application_for_file, nautilus_mime_set_default_component_for_file, nautilus_mime_set_short_list_applications_for_file, nautilus_mime_set_short_list_components_for_file, nautilus_mime_add_application_to_short_list_for_file, nautilus_mime_remove_application_from_short_list_for_file, nautilus_mime_add_component_to_short_list_for_file, nautilus_mime_remove_component_from_short_list_for_file, nautilus_mime_extend_all_applications_for_file, nautilus_mime_remove_from_all_applications_for_file, mime_type_get_supertype): Don't `nautilus_file_wait_until_ready' for the required attributes; instead assert (Well, return_if_fail) that they are available using `nautilus_file_check_if_ready'. Also, use `nautilus_file_get_uri_scheme' where possible. * libnautilus-extensions/nautilus-directory-async.c (mime_list_callback): Correct some coding mistakes. * libnautilus-extensions/nautilus-wait-until-ready.h, libnautilus-extensions/nautilus-directory.c: Remove `nautilus_directory_wait_until_ready'. * libnautilus-extensions/nautilus-file.h, libnautilus-extensions/nautilus-file.c (nautilus_file_get_uri_scheme): new convenience function. * libnautilus-extensions/nautilus-program-chooser.c: (repopulate_program_list, is_application_default_for_file, is_component_default_for_file, is_component_in_short_list_for_file, is_application_in_short_list_for_file, program_file_pair_is_default_for_file, program_file_pair_is_in_short_list_for_file, add_to_short_list_for_file, remove_from_short_list_for_file, remove_default_for_item, set_default_for_item): wait_until_ready for required file attributes. * libnautilus-extensions/nautilus-program-choosing.c: (any_programs_available_for_file): wait_until_ready for required file attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view, create_open_with_gtk_menu, reset_bonobo_open_with_menu, activate_callback): Wait for the right file attributes. * src/nautilus-applicable-views.c: (got_file_info_callback), (nautilus_navigation_info_new): Wait for the right file attributes. (no wait_until_ready). * src/nautilus-sidebar.c: (nautilus_sidebar_destroy, nautilus_sidebar_update_buttons, nautilus_sidebar_update_all), nautilus_sidebar_set_uri): Monitor the file the sidebar is displaying, and update when it's attributes change. * src/nautilus-window-manage-views.c (nautilus_window_set_content_view): Wait for the right file attributes. (no wait_until_ready). * src/nautilus-window.c: (nautilus_window_destroy, view_menu_choose_view_callback, view_menu_vfs_method_callback, nautilus_window_real_load_content_view_menu, nautilus_window_load_content_view_menu): Wait for the right attributes. (no wait_until_ready in this chain). * test/test-nautilus-mime-actions-set.c (main): Wait for the right attributes. * test/test-nautilus-mime-actions.c (main): Wait for the right attributes.
2000-10-18 21:57:19 +00:00
Worked on getting rid of wait_until_ready. * libnautilus-extensions/nautilus-directory.c: Got rid of include of nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-file.c: Got rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.c: (wait_until_ready_callback), (nautilus_mime_actions_wait_for_full_file_attributes): Reimplemented so the wait is in here so we can get rid of nautilus_file_wait_until_ready. * libnautilus-extensions/nautilus-mime-actions.h: Moved nautilus_mime_actions_wait_for_full_file_attributes into nautilus-wait-until-ready.h. * libnautilus-extensions/nautilus-program-chooser.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-program-choosing.c: Added include of nautilus-wait-until-ready.h since this is one of the two files that still uses the thing. * libnautilus-extensions/nautilus-wait-until-ready.h: Removed nautilsu_file_wait_until_ready and added nautilus_mime_actions_wait_for_full_file_attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view): Get rid of code that waits for attributes, because the code guarantees they will already be read at this point. (fm_directory_view_destroy): Stop monitoring the file for the open with menu. (files_changed_callback): Update the menus whenever a file changes or our knowledge about it changes. (create_open_with_gtk_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (reset_bonobo_open_with_menu): Use the new monitor call to arrange to get the information about the single selected file that we need. (activate_callback): Remove the hack to work around the wait_until_ready calls. Also remove the wait_until_ready in here because we now request all the attributes we will be needing in the call_when_ready call (that already existed). (fm_directory_view_activate_file): Request all the attributes needed for determining MIME actions. (monitor_file_for_open_with): New function to monitor the stuff we need to know for the Open with menu. * test/test-nautilus-mime-actions-set.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * test/test-nautilus-mime-actions.c: (ready_callback), (main): Use call_when_ready instead of wait_until_ready. * po/ui-extract.pl: Checked in new version from Kenneth. * po/update.pl: Kenneth wanted me to update the license.
2000-11-08 01:11:33 +00:00
attributes = nautilus_mime_actions_get_full_file_attributes ();
nautilus_file_call_when_ready (file, attributes, ready_callback, NULL);
while (!ready) {
gtk_main_iteration ();
}
Fixed bugzilla.eazel.com bugs 2222, 3177, 3468, 3650, 3788 (some vestiges of wait_until_ready remain in the farther reaches of the UI). * libnautilus-extensions/nautilus-mime-actions.h, libnautilus-extensions/nautilus-mime-actions.c (nautilus_mime_actions_check_if_required_attributes_ready, nautilus_mime_actions_get_required_file_attributes, nautilus_mime_actions_wait_for_required_file_attributes): New functions to help with monitoring or waiting for required attributes for the nautilus mime API. (nautilus_mime_get_default_action_type_for_file, nautilus_mime_get_default_action_for_file, nautilus_mime_get_default_application_for_file_internal, nautilus_mime_get_default_application_for_file, nautilus_mime_is_default_application_for_file_user_chosen, nautilus_mime_get_default_component_for_file_internal, nautilus_mime_get_default_component_for_file, nautilus_mime_is_default_component_for_file_user_chosen, nautilus_mime_get_short_list_applications_for_file, nautilus_mime_get_short_list_components_for_file, nautilus_mime_get_short_list_methods_for_file, nautilus_mime_get_all_applications_for_file, nautilus_mime_has_any_applications_for_file, nautilus_mime_get_all_components_for_file, nautilus_mime_has_any_components_for_file, nautilus_mime_set_default_action_type_for_file, nautilus_mime_set_default_application_for_file, nautilus_mime_set_default_component_for_file, nautilus_mime_set_short_list_applications_for_file, nautilus_mime_set_short_list_components_for_file, nautilus_mime_add_application_to_short_list_for_file, nautilus_mime_remove_application_from_short_list_for_file, nautilus_mime_add_component_to_short_list_for_file, nautilus_mime_remove_component_from_short_list_for_file, nautilus_mime_extend_all_applications_for_file, nautilus_mime_remove_from_all_applications_for_file, mime_type_get_supertype): Don't `nautilus_file_wait_until_ready' for the required attributes; instead assert (Well, return_if_fail) that they are available using `nautilus_file_check_if_ready'. Also, use `nautilus_file_get_uri_scheme' where possible. * libnautilus-extensions/nautilus-directory-async.c (mime_list_callback): Correct some coding mistakes. * libnautilus-extensions/nautilus-wait-until-ready.h, libnautilus-extensions/nautilus-directory.c: Remove `nautilus_directory_wait_until_ready'. * libnautilus-extensions/nautilus-file.h, libnautilus-extensions/nautilus-file.c (nautilus_file_get_uri_scheme): new convenience function. * libnautilus-extensions/nautilus-program-chooser.c: (repopulate_program_list, is_application_default_for_file, is_component_default_for_file, is_component_in_short_list_for_file, is_application_in_short_list_for_file, program_file_pair_is_default_for_file, program_file_pair_is_in_short_list_for_file, add_to_short_list_for_file, remove_from_short_list_for_file, remove_default_for_item, set_default_for_item): wait_until_ready for required file attributes. * libnautilus-extensions/nautilus-program-choosing.c: (any_programs_available_for_file): wait_until_ready for required file attributes. * src/file-manager/fm-directory-view.c: (switch_location_and_view, create_open_with_gtk_menu, reset_bonobo_open_with_menu, activate_callback): Wait for the right file attributes. * src/nautilus-applicable-views.c: (got_file_info_callback), (nautilus_navigation_info_new): Wait for the right file attributes. (no wait_until_ready). * src/nautilus-sidebar.c: (nautilus_sidebar_destroy, nautilus_sidebar_update_buttons, nautilus_sidebar_update_all), nautilus_sidebar_set_uri): Monitor the file the sidebar is displaying, and update when it's attributes change. * src/nautilus-window-manage-views.c (nautilus_window_set_content_view): Wait for the right file attributes. (no wait_until_ready). * src/nautilus-window.c: (nautilus_window_destroy, view_menu_choose_view_callback, view_menu_vfs_method_callback, nautilus_window_real_load_content_view_menu, nautilus_window_load_content_view_menu): Wait for the right attributes. (no wait_until_ready in this chain). * test/test-nautilus-mime-actions-set.c (main): Wait for the right attributes. * test/test-nautilus-mime-actions.c (main): Wait for the right attributes.
2000-10-18 21:57:19 +00:00
default_application = nautilus_mime_get_default_application_for_file (file);
puts("Default Application");
print_application (default_application);
puts ("");
all_applications = nautilus_mime_get_applications_for_file (file);
puts("All Applications");
print_application_list (all_applications);
puts ("");
return 0;
}