Example #1
0
static void
handle_drop( HDROP hDrop )
{
  size_t bufsize;
  char *namebuf;

  /* Check that only one file was dropped */
  if( DragQueryFile( hDrop, ~0UL, NULL, 0 ) == 1) {
    bufsize = DragQueryFile( hDrop, 0, NULL, 0 ) + 1;
    if( ( namebuf = malloc( bufsize ) ) ) {
      DragQueryFile( hDrop, 0, namebuf, bufsize );

      fuse_emulation_pause();

      utils_open_file( namebuf, tape_can_autoload(), NULL );

      free( namebuf );

      display_refresh_all();

      fuse_emulation_unpause();
    }
  }
  DragFinish( hDrop );
}
Example #2
0
static void gtkui_drag_data_received( GtkWidget *widget,
                                      GdkDragContext *drag_context,
                                      gint x, gint y,
                                      GtkSelectionData *data,
                                      guint info, guint time )
{
  static char uri_prefix[] = "file://";
  char *filename, *p, *data_end;

  if ( data && data->length > sizeof( uri_prefix ) ) {
    filename = ( char * )( data->data + sizeof( uri_prefix ) - 1 );
    data_end = ( char * )( data->data + data->length );
    p = filename; 
    do {
      if ( *p == '\r' || *p == '\n' ) {
        *p = '\0';
	break;
      }
    } while ( p++ != data_end );

    if ( ( filename = g_uri_unescape_string( filename, NULL ) ) != NULL ) {
      fuse_emulation_pause();
      utils_open_file( filename, settings_current.auto_load, NULL );
      free( filename );
      display_refresh_all();
      fuse_emulation_unpause();
    }
  }
  gtk_drag_finish(drag_context, FALSE, FALSE, time);
}