title: GTK4 Problem setting image from pixbuf with a GtkDropTarget
body: <p>I am testing a gtk4 widget which is GtkDropTarget. I plan on setting an image which is dragged to the window as the image of the window itself. But errors come up as soon as I drag an image file. To be clear, this is the code in vala:</p>
  <pre><code>int main (string[] args) {
      var app = new App();
      return app.run(args);
  }
  
  public class App : Gtk.Application {
      public App () {
      Object (
          application_id: &quot;com.github.ea&quot;,
          flags: ApplicationFlags.FLAGS_NONE
      );
      }
      public override void activate () {
      var window = new Window (this);
      add_window (window);
      }
  }
  
  public class Window : Gtk.ApplicationWindow {
      public Window (Gtk.Application app) {
          Object (application: app);
      }
  
  construct {
          title = &quot;Drag&quot;;
      set_default_size (640, 480);
      var drag_source = new DragSource ();
      set_child (drag_source.self);       
      show ();
      }
  }
  
  public class DragSource {
      public Gtk.Image self;
  
      public DragSource () {
  
          self = new Gtk.Image ();
          var drag_controller = new Gtk.DropTarget (GLib.Type.INVALID,     Gdk.DragAction.COPY);
  
          drag_controller.set_gtypes ({typeof(File)});
  
          self.add_controller (drag_controller);
          drag_controller.on_drop.connect (on_drop);
      }
  
      private bool on_drop (GLib.Value val, double x, double y) {
          File filename = (File) val;
          var file_path = filename.get_path ();
          
          if (val.holds(typeof(File)) == true) {
          print (&quot;The dragged object is a file.\n&quot;);
  
          if (&quot;png&quot; in file_path || &quot;jpg&quot; in file_path) {
                  print (&quot;The dragged object is an image.\n&quot;);
                  self.set_from_pixbuf (pixbuf(file_path));
          }
              else {
                  print (&quot;The dragged object is NOT an image.\n&quot;);
          }
      }
          else {
              print (&quot;The dragged object is NOT a file.\n&quot;);
          return false;
          }
          return true;
      }
  
      private Gdk.Pixbuf pixbuf (string file) {
          try {
              return new Gdk.Pixbuf.from_file (file);
          } catch (Error e) {
              error (&quot;%s&quot;, e.message);
              }
          }
  }
  </code></pre>
  <p>This compiles and runs. But as soon as I drag an image file to the window, error occurs and the image is not displayed. This are the pictures of what happens. What should happen is, when I drag a png file from my file manager, the dragged image should be the image showing in the GtkImage, which is the main widget of the window.</p>
  <p>On my first drag of an image file from my pc, this error shows up:</p>
  <pre><code>The dragged object is a file.
  The dragged object is an image.
  
  (v:3891): Gtk-CRITICAL **: 08:52:28.861: gtk_image_set_from_pixbuf: assertion 'GTK_IS_IMAGE (image)' failed
  </code></pre>
  <p>On the second drag, this shows up:</p>
  <pre><code>(v:3891): Gdk-CRITICAL **: 08:53:33.388: gdk_drop_set_actions: assertion 'priv-&gt;state == GDK_DROP_STATE_NONE' failed
  The dragged object is a file.
  The dragged object is an image.
  
  (v:3891): Gtk-CRITICAL **: 08:53:33.973: gtk_image_set_from_pixbuf: assertion 'GTK_IS_IMAGE (image)' failed
  </code></pre>
  <p>I would really appreciate a help. Thank You!</p>