Query the clipboard TARGET types so we can set the sensitivity of the

2002-04-17  Anders Carlsson  <andersca@gnu.org>

	* src/file-manager/fm-directory-view.c:
	(clipboard_targets_received), (real_update_menus):
	Query the clipboard TARGET types so we can set the sensitivity
	of the "Paste Files" items accordingly.
This commit is contained in:
Anders Carlsson 2002-04-17 20:52:15 +00:00 committed by Anders Carlsson
parent 99edfb77e2
commit 6adf4a12cb
2 changed files with 45 additions and 7 deletions

View file

@ -1,3 +1,10 @@
2002-04-17 Anders Carlsson <andersca@gnu.org>
* src/file-manager/fm-directory-view.c:
(clipboard_targets_received), (real_update_menus):
Query the clipboard TARGET types so we can set the sensitivity
of the "Paste Files" items accordingly.
2002-04-17 Anders Carlsson <andersca@gnu.org>
* libnautilus-private/nautilus-customization-data.c:

View file

@ -4177,6 +4177,33 @@ real_merge_menus (FMDirectoryView *view)
view->details->scripts_invalid = TRUE;
}
static void
clipboard_targets_received (GtkClipboard *clipboard,
GtkSelectionData *selection_data,
gpointer user_data)
{
FMDirectoryView *view;
gboolean can_paste;
GdkAtom *targets;
int n_targets;
int i;
view = FM_DIRECTORY_VIEW (user_data);
can_paste = FALSE;
if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets)) {
for (i=0; i < n_targets; i++) {
if (targets[i] == copied_files_atom) {
can_paste = TRUE;
}
}
}
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES,
can_paste);
}
static void
real_update_menus (FMDirectoryView *view)
{
@ -4375,13 +4402,17 @@ real_update_menus (FMDirectoryView *view)
FM_DIRECTORY_VIEW_COMMAND_COPY_FILES,
can_copy_files);
/* FIXME: Would be nice to set up paste item here based on
* contents of CLIPBOARD, but I'm not sure that's possible due
* to limitations of X clipboard support.
*/
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES,
!is_read_only);
if (is_read_only) {
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES,
FALSE);
} else {
/* Ask the clipboard */
gtk_clipboard_request_contents (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
gdk_atom_intern ("TARGETS", FALSE),
clipboard_targets_received,
view);
}
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_SHOW_TRASH,