Commit 5e384e1b authored by John Sullivan's avatar John Sullivan

reviewed by: Darin Adler <darin@eazel.com>

	Fixed bug 4427 (Should not execute text files by default).

	Now it asks whether to run or display executable text files.
	Advanced users can set a new preference.

	* libnautilus-extensions/nautilus-stock-dialogs.h:
	* libnautilus-extensions/nautilus-stock-dialogs.c:
	(create_message_box): New bottleneck function, contains former
	guts of show_message_box but doesn't call gtk_widget_show.
	(show_message_box): Now just a simple wrapper for
	calling create_message_box and showing the result.
	(nautilus_show_info_dialog), (nautilus_show_warning_dialog),
	(nautilus_show_error_dialog), (nautilus_show_yes_no_dialog),
	(nautilus_show_error_dialog_with_details):
	Renamed to add verb "show" to names.
	(nautilus_run_simple_dialog): Renamed to add verb "run" to name.
	(nautilus_create_question_dialog): New public function, does
	not show the dialog yet so caller can add more buttons or
	whatever before showing.

	* libnautilus-extensions/nautilus-global-preferences.h:
	* libnautilus-extensions/nautilus-global-preferences.c:
	(global_preferences_install_descriptions),
	(global_preferences_install_defaults),
	(global_preferences_install_visibility),
	(global_preferences_create_dialog): Add new preference for
	what to do when an executable text file is activated. It
	defaults to "Ask" and is visible only at Advanced level.

	* libnautilus-extensions/nautilus-file-private.h:
	* libnautilus-extensions/nautilus-file.h: Moved
	nautilus_file_contains_text into public header.

	* src/file-manager/fm-directory-view.c:
	(get_executable_text_file_action): New function, uses preference
	and dialog (if necessary) to determine how to handle activating
	an executable text file.
	(activate_callback): Now handles executable text files specially
	by using get_executable_text_file_action. Restructured the control
	flow a little.

	* components/music/nautilus-music-view.c: (set_album_cover),
	(play_current_file), (nautilus_music_view_update):
	* components/rpmview/nautilus-rpm-view-install.c:
	(nautilus_rpm_view_install_done):
	* components/services/summary/nautilus-view/nautilus-summary-dialogs.c:
	(nautilus_summary_login_failure_dialog),
	(generate_error_dialog):
	* components/text/nautilus-text-view.c: (file_read_callback):
	* libnautilus-extensions/nautilus-file-operations.c:
	(confirm_empty_trash),
	(handle_transfer_vfs_error), (handle_transfer_overwrite),
	(nautilus_file_operations_copy_move),
	(handle_new_folder_vfs_error),
	(nautilus_file_operations_move_to_trash):
	* libnautilus-extensions/nautilus-icon-dnd.c:
	(confirm_switch_to_manual_layout):
	* libnautilus-extensions/nautilus-program-chooser.c:
	(nautilus_program_chooser_show_no_choices_message):
	* libnautilus-extensions/nautilus-program-choosing.c:
	(nautilus_launch_application):
	* libnautilus-extensions/nautilus-volume-monitor.c:
	(display_mount_status):
	* src/file-manager/fm-desktop-icon-view.c:
	(icon_view_create_nautilus_links):
	* src/file-manager/fm-directory-view.c:
	(fm_directory_view_confirm_multiple_windows),
	(real_file_limit_reached), (fm_directory_view_confirm_deletion),
	(confirm_delete_from_trash), (report_broken_symbolic_link),
	* src/file-manager/fm-error-reporting.c:
	(fm_report_error_renaming_file), (fm_report_error_setting_group),
	(fm_report_error_setting_owner),
	(fm_report_error_setting_permissions):
	* src/file-manager/fm-properties-window.c: (set_custom_image):
	* src/file-manager/fm-search-list-view.c: (load_location_callback),
	(load_error_callback), (display_indexed_search_problems_dialog),
	(real_file_limit_reached):
	* src/file-manager/nautilus-indexing-info.c:
	(update_file_index_callback),
	(show_search_service_not_available_dialog):
	* src/nautilus-application.c: (check_required_directories),
	(nautilus_application_startup):
	* src/nautilus-location-bar.c: (drag_data_received_callback):
	* src/nautilus-property-browser.c: (remove_pattern),
	(remove_emblem), (emblem_image_file_changed),
	(add_pattern_to_browser), (add_color_to_browser),
	(emblem_dialog_clicked):
	* src/nautilus-sidebar.c: (receive_dropped_uri_list):
	* src/nautilus-theme-selector.c: (add_theme_to_icons),
	(theme_select_row_callback):
	* src/nautilus-window-manage-views.c: (handle_unreadable_location),
	(report_content_view_failure_to_user_internal),
	(report_sidebar_panel_failure_to_user),
	(nautilus_window_end_location_change_callback):
	* src/nautilus-window-menus.c: (forget_history_if_confirmed),
	(show_bogus_bookmark_window): Updated for dialog API name changes.

	* libnautilus-extensions/nautilus-file.c: (get_description):
	Lucky Aaron gets missing mime description complaints now.
parent 0e1358ee
2001-01-29 John Sullivan <sullivan@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
Fixed bug 4427 (Should not execute text files by default).
Now it asks whether to run or display executable text files.
Advanced users can set a new preference.
* libnautilus-extensions/nautilus-stock-dialogs.h:
* libnautilus-extensions/nautilus-stock-dialogs.c:
(create_message_box): New bottleneck function, contains former
guts of show_message_box but doesn't call gtk_widget_show.
(show_message_box): Now just a simple wrapper for
calling create_message_box and showing the result.
(nautilus_show_info_dialog), (nautilus_show_warning_dialog),
(nautilus_show_error_dialog), (nautilus_show_yes_no_dialog),
(nautilus_show_error_dialog_with_details):
Renamed to add verb "show" to names.
(nautilus_run_simple_dialog): Renamed to add verb "run" to name.
(nautilus_create_question_dialog): New public function, does
not show the dialog yet so caller can add more buttons or
whatever before showing.
* libnautilus-extensions/nautilus-global-preferences.h:
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_install_descriptions),
(global_preferences_install_defaults),
(global_preferences_install_visibility),
(global_preferences_create_dialog): Add new preference for
what to do when an executable text file is activated. It
defaults to "Ask" and is visible only at Advanced level.
* libnautilus-extensions/nautilus-file-private.h:
* libnautilus-extensions/nautilus-file.h: Moved
nautilus_file_contains_text into public header.
* src/file-manager/fm-directory-view.c:
(get_executable_text_file_action): New function, uses preference
and dialog (if necessary) to determine how to handle activating
an executable text file.
(activate_callback): Now handles executable text files specially
by using get_executable_text_file_action. Restructured the control
flow a little.
* components/music/nautilus-music-view.c: (set_album_cover),
(play_current_file), (nautilus_music_view_update):
* components/rpmview/nautilus-rpm-view-install.c:
(nautilus_rpm_view_install_done):
* components/services/summary/nautilus-view/nautilus-summary-dialogs.c:
(nautilus_summary_login_failure_dialog),
(generate_error_dialog):
* components/text/nautilus-text-view.c: (file_read_callback):
* libnautilus-extensions/nautilus-file-operations.c:
(confirm_empty_trash),
(handle_transfer_vfs_error), (handle_transfer_overwrite),
(nautilus_file_operations_copy_move),
(handle_new_folder_vfs_error),
(nautilus_file_operations_move_to_trash):
* libnautilus-extensions/nautilus-icon-dnd.c:
(confirm_switch_to_manual_layout):
* libnautilus-extensions/nautilus-program-chooser.c:
(nautilus_program_chooser_show_no_choices_message):
* libnautilus-extensions/nautilus-program-choosing.c:
(nautilus_launch_application):
* libnautilus-extensions/nautilus-volume-monitor.c:
(display_mount_status):
* src/file-manager/fm-desktop-icon-view.c:
(icon_view_create_nautilus_links):
* src/file-manager/fm-directory-view.c:
(fm_directory_view_confirm_multiple_windows),
(real_file_limit_reached), (fm_directory_view_confirm_deletion),
(confirm_delete_from_trash), (report_broken_symbolic_link),
* src/file-manager/fm-error-reporting.c:
(fm_report_error_renaming_file), (fm_report_error_setting_group),
(fm_report_error_setting_owner),
(fm_report_error_setting_permissions):
* src/file-manager/fm-properties-window.c: (set_custom_image):
* src/file-manager/fm-search-list-view.c: (load_location_callback),
(load_error_callback), (display_indexed_search_problems_dialog),
(real_file_limit_reached):
* src/file-manager/nautilus-indexing-info.c:
(update_file_index_callback),
(show_search_service_not_available_dialog):
* src/nautilus-application.c: (check_required_directories),
(nautilus_application_startup):
* src/nautilus-location-bar.c: (drag_data_received_callback):
* src/nautilus-property-browser.c: (remove_pattern),
(remove_emblem), (emblem_image_file_changed),
(add_pattern_to_browser), (add_color_to_browser),
(emblem_dialog_clicked):
* src/nautilus-sidebar.c: (receive_dropped_uri_list):
* src/nautilus-theme-selector.c: (add_theme_to_icons),
(theme_select_row_callback):
* src/nautilus-window-manage-views.c: (handle_unreadable_location),
(report_content_view_failure_to_user_internal),
(report_sidebar_panel_failure_to_user),
(nautilus_window_end_location_change_callback):
* src/nautilus-window-menus.c: (forget_history_if_confirmed),
(show_bogus_bookmark_window): Updated for dialog API name changes.
* libnautilus-extensions/nautilus-file.c: (get_description):
Lucky Aaron gets missing mime description complaints now.
2001-01-29 Michael Engber <engber@eazel.com>
* libnautilus-extensions/nautilus-background.c:
......@@ -256,6 +360,7 @@ Fri Jan 26 23:58:42 2001 George Lebl <jirka@5z.com>
* libnautilus-extensions/nautilus-glib-extensions.c:
Correct spelling and naming error in a comment
2001-01-25 Darin Adler <darin@eazel.com>
reviewed by: John Sullivan <sullivan@eazel.com>
......
......@@ -687,7 +687,7 @@ set_album_cover (GtkWidget *widget, gpointer *data)
char *message = g_strdup_printf
(_("Sorry, but '%s' is not a usable image file."),
path_name);
nautilus_error_dialog (message, _("Not an Image"), NULL);
nautilus_show_error_dialog (message, _("Not an Image"), NULL);
g_free (message);
g_free (path_uri);
......@@ -1185,12 +1185,12 @@ play_current_file (NautilusMusicView *music_view, gboolean from_start)
int length;
if (esdout_playing ()) {
nautilus_error_dialog (_("Sorry, but the music view is unable to play back sound right now. "
"Either another program is using or blocking the sound card, "
"or your sound card is not configured properly. Try quitting any "
"applications that may be blocking use of the sound card."),
_("Unable to Play File"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (&music_view->parent))));
nautilus_show_error_dialog (_("Sorry, but the music view is unable to play back sound right now. "
"Either another program is using or blocking the sound card, "
"or your sound card is not configured properly. Try quitting any "
"applications that may be blocking use of the sound card."),
_("Unable to Play File"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (&music_view->parent))));
return;
}
......@@ -1209,7 +1209,7 @@ play_current_file (NautilusMusicView *music_view, gboolean from_start)
/* for now, we can only play local files, so apologize to the user and give up */
if (song_filename == NULL) {
nautilus_error_dialog
nautilus_show_error_dialog
( _("Sorry, but the music view can't play non-local files yet."),
_("Can't Play Remote Files"),
NULL);
......@@ -1717,8 +1717,8 @@ nautilus_music_view_update (NautilusMusicView *music_view)
if (result != GNOME_VFS_OK) {
path = gnome_vfs_get_local_path_from_uri (uri);
message = g_strdup_printf (_("Sorry, but there was an error reading %s."), path);
nautilus_error_dialog (message, _("Can't Read Folder"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (music_view))));
nautilus_show_error_dialog (message, _("Can't Read Folder"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (music_view))));
g_free (path);
g_free (message);
g_free (uri);
......
......@@ -249,10 +249,10 @@ nautilus_rpm_view_install_done (EazelInstallCallback *service,
window = gtk_widget_get_toplevel (GTK_WIDGET (rpm_view));
g_assert (window);
g_assert (GTK_IS_WINDOW (window));
d = nautilus_error_dialog_with_details (terse,
dialog_title,
detailed,
GTK_WINDOW (window));
d = nautilus_show_error_dialog_with_details (terse,
dialog_title,
detailed,
GTK_WINDOW (window));
/* gnome_dialog_run_and_close (d); */
g_free (terse);
......
......@@ -64,9 +64,9 @@ static void name_or_password_field_activated (GtkWidget *caption_table,
void
nautilus_summary_login_failure_dialog (NautilusSummaryView *view, const char *message)
{
nautilus_error_dialog (message,
_("Eazel Service Login Error"),
get_window_from_summary_view (view));
nautilus_show_error_dialog (message,
_("Eazel Service Login Error"),
get_window_from_summary_view (view));
}
void
......@@ -74,9 +74,9 @@ generate_error_dialog (NautilusSummaryView *view, const char *message)
{
GnomeDialog *dialog;
dialog = nautilus_error_dialog (message,
_("Service Error"),
get_window_from_summary_view (view));
dialog = nautilus_show_error_dialog (message,
_("Service Error"),
get_window_from_summary_view (view));
gtk_signal_connect (GTK_OBJECT (dialog),
"destroy",
error_dialog_cancel_cb,
......
......@@ -64,9 +64,9 @@ static void name_or_password_field_activated (GtkWidget *caption_table,
void
nautilus_summary_login_failure_dialog (NautilusSummaryView *view, const char *message)
{
nautilus_error_dialog (message,
_("Eazel Service Login Error"),
get_window_from_summary_view (view));
nautilus_show_error_dialog (message,
_("Eazel Service Login Error"),
get_window_from_summary_view (view));
}
void
......@@ -74,9 +74,9 @@ generate_error_dialog (NautilusSummaryView *view, const char *message)
{
GnomeDialog *dialog;
dialog = nautilus_error_dialog (message,
_("Service Error"),
get_window_from_summary_view (view));
dialog = nautilus_show_error_dialog (message,
_("Service Error"),
get_window_from_summary_view (view));
gtk_signal_connect (GTK_OBJECT (dialog),
"destroy",
error_dialog_cancel_cb,
......
......@@ -314,7 +314,7 @@ file_read_callback (GnomeVFSAsyncHandle *vfs_handle,
} else {
char *filename = nautilus_file_get_name(text_view->details->file);
char *message = g_strdup_printf (_("Sorry, but %s is too large for Nautilus to load all of it."), filename);
nautilus_error_dialog (message, _("File too large"), NULL);
nautilus_show_error_dialog (message, _("File too large"), NULL);
g_free (filename);
g_free (message);
......
......@@ -918,7 +918,7 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
if (error_location == ERROR_LOCATION_TARGET) {
/* We can't continue, just tell the user. */
nautilus_simple_dialog (parent_for_error_dialog (transfer_info),
nautilus_run_simple_dialog (parent_for_error_dialog (transfer_info),
TRUE, text, dialog_title, _("Stop"), NULL);
error_dialog_result = GNOME_VFS_XFER_ERROR_ACTION_ABORT;
......@@ -931,7 +931,7 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
* in the moved/copied/deleted hierarchy, we can probably
* continue. Allow the user to skip.
*/
error_dialog_button_pressed = nautilus_simple_dialog
error_dialog_button_pressed = nautilus_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE, text,
dialog_title,
_("Skip"), _("Stop"), NULL);
......@@ -950,7 +950,7 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
} else {
/* Generic error, offer to retry and skip. */
error_dialog_button_pressed = nautilus_simple_dialog
error_dialog_button_pressed = nautilus_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE, text,
dialog_title,
_("Skip"), _("Retry"), _("Stop"), NULL);
......@@ -1044,7 +1044,7 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
formatted_name, formatted_name);
}
nautilus_simple_dialog (parent_for_error_dialog (transfer_info), TRUE, text,
nautilus_run_simple_dialog (parent_for_error_dialog (transfer_info), TRUE, text,
_("Unable to replace file."), _("OK"), NULL, NULL);
g_free (text);
......@@ -1064,7 +1064,7 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
/* we are going to only get one duplicate alert, don't offer
* Replace All
*/
result = nautilus_simple_dialog
result = nautilus_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE, text,
_("Conflict while copying"),
_("Replace"), _("Skip"), NULL);
......@@ -1078,7 +1078,7 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
return GNOME_VFS_XFER_OVERWRITE_ACTION_SKIP;
}
} else {
result = nautilus_simple_dialog
result = nautilus_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE, text,
_("Conflict while copying"),
_("Replace All"), _("Replace"), _("Skip"), NULL);
......@@ -1823,7 +1823,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) == 0) {
/* don't allow copying into Trash */
if (check_target_directory_is_or_in_trash (trash_dir_uri, target_dir_uri)) {
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view,
FALSE,
_("You cannot copy items into the Trash."),
......@@ -1849,7 +1849,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
*/
is_desktop_trash_link = vfs_uri_is_special_link (uri);
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view,
FALSE,
......@@ -1876,7 +1876,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
if ((move_options & GNOME_VFS_XFER_LINK_ITEMS) == 0
&& (gnome_vfs_uri_equal (uri, target_dir_uri)
|| gnome_vfs_uri_is_parent (uri, target_dir_uri, TRUE))) {
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view,
FALSE,
((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
......@@ -1891,7 +1891,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
break;
}
if (gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view,
FALSE,
((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0)
......@@ -1964,8 +1964,8 @@ handle_new_folder_vfs_error (const GnomeVFSXferProgressInfo *progress_info, NewF
gnome_vfs_result_to_string(progress_info->vfs_status));
}
nautilus_error_dialog (error_string, _("Error creating new folder"),
GTK_WINDOW (state->parent_view));
nautilus_show_error_dialog (error_string, _("Error creating new folder"),
GTK_WINDOW (state->parent_view));
g_free (error_string_to_free);
......@@ -2113,7 +2113,7 @@ nautilus_file_operations_move_to_trash (const GList *item_uris,
target_uri_list = g_list_prepend (target_uri_list, append_basename (trash_dir_uri, source_uri));
if (gnome_vfs_uri_equal (source_uri, trash_dir_uri)) {
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view,
FALSE,
_("The Trash must remain on the desktop."),
......@@ -2125,7 +2125,7 @@ nautilus_file_operations_move_to_trash (const GList *item_uris,
text = g_strdup_printf
(_("You cannot throw \"%s\" into the Trash."),
item_name);
nautilus_simple_dialog
nautilus_run_simple_dialog
(parent_view, FALSE, text,
_("Error Moving to Trash"),
GNOME_STOCK_BUTTON_OK, NULL, NULL);
......@@ -2269,7 +2269,7 @@ confirm_empty_trash (GtkWidget *parent_view)
parent_window = GTK_WINDOW (gtk_widget_get_toplevel (parent_view));
dialog = nautilus_yes_no_dialog (
dialog = nautilus_show_yes_no_dialog (
_("Are you sure you want to permanently delete "
"all of the items in the trash?"),
_("Delete Trash Contents?"),
......
......@@ -108,7 +108,6 @@ gboolean nautilus_file_info_missing (NautilusFile
GnomeVFSFileInfoFields needed_mask);
char * nautilus_extract_top_left_text (const char *text,
int length);
gboolean nautilus_file_contains_text (NautilusFile *file);
void nautilus_file_set_directory (NautilusFile *file,
NautilusDirectory *directory);
gboolean nautilus_file_get_date (NautilusFile *file,
......
......@@ -3698,7 +3698,7 @@ get_description (NautilusFile *file)
"or isn't being found for some other reason."));
} else {
g_warning (_("No description found for mime type \"%s\" (file is \"%s\"), "
"tell sullivan@eazel.com"),
"tell aaron@eazel.com"),
mime_type,
file->details->relative_uri);
}
......
......@@ -116,6 +116,7 @@ void nautilus_file_invalidate_attributes (Nautilu
void nautilus_file_invalidate_all_attributes (NautilusFile *file);
/* Basic attributes for file objects. */
gboolean nautilus_file_contains_text (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file);
char * nautilus_file_get_uri (NautilusFile *file);
char * nautilus_file_get_uri_scheme (NautilusFile *file);
......
......@@ -109,6 +109,25 @@ global_preferences_install_descriptions (void)
_("Activate items with a double click"),
NAUTILUS_CLICK_POLICY_DOUBLE);
/* Click activation type */
nautilus_preferences_set_description (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
_("Activating Executable Text Files"));
nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
_("launch"),
_("Always execute"),
NAUTILUS_EXECUTABLE_TEXT_LAUNCH);
nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
_("display"),
_("Always display"),
NAUTILUS_EXECUTABLE_TEXT_DISPLAY);
nautilus_preferences_enumeration_insert (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
_("ask"),
_("Ask each time"),
NAUTILUS_EXECUTABLE_TEXT_ASK);
/*
* Speed tradeoffs
*/
......@@ -242,6 +261,10 @@ global_preferences_install_defaults (void)
NAUTILUS_USER_LEVEL_NOVICE,
NAUTILUS_CLICK_POLICY_DOUBLE);
nautilus_preferences_default_set_integer (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
NAUTILUS_USER_LEVEL_NOVICE,
NAUTILUS_EXECUTABLE_TEXT_ASK);
nautilus_preferences_default_set_string (NAUTILUS_PREFERENCES_THEME,
NAUTILUS_USER_LEVEL_NOVICE,
"default");
......@@ -386,6 +409,9 @@ global_preferences_install_visibility (void)
nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS,
NAUTILUS_USER_LEVEL_HACKER);
nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
NAUTILUS_USER_LEVEL_HACKER);
nautilus_preferences_set_visible_user_level (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE,
NAUTILUS_USER_LEVEL_INTERMEDIATE);
......@@ -576,6 +602,13 @@ global_preferences_create_dialog (void)
NAUTILUS_PREFERENCES_SHOW_SPECIAL_FLAGS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane), _("Activating Executable Text Files"));
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (directory_views_pane),
4,
NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION,
NAUTILUS_PREFERENCE_ITEM_ENUM);
/*
* Search Settings
*/
......
......@@ -68,6 +68,9 @@ BEGIN_GNOME_DECLS
/* Single/Double click preference */
#define NAUTILUS_PREFERENCES_CLICK_POLICY "preferences/click_policy"
/* Activating executable text files */
#define NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "preferences/executable_text_activation"
/* Smooth graphics mode (smoother but slower) */
#define NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE "preferences/smooth_graphics_mode"
......@@ -99,6 +102,13 @@ enum
NAUTILUS_CLICK_POLICY_DOUBLE
};
enum
{
NAUTILUS_EXECUTABLE_TEXT_LAUNCH,
NAUTILUS_EXECUTABLE_TEXT_DISPLAY,
NAUTILUS_EXECUTABLE_TEXT_ASK
};
typedef enum
{
NAUTILUS_SPEED_TRADEOFF_ALWAYS,
......
......@@ -740,10 +740,10 @@ confirm_switch_to_manual_layout (NautilusIconContainer *container)
}
}
dialog = nautilus_yes_no_dialog (message, _("Switch to Manual Layout?"),
_("Switch"), GNOME_STOCK_BUTTON_CANCEL,
GTK_WINDOW (gtk_widget_get_ancestor
(GTK_WIDGET (container), GTK_TYPE_WINDOW)));
dialog = nautilus_show_yes_no_dialog (message, _("Switch to Manual Layout?"),
_("Switch"), GNOME_STOCK_BUTTON_CANCEL,
GTK_WINDOW (gtk_widget_get_ancestor
(GTK_WIDGET (container), GTK_TYPE_WINDOW)));
return gnome_dialog_run (dialog) == GNOME_OK;
}
......
......@@ -1455,7 +1455,7 @@ nautilus_program_chooser_show_no_choices_message (GnomeVFSMimeActionType action_
"for which file types with the \"File Types and "
"Programs\" part of the GNOME Control Center. Do "
"you want to go there now?", unavailable_message);
dialog = nautilus_yes_no_dialog
dialog = nautilus_show_yes_no_dialog
(prompt, dialog_title, GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, parent_window);
gnome_dialog_button_connect (dialog, GNOME_OK, launch_mime_capplet, NULL);
......
......@@ -445,7 +445,7 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
"\"%s\" is remote. If you want to open it "
"with %s, make a local copy first."),
application->name, uri, application->name);
dialog = nautilus_error_dialog (prompt, _("Can't open remote file"), parent_window);
dialog = nautilus_show_error_dialog (prompt, _("Can't open remote file"), parent_window);
g_free (prompt);
return;
}
......
......@@ -314,7 +314,7 @@ delete_event_callback (gpointer data,
}
int
nautilus_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
nautilus_run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box,
const char *text, const char *title, ...)
{
va_list button_title_args;
......@@ -397,11 +397,11 @@ find_message_label_callback (GtkWidget *widget, gpointer callback_data)
}
static GnomeDialog *
show_message_box (const char *message,
create_message_box (const char *message,
const char *dialog_title,
const char *type,
const char *button_one,
const char *button_two,
const char *button_0,
const char *button_1,
GtkWindow *parent)
{
GtkWidget *box;
......@@ -409,7 +409,7 @@ show_message_box (const char *message,
g_assert (dialog_title != NULL);
box = gnome_message_box_new (message, type, button_one, button_two, NULL);
box = gnome_message_box_new (message, type, button_0, button_1, NULL);
gtk_window_set_title (GTK_WINDOW (box), dialog_title);
gtk_window_set_wmclass (GTK_WINDOW (box), "stock_dialog", "Nautilus");
......@@ -424,10 +424,26 @@ show_message_box (const char *message,
if (parent != NULL) {
gnome_dialog_set_parent (GNOME_DIALOG (box), parent);
}
gtk_widget_show (box);
return GNOME_DIALOG (box);
}
static GnomeDialog *
show_message_box (const char *message,
const char *dialog_title,
const char *type,
const char *button_0,
const char *button_1,
GtkWindow *parent)
{
GnomeDialog *dialog;
dialog = create_message_box (message, dialog_title, type,
button_0, button_1, parent);
gtk_widget_show (GTK_WIDGET (dialog));
return dialog;
}
static GnomeDialog *
show_ok_box (const char *message,
const char *dialog_title,
......@@ -438,9 +454,9 @@ show_ok_box (const char *message,
}
GnomeDialog *
nautilus_info_dialog (const char *info,
const char *dialog_title,
GtkWindow *parent)
nautilus_show_info_dialog (const char *info,
const char *dialog_title,
GtkWindow *parent)
{
return show_ok_box (info,
dialog_title == NULL ? _("Info") : dialog_title,
......@@ -448,9 +464,9 @@ nautilus_info_dialog (const char *info,
}
GnomeDialog *
nautilus_warning_dialog (const char *warning,
const char *dialog_title,
GtkWindow *parent)
nautilus_show_warning_dialog (const char *warning,
const char *dialog_title,
GtkWindow *parent)
{
return show_ok_box (warning,
dialog_title == NULL ? _("Warning") : dialog_title,
......@@ -458,9 +474,9 @@ nautilus_warning_dialog (const char *warning,
}
GnomeDialog *
nautilus_error_dialog (const char *error,
const char *dialog_title,
GtkWindow *parent)
nautilus_show_error_dialog (const char *error,
const char *dialog_title,
GtkWindow *parent)
{
return show_ok_box (error,
dialog_title == NULL ? _("Error") : dialog_title,
......@@ -487,10 +503,10 @@ clicked_callback (GnomeDialog *dialog,
}
GnomeDialog *
nautilus_error_dialog_with_details (const char *error_message,
const char *dialog_title,
const char *detailed_error_message,
GtkWindow *parent)
nautilus_show_error_dialog_with_details (const char *error_message,
const char *dialog_title,
const char *detailed_error_message,
GtkWindow *parent)
{
GnomeDialog *dialog;
......@@ -499,7 +515,7 @@ nautilus_error_dialog_with_details (const char *error_message,
if (detailed_error_message == NULL
|| strcmp (error_message, detailed_error_message) == 0) {
return nautilus_error_dialog (error_message, dialog_title, parent);
return nautilus_show_error_dialog (error_message, dialog_title, parent);
}
dialog = show_message_box (error_message,
......@@ -517,22 +533,23 @@ nautilus_error_dialog_with_details (const char *error_message,
}
/**
* nautilus_yes_no_dialog:
* nautilus_show_yes_no_dialog:
*
* Create a dialog asking a question with two choices.
* Create and show a dialog asking a question with two choices.
* The caller needs to set up any necessary callbacks
* for the buttons.
* for the buttons. Use nautilus_create_question_dialog instead
* if any visual changes need to be made, to avoid flashiness.
* @question: The text of the question.
* @yes_label: The label of the "yes" button.
* @no_label: The label of the "no" button.
* @parent: The parent window for this dialog.
*/
GnomeDialog *
nautilus_yes_no_dialog (const char *question,
const char *dialog_title,
const char *yes_label,
const char *no_label,
GtkWindow *parent)
nautilus_show_yes_no_dialog (const char *question,
const char *dialog_title,
const char *yes_label,
const char *no_label,
GtkWindow *parent)
{
return show_message_box (question,
dialog_title == NULL ? _("Question") : dialog_title,
......@@ -541,3 +558,31 @@ nautilus_yes_no_dialog (const char *question,
no_label,
parent);
}
/**
* nautilus_create_question_dialog:
*
* Create a dialog asking a question with at least two choices.
* The caller needs to set up any necessary callbacks
* for the buttons. The dialog is not yet shown, so that the
* caller can add additional buttons or make other visual changes
* without causing flashiness.
* @question: The text of the question.
* @answer_0: The label of the leftmost button (index 0)
* @answer_1: The label of the 2nd-to-leftmost button (index 1)
* @parent: The parent window for this dialog.
*/
GnomeDialog *
nautilus_create_question_dialog (const char *question,
const char *dialog_title,
const char *answer_0,
const char *answer_1,
GtkWindow *parent)
{
return create_message_box (question,
dialog_title == NULL ? _("Question") : dialog_title,
GNOME_MESSAGE_BOX_QUESTION,
answer_0,
answer_1,
parent);
}
......@@ -46,7 +46,7 @@ void nautilus_timed_wait_stop (NautilusCancelCallback cancel_
gpointer callback_data);
/* Basic dialog with buttons. */
int nautilus_simple_dialog (GtkWidget *parent,
int nautilus_run_simple_dialog (GtkWidget *parent,
gboolean ignore_close_box,
const char *text,
const char *title,
......@@ -56,23 +56,29 @@ int nautilus_simple_dialog (GtkWidget *parent,
* bother with non-parented versions, we allow setting the title,
* and we return GnomeDialog pointers instead of GtkWidget pointers.
*/
GnomeDialog *nautilus_info_dialog (const char *informative_message,
const char *dialog_title,
GtkWindow *parent);
GnomeDialog *nautilus_warning_dialog (const char *warning_message,