diff options
author | Holger Berndt <berndth@gmx.de> | 2009-06-11 16:44:43 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2009-12-10 18:06:36 +0100 |
commit | 4cc909a668692551db92a67bcb36b7cdeb473579 (patch) | |
tree | e1e305bbcfce58f06ea160081d39dc76f5dbd1c7 | |
parent | 7191f6fa4f3013481463c1181b51b705d5c48d9a (diff) | |
download | nautilus-4cc909a668692551db92a67bcb36b7cdeb473579.tar.gz |
Implement "{copy,move} to other pane" menus.
-rw-r--r-- | libnautilus-private/nautilus-window-info.c | 17 | ||||
-rw-r--r-- | libnautilus-private/nautilus-window-info.h | 9 | ||||
-rw-r--r-- | src/file-manager/fm-actions.h | 2 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.c | 98 | ||||
-rw-r--r-- | src/file-manager/fm-directory-view.h | 3 | ||||
-rw-r--r-- | src/file-manager/nautilus-directory-view-ui.xml | 17 | ||||
-rw-r--r-- | src/nautilus-shell-ui.xml | 2 | ||||
-rw-r--r-- | src/nautilus-window-private.h | 1 | ||||
-rw-r--r-- | src/nautilus-window.c | 72 |
9 files changed, 207 insertions, 14 deletions
diff --git a/libnautilus-private/nautilus-window-info.c b/libnautilus-private/nautilus-window-info.c index 7d8cadf60..224033b80 100644 --- a/libnautilus-private/nautilus-window-info.c +++ b/libnautilus-private/nautilus-window-info.c @@ -260,6 +260,23 @@ nautilus_window_info_get_ui_manager (NautilusWindowInfo *window) return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_ui_manager) (window); } +gboolean +nautilus_window_info_next_pane_is_writable (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), FALSE); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->next_pane_is_writable) (window); +} + +void +nautilus_window_info_copy_move_selection_to_next_pane (NautilusWindowInfo *window, + gboolean want_copy) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->copy_move_selection_to_next_pane) (window, want_copy); +} + NautilusWindowSlotInfo * nautilus_window_info_get_active_slot (NautilusWindowInfo *window) { diff --git a/libnautilus-private/nautilus-window-info.h b/libnautilus-private/nautilus-window-info.h index be0851938..cb61673ea 100644 --- a/libnautilus-private/nautilus-window-info.h +++ b/libnautilus-private/nautilus-window-info.h @@ -141,6 +141,11 @@ struct _NautilusWindowInfoIface void (* show_window) (NautilusWindowInfo *window); void (* close_window) (NautilusWindowInfo *window); GtkUIManager * (* get_ui_manager) (NautilusWindowInfo *window); + /* return TRUE if other pane is writable (files can be moved/copied + * there), FALSE if it is not writable or no other pane exists */ + gboolean (* next_pane_is_writable) (NautilusWindowInfo *window); + void (* copy_move_selection_to_next_pane) (NautilusWindowInfo *window, + gboolean want_copy); }; GType nautilus_window_info_get_type (void); @@ -167,7 +172,9 @@ NautilusWindowShowHiddenFilesMode nautilus_window_info_get_hidden_files_mode void nautilus_window_info_set_hidden_files_mode (NautilusWindowInfo *window, NautilusWindowShowHiddenFilesMode mode); GtkUIManager * nautilus_window_info_get_ui_manager (NautilusWindowInfo *window); - +gboolean nautilus_window_info_next_pane_is_writable (NautilusWindowInfo *window); +void nautilus_window_info_copy_move_selection_to_next_pane (NautilusWindowInfo *window, + gboolean want_copy); G_END_DECLS diff --git a/src/file-manager/fm-actions.h b/src/file-manager/fm-actions.h index e0162e184..237b5390c 100644 --- a/src/file-manager/fm-actions.h +++ b/src/file-manager/fm-actions.h @@ -49,6 +49,8 @@ #define FM_ACTION_LOCATION_COPY "LocationCopy" #define FM_ACTION_PASTE "Paste" #define FM_ACTION_PASTE_FILES_INTO "Paste Files Into" +#define FM_ACTION_COPY_TO_NEXT_PANE "Copy to next pane" +#define FM_ACTION_MOVE_TO_NEXT_PANE "Move to next pane" #define FM_ACTION_LOCATION_PASTE_FILES_INTO "LocationPasteFilesInto" #define FM_ACTION_NEW_LAUNCHER "New Launcher" #define FM_ACTION_NEW_LAUNCHER_DESKTOP "New Launcher Desktop" diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index de31b6daf..408be6c8d 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -341,6 +341,10 @@ static void action_copy_files_callback (GtkAction *action, gpointer callback_data); static void action_paste_files_callback (GtkAction *action, gpointer callback_data); +static void action_copy_to_next_pane_callback (GtkAction *action, + gpointer callback_data); +static void action_move_to_next_pane_callback (GtkAction *action, + gpointer callback_data); static void action_rename_callback (GtkAction *action, gpointer callback_data); static void action_rename_select_all_callback (GtkAction *action, @@ -5847,13 +5851,11 @@ copy_or_cut_files (FMDirectoryView *view, } static void -action_copy_files_callback (GtkAction *action, - gpointer callback_data) +action_copy_files (GtkAction *action, + FMDirectoryView *view) { - FMDirectoryView *view; GList *selection; - view = get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data)); g_assert (FM_IS_DIRECTORY_VIEW (view)); selection = fm_directory_view_get_selection_for_file_transfer (view); @@ -5862,13 +5864,30 @@ action_copy_files_callback (GtkAction *action, } static void -action_cut_files_callback (GtkAction *action, - gpointer callback_data) +action_copy_files_callback (GtkAction *action, + gpointer callback_data) +{ + action_copy_files (action, get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data))); +} + +static void +action_copy_to_next_pane_callback (GtkAction *action, gpointer callback_data) +{ + nautilus_window_info_copy_move_selection_to_next_pane (NAUTILUS_WINDOW_INFO (callback_data), TRUE); +} + +static void +action_move_to_next_pane_callback (GtkAction *action, gpointer callback_data) +{ + nautilus_window_info_copy_move_selection_to_next_pane (NAUTILUS_WINDOW_INFO (callback_data), FALSE); +} + +static void +action_cut_files (GtkAction *action, + FMDirectoryView *view) { - FMDirectoryView *view; GList *selection; - view = get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data)); g_assert (FM_IS_DIRECTORY_VIEW (view)); selection = fm_directory_view_get_selection_for_file_transfer (view); @@ -5877,6 +5896,13 @@ action_cut_files_callback (GtkAction *action, } static void +action_cut_files_callback (GtkAction *action, + gpointer callback_data) +{ + action_cut_files (action, get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data))); +} + +static void paste_clipboard_data (FMDirectoryView *view, GtkSelectionData *selection_data, char *destination_uri) @@ -5959,12 +5985,9 @@ paste_into_clipboard_received_callback (GtkClipboard *clipboard, } static void -action_paste_files_callback (GtkAction *action, - gpointer callback_data) +action_paste_files (GtkAction *action, + FMDirectoryView *view) { - FMDirectoryView *view; - - view = get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data)); g_assert (FM_IS_DIRECTORY_VIEW (view)); g_object_ref (view); @@ -5975,6 +5998,13 @@ action_paste_files_callback (GtkAction *action, } static void +action_paste_files_callback (GtkAction *action, + gpointer callback_data) +{ + action_paste_files (action, get_active_directory_view (NAUTILUS_WINDOW_INFO (callback_data))); +} + +static void paste_into (FMDirectoryView *view, NautilusFile *target) { @@ -7097,6 +7127,8 @@ static const GtkActionEntry directory_view_entries[] = { /* label, accelerator */ N_("_Paste Into Folder"), "", /* tooltip */ N_("Move or copy files previously selected by a Cut or Copy command into the selected folder"), G_CALLBACK (action_paste_files_into_callback) }, + /* name, stock id, label */ { "CopyToMenu", NULL, N_("Copy to") }, + /* name, stock id, label */ { "MoveToMenu", NULL, N_("Move to") }, /* name, stock id */ { "Select All", NULL, /* label, accelerator */ N_("Select _All"), "<control>A", /* tooltip */ N_("Select all items in this window"), @@ -7305,6 +7337,13 @@ static const GtkActionEntry directory_view_entries[] = { /* label, accelerator */ N_("_Properties"), NULL, /* tooltip */ N_("View or modify the properties of this folder"), G_CALLBACK (action_location_properties_callback) }, + + /* name, stock id, label */ {"Copy to next pane", NULL, N_("Copy to other pane"), + NULL, N_("Copy the current selection to the other side of the split view"), + G_CALLBACK (action_copy_to_next_pane_callback) }, + /* name, stock id, label */ {"Move to next pane", NULL, N_("Move to other pane"), + NULL, N_("Move the current selection to the other side of the split view"), + G_CALLBACK (action_move_to_next_pane_callback) }, }; static void @@ -8502,6 +8541,7 @@ real_update_menus (FMDirectoryView *view) gchar *delete_actions[] = {FM_ACTION_DELETE, FM_ACTION_DELETE2, NULL}; + gboolean next_pane_is_writable; selection = fm_directory_view_get_selection (view); selection_count = g_list_length (selection); @@ -8683,6 +8723,14 @@ real_update_menus (FMDirectoryView *view) action = gtk_action_group_get_action (view->details->dir_action_group, FM_ACTION_OPEN_IN_NEW_TAB); gtk_action_set_visible (action, FALSE); + + /* next pane actions */ + action = gtk_action_group_get_action (view->details->dir_action_group, + FM_ACTION_COPY_TO_NEXT_PANE); + gtk_action_set_visible (action, FALSE); + action = gtk_action_group_get_action (view->details->dir_action_group, + FM_ACTION_MOVE_TO_NEXT_PANE); + gtk_action_set_visible (action, FALSE); } @@ -8842,6 +8890,18 @@ real_update_menus (FMDirectoryView *view) if (can_create_files && view->details->templates_invalid) { update_templates_menu (view); } + + next_pane_is_writable = nautilus_window_info_next_pane_is_writable(fm_directory_view_get_nautilus_window (view)); + + /* next pane: works if file is copyable, and next pane is writable */ + action = gtk_action_group_get_action(view->details->dir_action_group, + FM_ACTION_COPY_TO_NEXT_PANE); + gtk_action_set_sensitive (action, can_copy_files && next_pane_is_writable); + + /* move to next pane: works if file is cuttable, and next pane is writable */ + action = gtk_action_group_get_action(view->details->dir_action_group, + FM_ACTION_MOVE_TO_NEXT_PANE); + gtk_action_set_sensitive (action, can_delete_files && next_pane_is_writable); } /** @@ -10784,3 +10844,15 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) klass->trash = real_trash; klass->delete = real_delete; } + +void +fm_directory_view_move_copy_items_between_views (FMDirectoryView *source, FMDirectoryView *target, gboolean copy) +{ + if (copy) { + action_copy_files (NULL, source); + } + else { + action_cut_files (NULL, source); + } + action_paste_files (NULL, target); +} diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index acee811a6..6e9779246 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -482,4 +482,7 @@ void fm_directory_view_remove_subdirectory (FMDirecto gboolean fm_directory_view_is_editable (FMDirectoryView *view); +/* operations affecting two directory views */ +void fm_directory_view_move_copy_items_between_views (FMDirectoryView *source, FMDirectoryView *target, gboolean copy); + #endif /* FM_DIRECTORY_VIEW_H */ diff --git a/src/file-manager/nautilus-directory-view-ui.xml b/src/file-manager/nautilus-directory-view-ui.xml index 56d6d93bf..fa247bc1e 100644 --- a/src/file-manager/nautilus-directory-view-ui.xml +++ b/src/file-manager/nautilus-directory-view-ui.xml @@ -61,6 +61,14 @@ <menuitem name="Copy" action="Copy"/> <menuitem name="Paste" action="Paste"/> </placeholder> + <placeholder name="Copy Move to Placeholder"> + <menu action="CopyToMenu"> + <menuitem name="Copy to next pane" action="Copy to next pane"/> + </menu> + <menu action="MoveToMenu"> + <menuitem name="Move to next pane" action="Move to next pane"/> + </menu> + </placeholder> <placeholder name="Select Items"> <menuitem name="Select All" action="Select All"/> <menuitem name="Select Pattern" action="Select Pattern"/> @@ -152,6 +160,15 @@ <menuitem name="Copy" action="Copy"/> <menuitem name="Paste Files Into" action="Paste Files Into"/> </placeholder> + <separator name="Copy Move to separator"/> + <placeholder name="Copy Move to Placeholder"> + <menu action="CopyToMenu"> + <menuitem name="Copy to next pane" action="Copy to next pane"/> + </menu> + <menu action="MoveToMenu"> + <menuitem name="Move to next pane" action="Move to next pane"/> + </menu> + </placeholder> <separator name="File actions separator"/> <placeholder name="File Actions"> <menuitem name="Create Link" action="Create Link"/> diff --git a/src/nautilus-shell-ui.xml b/src/nautilus-shell-ui.xml index 343f7b59d..05ad73e67 100644 --- a/src/nautilus-shell-ui.xml +++ b/src/nautilus-shell-ui.xml @@ -24,6 +24,8 @@ <placeholder name="Clipboard Actions"> </placeholder> <separator/> + <placeholder name="Copy Move to Placeholder"/> + <separator/> <placeholder name="Select Items"/> <separator/> <placeholder name="File Items Placeholder"/> diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index b3bfc9943..9b9cea00e 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -161,6 +161,7 @@ void nautilus_window_load_extension_menus (Nautil void nautilus_window_initialize_menus (NautilusWindow *window); void nautilus_navigation_window_pane_initialize_tabs_menu (struct _NautilusNavigationWindowPane *pane); void nautilus_window_remove_trash_monitor_callback (NautilusWindow *window); +NautilusWindowPane *nautilus_window_get_next_pane (NautilusWindow *window); void nautilus_menus_append_bookmark_to_menu (NautilusWindow *window, NautilusBookmark *bookmark, const char *parent_path, diff --git a/src/nautilus-window.c b/src/nautilus-window.c index ed5311f11..7bc6fa4c0 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -42,6 +42,7 @@ #include "nautilus-zoom-control.h" #include "nautilus-search-bar.h" #include "nautilus-navigation-window-pane.h" +#include "file-manager/fm-directory-view.h" #include <eel/eel-debug.h> #include <eel/eel-marshal.h> #include <eel/eel-gtk-macros.h> @@ -1487,6 +1488,75 @@ nautilus_window_get_ui_manager (NautilusWindow *window) return window->details->ui_manager; } +NautilusWindowPane * +nautilus_window_get_next_pane (NautilusWindow *window) +{ + NautilusWindowPane *next_pane; + GList *node; + + /* return NULL if there is only one pane */ + if (!window->details->panes || !window->details->panes->next) { + return NULL; + } + + /* get next pane in the (wrapped around) list */ + node = g_list_find(window->details->panes, window->details->active_pane); + g_return_val_if_fail (node, FALSE); + if (node->next) { + next_pane = node->next->data; + } + else { + next_pane = window->details->panes->data; + } + + return next_pane; +} + +static gboolean +nautilus_window_next_pane_is_writable (NautilusWindow *window) +{ + NautilusWindowPane *next_pane; + + g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), FALSE); + + /* check if there is just one pane */ + if (!window->details->panes || !window->details->panes->next) { + return FALSE; + } + + /* get next pane */ + next_pane = nautilus_window_get_next_pane (window); + if(!next_pane) { + return FALSE; + } + + g_return_val_if_fail(FM_IS_DIRECTORY_VIEW (next_pane->active_slot->content_view), FALSE); + + return !fm_directory_view_is_read_only (FM_DIRECTORY_VIEW (next_pane->active_slot->content_view)); +} + +static void +nautilus_window_copy_move_selection_to_next_pane (NautilusWindow *window, + gboolean want_copy) +{ + NautilusWindowPane *source_pane, *target_pane; + FMDirectoryView *source, *target; + + /* there must be more than one pane */ + g_return_if_fail (window->details->panes && window->details->panes->next); + + source_pane = NAUTILUS_WINDOW_PANE (window->details->active_pane); + target_pane = nautilus_window_get_next_pane(window); + + g_return_if_fail (FM_IS_DIRECTORY_VIEW (source_pane->active_slot->content_view)); + g_return_if_fail (FM_IS_DIRECTORY_VIEW (target_pane->active_slot->content_view)); + + source = FM_DIRECTORY_VIEW (source_pane->active_slot->content_view); + target = FM_DIRECTORY_VIEW (target_pane->active_slot->content_view); + + fm_directory_view_move_copy_items_between_views (source, target, want_copy); +} + void nautilus_window_slot_set_viewed_file (NautilusWindowSlot *slot, NautilusFile *file) @@ -1867,6 +1937,8 @@ nautilus_window_info_iface_init (NautilusWindowInfoIface *iface) iface->get_bookmark_list = nautilus_window_get_bookmark_list; iface->get_current_location = nautilus_window_get_location_uri; iface->get_ui_manager = nautilus_window_get_ui_manager; + iface->next_pane_is_writable = nautilus_window_next_pane_is_writable; + iface->copy_move_selection_to_next_pane = nautilus_window_copy_move_selection_to_next_pane; iface->get_selection_count = nautilus_window_get_selection_count; iface->get_selection = nautilus_window_get_selection; iface->get_hidden_files_mode = nautilus_window_get_hidden_files_mode; |