diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-01-07 00:46:00 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-01-08 18:48:22 -0500 |
commit | a59a20c1d4b736d7704fbc979add42503ba82c59 (patch) | |
tree | 7584174ab9c18b213e8b127c340fec6cb19c30b7 /gtk/gtkplacessidebar.c | |
parent | fb4b5c666b36a0a2e1f1f0127ee920cfd160a10f (diff) | |
download | gtk+-a59a20c1d4b736d7704fbc979add42503ba82c59.tar.gz |
placessidebar: Use GDK content formats api
Diffstat (limited to 'gtk/gtkplacessidebar.c')
-rw-r--r-- | gtk/gtkplacessidebar.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 8f3d0cbef0..bf348ade9b 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -312,16 +312,6 @@ enum { DND_TEXT_URI_LIST }; -/* Target types for dragging from the shortcuts list */ -static const char *dnd_source_targets[] = { - "DND_GTK_SIDEBAR_ROW" -}; - -/* Target types for dropping into the shortcuts list */ -static const char *dnd_drop_targets [] = { - "DND_GTK_SIDEBAR_ROW" -}; - G_DEFINE_TYPE (GtkPlacesSidebar, gtk_places_sidebar, GTK_TYPE_WIDGET); static void @@ -4038,6 +4028,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar) GtkStyleContext *context; GtkEventController *controller; GtkGesture *gesture; + GdkContentFormatsBuilder *builder; sidebar->cancellable = g_cancellable_new (); @@ -4090,16 +4081,21 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar) gtk_widget_add_controller (GTK_WIDGET (sidebar), GTK_EVENT_CONTROLLER (gesture)); /* DND support */ - formats = gdk_content_formats_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets)); - formats = gtk_content_formats_add_uri_targets (formats); + builder = gdk_content_formats_builder_new (); + gdk_content_formats_builder_add_mime_type (builder, "DND_GTK_SIDEBAR_ROW"); + gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_FILE_LIST); + formats = gdk_content_formats_builder_free_to_formats (builder); dest = gtk_drop_target_new (formats, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK); gdk_content_formats_unref (formats); g_signal_connect (dest, "drag-motion", G_CALLBACK (drag_motion_callback), sidebar); g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop_callback), sidebar); g_signal_connect (dest, "drag-leave", G_CALLBACK (drag_leave_callback), sidebar); gtk_widget_add_controller (sidebar->list_box, GTK_EVENT_CONTROLLER (dest)); - sidebar->source_targets = gdk_content_formats_new (dnd_source_targets, G_N_ELEMENTS (dnd_source_targets)); - sidebar->source_targets = gtk_content_formats_add_text_targets (sidebar->source_targets); + + builder = gdk_content_formats_builder_new (); + gdk_content_formats_builder_add_mime_type (builder, "DND_GTK_SIDEBAR_ROW"); + gdk_content_formats_builder_add_gtype (builder, G_TYPE_STRING); + sidebar->source_targets = gdk_content_formats_builder_free_to_formats (builder); sidebar->drag_row = NULL; sidebar->row_placeholder = NULL; |