New API to set whether URI drops are accepted

The file chooser will not accept dropping URIs in a shortcut item.  However, Nautilus will,
to perform normal DnD for files.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
Federico Mena Quintero
2012-12-04 12:57:48 -06:00
parent 4fe86f1d10
commit 10b22e0ee2
2 changed files with 22 additions and 9 deletions

View File

@ -135,6 +135,7 @@ struct _GtkPlacesSidebar {
guint show_trash : 1; guint show_trash : 1;
guint trash_is_full : 1; guint trash_is_full : 1;
guint show_cwd : 1; guint show_cwd : 1;
guint accept_uri_drops : 1;
}; };
struct _GtkPlacesSidebarClass { struct _GtkPlacesSidebarClass {
@ -1461,15 +1462,17 @@ drag_motion_callback (GtkTreeView *tree_view,
} }
} else { } else {
action = 0; action = 0;
if (sidebar->drag_list != NULL) { if (sidebar->accept_uri_drops) {
gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), if (sidebar->drag_list != NULL) {
&iter, path); gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store),
gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, path);
&iter, gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store),
PLACES_SIDEBAR_COLUMN_URI, &uri, &iter,
-1); PLACES_SIDEBAR_COLUMN_URI, &uri,
emit_drag_action_requested (sidebar, context, uri, sidebar->drag_list, &action); -1);
g_free (uri); emit_drag_action_requested (sidebar, context, uri, sidebar->drag_list, &action);
g_free (uri);
}
} }
} }
@ -4047,3 +4050,11 @@ gtk_places_sidebar_set_show_cwd (GtkPlacesSidebar *sidebar, gboolean show_cwd)
sidebar->show_cwd = !!show_cwd; sidebar->show_cwd = !!show_cwd;
update_places (sidebar); update_places (sidebar);
} }
void
gtk_places_sidebar_set_accept_uri_drops (GtkPlacesSidebar *sidebar, gboolean accept_uri_drops)
{
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
sidebar->accept_uri_drops = !!accept_uri_drops;
}

View File

@ -70,6 +70,8 @@ void gtk_places_sidebar_set_trash_is_full (GtkPlacesSidebar *sidebar, gboolean i
void gtk_places_sidebar_set_show_cwd (GtkPlacesSidebar *sidebar, gboolean show_cwd); void gtk_places_sidebar_set_show_cwd (GtkPlacesSidebar *sidebar, gboolean show_cwd);
void gtk_places_sidebar_set_file_dnd_enabled (GtkPlacesSidebar *sidebar, gboolean file_dnd_enabled);
G_END_DECLS G_END_DECLS
#endif /* __GTK_PLACES_SIDEBAR_H__ */ #endif /* __GTK_PLACES_SIDEBAR_H__ */