73fce3b862796e96dd25fb39137f4c251d267d6e
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index c8b71e5..a737b56 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4276,35 +4276,25 @@ primary_clear_cb (GtkClipboard *clipboard,
 static void
 gtk_entry_update_primary_selection (GtkEntry *entry)
 {
-  static GtkTargetEntry targets[] = {
-    { "UTF8_STRING", 0, 0 },
-    { "STRING", 0, 0 },
-    { "TEXT",   0, 0 }, 
-    { "COMPOUND_TEXT", 0, 0 },
-    { "text/plain;charset=utf-8",   0, 0 }, 
-    { NULL,   0, 0 },
-    { "text/plain", 0, 0 }
-  };
-  
+  GtkTargetList *list;
+  GtkTargetEntry *targets;
   GtkClipboard *clipboard;
   gint start, end;
-
-  if (targets[5].target == NULL)
-    {
-      const gchar *charset;
-
-      g_get_charset (&charset);
-      targets[5].target = g_strdup_printf ("text/plain;charset=%s", charset);
-    }
+  gint n_targets;
 
   if (!GTK_WIDGET_REALIZED (entry))
     return;
 
+  list = gtk_target_list_new (NULL, 0);
+  gtk_target_list_add_text_targets (list, 0);
+
+  targets = gtk_target_table_new_from_list (list, &n_targets);
+
   clipboard = gtk_widget_get_clipboard (GTK_WIDGET (entry), GDK_SELECTION_PRIMARY);
   
   if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start, &end))
     {
-      if (!gtk_clipboard_set_with_owner (clipboard, targets, G_N_ELEMENTS (targets),
+      if (!gtk_clipboard_set_with_owner (clipboard, targets, n_targets,
 					 primary_get_cb, primary_clear_cb, G_OBJECT (entry)))
 	primary_clear_cb (clipboard, entry);
     }
@@ -4313,6 +4303,9 @@ gtk_entry_update_primary_selection (GtkEntry *entry)
       if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry))
 	gtk_clipboard_clear (clipboard);
     }
+
+  gtk_target_table_free (targets, n_targets);
+  gtk_target_list_unref (list);
 }
 
 /* Public API
@@ -5201,7 +5194,7 @@ popup_targets_received (GtkClipboard     *clipboard,
       gboolean show_input_method_menu;
       gboolean show_unicode_menu;
       
-        clipboard_contains_text = gtk_selection_data_targets_include_text (data);
+      clipboard_contains_text = gtk_selection_data_targets_include_text (data);
       if (entry->popup_menu)
 	gtk_widget_destroy (entry->popup_menu);
       
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 3197831..a4eb763 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -230,45 +230,8 @@ enum {
 /* Identifiers for target types */
 enum {
   GTK_TREE_MODEL_ROW,
-  TEXT_URI_LIST
 };
 
-/* Target types for dragging from the shortcuts list */
-static const GtkTargetEntry shortcuts_source_targets[] = {
-  { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
-};
-
-static const int num_shortcuts_source_targets = G_N_ELEMENTS (shortcuts_source_targets); 
-
-/* Target types for dropping into the shortcuts list */
-static const GtkTargetEntry shortcuts_dest_targets[] = {
-  { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW },
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
-static const int num_shortcuts_dest_targets = G_N_ELEMENTS (shortcuts_dest_targets); 
-
-/* Target types for DnD from the file list */
-static const GtkTargetEntry file_list_source_targets[] = {
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
-static const int num_file_list_source_targets = G_N_ELEMENTS (file_list_source_targets); 
-
-/* Target types for dropping into the file list */
-static const GtkTargetEntry file_list_dest_targets[] = {
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
-static const int num_file_list_dest_targets = G_N_ELEMENTS (file_list_dest_targets); 
-
-/* Target types for dragging from the recent files list */
-static const GtkTargetEntry recent_list_source_targets[] = {
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
-static const int num_recent_list_source_targets = G_N_ELEMENTS (recent_list_source_targets);
-
 static gboolean
 search_is_possible (GtkFileChooserDefault *impl)
 {
@@ -3498,13 +3461,15 @@ shortcuts_drag_drop_cb (GtkWidget             *widget,
 /* Parses a "text/uri-list" string and inserts its URIs as bookmarks */
 static void
 shortcuts_drop_uris (GtkFileChooserDefault *impl,
-		     const char            *data,
+		     GtkSelectionData      *selection_data,
 		     int                    position)
 {
   gchar **uris;
   gint i;
 
-  uris = g_uri_list_extract_uris (data);
+  uris = gtk_selection_data_get_uris (selection_data);
+  if (!uris)
+    return;
 
   for (i = 0; uris[i]; i++)
     {
@@ -3635,8 +3600,8 @@ shortcuts_drag_data_received_cb (GtkWidget          *widget,
   g_assert (position >= bookmarks_index);
   position -= bookmarks_index;
 
-  if (selection_data->target == gdk_atom_intern_static_string ("text/uri-list"))
-    shortcuts_drop_uris (impl, (const char *) selection_data->data, position);
+  if (gtk_targets_include_uri (&selection_data->target, 1))
+    shortcuts_drop_uris (impl, selection_data, position);
   else if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW"))
     shortcuts_reorder (impl, position);
 
@@ -3896,6 +3861,11 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
 
+  /* Target types for dragging a row to/from the shortcuts list */
+  const GtkTargetEntry tree_model_row_targets[] = {
+    { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
+  };
+
   /* Scrolled window */
 
   swin = gtk_scrolled_window_new (NULL, NULL);
@@ -3924,15 +3894,16 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
 
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
 					  GDK_BUTTON1_MASK,
-					  shortcuts_source_targets,
-					  num_shortcuts_source_targets,
+					  tree_model_row_targets,
+					  G_N_ELEMENTS (tree_model_row_targets),
 					  GDK_ACTION_MOVE);
 
   gtk_drag_dest_set (impl->browse_shortcuts_tree_view,
 		     GTK_DEST_DEFAULT_ALL,
-		     shortcuts_dest_targets,
-		     num_shortcuts_dest_targets,
+		     tree_model_row_targets,
+		     G_N_ELEMENTS (tree_model_row_targets),
 		     GDK_ACTION_COPY | GDK_ACTION_MOVE);
+  gtk_drag_dest_add_uri_targets (impl->browse_shortcuts_tree_view);
 
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
@@ -4247,8 +4218,8 @@ file_list_drag_data_received_cb (GtkWidget          *widget,
   chooser = GTK_FILE_CHOOSER (data);
   
   /* Parse the text/uri-list string, navigate to the first one */
-  uris = g_uri_list_extract_uris ((const char *) selection_data->data);
-  if (uris[0]) 
+  uris = gtk_selection_data_get_uris (selection_data);
+  if (uris && uris[0])
     {
       uri = uris[0];
       path = gtk_file_system_uri_to_path (impl->file_system, uri);
@@ -4578,7 +4549,6 @@ create_file_list (GtkFileChooserDefault *impl)
   GtkCellRenderer *renderer;
 
   /* Scrolled window */
-
   swin = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
 				  GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
@@ -4599,9 +4569,9 @@ create_file_list (GtkFileChooserDefault *impl)
 
   gtk_drag_dest_set (impl->browse_files_tree_view,
                      GTK_DEST_DEFAULT_ALL,
-                     file_list_dest_targets,
-                     num_file_list_dest_targets,
+                     NULL, 0,
                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
+  gtk_drag_dest_add_uri_targets (impl->browse_files_tree_view);
   
   g_signal_connect (impl->browse_files_tree_view, "row_activated",
 		    G_CALLBACK (list_row_activated), impl);
@@ -4629,9 +4599,9 @@ create_file_list (GtkFileChooserDefault *impl)
 					  impl, NULL);
   gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_files_tree_view),
 					  GDK_BUTTON1_MASK,
-					  file_list_source_targets,
-					  num_file_list_source_targets,
+					  NULL, 0,
 					  GDK_ACTION_COPY);
+  gtk_drag_source_add_uri_targets (impl->browse_files_tree_view);
 
   g_signal_connect (selection, "changed",
 		    G_CALLBACK (list_selection_changed), impl);
diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c
index 295e8f1..adabb6f 100644
--- a/gtk/gtkfilesel.c
+++ b/gtk/gtkfilesel.c
@@ -831,49 +831,6 @@ gtk_file_selection_init (GtkFileSelection *filesel)
   gtk_widget_pop_composite_child ();
 }
 
-static gchar *
-uri_list_extract_first_uri (const gchar* uri_list)
-{
-  const gchar *p, *q;
-  
-  g_return_val_if_fail (uri_list != NULL, NULL);
-  
-  p = uri_list;
-  /* We don't actually try to validate the URI according to RFC
-   * 2396, or even check for allowed characters - we just ignore
-   * comments and trim whitespace off the ends.  We also
-   * allow LF delimination as well as the specified CRLF.
-   *
-   * We do allow comments like specified in RFC 2483.
-   */
-  while (p)
-    {
-      if (*p != '#')
-	{
-	  while (g_ascii_isspace(*p))
-	    p++;
-	  
-	  q = p;
-	  while (*q && (*q != '\n') && (*q != '\r'))
-	    q++;
-	  
-	  if (q > p)
-	    {
-	      q--;
-	      while (q > p && g_ascii_isspace (*q))
-		q--;
-
-	      if (q > p)
-		return g_strndup (p, q - p + 1);
-	    }
-	}
-      p = strchr (p, '\n');
-      if (p)
-	p++;
-    }
-  return NULL;
-}
-
 static void
 dnd_really_drop  (GtkWidget *dialog, gint response_id, GtkFileSelection *fs)
 {
@@ -889,7 +846,6 @@ dnd_really_drop  (GtkWidget *dialog, gint response_id, GtkFileSelection *fs)
   gtk_widget_destroy (dialog);
 }
 
-
 static void
 filenames_dropped (GtkWidget        *widget,
 		   GdkDragContext   *context,
@@ -899,22 +855,21 @@ filenames_dropped (GtkWidget        *widget,
 		   guint             info,
 		   guint             time)
 {
-  char *uri = NULL;
+  char **uris = NULL;
   char *filename = NULL;
   char *hostname;
   const char *this_hostname;
   GError *error = NULL;
-	
-  if (!selection_data->data)
-    return;
 
-  uri = uri_list_extract_first_uri ((char *)selection_data->data);
-  
-  if (!uri)
-    return;
+  uris = gtk_selection_data_get_uris (selection_data);
+  if (!uris || !uris[0])
+    {
+      g_strfreev (uris);
+      return;
+    }
 
-  filename = g_filename_from_uri (uri, &hostname, &error);
-  g_free (uri);
+  filename = g_filename_from_uri (uris[0], &hostname, &error);
+  g_strfreev (uris);
   
   if (!filename)
     {
@@ -963,16 +918,6 @@ filenames_dropped (GtkWidget        *widget,
   g_free (filename);
 }
 
-enum
-{
-  TARGET_URILIST,
-  TARGET_UTF8_STRING,
-  TARGET_STRING,
-  TARGET_TEXT,
-  TARGET_COMPOUND_TEXT
-};
-
-
 static void
 filenames_drag_get (GtkWidget        *widget,
 		    GdkDragContext   *context,
@@ -982,64 +927,57 @@ filenames_drag_get (GtkWidget        *widget,
 		    GtkFileSelection *filesel)
 {
   const gchar *file;
-  gchar *uri_list;
-  const char *hostname;
-  GError *error;
+  gchar *filename_utf8;
 
   file = gtk_file_selection_get_filename (filesel);
+  if (!file)
+    return;
 
-  if (file)
+  if (gtk_targets_include_uri (&selection_data->target, 1))
     {
-      if (info == TARGET_URILIST)
-	{
-	  hostname = g_get_host_name ();
-	  
-	  error = NULL;
-	  uri_list = g_filename_to_uri (file, hostname, &error);
-	  if (!uri_list)
-	    {
-	      g_warning ("Error getting filename: %s\n",
-			 error->message);
-	      g_error_free (error);
-	      return;
-	    }
+      gchar *file_uri;
+      const char *hostname;
+      GError *error;
+      char *uris[2];
+
+      hostname = g_get_host_name ();
+
+      error = NULL;
+      file_uri = g_filename_to_uri (file, hostname, &error);
+      if (!file_uri)
+        {
+          g_warning ("Error getting filename: %s\n",
+                      error->message);
+          g_error_free (error);
+          return;
+        }
 	  
-	  gtk_selection_data_set (selection_data,
-				  selection_data->target, 8,
-				  (void *)uri_list, strlen((char *)uri_list));
-	  g_free (uri_list);
-	}
-      else
-	{
-	  gchar *filename_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
-	  g_assert (filename_utf8);
-	  gtk_selection_data_set_text (selection_data, filename_utf8, -1);
-	  g_free (filename_utf8);
-	}
+      uris[0] = file_uri;
+      uris[1] = NULL;
+      gtk_selection_data_set_uris (selection_data, uris);
+      g_free (file_uri);
+
+      return;
     }
+	  
+  filename_utf8 = g_filename_to_utf8 (file, -1, NULL, NULL, NULL);
+  if (!filename_utf8)
+    return;
+
+  gtk_selection_data_set_text (selection_data, filename_utf8, -1);
+  g_free (filename_utf8);
 }
 
 static void
 file_selection_setup_dnd (GtkFileSelection *filesel)
 {
   GtkWidget *eventbox;
-  static const GtkTargetEntry drop_types[] = {
-    { "text/uri-list", 0, TARGET_URILIST}
-  };
-  static const gint n_drop_types = sizeof(drop_types)/sizeof(drop_types[0]);
-  static const GtkTargetEntry drag_types[] = {
-    { "text/uri-list", 0, TARGET_URILIST},
-    { "UTF8_STRING", 0, TARGET_UTF8_STRING },
-    { "STRING", 0, 0 },
-    { "TEXT",   0, 0 }, 
-    { "COMPOUND_TEXT", 0, 0 }
-  };
-  static const gint n_drag_types = sizeof(drag_types)/sizeof(drag_types[0]);
 
   gtk_drag_dest_set (GTK_WIDGET (filesel),
 		     GTK_DEST_DEFAULT_ALL,
-		     drop_types, n_drop_types,
+		     NULL, 0,
 		     GDK_ACTION_COPY);
+  gtk_drag_dest_add_uri_targets (GTK_WIDGET (filesel));
 
   g_signal_connect (filesel, "drag_data_received",
 		    G_CALLBACK (filenames_dropped), NULL);
@@ -1047,8 +985,10 @@ file_selection_setup_dnd (GtkFileSelection *filesel)
   eventbox = gtk_widget_get_parent (filesel->selection_text);
   gtk_drag_source_set (eventbox,
 		       GDK_BUTTON1_MASK,
-		       drag_types, n_drag_types,
+		       NULL, 0,
 		       GDK_ACTION_COPY);
+  gtk_drag_source_add_uri_targets (eventbox);
+  gtk_drag_source_add_text_targets (eventbox);
 
   g_signal_connect (eventbox, "drag_data_get",
 		    G_CALLBACK (filenames_drag_get), filesel);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 814b536..56bd297 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3413,13 +3413,6 @@ gtk_label_select_region_index (GtkLabel *label,
                                gint      anchor_index,
                                gint      end_index)
 {
-  static const GtkTargetEntry targets[] = {
-    { "STRING", 0, 0 },
-    { "TEXT",   0, 0 }, 
-    { "COMPOUND_TEXT", 0, 0 },
-    { "UTF8_STRING", 0, 0 }
-  };
-
   g_return_if_fail (GTK_IS_LABEL (label));
   
   if (label->select_info)
@@ -3438,12 +3431,22 @@ gtk_label_select_region_index (GtkLabel *label,
       
       if (anchor_index != end_index)
         {
+          GtkTargetList *list;
+          GtkTargetEntry *targets;
+          gint n_targets;
+
+          list = gtk_target_list_new (NULL, 0);
+          gtk_target_list_add_text_targets (list, 0);
+          targets = gtk_target_table_new_from_list (list, &n_targets);
+
           gtk_clipboard_set_with_owner (clipboard,
-                                        targets,
-                                        G_N_ELEMENTS (targets),
+                                        targets, n_targets,
                                         get_text_callback,
                                         clear_text_callback,
                                         G_OBJECT (label));
+
+          gtk_target_table_free (targets, n_targets);
+          gtk_target_list_unref (list);
         }
       else
         {
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 440d875..0594251 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -1344,10 +1344,6 @@ make_directory_button (GtkPathBar  *path_bar,
 		       gboolean     current_dir,
 		       gboolean     file_is_hidden)
 {
-  const GtkTargetEntry targets[] = {
-    { "text/uri-list", 0, 0 }
-  };
-
   AtkObject *atk_obj;
   GtkWidget *child = NULL;
   GtkWidget *label_alignment = NULL;
@@ -1414,9 +1410,9 @@ make_directory_button (GtkPathBar  *path_bar,
 
   gtk_drag_source_set (button_data->button,
 		       GDK_BUTTON1_MASK,
-		       targets,
-		       G_N_ELEMENTS (targets),
+		       NULL, 0,
 		       GDK_ACTION_COPY);
+  gtk_drag_source_add_uri_targets (button_data->button);
   g_signal_connect (button_data->button, "drag_data_get",
 		    G_CALLBACK (button_drag_data_get_cb), button_data);
 
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 2eafcde..7f47d30 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -153,15 +153,6 @@ enum {
   LOAD_FINISHED  /* the model is fully loaded and inserted */
 };
 
-enum {
-  TEXT_URI_LIST
-};
-
-/* Target types for DnD from the file list */
-static const GtkTargetEntry recent_list_source_targets[] = {
-  { "text/uri-list", 0, TEXT_URI_LIST }
-};
-
 /* Icon size for if we can't get it from the theme */
 #define FALLBACK_ICON_SIZE  48
 #define FALLBACK_ITEM_LIMIT 20
@@ -451,9 +442,9 @@ gtk_recent_chooser_default_constructor (GType                  type,
   /* drag and drop */
   gtk_drag_source_set (impl->recent_view,
 		       GDK_BUTTON1_MASK,
-		       recent_list_source_targets,
-		       G_N_ELEMENTS (recent_list_source_targets),
+		       NULL, 0,
 		       GDK_ACTION_COPY);
+  gtk_drag_source_add_uri_targets (impl->recent_view);
 
   impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
   
@@ -1535,25 +1526,23 @@ recent_view_drag_data_get_cb (GtkWidget        *widget,
 			      gpointer          data)
 {
   GtkRecentChooserDefault *impl = GTK_RECENT_CHOOSER_DEFAULT (data);
-  DragData *drag_data;
+  DragData drag_data;
   gsize n_uris;
   
   n_uris = gtk_tree_selection_count_selected_rows (impl->selection);
   if (n_uris == 0)
-	  return;
+    return;
 
-  drag_data = g_new (DragData, 1);
-  drag_data->uri_list = g_new0 (gchar *, n_uris + 1);
-  drag_data->next_pos = 0;
+  drag_data.uri_list = g_new0 (gchar *, n_uris + 1);
+  drag_data.next_pos = 0;
   
   gtk_tree_selection_selected_foreach (impl->selection,
       				       append_uri_to_urilist,
-      				       drag_data);
+      				       &drag_data);
   
-  gtk_selection_data_set_uris (selection_data, drag_data->uri_list);
+  gtk_selection_data_set_uris (selection_data, drag_data.uri_list);
 
-  g_strfreev (drag_data->uri_list);
-  g_free (drag_data);
+  g_strfreev (drag_data.uri_list);
 }
 
 static gboolean
