diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-11-16 18:16:25 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-11-16 18:16:25 +0000 |
commit | bc9068b70325604d549360500fb02a8ee65efb83 (patch) | |
tree | 25e055e4d6c0ab78ad7fd724c054d47f0a7a08d7 | |
parent | 68cb4f41bb28206ea666dd398298f030c5b8746c (diff) | |
download | nautilus-bc9068b70325604d549360500fb02a8ee65efb83.tar.gz |
Removed a ton of code that was used only for the gtk
context menus, which are gone now that we're using
Bonobo for context menus. There's still some reworking
of code formerly shared by gtk & Bonobo menus to do, but
I'll do that in a separate pass.
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-directory-view.c:
(fm_directory_view_initialize_class): Removed signal definitions
and function assignments for create_selection_context_menu_items
and create_background_context_menu_items.
(compute_menu_item_info): Do special_link_in_selection tests here;
previously they were done only for the gtk context menus (so for
the past day we've had an as-yet-unnoticed bug where certain
context menu items on the desktop were sensitive but shouldn't
have been).
(fm_directory_view_pop_up_selection_context_menu),
(fm_directory_view_pop_up_background_context_menu):
Removed the iffed-out case that used the gtk context menus.
(zoom_in_callback), (zoom_out_callback), (zoom_default_callback),
(finish_inserting_menu_item), (finish_appending_menu_item),
(set_menu_item_path), (append_gtk_menu_item),
(append_selection_menu_subtree),
(fm_directory_view_insert_context_menu_item),
(fm_directory_view_append_context_menu_item),
(create_background_context_menu_items),
(real_create_background_context_menu_items),
(launch_application_from_menu_item), (view_uri_from_menu_item),
(add_application_to_gtk_menu), (add_component_to_gtk_menu),
(create_open_with_gtk_menu),
(real_create_selection_context_menu_items),
(create_selection_context_menu),
(fm_directory_view_create_background_context_menu_items),
(create_background_context_menu), (menu_item_matches_path),
(fm_directory_view_get_context_menu_index):
Removed obsolete functions.
* src/file-manager/fm-desktop-icon-view.c:
(fm_desktop_icon_view_initialize_class): Removed obsolete
virtual function overrides.
(real_update_menus): Removed debugging spam I had accidentally
left in.
(new_terminal_menu_item_callback),
(reset_desktop_background_menu_item_callback),
(change_desktop_background_menu_item_callback),
(quit_nautilus_desktop_menu_item_callback),
(empty_trash_menu_item_callback),
(fm_desktop_icon_view_create_selection_context_menu_items),
(fm_desktop_icon_view_create_background_context_menu_items),
(mount_unmount_removable): Removed obsolete functions.
* src/file-manager/fm-icon-view.c:
(special_link_in_selection): Just moved this function up.
(compute_menu_item_info): Check special_link_in_function for
rename menu item; formerly this only happened for the gtk
context menu.
(fm_icon_view_initialize_class): Removed obsolete virtual
function overrides.
(gtk_tighter_layout_callback), (gtk_sort_reversed_callback),
(context_menu_layout_radio_item_callback),
(append_one_context_menu_layout_item),
(insert_one_context_menu_item), (append_one_context_menu_item),
(append_one_toggle_context_menu_item),
(fm_icon_view_create_selection_context_menu_items),
(fm_icon_view_create_background_context_menu_items):
Removed obsolete functions.
* src/file-manager/fm-search-list-view.c:
(fm_search_list_view_initialize_class): Removed obsolete
virtual function override.
(real_create_selection_context_menu_items):
Removed obsolete function.
-rw-r--r-- | ChangeLog | 80 | ||||
-rw-r--r-- | src/file-manager/fm-desktop-icon-view.c | 219 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 607 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.h | 30 | ||||
-rw-r--r-- | src/file-manager/fm-icon-view.c | 330 | ||||
-rw-r--r-- | src/file-manager/fm-search-list-view.c | 38 |
6 files changed, 122 insertions, 1182 deletions
@@ -1,5 +1,85 @@ 2000-11-16 John Sullivan <sullivan@eazel.com> + Removed a ton of code that was used only for the gtk + context menus, which are gone now that we're using + Bonobo for context menus. There's still some reworking + of code formerly shared by gtk & Bonobo menus to do, but + I'll do that in a separate pass. + + * src/file-manager/fm-directory-view.h: + * src/file-manager/fm-directory-view.c: + (fm_directory_view_initialize_class): Removed signal definitions + and function assignments for create_selection_context_menu_items + and create_background_context_menu_items. + + (compute_menu_item_info): Do special_link_in_selection tests here; + previously they were done only for the gtk context menus (so for + the past day we've had an as-yet-unnoticed bug where certain + context menu items on the desktop were sensitive but shouldn't + have been). + (fm_directory_view_pop_up_selection_context_menu), + (fm_directory_view_pop_up_background_context_menu): + Removed the iffed-out case that used the gtk context menus. + + (zoom_in_callback), (zoom_out_callback), (zoom_default_callback), + (finish_inserting_menu_item), (finish_appending_menu_item), + (set_menu_item_path), (append_gtk_menu_item), + (append_selection_menu_subtree), + (fm_directory_view_insert_context_menu_item), + (fm_directory_view_append_context_menu_item), + (create_background_context_menu_items), + (real_create_background_context_menu_items), + (launch_application_from_menu_item), (view_uri_from_menu_item), + (add_application_to_gtk_menu), (add_component_to_gtk_menu), + (create_open_with_gtk_menu), + (real_create_selection_context_menu_items), + (create_selection_context_menu), + (fm_directory_view_create_background_context_menu_items), + (create_background_context_menu), (menu_item_matches_path), + (fm_directory_view_get_context_menu_index): + Removed obsolete functions. + + * src/file-manager/fm-desktop-icon-view.c: + (fm_desktop_icon_view_initialize_class): Removed obsolete + virtual function overrides. + (real_update_menus): Removed debugging spam I had accidentally + left in. + + (new_terminal_menu_item_callback), + (reset_desktop_background_menu_item_callback), + (change_desktop_background_menu_item_callback), + (quit_nautilus_desktop_menu_item_callback), + (empty_trash_menu_item_callback), + (fm_desktop_icon_view_create_selection_context_menu_items), + (fm_desktop_icon_view_create_background_context_menu_items), + (mount_unmount_removable): Removed obsolete functions. + + * src/file-manager/fm-icon-view.c: + (special_link_in_selection): Just moved this function up. + (compute_menu_item_info): Check special_link_in_function for + rename menu item; formerly this only happened for the gtk + context menu. + (fm_icon_view_initialize_class): Removed obsolete virtual + function overrides. + + (gtk_tighter_layout_callback), (gtk_sort_reversed_callback), + (context_menu_layout_radio_item_callback), + (append_one_context_menu_layout_item), + (insert_one_context_menu_item), (append_one_context_menu_item), + (append_one_toggle_context_menu_item), + (fm_icon_view_create_selection_context_menu_items), + (fm_icon_view_create_background_context_menu_items): + Removed obsolete functions. + + * src/file-manager/fm-search-list-view.c: + (fm_search_list_view_initialize_class): Removed obsolete + virtual function override. + + (real_create_selection_context_menu_items): + Removed obsolete function. + +2000-11-16 John Sullivan <sullivan@eazel.com> + * libnautilus-extensions/nautilus-file-utilities.h: Added #define NAUTILUS_TRASH_URI "trash:" diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 200b91a36..6e8cc331e 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -83,11 +83,6 @@ typedef struct { static void fm_desktop_icon_view_initialize (FMDesktopIconView *desktop_icon_view); static void fm_desktop_icon_view_initialize_class (FMDesktopIconViewClass *klass); -static void fm_desktop_icon_view_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu); -static void fm_desktop_icon_view_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *files); static void fm_desktop_icon_view_trash_state_changed_callback (NautilusTrashMonitor *trash, gboolean state, gpointer callback_data); @@ -102,8 +97,6 @@ static void icon_view_create_nautilus_links (NautilusIconContainer *contai int x, int y, FMDirectoryView *view); -static void mount_unmount_removable (GtkCheckMenuItem *item, - FMDesktopIconView *icon_view); static void place_home_directory (FMDesktopIconView *icon_view); static void remove_old_mount_links (void); static int desktop_icons_compare_callback (NautilusIconContainer *container, @@ -164,8 +157,6 @@ fm_desktop_icon_view_initialize_class (FMDesktopIconViewClass *klass) object_class->destroy = fm_desktop_icon_view_destroy; - fm_directory_view_class->create_background_context_menu_items = fm_desktop_icon_view_create_background_context_menu_items; - fm_directory_view_class->create_selection_context_menu_items = fm_desktop_icon_view_create_selection_context_menu_items; fm_directory_view_class->merge_menus = real_merge_menus; fm_directory_view_class->update_menus = real_update_menus; fm_directory_view_class->supports_zooming = real_supports_zooming; @@ -403,54 +394,6 @@ quit_desktop_callback (BonoboUIComponent *component, nautilus_application_close_desktop (); } -/* FIXME bugzilla.eazel.com 3579: - * This is obsolete when the context menus are converted to Bonobo. - */ -static void -new_terminal_menu_item_callback (GtkMenuItem *item, FMDirectoryView *view) -{ - g_assert (FM_IS_DIRECTORY_VIEW (view)); - nautilus_gnome_open_terminal (NULL); -} - -/* FIXME bugzilla.eazel.com 3579: - * This is obsolete when the context menus are converted to Bonobo. - */ -static void -reset_desktop_background_menu_item_callback (GtkMenuItem *item, FMDirectoryView *view) -{ - nautilus_background_reset (fm_directory_view_get_background (view)); -} - -/* FIXME bugzilla.eazel.com 3579: - * This is obsolete when the context menus are converted to Bonobo. - */ -static void -change_desktop_background_menu_item_callback (GtkMenuItem *item, FMDirectoryView *view) -{ - nautilus_launch_application_from_command ("background-properties-capplet", NULL, FALSE); -} - -/* FIXME bugzilla.eazel.com 3579: - * This is obsolete when the context menus are converted to Bonobo. - */ -static void -quit_nautilus_desktop_menu_item_callback (GtkMenuItem *item, FMDirectoryView *view) -{ - nautilus_application_close_desktop (); -} - -/* FIXME bugzilla.eazel.com 3579: - * This is obsolete when the context menus are converted to Bonobo. - */ -static void -empty_trash_menu_item_callback (gpointer ignored, gpointer view) -{ - g_assert (FM_IS_DIRECTORY_VIEW (view)); - - nautilus_file_operations_empty_trash (GTK_WIDGET (FM_DIRECTORY_VIEW (view))); -} - static gboolean trash_link_is_selection (FMDirectoryView *view) { @@ -482,148 +425,6 @@ trash_link_is_selection (FMDirectoryView *view) } static void -fm_desktop_icon_view_create_selection_context_menu_items (FMDirectoryView *view, GtkMenu *menu, GList *files) -{ - GtkWidget *menu_item; - - g_assert (FM_IS_ICON_VIEW (view)); - g_assert (GTK_IS_MENU (menu)); - - NAUTILUS_CALL_PARENT_CLASS - (FM_DIRECTORY_VIEW_CLASS, - create_selection_context_menu_items, - (view, menu, files)); - - /* Add Empty Trash item if only the trash link is the selection */ - if (trash_link_is_selection (view)) { - /* add a separator for more clarity */ - menu_item = gtk_menu_item_new (); - gtk_widget_show (menu_item); - gtk_menu_append (menu, menu_item); - - menu_item = gtk_menu_item_new_with_label (_("Empty Trash")); - gtk_widget_show (menu_item); - gtk_menu_append (menu, menu_item); - gtk_signal_connect (GTK_OBJECT (menu_item), - "activate", - empty_trash_menu_item_callback, - view); - gtk_widget_set_sensitive (menu_item, !nautilus_trash_monitor_is_empty ()); - } -} - -static void -fm_desktop_icon_view_create_background_context_menu_items (FMDirectoryView *view, GtkMenu *menu) -{ - GtkWidget *menu_item; - int position; - - g_assert (FM_IS_DIRECTORY_VIEW (view)); - g_assert (GTK_IS_MENU (menu)); - - NAUTILUS_CALL_PARENT_CLASS - (FM_DIRECTORY_VIEW_CLASS, - create_background_context_menu_items, - (view, menu)); - - position = fm_directory_view_get_context_menu_index - (menu, FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER) + 1; - fm_directory_view_insert_context_menu_item - (view, menu, - _("New Terminal"), - NULL, - position, - new_terminal_menu_item_callback, - TRUE); - - /* Add Disks item to show state of removable volumes */ - nautilus_gtk_menu_append_separator (menu); - - menu_item = gtk_menu_item_new_with_label (_("Disks")); - gtk_widget_show (menu_item); - gtk_menu_append (menu, menu_item); - - { - GtkMenu *sub_menu; - GList *disk_list; - GList *element; - GtkWidget *check_menu_item; - gboolean active; - char *name; - NautilusVolume *volume; - - /* Get a list containing the all removable volumes in the volume monitor */ - disk_list = nautilus_volume_monitor_get_removable_volumes (nautilus_volume_monitor_get ()); - - /* Create submenu to place them in */ - sub_menu = GTK_MENU (gtk_menu_new ()); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), GTK_WIDGET (sub_menu)); - - /* Iterate list and populate menu with removable volumes */ - for (element = disk_list; element != NULL; element = element->next) { - volume = element->data; - - /* Create item with human readable name */ - name = strrchr (volume->mount_path, '/'); - if (name != NULL) { - check_menu_item = gtk_check_menu_item_new_with_label (name + 1); - } else { - check_menu_item = gtk_check_menu_item_new_with_label (volume->mount_path); - } - - /* Add check mark if volume is mounted */ - active = nautilus_volume_monitor_volume_is_mounted (volume); - gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (check_menu_item), TRUE); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (check_menu_item), active); - - /* Add some data to the menu item for later mount operations */ - gtk_object_set_data_full (GTK_OBJECT (check_menu_item), "mount_point", - g_strdup (volume->mount_path), g_free); - - gtk_signal_connect (GTK_OBJECT (check_menu_item), - "activate", - GTK_SIGNAL_FUNC (mount_unmount_removable), - FM_DESKTOP_ICON_VIEW (view)); - - gtk_menu_append (sub_menu, check_menu_item); - gtk_widget_show (check_menu_item); - } - g_list_free (disk_list); - } - - position = fm_directory_view_get_context_menu_index - (menu, FM_DIRECTORY_VIEW_COMMAND_RESET_BACKGROUND); - /* Hide the old Reset Background item so we can replace it with one of our own */ - nautilus_gtk_menu_set_item_visibility (menu, position, FALSE); - - fm_directory_view_insert_context_menu_item - (view, menu, - _("Reset Desktop Background"), - NULL, - position++, - reset_desktop_background_menu_item_callback, - nautilus_file_background_is_set (fm_directory_view_get_background (view))); - - fm_directory_view_insert_context_menu_item - (view, menu, - _("Change Desktop Background"), - NULL, - position++, - change_desktop_background_menu_item_callback, - TRUE); - - nautilus_gtk_menu_insert_separator (menu, position++); - - fm_directory_view_insert_context_menu_item - (view, menu, - _("Quit Nautilus Desktop"), - NULL, - position++, - quit_nautilus_desktop_menu_item_callback, - TRUE); -} - -static void fm_desktop_icon_view_trash_state_changed_callback (NautilusTrashMonitor *trash_monitor, gboolean state, gpointer callback_data) { @@ -830,25 +631,6 @@ icon_view_create_nautilus_links (NautilusIconContainer *container, const GList * } -static void -mount_unmount_removable (GtkCheckMenuItem *item, FMDesktopIconView *icon_view) -{ - gboolean is_mounted; - char *mount_point; - - is_mounted = FALSE; - - /* Locate our mount point data */ - mount_point = gtk_object_get_data (GTK_OBJECT (item), "mount_point"); - if (mount_point != NULL) { - is_mounted = nautilus_volume_monitor_mount_unmount_removable - (nautilus_volume_monitor_get (), mount_point); - } - - /* Set the check state of menu item even thought the user may not see it */ - gtk_check_menu_item_set_active (item, is_mounted); -} - static gboolean find_and_update_home_link (void) { @@ -1263,7 +1045,6 @@ real_update_menus (FMDirectoryView *view) } else { label = g_strdup (_("Empty Trash")); } - g_message ("calling nautilus_bonobo_set_label on %s with %s", DESKTOP_COMMAND_EMPTY_TRASH_CONDITIONAL, label); nautilus_bonobo_set_label (desktop_view->details->ui, DESKTOP_COMMAND_EMPTY_TRASH_CONDITIONAL, diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 0a03648e4..c3837b973 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -102,8 +102,6 @@ enum { ADD_FILE, - CREATE_BACKGROUND_CONTEXT_MENU_ITEMS, - CREATE_SELECTION_CONTEXT_MENU_ITEMS, BEGIN_ADDING_FILES, BEGIN_LOADING, LOAD_ERROR, @@ -169,17 +167,10 @@ static void fm_directory_view_destroy static void fm_directory_view_activate_file (FMDirectoryView *view, NautilusFile *file, gboolean use_new_window); -static void fm_directory_view_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu); static void load_directory (FMDirectoryView *view, NautilusDirectory *directory, gboolean force_reload); static void fm_directory_view_merge_menus (FMDirectoryView *view); -static void real_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu); -static void real_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *files); static void real_merge_menus (FMDirectoryView *view); static void real_update_menus (FMDirectoryView *view); static gboolean real_is_read_only (FMDirectoryView *view); @@ -187,8 +178,6 @@ static gboolean real_supports_creating_files static gboolean real_accepts_dragged_files (FMDirectoryView *view); static gboolean real_supports_zooming (FMDirectoryView *view); static gboolean real_supports_properties (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_loading_callback (NautilusView *nautilus_view, FMDirectoryView *directory_view); @@ -306,23 +295,7 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass) GTK_SIGNAL_OFFSET (FMDirectoryViewClass, load_error), gtk_marshal_NONE__INT, GTK_TYPE_NONE, 1, GTK_TYPE_INT); - signals[CREATE_SELECTION_CONTEXT_MENU_ITEMS] = - gtk_signal_new ("create_selection_context_menu_items", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (FMDirectoryViewClass, create_selection_context_menu_items), - nautilus_gtk_marshal_NONE__BOXED_BOXED, - GTK_TYPE_NONE, 2, GTK_TYPE_BOXED, GTK_TYPE_BOXED); - signals[CREATE_BACKGROUND_CONTEXT_MENU_ITEMS] = - gtk_signal_new ("create_background_context_menu_items", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (FMDirectoryViewClass, create_background_context_menu_items), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - klass->create_selection_context_menu_items = real_create_selection_context_menu_items; - klass->create_background_context_menu_items = real_create_background_context_menu_items; klass->merge_menus = real_merge_menus; klass->update_menus = real_update_menus; klass->get_emblem_names_to_exclude = real_get_emblem_names_to_exclude; @@ -1447,25 +1420,6 @@ reset_background_callback (gpointer ignored, gpointer callback_data) /* handle the zoom in/out menu items */ static void -zoom_in_callback (GtkMenuItem *item, FMDirectoryView *directory_view) -{ - fm_directory_view_bump_zoom_level (directory_view, 1); -} - -static void -zoom_out_callback (GtkMenuItem *item, FMDirectoryView *directory_view) -{ - fm_directory_view_bump_zoom_level (directory_view, -1); -} - -static void -zoom_default_callback (GtkMenuItem *item, FMDirectoryView *directory_view) -{ - fm_directory_view_restore_default_zoom_level (directory_view); -} - - -static void zoomable_zoom_in_callback (NautilusZoomable *zoomable, FMDirectoryView *directory_view) { fm_directory_view_bump_zoom_level (directory_view, 1); @@ -2737,23 +2691,6 @@ remove_custom_icons_callback (gpointer ignored, gpointer view) } static void -finish_inserting_menu_item (GtkMenu *menu, - GtkWidget *menu_item, - int position, - gboolean sensitive) -{ - gtk_widget_set_sensitive (menu_item, sensitive); - gtk_widget_show (menu_item); - gtk_menu_insert (menu, menu_item, position); -} - -static void -finish_appending_menu_item (GtkMenu *menu, GtkWidget *menu_item, gboolean sensitive) -{ - finish_inserting_menu_item (menu, menu_item, -1, sensitive); -} - -static void compute_menu_item_info (FMDirectoryView *directory_view, const char *path, GList *selection, @@ -2805,17 +2742,23 @@ compute_menu_item_info (FMDirectoryView *directory_view, } else { name_with_underscore = g_strdup (_("Move to _Trash")); } - *return_sensitivity = !fm_directory_view_is_read_only (directory_view) && selection != NULL; + *return_sensitivity = !fm_directory_view_is_read_only (directory_view) + && selection != NULL + && !special_link_in_selection (directory_view); } else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE) == 0) { name_with_underscore = g_strdup (_("_Duplicate")); - *return_sensitivity = fm_directory_view_supports_creating_files (directory_view) && selection != NULL; + *return_sensitivity = fm_directory_view_supports_creating_files (directory_view) + && selection != NULL + && !special_link_in_selection (directory_view); } else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_CREATE_LINK) == 0) { if (selection != NULL && !nautilus_g_list_exactly_one_item (selection)) { name_with_underscore = g_strdup (_("Create _Links")); } else { name_with_underscore = g_strdup (_("Create _Link")); } - *return_sensitivity = fm_directory_view_supports_creating_files (directory_view) && selection != NULL; + *return_sensitivity = fm_directory_view_supports_creating_files (directory_view) + && selection != NULL + && !special_link_in_selection (directory_view); } else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_SHOW_PROPERTIES) == 0) { /* No ellipses here because this command does not require further * information to be completed. @@ -2860,389 +2803,6 @@ compute_menu_item_info (FMDirectoryView *directory_view, } static void -set_menu_item_path (GtkMenuItem *item, const char *path) -{ - /* set_data_full is unhappy if you give it a destroy_func - * and a NULL, even though it would work fine in this case. - */ - if (path == NULL) { - return; - } - - gtk_object_set_data_full (GTK_OBJECT (item), - "path", - g_strdup (path), - g_free); -} - -/* Append a new menu item to a GtkMenu, with the FMDirectoryView * - * being the callback data. - */ -static void -append_gtk_menu_item (FMDirectoryView *view, - GtkMenu *menu, - GList *files, - const char *menu_path, - const char *verb_path, - GtkSignalFunc callback) -{ - GtkWidget *menu_item; - char *label_string; - gboolean sensitive; - - compute_menu_item_info (view, menu_path, files, NULL, &label_string, &sensitive); - menu_item = gtk_menu_item_new_with_label (label_string); - g_free (label_string); - - set_menu_item_path (GTK_MENU_ITEM (menu_item), verb_path); - - gtk_signal_connect (GTK_OBJECT (menu_item), - "activate", - callback, - view); - - finish_appending_menu_item (menu, menu_item, sensitive); -} - -static void -append_selection_menu_subtree (FMDirectoryView *view, - GtkMenu *parent_menu, - GtkMenu *child_menu, - GList *files, - const char *path, - const char *identifier) -{ - GtkWidget *menu_item; - char *label_string; - gboolean sensitive; - - compute_menu_item_info (view, path, files, NULL, &label_string, &sensitive); - menu_item = gtk_menu_item_new_with_label (label_string); - g_free (label_string); - - finish_appending_menu_item (parent_menu, menu_item, sensitive); - - /* Store identifier in item, so we can find this item later */ - set_menu_item_path (GTK_MENU_ITEM (menu_item), identifier); - - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), - GTK_WIDGET (child_menu)); -} - -/* fm_directory_view_insert_context_menu_item: - * - * Insert a menu item into a context menu for a directory view. - * - * @view: The FMDirectoryView in question. - * @menu: The context menu in which to insert the new item. - * @label: The user-visible text to appear in the menu item. - * @identifier: A string that uniquely distinguishes this item from other - * items in this menu. These can be published so that subclasses - * can locate specific menu items for modification, positioning, - * or removing. Pass NULL if you don't want subclasses to be able - * to discover this item. - * @position: The index at which to insert the new item. - * @callback: The function that's called when this item is selected. Note that - * the second parameter (the "callback data") is always @view. - * @sensitive: Whether or not this item should be sensitive. - */ -GtkMenuItem * -fm_directory_view_insert_context_menu_item (FMDirectoryView *view, - GtkMenu *menu, - const char *label, - const char *identifier, - int position, - void (* callback) (GtkMenuItem *, FMDirectoryView *), - gboolean sensitive) -{ - GtkWidget *menu_item; - guint accel_key; - - menu_item = gtk_menu_item_new_with_label (label); - - /* Add accelerator */ - accel_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (menu_item)->child), label); - if (accel_key != GDK_VoidSymbol) - { - gtk_widget_add_accelerator (menu_item, "activate", gtk_accel_group_get_default (), - accel_key, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); - } - - /* Store command path in item, so we can find this item by command path later */ - set_menu_item_path (GTK_MENU_ITEM (menu_item), identifier); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", - GTK_SIGNAL_FUNC (callback), view); - finish_inserting_menu_item (menu, menu_item, position, sensitive); - - return GTK_MENU_ITEM (menu_item); -} - -static void -fm_directory_view_append_context_menu_item (FMDirectoryView *view, - GtkMenu *menu, - const char *label, - const char *path, - void (* activate_handler) (GtkMenuItem *, FMDirectoryView *), - gboolean sensitive) -{ - fm_directory_view_insert_context_menu_item - (view, - menu, - label, - path, - -1, - activate_handler, - sensitive); -} - -static void -create_background_context_menu_zoom_items (FMDirectoryView *view, - GtkMenu *menu) -{ - nautilus_gtk_menu_append_separator (menu); - - fm_directory_view_append_context_menu_item (view, menu, _("Zoom In"), NULL, zoom_in_callback, - fm_directory_view_can_zoom_in (view)); - fm_directory_view_append_context_menu_item (view, menu, _("Zoom Out"), NULL, zoom_out_callback, - fm_directory_view_can_zoom_out (view)); - fm_directory_view_append_context_menu_item (view, menu, _("Normal Size"), NULL, zoom_default_callback, TRUE); -} - -static void -real_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu) - -{ - /* FIXME: This should share code by using compute_menu_item_info, - * but can't because of the "use underline for control key shortcut" - * hack here. - */ - fm_directory_view_append_context_menu_item - (view, menu, - _("_New Folder"), - FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER, - GTK_SIGNAL_FUNC (new_folder_callback), - fm_directory_view_supports_creating_files (view)); - - if (fm_directory_view_supports_zooming (view)) { - create_background_context_menu_zoom_items (view, menu); - } - - nautilus_gtk_menu_append_separator (menu); - - append_gtk_menu_item (view, - menu, - NULL, - FM_DIRECTORY_VIEW_MENU_PATH_RESET_BACKGROUND, - FM_DIRECTORY_VIEW_COMMAND_RESET_BACKGROUND, - reset_background_callback); -} - -static void -launch_application_from_menu_item (GtkMenuItem *menu_item, gpointer callback_data) -{ - ApplicationLaunchParameters *launch_parameters; - - g_assert (GTK_IS_MENU_ITEM (menu_item)); - g_assert (callback_data != NULL); - - launch_parameters = (ApplicationLaunchParameters *)callback_data; - - fm_directory_view_launch_application - (launch_parameters->application, - launch_parameters->uri, - launch_parameters->directory_view); -} - -static void -view_uri_from_menu_item (GtkMenuItem *menu_item, gpointer callback_data) -{ - ViewerLaunchParameters *launch_parameters; - - g_assert (GTK_IS_MENU_ITEM (menu_item)); - g_assert (callback_data != NULL); - - launch_parameters = (ViewerLaunchParameters *)callback_data; - - switch_location_and_view (launch_parameters->identifier, - launch_parameters->uri, - launch_parameters->directory_view); -} - -static void -add_application_to_gtk_menu (FMDirectoryView *directory_view, - GtkMenu *menu, - GnomeVFSMimeApplication *application, - const char *uri) -{ - GtkWidget *menu_item; - ApplicationLaunchParameters *launch_parameters; - char *label_string; - - g_assert (GTK_IS_MENU (menu)); - - label_string = g_strdup (application->name); - menu_item = gtk_menu_item_new_with_label (label_string); - g_free (label_string); - - launch_parameters = application_launch_parameters_new - (application, uri, directory_view); - - nautilus_gtk_signal_connect_free_data_custom - (GTK_OBJECT (menu_item), - "activate", - launch_application_from_menu_item, - launch_parameters, - (GtkDestroyNotify) application_launch_parameters_free); - - finish_appending_menu_item (menu, menu_item, TRUE); -} - -static void -add_component_to_gtk_menu (FMDirectoryView *directory_view, - GtkMenu *menu, - OAF_ServerInfo *component, - const char *uri) -{ - GtkWidget *menu_item; - NautilusViewIdentifier *identifier; - ViewerLaunchParameters *launch_parameters; - char *label; - - g_assert (GTK_IS_MENU (menu)); - - identifier = nautilus_view_identifier_new_from_content_view (component); - - label = g_strdup_printf (_("%s Viewer"), identifier->name); - menu_item = gtk_menu_item_new_with_label (label); - g_free (label); - - launch_parameters = viewer_launch_parameters_new - (identifier, uri, directory_view); - nautilus_view_identifier_free (identifier); - - nautilus_gtk_signal_connect_free_data_custom - (GTK_OBJECT (menu_item), - "activate", - view_uri_from_menu_item, - launch_parameters, - (GtkDestroyNotify) viewer_launch_parameters_free); - - finish_appending_menu_item (menu, menu_item, TRUE); -} - -static GtkMenu * -create_open_with_gtk_menu (FMDirectoryView *view, GList *files) -{ - GtkMenu *open_with_menu; - GList *applications, *components; - GList *node; - NautilusFile *file; - char *uri; - - open_with_menu = GTK_MENU (gtk_menu_new ()); - gtk_widget_show (GTK_WIDGET (open_with_menu)); - - /* This menu is only displayed when there's one selected item. */ - if (!nautilus_g_list_exactly_one_item (files)) { - monitor_file_for_open_with (view, NULL); - } else { - file = NAUTILUS_FILE (files->data); - - monitor_file_for_open_with (view, file); - - uri = nautilus_file_get_uri (file); - - applications = nautilus_mime_get_short_list_applications_for_file (NAUTILUS_FILE (files->data)); - for (node = applications; node != NULL; node = node->next) { - add_application_to_gtk_menu (view, open_with_menu, node->data, uri); - } - gnome_vfs_mime_application_list_free (applications); - - append_gtk_menu_item (view, - open_with_menu, - files, - FM_DIRECTORY_VIEW_MENU_PATH_OTHER_APPLICATION, - FM_DIRECTORY_VIEW_COMMAND_OTHER_APPLICATION, - other_application_callback); - - nautilus_gtk_menu_append_separator (open_with_menu); - - components = nautilus_mime_get_short_list_components_for_file (NAUTILUS_FILE (files->data)); - for (node = components; node != NULL; node = node->next) { - add_component_to_gtk_menu (view, open_with_menu, node->data, uri); - } - gnome_vfs_mime_component_list_free (components); - - - g_free (uri); - - append_gtk_menu_item (view, - open_with_menu, - files, - FM_DIRECTORY_VIEW_MENU_PATH_OTHER_VIEWER, - FM_DIRECTORY_VIEW_COMMAND_OTHER_VIEWER, - other_viewer_callback); - } - - return open_with_menu; -} - -static void -real_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *files) -{ - gboolean link_in_selection; - - /* Check for special links */ - link_in_selection = special_link_in_selection (view); - - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_OPEN, - FM_DIRECTORY_VIEW_COMMAND_OPEN, - open_callback); - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_OPEN_IN_NEW_WINDOW, - FM_DIRECTORY_VIEW_COMMAND_OPEN_IN_NEW_WINDOW, - open_in_new_window_callback); - append_selection_menu_subtree (view, menu, - create_open_with_gtk_menu (view, files), files, - FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH, - FM_DIRECTORY_VIEW_COMMAND_OPEN_WITH); - - nautilus_gtk_menu_append_separator (menu); - - /* Don't add item if Trash link is in selection */ - if (!link_in_selection) { - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_TRASH, - FM_DIRECTORY_VIEW_COMMAND_TRASH, - trash_callback); - } - - if (!link_in_selection) { - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE, - FM_DIRECTORY_VIEW_COMMAND_DUPLICATE, - duplicate_callback); - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_CREATE_LINK, - FM_DIRECTORY_VIEW_COMMAND_CREATE_LINK, - create_link_callback); - } - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_SHOW_PROPERTIES, - FM_DIRECTORY_VIEW_COMMAND_SHOW_PROPERTIES, - open_properties_window_callback); - append_gtk_menu_item (view, menu, files, - FM_DIRECTORY_VIEW_MENU_PATH_REMOVE_CUSTOM_ICONS, - FM_DIRECTORY_VIEW_COMMAND_REMOVE_CUSTOM_ICONS, - remove_custom_icons_callback); -} - -static void bonobo_launch_application_callback (BonoboUIComponent *component, gpointer callback_data, const char *path) { ApplicationLaunchParameters *launch_parameters; @@ -3590,67 +3150,6 @@ real_update_menus (FMDirectoryView *view) nautilus_file_list_free (selection); } -static GtkMenu * -create_selection_context_menu (FMDirectoryView *view) -{ - GtkMenu *menu; - GList *selected_files; - - g_assert (FM_IS_DIRECTORY_VIEW (view)); - - selected_files = fm_directory_view_get_selection (view); - - /* We've seen this happen in at least bugzilla.eazel.com 3322 */ - g_return_val_if_fail (selected_files != NULL, NULL); - - menu = GTK_MENU (gtk_menu_new ()); - - /* Attach selection to menu, and free it when menu is freed. - * This lets menu item callbacks hold onto the files parameter. - */ - gtk_object_set_data_full (GTK_OBJECT (menu), - "selected_items", - selected_files, - (GtkDestroyNotify) nautilus_file_list_free); - - gtk_signal_emit (GTK_OBJECT (view), - signals[CREATE_SELECTION_CONTEXT_MENU_ITEMS], - menu, selected_files); - - return menu; -} - -/** - * fm_directory_view_create_background_context_menu_items: - * - * Add background menu items (i.e., those not dependent on a particular file) - * to a context menu. - * @view: An FMDirectoryView. - * @menu: The menu being constructed. Could be a background menu or an item-specific - * menu, because the background items are present in both. - * - **/ -static void -fm_directory_view_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu) -{ - gtk_signal_emit (GTK_OBJECT (view), - signals[CREATE_BACKGROUND_CONTEXT_MENU_ITEMS], - menu); -} - - -static GtkMenu * -create_background_context_menu (FMDirectoryView *view) -{ - GtkMenu *menu; - - menu = GTK_MENU (gtk_menu_new ()); - fm_directory_view_create_background_context_menu_items (view, menu); - - return menu; -} - /** * fm_directory_view_pop_up_selection_context_menu * @@ -3664,27 +3163,13 @@ create_background_context_menu (FMDirectoryView *view) void fm_directory_view_pop_up_selection_context_menu (FMDirectoryView *view) { - GtkMenu *menu; - g_assert (FM_IS_DIRECTORY_VIEW (view)); - /* work in progress */ - if (FALSE) { - menu = create_selection_context_menu (view); - if (menu != NULL) { - nautilus_pop_up_context_menu (menu, - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - 0); - } - } else { - nautilus_pop_up_context_menu (create_popup_menu - (view, FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION), - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - 0); - } - + nautilus_pop_up_context_menu (create_popup_menu + (view, FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION), + NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, + NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, + 0); } /** @@ -3701,19 +3186,11 @@ fm_directory_view_pop_up_background_context_menu (FMDirectoryView *view) { g_assert (FM_IS_DIRECTORY_VIEW (view)); - /* work in progress */ - if (FALSE) { - nautilus_pop_up_context_menu (create_background_context_menu (view), - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - 0); - } else { - nautilus_pop_up_context_menu (create_popup_menu - (view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND), - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, - 0); - } + nautilus_pop_up_context_menu (create_popup_menu + (view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND), + NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, + NAUTILUS_DEFAULT_POPUP_MENU_DISPLACEMENT, + 0); } static void @@ -4478,52 +3955,6 @@ fm_directory_view_can_accept_item (NautilusFile *target_item, return nautilus_drag_can_accept_item (target_item, item_uri); } -static gboolean -menu_item_matches_path (GtkMenuItem *item, const char *path) -{ - return nautilus_strcmp ((const char *) gtk_object_get_data (GTK_OBJECT (item), "path"), - path) == 0; -} - -/** - * fm_directory_view_get_context_menu_index: - * - * Return index of specified menu item in the passed-in context menu. - * Return -1 if item is not found. This is intended for subclasses to - * use to properly position new items in the context menu. - * - * @menu: A GtkMenu, either the item-specific or background context menu - * as passed to _create_selection_context_menu_items or - * _create_background_context_menu_items. - * @verb_path: command name (e.g. "/commands/Open") whose index in @menu should be returned. - */ -int -fm_directory_view_get_context_menu_index (GtkMenu *menu, const char *verb_path) -{ - GList *children, *node; - GtkMenuItem *menu_item; - int index; - int result; - - g_return_val_if_fail (GTK_IS_MENU (menu), -1); - g_return_val_if_fail (verb_path != NULL, -1); - - children = gtk_container_children (GTK_CONTAINER (menu)); - result = -1; - - for (node = children, index = 0; node != NULL; node = node->next, ++index) { - menu_item = GTK_MENU_ITEM (node->data); - if (menu_item_matches_path (menu_item, verb_path)) { - result = index; - break; - } - } - - g_list_free (children); - - return result; -} - static void fm_directory_view_trash_state_changed_callback (NautilusTrashMonitor *trash_monitor, gboolean state, gpointer callback_data) diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index eb353af70..f70b2a55b 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -124,27 +124,6 @@ struct FMDirectoryViewClass { void (* load_error) (FMDirectoryView *view, GnomeVFSResult result); - /* The 'create_selection_context_menu_items' signal is emitted - * when creating a context menu for the selected items. @files is - * the list of selected files; it isn't destroyed until the menu - * is destroyed so it can be used in callbacks. - * Subclasses might want to override this function to - * modify the menu contents. - */ - void (* create_selection_context_menu_items) - (FMDirectoryView *view, - GtkMenu *menu, - GList *files); - - /* The 'create_background_context_menu_items' signal is emitted - * when creating a context menu, either an item-specific one or - * a background one. Subclasses might want to override this to - * modify the menu contents. - */ - void (* create_background_context_menu_items) - (FMDirectoryView *view, - GtkMenu *menu); - /* Function pointers that don't have corresponding signals */ /* get_selection is not a signal; it is just a function pointer for @@ -316,8 +295,6 @@ void fm_directory_view_move_copy_items (const GList int x, int y, FMDirectoryView *view); -gint fm_directory_view_get_context_menu_index (GtkMenu *menu, - const char *verb_path); gboolean fm_directory_link_type_in_selection (FMDirectoryView *view, NautilusLinkType link_type); @@ -348,13 +325,6 @@ NautilusBackground *fm_directory_view_get_background (FMDirectoryView * 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); -GtkMenuItem *fm_directory_view_insert_context_menu_item (FMDirectoryView *view, - GtkMenu *menu, - const char *label, - const char *identifier, - int position, - void (* callback) (GtkMenuItem *, FMDirectoryView *), - gboolean sensitive); void fm_directory_view_new_folder (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 f9f12cf56..cd4c0f2da 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -414,40 +414,6 @@ set_tighter_layout (FMIconView *icon_view, gboolean new_value) } static void -gtk_tighter_layout_callback (GtkWidget *menu_item, gpointer user_data) -{ - FMIconView *icon_view; - - icon_view = FM_ICON_VIEW (user_data); - - /* This callback is called only by the context menu. It will - * go away when we switch the context menus to use Bonobo. - * This callback is only called when the user has actually chosen - * the menu item, so we can be confident that the desired new - * value is the opposite of the current value. - */ - set_tighter_layout (icon_view, !fm_icon_view_using_tighter_layout (icon_view)); -} - -static void -gtk_sort_reversed_callback (GtkWidget *menu_item, gpointer user_data) -{ - FMIconView *icon_view; - - icon_view = FM_ICON_VIEW (user_data); - - /* This callback is called only by the context menu. It will - * go away when we switch the context menus to use Bonobo. - * This callback is only called when the user has actually chosen - * the menu item, so we can be confident that the desired new - * value is the opposite of the current value. - */ - if (set_sort_reversed (icon_view, !icon_view->details->sort_reversed)) { - nautilus_icon_container_sort (get_icon_container (icon_view)); - } -} - -static void tighter_layout_state_changed_callback (BonoboUIComponent *component, const char *path, Bonobo_UIComponent_EventType type, @@ -480,6 +446,27 @@ fm_icon_view_using_tighter_layout (FMIconView *icon_view) (get_icon_container (icon_view)); } +/* special_link_in_selection + * + * Return TRUE is one of our special links is the selection. + * Special links include the following: + * NAUTILUS_LINK_TRASH, NAUTILUS_LINK_HOME, NAUTILUS_LINK_MOUNT + */ + +static gboolean +special_link_in_selection (FMIconView *view) +{ + if (fm_directory_link_type_in_selection (FM_DIRECTORY_VIEW (view), NAUTILUS_LINK_TRASH)) { + return TRUE; + } + + if (fm_directory_link_type_in_selection (FM_DIRECTORY_VIEW (view), NAUTILUS_LINK_MOUNT)) { + return TRUE; + } + + return FALSE; +} + static void compute_menu_item_info (FMIconView *view, GList *selection, @@ -524,7 +511,8 @@ compute_menu_item_info (FMIconView *view, /* Modify file name. We only allow this on a single file selection. */ name_with_underscore = g_strdup (_("_Rename")); sensitive = nautilus_g_list_exactly_one_item (selection) - && nautilus_file_can_rename (selection->data); + && nautilus_file_can_rename (selection->data) + && !special_link_in_selection (view); } else if (strcmp (MENU_PATH_CLEAN_UP, menu_path) == 0) { name_with_underscore = g_strdup (_("_Clean Up by Name")); sensitive = !fm_icon_view_using_auto_layout (view); @@ -577,176 +565,6 @@ handle_radio_item (FMIconView *view, } } -static void -context_menu_layout_radio_item_callback (GtkWidget *menu_item, gpointer user_data) -{ - FMIconView *icon_view; - const char *id; - - icon_view = FM_ICON_VIEW (user_data); - - id = (const char *) gtk_object_get_data (GTK_OBJECT (menu_item), "id"); - g_assert (id != NULL); - handle_radio_item (icon_view, id); -} - -static GtkMenuItem * -append_one_context_menu_layout_item (FMIconView *view, - GtkMenu *menu, - GtkRadioMenuItem *item_in_group, - const char *id, - const char *menu_label) -{ - GtkWidget *menu_item; - char *label_for_display; - - label_for_display = nautilus_str_strip_chr (menu_label, '_'); - menu_item = gtk_radio_menu_item_new_with_label ( - item_in_group ? gtk_radio_menu_item_group (item_in_group) : NULL, - label_for_display); - g_free (label_for_display); - - /* Match appearance of Bonobo menu items, where unchosen items are still marked. */ - gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menu_item), TRUE); - - /* Attach id to menu item so we can check it in the callback. */ - gtk_object_set_data_full (GTK_OBJECT (menu_item), "id", - g_strdup (id), g_free); - - gtk_widget_show (menu_item); - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", context_menu_layout_radio_item_callback, view); - gtk_menu_append (menu, menu_item); - - return GTK_MENU_ITEM (menu_item); -} - -static GtkMenuItem * -insert_one_context_menu_item (FMIconView *view, - GtkMenu *menu, - GList *selection, - const char *menu_path, - gint position, - GtkSignalFunc callback, - gboolean initial_state) -{ - GtkWidget *menu_item; - char *label; - gboolean sensitive; - MenuItemType type; - - compute_menu_item_info (view, selection, menu_path, NULL, &label, &sensitive, &type); - - switch (type) { - case MENU_ITEM_TYPE_CHECK: - menu_item = gtk_check_menu_item_new_with_label (label); - /* Match appearance of Bonobo toggle items, where inactive - * check items are still marked. - */ - gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menu_item), TRUE); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), - initial_state); - break; - - case MENU_ITEM_TYPE_TREE: - case MENU_ITEM_TYPE_STANDARD: - menu_item = gtk_menu_item_new_with_label (label); - break; - - case MENU_ITEM_TYPE_RADIO: /* Not handled here due to required group parameter */ - default: - g_assert_not_reached (); - menu_item = NULL; - } - - g_free (label); - gtk_widget_set_sensitive (menu_item, sensitive); - gtk_widget_show (menu_item); - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", callback, view); - gtk_menu_insert (menu, menu_item, position); - - return GTK_MENU_ITEM (menu_item); -} - -static GtkMenuItem * -append_one_context_menu_item (FMIconView *view, - GtkMenu *menu, - GList *selection, - const char *menu_path, - GtkSignalFunc callback) -{ - return insert_one_context_menu_item (view, menu, selection, menu_path, -1, callback, FALSE); -} - -static GtkMenuItem * -append_one_toggle_context_menu_item (FMIconView *view, - GtkMenu *menu, - GList *selection, - const char *menu_path, - GtkSignalFunc callback, - gboolean initial_state) -{ - return insert_one_context_menu_item (view, menu, selection, menu_path, -1, callback, initial_state); -} - -/* special_link_in_selection - * - * Return TRUE is one of our special links is the selection. - * Special links include the following: - * NAUTILUS_LINK_TRASH, NAUTILUS_LINK_HOME, NAUTILUS_LINK_MOUNT - */ - -static gboolean -special_link_in_selection (FMDirectoryView *view) -{ - if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_TRASH)) { - return TRUE; - } - - if (fm_directory_link_type_in_selection (view, NAUTILUS_LINK_MOUNT)) { - return TRUE; - } - - return FALSE; -} - -static void -fm_icon_view_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *selection) -{ - gint position; - - g_assert (FM_IS_ICON_VIEW (view)); - g_assert (GTK_IS_MENU (menu)); - - NAUTILUS_CALL_PARENT_CLASS - (FM_DIRECTORY_VIEW_CLASS, - create_selection_context_menu_items, - (view, menu, selection)); - - append_one_context_menu_item - (FM_ICON_VIEW (view), menu, selection, - MENU_PATH_STRETCH_ICON, - GTK_SIGNAL_FUNC (show_stretch_handles_callback)); - append_one_context_menu_item - (FM_ICON_VIEW (view), menu, selection, - MENU_PATH_UNSTRETCH_ICONS, - GTK_SIGNAL_FUNC (unstretch_icons_callback)); - - /* The Rename item is inserted directly after the - * Duplicate item created by the FMDirectoryView. - */ - if (!special_link_in_selection (view)) { - position = fm_directory_view_get_context_menu_index - (menu, FM_DIRECTORY_VIEW_COMMAND_DUPLICATE) + 1; - insert_one_context_menu_item - (FM_ICON_VIEW (view), menu, selection, - MENU_PATH_RENAME, position, - GTK_SIGNAL_FUNC (rename_icon_callback), - FALSE); - } -} - /* Note that this is used both as a Bonobo menu callback and a signal callback. * The first parameter is different in these cases, but we just ignore it anyway. */ @@ -757,104 +575,6 @@ customize_icon_text_callback (gpointer ignored1, gpointer ignored2) } static void -fm_icon_view_create_background_context_menu_items (FMDirectoryView *view, - GtkMenu *menu) -{ - FMIconView *icon_view; - char *manual_item_label; - GtkMenuItem *lay_out_item; - GtkMenuItem *toggle_item; - GtkRadioMenuItem *manual_item; - GtkMenu *layout_submenu; - gboolean is_auto_layout; - int position; - guint i; - - g_assert (GTK_IS_MENU (menu)); - - icon_view = FM_ICON_VIEW (view); - - NAUTILUS_CALL_PARENT_CLASS - (FM_DIRECTORY_VIEW_CLASS, - create_background_context_menu_items, - (view, menu)); - - position = fm_directory_view_get_context_menu_index - (menu, FM_DIRECTORY_VIEW_COMMAND_NEW_FOLDER) + 1; - - nautilus_gtk_menu_insert_separator (menu, position++); - - if (fm_icon_view_supports_auto_layout (icon_view)) { - - is_auto_layout = fm_icon_view_using_auto_layout (icon_view); - - lay_out_item = GTK_MENU_ITEM (insert_one_context_menu_item - (icon_view, menu, NULL, - MENU_PATH_LAY_OUT, position++, - NULL, - FALSE)); - layout_submenu = GTK_MENU (gtk_menu_new ()); - - /* Compute label the standard bonobo_or_gtk way, to avoid - * duplicating string constant. - */ - compute_menu_item_info (icon_view, - NULL, - MENU_PATH_MANUAL_LAYOUT, - NULL, - &manual_item_label, - NULL, - NULL); - manual_item = GTK_RADIO_MENU_ITEM (append_one_context_menu_layout_item - (icon_view, layout_submenu, NULL, - ID_MANUAL_LAYOUT, manual_item_label)); - g_free (manual_item_label); - if (!is_auto_layout) { - gtk_check_menu_item_set_active - (GTK_CHECK_MENU_ITEM (manual_item), TRUE); - } - - nautilus_gtk_menu_append_separator (layout_submenu); - - for (i = 0; i < NAUTILUS_N_ELEMENTS (sort_criteria); i++) { - toggle_item = append_one_context_menu_layout_item - (icon_view, layout_submenu, manual_item, - sort_criteria[i].id, - sort_criteria[i].menu_label); - if (is_auto_layout && strcmp (icon_view->details->sort->id, - sort_criteria[i].id) == 0) { - gtk_check_menu_item_set_active - (GTK_CHECK_MENU_ITEM (toggle_item), TRUE); - } - } - - nautilus_gtk_menu_append_separator (layout_submenu); - - /* No callback here, since that is handled by the bonobo "id" field */ - toggle_item = append_one_toggle_context_menu_item - (icon_view, layout_submenu, NULL, - MENU_PATH_TIGHTER_LAYOUT, - gtk_tighter_layout_callback, - fm_icon_view_using_tighter_layout (icon_view)); - - - toggle_item = append_one_toggle_context_menu_item - (icon_view, layout_submenu, NULL, - MENU_PATH_SORT_REVERSED, - gtk_sort_reversed_callback, - icon_view->details->sort_reversed); - - gtk_menu_item_set_submenu (lay_out_item, GTK_WIDGET (layout_submenu)); - } - - insert_one_context_menu_item - (icon_view, menu, NULL, - MENU_PATH_CLEAN_UP, position++, - GTK_SIGNAL_FUNC (clean_up_callback), - FALSE); -} - -static void unref_cover (NautilusIconData *data, gpointer callback_data) { nautilus_file_unref (NAUTILUS_FILE (data)); @@ -2181,10 +1901,6 @@ fm_icon_view_initialize_class (FMIconViewClass *klass) fm_directory_view_class->select_all = fm_icon_view_select_all; fm_directory_view_class->set_selection = fm_icon_view_set_selection; fm_directory_view_class->reveal_selection = fm_icon_view_reveal_selection; - fm_directory_view_class->create_background_context_menu_items = - fm_icon_view_create_background_context_menu_items; - fm_directory_view_class->create_selection_context_menu_items = - fm_icon_view_create_selection_context_menu_items; fm_directory_view_class->merge_menus = fm_icon_view_merge_menus; fm_directory_view_class->update_menus = fm_icon_view_update_menus; fm_directory_view_class->start_renaming_item = fm_icon_view_start_renaming_item; diff --git a/src/file-manager/fm-search-list-view.c b/src/file-manager/fm-search-list-view.c index bf4fd2ba5..991b7a341 100644 --- a/src/file-manager/fm-search-list-view.c +++ b/src/file-manager/fm-search-list-view.c @@ -70,9 +70,6 @@ static void fm_search_list_view_initialize_class (gpointer klass); static void real_destroy (GtkObject *object); static void real_add_file (FMDirectoryView *view, NautilusFile *file); -static void real_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *selection); static void real_adding_file (FMListView *view, NautilusFile *file); static void real_removing_file (FMListView *view, @@ -169,8 +166,6 @@ fm_search_list_view_initialize_class (gpointer klass) object_class->destroy = real_destroy; fm_directory_view_class->add_file = real_add_file; - fm_directory_view_class->create_selection_context_menu_items = - real_create_selection_context_menu_items; fm_directory_view_class->get_emblem_names_to_exclude = real_get_emblem_names_to_exclude; fm_directory_view_class->merge_menus = real_merge_menus; @@ -428,39 +423,6 @@ real_add_file (FMDirectoryView *view, NautilusFile *file) } static void -real_create_selection_context_menu_items (FMDirectoryView *view, - GtkMenu *menu, - GList *selection) -{ - GtkWidget *menu_item; - char *name; - gboolean sensitive; - gint position; - - g_assert (FM_IS_SEARCH_LIST_VIEW (view)); - g_assert (GTK_IS_MENU (menu)); - - NAUTILUS_CALL_PARENT_CLASS - (FM_DIRECTORY_VIEW_CLASS, - create_selection_context_menu_items, - (view, menu, selection)); - - /* The Reveal item is inserted directly after the - * existing Open With item. - */ - position = fm_directory_view_get_context_menu_index - (menu, FM_DIRECTORY_VIEW_COMMAND_OPEN_WITH) + 1; - compute_reveal_item_name_and_sensitivity (selection, NULL, &name, &sensitive); - menu_item = gtk_menu_item_new_with_label (name); - g_free (name); - gtk_widget_set_sensitive (menu_item, sensitive); - gtk_widget_show (menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), "activate", reveal_selected_items_callback, view); - gtk_menu_insert (menu, menu_item, position); -} - -static void real_adding_file (FMListView *view, NautilusFile *file) { GList *attributes; |